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] x86: Clean up do_iret() hypercall.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: Clean up do_iret() hypercall.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 03 Jul 2007 13:36:05 -0700
Delivery-date: Tue, 03 Jul 2007 13:34:20 -0700
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 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: Clean up do_iret() hypercall., Xen patchbot-unstable <=