[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



# 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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.