ia64/xen-unstable

changeset 12558:2d8784764b52

[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@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Thu Nov 23 17:21:26 2006 +0000 (2006-11-23)
parents c98a8e2c62d1
children 62307643804e
files xen/arch/x86/traps.c
line diff
     1.1 --- a/xen/arch/x86/traps.c	Thu Nov 23 15:06:35 2006 +0000
     1.2 +++ b/xen/arch/x86/traps.c	Thu Nov 23 17:21:26 2006 +0000
     1.3 @@ -1026,8 +1026,6 @@ void host_to_guest_gpr_switch(struct cpu
     1.4      __attribute__((__regparm__(1)));
     1.5  unsigned long guest_to_host_gpr_switch(unsigned long)
     1.6      __attribute__((__regparm__(1)));
     1.7 -typedef unsigned long (*io_emul_stub_t)(struct cpu_user_regs *)
     1.8 -    __attribute__((__regparm__(1)));
     1.9  
    1.10  /* Instruction fetch with error handling. */
    1.11  #define insn_fetch(_type, _size, cs, eip)                                   \
    1.12 @@ -1048,6 +1046,8 @@ static int emulate_privileged_op(struct 
    1.13      u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0;
    1.14      unsigned int port, i, op_bytes = 4, data, rc;
    1.15      char io_emul_stub[16];
    1.16 +    void (*io_emul)(struct cpu_user_regs *) __attribute__((__regparm__(1))) \
    1.17 +        = (void*)&io_emul_stub[0];
    1.18      u32 l, h;
    1.19  
    1.20      /* Legacy prefixes. */
    1.21 @@ -1204,22 +1204,20 @@ static int emulate_privileged_op(struct 
    1.22          switch ( op_bytes )
    1.23          {
    1.24          case 1:
    1.25 -            res = regs->eax & ~0xffUL;
    1.26              if ( guest_inb_okay(port, v, regs) )
    1.27 -                regs->eax = res | (u8)((io_emul_stub_t)io_emul_stub)(regs);
    1.28 +                io_emul(regs);
    1.29              else
    1.30 -                regs->eax = res | (u8)~0;
    1.31 +                regs->eax = (regs->eax & ~0xffUL) | (u8)~0;
    1.32              break;
    1.33          case 2:
    1.34 -            res = regs->eax & ~0xffffUL;
    1.35              if ( guest_inw_okay(port, v, regs) )
    1.36 -                regs->eax = res | (u16)((io_emul_stub_t)io_emul_stub)(regs);
    1.37 +                io_emul(regs);
    1.38              else
    1.39 -                regs->eax = res | (u16)~0;
    1.40 +                regs->eax = (regs->eax & ~0xffffUL) | (u16)~0;
    1.41              break;
    1.42          case 4:
    1.43              if ( guest_inl_okay(port, v, regs) )
    1.44 -                regs->eax = (u32)((io_emul_stub_t)io_emul_stub)(regs);
    1.45 +                io_emul(regs);
    1.46              else
    1.47                  regs->eax = (u32)~0;
    1.48              break;
    1.49 @@ -1244,15 +1242,15 @@ static int emulate_privileged_op(struct 
    1.50          {
    1.51          case 1:
    1.52              if ( guest_outb_okay(port, v, regs) )
    1.53 -                ((io_emul_stub_t)io_emul_stub)(regs);
    1.54 +                io_emul(regs);
    1.55              break;
    1.56          case 2:
    1.57              if ( guest_outw_okay(port, v, regs) )
    1.58 -                ((io_emul_stub_t)io_emul_stub)(regs);
    1.59 +                io_emul(regs);
    1.60              break;
    1.61          case 4:
    1.62              if ( guest_outl_okay(port, v, regs) )
    1.63 -                ((io_emul_stub_t)io_emul_stub)(regs);
    1.64 +                io_emul(regs);
    1.65              break;
    1.66          }
    1.67          goto done;