From patchwork Thu Mar 14 19:39:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 2273431 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 37389DFB79 for ; Thu, 14 Mar 2013 19:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751292Ab3CNTjg (ORCPT ); Thu, 14 Mar 2013 15:39:36 -0400 Received: from david.siemens.de ([192.35.17.14]:15842 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951Ab3CNTjf (ORCPT ); Thu, 14 Mar 2013 15:39:35 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id r2EJdVbS027554; Thu, 14 Mar 2013 20:39:31 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id r2EJdViT025770; Thu, 14 Mar 2013 20:39:31 +0100 Message-ID: <51422773.9010901@siemens.com> Date: Thu, 14 Mar 2013 20:39:31 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Marcelo Tosatti CC: Gleb Natapov , kvm , Paolo Bonzini Subject: [PATCH v2] KVM: VMX: Do not overwrite vcpu->srcu_idx in vmx_vcpu_reset References: <5141E41B.8080804@siemens.com> <20130314150004.GX11223@redhat.com> <20130314191438.GA9009@amt.cnet> <514222FA.9060706@siemens.com> In-Reply-To: <514222FA.9060706@siemens.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org vmx_vcpu_reset may now be called while already holding the srcu lock, so we may overwrite what was already saved there. Save and restore it. Signed-off-by: Jan Kiszka --- Even if this should be unneeded, it looks more consistent. In any case, all versions on the table, pick what you prefer. arch/x86/kvm/vmx.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 958ac3a..7bc49ca 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4117,6 +4117,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); u64 msr; + int idx; vmx->rmode.vm86_active = 0; @@ -4190,9 +4191,11 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu) vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; + idx = vcpu->srcu_idx; vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */ srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); + vcpu->srcu_idx = idx; vmx_set_cr4(&vmx->vcpu, 0); vmx_set_efer(&vmx->vcpu, 0); vmx_fpu_activate(&vmx->vcpu);