WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XEN] Avoid using regparm on a typedef.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEN] Avoid using regparm on a typedef.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Nov 2006 19:00:37 +0000
Delivery-date: Thu, 23 Nov 2006 11:00:16 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxxxxx>
# Node ID 2d8784764b52971f0f06658444f25fb0109a3570
# Parent  c98a8e2c62d1870f804bf6290ac559c63703bba0
[XEN] Avoid using regparm on a typedef.

This does not work reliably across gcc versions. Workaround this by attaching
the regparm attribute to a variable instead.

Also since guest_to_host_gpr_switch() updates the guest EAX on the stack there
is no need to do so in emulate_privileged_op() as well. Therefore io_emul stub
now returns void.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxxxxx>
---
 xen/arch/x86/traps.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff -r c98a8e2c62d1 -r 2d8784764b52 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Thu Nov 23 15:06:35 2006 +0000
+++ b/xen/arch/x86/traps.c      Thu Nov 23 17:21:26 2006 +0000
@@ -1026,8 +1026,6 @@ void host_to_guest_gpr_switch(struct cpu
     __attribute__((__regparm__(1)));
 unsigned long guest_to_host_gpr_switch(unsigned long)
     __attribute__((__regparm__(1)));
-typedef unsigned long (*io_emul_stub_t)(struct cpu_user_regs *)
-    __attribute__((__regparm__(1)));
 
 /* Instruction fetch with error handling. */
 #define insn_fetch(_type, _size, cs, eip)                                   \
@@ -1048,6 +1046,8 @@ static int emulate_privileged_op(struct 
     u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0;
     unsigned int port, i, op_bytes = 4, data, rc;
     char io_emul_stub[16];
+    void (*io_emul)(struct cpu_user_regs *) __attribute__((__regparm__(1))) \
+        = (void*)&io_emul_stub[0];
     u32 l, h;
 
     /* Legacy prefixes. */
@@ -1204,22 +1204,20 @@ static int emulate_privileged_op(struct 
         switch ( op_bytes )
         {
         case 1:
-            res = regs->eax & ~0xffUL;
             if ( guest_inb_okay(port, v, regs) )
-                regs->eax = res | (u8)((io_emul_stub_t)io_emul_stub)(regs);
+                io_emul(regs);
             else
-                regs->eax = res | (u8)~0;
+                regs->eax = (regs->eax & ~0xffUL) | (u8)~0;
             break;
         case 2:
-            res = regs->eax & ~0xffffUL;
             if ( guest_inw_okay(port, v, regs) )
-                regs->eax = res | (u16)((io_emul_stub_t)io_emul_stub)(regs);
+                io_emul(regs);
             else
-                regs->eax = res | (u16)~0;
+                regs->eax = (regs->eax & ~0xffffUL) | (u16)~0;
             break;
         case 4:
             if ( guest_inl_okay(port, v, regs) )
-                regs->eax = (u32)((io_emul_stub_t)io_emul_stub)(regs);
+                io_emul(regs);
             else
                 regs->eax = (u32)~0;
             break;
@@ -1244,15 +1242,15 @@ static int emulate_privileged_op(struct 
         {
         case 1:
             if ( guest_outb_okay(port, v, regs) )
-                ((io_emul_stub_t)io_emul_stub)(regs);
+                io_emul(regs);
             break;
         case 2:
             if ( guest_outw_okay(port, v, regs) )
-                ((io_emul_stub_t)io_emul_stub)(regs);
+                io_emul(regs);
             break;
         case 4:
             if ( guest_outl_okay(port, v, regs) )
-                ((io_emul_stub_t)io_emul_stub)(regs);
+                io_emul(regs);
             break;
         }
         goto done;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEN] Avoid using regparm on a typedef., Xen patchbot-unstable <=