From 712a8222302c6bd5221c2fbd03aedac18e4422ca Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 27 Nov 2014 14:03:23 +0100 Subject: [PATCH] x86/PVH: properly disable vLAPIC Rather than guarding higher level operations (like vPMU initialization as suggested by Boris in http://lists.xenproject.org/archives/html/xen-devel/2014-11/msg02278.html) mark the vLAPIC hardware disabled for PVH guests and prevent it from getting moved out of this state. Reported-by: Boris Ostrovsky Signed-off-by: Jan Beulich Release-Acked-by: Konrad Rzeszutek Wilk --- xen/arch/x86/hvm/hvm.c | 6 +++--- xen/arch/x86/hvm/vlapic.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8f49b440dd..51ffc90a57 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2217,8 +2217,7 @@ int hvm_vcpu_initialise(struct vcpu *v) goto fail1; /* NB: vlapic_init must be called before hvm_funcs.vcpu_initialise */ - if ( is_hvm_vcpu(v) ) - rc = vlapic_init(v); + rc = vlapic_init(v); if ( rc != 0 ) /* teardown: vlapic_destroy */ goto fail2; @@ -4483,7 +4482,8 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content) break; case MSR_IA32_APICBASE: - if ( !vlapic_msr_set(vcpu_vlapic(v), msr_content) ) + if ( unlikely(is_pvh_vcpu(v)) || + !vlapic_msr_set(vcpu_vlapic(v), msr_content) ) goto gp_fault; break; diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 0b7b607de4..72b6509c5e 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1429,6 +1429,12 @@ int vlapic_init(struct vcpu *v) HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "%d", v->vcpu_id); + if ( is_pvh_vcpu(v) ) + { + vlapic->hw.disabled = VLAPIC_HW_DISABLED; + return 0; + } + vlapic->pt.source = PTSRC_lapic; if (vlapic->regs_page == NULL) -- 2.39.5