From: kfraser@localhost.localdomain Date: Mon, 15 Jan 2007 15:58:51 +0000 (+0000) Subject: [HVM] Fix calculation of address size in long mode. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15396^2~19 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6127793b4cb670dff71bfa89082bdbc8c6db8576;p=xen.git [HVM] Fix calculation of address size in long mode. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 2a3e6370d6..ba3121618e 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -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; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 74e0776016..a665367c6d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -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; diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index ac35c7e5cb..115ad74d72 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -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 ) {