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-devel

[Xen-devel] [PATCH] x86/emulation: honor failure of in_longmode()

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86/emulation: honor failure of in_longmode()
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Fri, 28 Aug 2009 09:21:42 +0100
Delivery-date: Fri, 28 Aug 2009 01:22:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Failure of in_longmode() shouldn't be treated the same as the function
returning 'true'.

Besides that, the function should always return false on 32-bits,
eliminating the possibility for it failing there altogether.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2009-08-18.orig/xen/arch/x86/x86_emulate/x86_emulate.c      2009-08-18 
14:18:20.000000000 +0200
+++ 2009-08-18/xen/arch/x86/x86_emulate/x86_emulate.c   2009-08-24 
11:30:17.000000000 +0200
@@ -958,6 +958,7 @@ in_longmode(
     struct x86_emulate_ctxt *ctxt,
     struct x86_emulate_ops *ops)
 {
+#ifdef __x86_64__
     uint64_t efer;
 
     if (ops->read_msr == NULL)
@@ -965,6 +966,9 @@ in_longmode(
 
     ops->read_msr(MSR_EFER, &efer, ctxt);
     return !!(efer & EFER_LMA);
+#else
+    return 0;
+#endif
 }
 
 static int
@@ -3605,7 +3609,10 @@ x86_emulate(
         ss.attr.bytes = 0xc93; /* G+DB+P+S+Data */
 
 #ifdef __x86_64__
-        if ( in_longmode(ctxt, ops) )
+        rc = in_longmode(ctxt, ops);
+        if ( rc < 0 )
+            goto cannot_emulate;
+        if ( rc )
         {
             cs.attr.fields.db = 0;
             cs.attr.fields.l = 1;
@@ -3777,7 +3784,10 @@ x86_emulate(
         ss.limit = ~0u;  /* 4GB limit */
         ss.attr.bytes = 0xc93; /* G+DB+P+S+Data */
 
-        if ( in_longmode(ctxt, ops) )
+        rc = in_longmode(ctxt, ops);
+        if ( rc < 0 )
+            goto cannot_emulate;
+        if ( rc )
         {
             cs.attr.fields.db = 0;
             cs.attr.fields.l = 1;




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86/emulation: honor failure of in_longmode(), Jan Beulich <=