direct-io.hg

changeset 15463:56da8753ba8d

x86: Clean up do_iret() hypercall.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 03 16:02:31 2007 +0100 (2007-07-03)
parents eb71f258e855
children f1b62eb7f8be
files xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/compat/traps.c
line diff
     1.1 --- a/xen/arch/x86/x86_32/traps.c	Tue Jul 03 15:51:59 2007 +0100
     1.2 +++ b/xen/arch/x86/x86_32/traps.c	Tue Jul 03 16:02:31 2007 +0100
     1.3 @@ -179,12 +179,12 @@ unsigned long do_iret(void)
     1.4          goto exit_and_crash;
     1.5  
     1.6      /* Pop and restore EAX (clobbered by hypercall). */
     1.7 -    if ( unlikely(__copy_from_user(&regs->eax, (void __user *)regs->esp, 4)) )
     1.8 +    if ( unlikely(__copy_from_user(&regs->eax, (void *)regs->esp, 4)) )
     1.9          goto exit_and_crash;
    1.10      regs->esp += 4;
    1.11  
    1.12      /* Pop and restore CS and EIP. */
    1.13 -    if ( unlikely(__copy_from_user(&regs->eip, (void __user *)regs->esp, 8)) )
    1.14 +    if ( unlikely(__copy_from_user(&regs->eip, (void *)regs->esp, 8)) )
    1.15          goto exit_and_crash;
    1.16      regs->esp += 8;
    1.17  
    1.18 @@ -192,7 +192,7 @@ unsigned long do_iret(void)
    1.19       * Pop, fix up and restore EFLAGS. We fix up in a local staging area
    1.20       * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest.
    1.21       */
    1.22 -    if ( unlikely(__copy_from_user(&eflags, (void __user *)regs->esp, 4)) )
    1.23 +    if ( unlikely(__copy_from_user(&eflags, (void *)regs->esp, 4)) )
    1.24          goto exit_and_crash;
    1.25      regs->esp += 4;
    1.26      regs->eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF;
    1.27 @@ -200,7 +200,7 @@ unsigned long do_iret(void)
    1.28      if ( vm86_mode(regs) )
    1.29      {
    1.30          /* Return to VM86 mode: pop and restore ESP,SS,ES,DS,FS and GS. */
    1.31 -        if ( __copy_from_user(&regs->esp, (void __user *)regs->esp, 24) )
    1.32 +        if ( __copy_from_user(&regs->esp, (void *)regs->esp, 24) )
    1.33              goto exit_and_crash;
    1.34      }
    1.35      else if ( unlikely(ring_0(regs)) )
    1.36 @@ -210,7 +210,7 @@ unsigned long do_iret(void)
    1.37      else if ( !ring_1(regs) )
    1.38      {
    1.39          /* Return to ring 2/3: pop and restore ESP and SS. */
    1.40 -        if ( __copy_from_user(&regs->esp, (void __user *)regs->esp, 8) )
    1.41 +        if ( __copy_from_user(&regs->esp, (void *)regs->esp, 8) )
    1.42              goto exit_and_crash;
    1.43      }
    1.44  
     2.1 --- a/xen/arch/x86/x86_64/compat/traps.c	Tue Jul 03 15:51:59 2007 +0100
     2.2 +++ b/xen/arch/x86/x86_64/compat/traps.c	Tue Jul 03 16:02:31 2007 +0100
     2.3 @@ -39,20 +39,23 @@ unsigned int compat_iret(void)
     2.4      struct cpu_user_regs *regs = guest_cpu_user_regs();
     2.5      u32 eflags;
     2.6  
     2.7 +    /* Trim stack pointer to 32 bits. */
     2.8 +    regs->rsp = (u32)regs->rsp;
     2.9 +
    2.10      /* Restore EAX (clobbered by hypercall). */
    2.11 -    if ( unlikely(__get_user(regs->_eax, (u32 __user *)regs->rsp)) )
    2.12 +    if ( unlikely(__get_user(regs->_eax, (u32 *)regs->rsp)) )
    2.13          goto exit_and_crash;
    2.14  
    2.15      /* Restore CS and EIP. */
    2.16 -    if ( unlikely(__get_user(regs->_eip, (u32 __user *)regs->rsp + 1)) ||
    2.17 -        unlikely(__get_user(regs->cs, (u32 __user *)regs->rsp + 2)) )
    2.18 +    if ( unlikely(__get_user(regs->_eip, (u32 *)regs->rsp + 1)) ||
    2.19 +        unlikely(__get_user(regs->cs, (u32 *)regs->rsp + 2)) )
    2.20          goto exit_and_crash;
    2.21  
    2.22      /*
    2.23       * Fix up and restore EFLAGS. We fix up in a local staging area
    2.24       * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest.
    2.25       */
    2.26 -    if ( unlikely(__get_user(eflags, (u32 __user *)regs->rsp + 3)) )
    2.27 +    if ( unlikely(__get_user(eflags, (u32 *)regs->rsp + 3)) )
    2.28          goto exit_and_crash;
    2.29      regs->_eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF;
    2.30  
    2.31 @@ -77,16 +80,16 @@ unsigned int compat_iret(void)
    2.32          {
    2.33              for (i = 1; i < 10; ++i)
    2.34              {
    2.35 -                rc |= __get_user(x, (u32 __user *)regs->rsp + i);
    2.36 -                rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i);
    2.37 +                rc |= __get_user(x, (u32 *)regs->rsp + i);
    2.38 +                rc |= __put_user(x, (u32 *)(unsigned long)ksp + i);
    2.39              }
    2.40          }
    2.41          else if ( ksp > regs->_esp )
    2.42          {
    2.43              for (i = 9; i > 0; ++i)
    2.44              {
    2.45 -                rc |= __get_user(x, (u32 __user *)regs->rsp + i);
    2.46 -                rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i);
    2.47 +                rc |= __get_user(x, (u32 *)regs->rsp + i);
    2.48 +                rc |= __put_user(x, (u32 *)(unsigned long)ksp + i);
    2.49              }
    2.50          }
    2.51          if ( rc )
    2.52 @@ -100,7 +103,7 @@ unsigned int compat_iret(void)
    2.53          regs->_eflags = eflags & ~(X86_EFLAGS_VM|X86_EFLAGS_RF|
    2.54                                     X86_EFLAGS_NT|X86_EFLAGS_TF);
    2.55  
    2.56 -        if ( unlikely(__put_user(0, (u32 __user *)regs->rsp)) )
    2.57 +        if ( unlikely(__put_user(0, (u32 *)regs->rsp)) )
    2.58              goto exit_and_crash;
    2.59          regs->_eip = ti->address;
    2.60          regs->cs = ti->cs;
    2.61 @@ -110,8 +113,8 @@ unsigned int compat_iret(void)
    2.62      else if ( !ring_1(regs) )
    2.63      {
    2.64          /* Return to ring 2/3: restore ESP and SS. */
    2.65 -        if ( __get_user(regs->ss, (u32 __user *)regs->rsp + 5)
    2.66 -            || __get_user(regs->_esp, (u32 __user *)regs->rsp + 4))
    2.67 +        if ( __get_user(regs->ss, (u32 *)regs->rsp + 5)
    2.68 +            || __get_user(regs->_esp, (u32 *)regs->rsp + 4))
    2.69              goto exit_and_crash;
    2.70      }
    2.71      else