[HVM] Fix calculation of address size in long mode.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 15 Jan 2007 15:58:51 +0000 (15:58 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 15 Jan 2007 15:58:51 +0000 (15:58 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/mm/shadow/common.c

index 2a3e6370d6f98b3855df5298b60748287547abd2..ba3121618ebe21257566e481cf20a52bf4dea78f 100644 (file)
@@ -482,8 +482,8 @@ static int svm_guest_x86_mode(struct vcpu *v)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
 
-    if ( vmcb->efer & EFER_LMA )
-        return (vmcb->cs.attr.fields.l ? 8 : 4);
+    if ( (vmcb->efer & EFER_LMA) && vmcb->cs.attr.fields.l )
+        return 8;
 
     if ( svm_realmode(v) )
         return 2;
index 74e0776016446f199ef286e77f9289ca6af71e9e..a665367c6d8813dd2c312133cad96840458bbf34 100644 (file)
@@ -491,8 +491,7 @@ static unsigned long vmx_get_segment_base(struct vcpu *v, enum x86_segment seg)
     ASSERT(v == current);
 
 #ifdef __x86_64__
-    if ( vmx_long_mode_enabled(v) &&
-         (__vmread(GUEST_CS_AR_BYTES) & (1u<<13)) )
+    if ( vmx_long_mode_enabled(v) && (__vmread(GUEST_CS_AR_BYTES) & (1u<<13)) )
         long_mode = 1;
 #endif
 
@@ -667,8 +666,8 @@ static int vmx_guest_x86_mode(struct vcpu *v)
 
     cs_ar_bytes = __vmread(GUEST_CS_AR_BYTES);
 
-    if ( vmx_long_mode_enabled(v) )
-        return ((cs_ar_bytes & (1u<<13)) ? 8 : 4);
+    if ( vmx_long_mode_enabled(v) && (cs_ar_bytes & (1u<<13)) )
+        return 8;
 
     if ( vmx_realmode(v) )
         return 2;
index ac35c7e5cbcd28f4b80050fa1ec487a870d8bce9..115ad74d72dace8c4e4b9ba3489dcfb97c27c8f9 100644 (file)
@@ -416,14 +416,9 @@ struct x86_emulate_ops *shadow_init_emulation(
     creg = hvm_get_seg_reg(x86_seg_cs, sh_ctxt);
 
     /* Work out the emulation mode. */
-    if ( hvm_long_mode_enabled(v) )
+    if ( hvm_long_mode_enabled(v) && creg->attr.fields.l )
     {
-        sh_ctxt->ctxt.addr_size = creg->attr.fields.l ? 64 : 32;
-        if ( (sh_ctxt->ctxt.sp_size = sh_ctxt->ctxt.addr_size) != 64 )
-        {
-            sreg = hvm_get_seg_reg(x86_seg_ss, sh_ctxt);
-            sh_ctxt->ctxt.sp_size = sreg->attr.fields.db ? 32 : 16;
-        }
+        sh_ctxt->ctxt.addr_size = sh_ctxt->ctxt.sp_size = 64;
     }
     else if ( regs->eflags & X86_EFLAGS_VM )
     {