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

[Xen-changelog] [xen-unstable] x86: Clean up do_iret() hypercall.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1183474951 -3600
# Node ID 56da8753ba8d958e29262a45052a72dd7cfbaa79
# Parent  eb71f258e8551858ff11d2331f008539cf399a55
x86: Clean up do_iret() hypercall.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/x86_32/traps.c        |   10 +++++-----
 xen/arch/x86/x86_64/compat/traps.c |   25 ++++++++++++++-----------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff -r eb71f258e855 -r 56da8753ba8d xen/arch/x86/x86_32/traps.c
--- a/xen/arch/x86/x86_32/traps.c       Tue Jul 03 15:51:59 2007 +0100
+++ b/xen/arch/x86/x86_32/traps.c       Tue Jul 03 16:02:31 2007 +0100
@@ -179,12 +179,12 @@ unsigned long do_iret(void)
         goto exit_and_crash;
 
     /* Pop and restore EAX (clobbered by hypercall). */
-    if ( unlikely(__copy_from_user(&regs->eax, (void __user *)regs->esp, 4)) )
+    if ( unlikely(__copy_from_user(&regs->eax, (void *)regs->esp, 4)) )
         goto exit_and_crash;
     regs->esp += 4;
 
     /* Pop and restore CS and EIP. */
-    if ( unlikely(__copy_from_user(&regs->eip, (void __user *)regs->esp, 8)) )
+    if ( unlikely(__copy_from_user(&regs->eip, (void *)regs->esp, 8)) )
         goto exit_and_crash;
     regs->esp += 8;
 
@@ -192,7 +192,7 @@ unsigned long do_iret(void)
      * Pop, fix up and restore EFLAGS. We fix up in a local staging area
      * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest.
      */
-    if ( unlikely(__copy_from_user(&eflags, (void __user *)regs->esp, 4)) )
+    if ( unlikely(__copy_from_user(&eflags, (void *)regs->esp, 4)) )
         goto exit_and_crash;
     regs->esp += 4;
     regs->eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF;
@@ -200,7 +200,7 @@ unsigned long do_iret(void)
     if ( vm86_mode(regs) )
     {
         /* Return to VM86 mode: pop and restore ESP,SS,ES,DS,FS and GS. */
-        if ( __copy_from_user(&regs->esp, (void __user *)regs->esp, 24) )
+        if ( __copy_from_user(&regs->esp, (void *)regs->esp, 24) )
             goto exit_and_crash;
     }
     else if ( unlikely(ring_0(regs)) )
@@ -210,7 +210,7 @@ unsigned long do_iret(void)
     else if ( !ring_1(regs) )
     {
         /* Return to ring 2/3: pop and restore ESP and SS. */
-        if ( __copy_from_user(&regs->esp, (void __user *)regs->esp, 8) )
+        if ( __copy_from_user(&regs->esp, (void *)regs->esp, 8) )
             goto exit_and_crash;
     }
 
diff -r eb71f258e855 -r 56da8753ba8d xen/arch/x86/x86_64/compat/traps.c
--- a/xen/arch/x86/x86_64/compat/traps.c        Tue Jul 03 15:51:59 2007 +0100
+++ b/xen/arch/x86/x86_64/compat/traps.c        Tue Jul 03 16:02:31 2007 +0100
@@ -39,20 +39,23 @@ unsigned int compat_iret(void)
     struct cpu_user_regs *regs = guest_cpu_user_regs();
     u32 eflags;
 
+    /* Trim stack pointer to 32 bits. */
+    regs->rsp = (u32)regs->rsp;
+
     /* Restore EAX (clobbered by hypercall). */
-    if ( unlikely(__get_user(regs->_eax, (u32 __user *)regs->rsp)) )
+    if ( unlikely(__get_user(regs->_eax, (u32 *)regs->rsp)) )
         goto exit_and_crash;
 
     /* Restore CS and EIP. */
-    if ( unlikely(__get_user(regs->_eip, (u32 __user *)regs->rsp + 1)) ||
-        unlikely(__get_user(regs->cs, (u32 __user *)regs->rsp + 2)) )
+    if ( unlikely(__get_user(regs->_eip, (u32 *)regs->rsp + 1)) ||
+        unlikely(__get_user(regs->cs, (u32 *)regs->rsp + 2)) )
         goto exit_and_crash;
 
     /*
      * Fix up and restore EFLAGS. We fix up in a local staging area
      * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest.
      */
-    if ( unlikely(__get_user(eflags, (u32 __user *)regs->rsp + 3)) )
+    if ( unlikely(__get_user(eflags, (u32 *)regs->rsp + 3)) )
         goto exit_and_crash;
     regs->_eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF;
 
@@ -77,16 +80,16 @@ unsigned int compat_iret(void)
         {
             for (i = 1; i < 10; ++i)
             {
-                rc |= __get_user(x, (u32 __user *)regs->rsp + i);
-                rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i);
+                rc |= __get_user(x, (u32 *)regs->rsp + i);
+                rc |= __put_user(x, (u32 *)(unsigned long)ksp + i);
             }
         }
         else if ( ksp > regs->_esp )
         {
             for (i = 9; i > 0; ++i)
             {
-                rc |= __get_user(x, (u32 __user *)regs->rsp + i);
-                rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i);
+                rc |= __get_user(x, (u32 *)regs->rsp + i);
+                rc |= __put_user(x, (u32 *)(unsigned long)ksp + i);
             }
         }
         if ( rc )
@@ -100,7 +103,7 @@ unsigned int compat_iret(void)
         regs->_eflags = eflags & ~(X86_EFLAGS_VM|X86_EFLAGS_RF|
                                    X86_EFLAGS_NT|X86_EFLAGS_TF);
 
-        if ( unlikely(__put_user(0, (u32 __user *)regs->rsp)) )
+        if ( unlikely(__put_user(0, (u32 *)regs->rsp)) )
             goto exit_and_crash;
         regs->_eip = ti->address;
         regs->cs = ti->cs;
@@ -110,8 +113,8 @@ unsigned int compat_iret(void)
     else if ( !ring_1(regs) )
     {
         /* Return to ring 2/3: restore ESP and SS. */
-        if ( __get_user(regs->ss, (u32 __user *)regs->rsp + 5)
-            || __get_user(regs->_esp, (u32 __user *)regs->rsp + 4))
+        if ( __get_user(regs->ss, (u32 *)regs->rsp + 5)
+            || __get_user(regs->_esp, (u32 *)regs->rsp + 4))
             goto exit_and_crash;
     }
     else

_______________________________________________
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®.