From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 07/11] KVM: VMX: Fix delayed load of shared MSRs Date: Wed, 9 May 2012 16:10:43 +0300 Message-ID: <1336569047-23576-8-git-send-email-avi@redhat.com> References: <1336569047-23576-1-git-send-email-avi@redhat.com> Cc: Marcelo Tosatti , kvm@vger.kernel.org To: stable@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:27386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756981Ab2EINLW (ORCPT ); Wed, 9 May 2012 09:11:22 -0400 In-Reply-To: <1336569047-23576-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Shared MSRs (MSR_*STAR and related) are stored in both vmx->guest_msrs and in the CPU registers, but vmx_set_msr() only updated memory. Prior to 46199f33c2953, this didn't matter, since we called vmx_load_host_state(), which scheduled a vmx_save_host_state(), which re-synchronized the CPU state, but now we don't, so the CPU state will not be synchronized until the next exit to host userspace. This mostly affects nested vmx workloads, which play with these MSRs a lot. Fix by loading the MSR eagerly. Signed-off-by: Avi Kivity (cherry picked from commit 9ee73970c03edb68146ceb1ba2a7033c99a5e017) --- arch/x86/kvm/vmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3b4c8d8..fafb325 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2219,6 +2219,9 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) msr = find_msr_entry(vmx, msr_index); if (msr) { msr->data = data; + if (msr - vmx->guest_msrs < vmx->save_nmsrs) + kvm_set_shared_msr(msr->index, msr->data, + msr->mask); break; } ret = kvm_set_msr_common(vcpu, msr_index, data); -- 1.7.10.1