Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5989722ybc; Wed, 27 Nov 2019 13:00:56 -0800 (PST) X-Google-Smtp-Source: APXvYqzM/QNu1D4rg+eGbH7KE3VDZ3nb3uuijkit1Bj4KT9Ec6Z34vFFWit5uRiFDAuM3TOn2cBN X-Received: by 2002:a1c:750f:: with SMTP id o15mr5938705wmc.161.1574888456091; Wed, 27 Nov 2019 13:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888456; cv=none; d=google.com; s=arc-20160816; b=Y9w7LAtnvyU93/cTxHt4PwiOhBvUzHNntMhlpfeQRmiFXJFWrv8fsDuEWAZOk0BYbm pGd+q5T9zTpIyZ1ht/qs7n4hxNXbFpqgSzwN4aLjFMpV+BCyp8rnXlvZUHkOBybWS0/C IadRsIMeliROMyDDQlsZoHj6iZOyJwsFX9Hk3jc07ZKZwaAef4LyJxJh0Ql2uSk9XMmZ bY83wqkL9Rwqxhh0dfaqRO3Mkh5EQP8+HOjf8Wj4idBAHUirtNHo3rKVyPaQ15o4ErXm gmMNBVt5rJfqbRuu1y+rbS3iPsuSZgnJaU0NB8EqPpXn4Hbjo0IzMOvu4mtNlUxbDWK8 x70A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hA5BkLkYltzzxJxW6A6y/xDI0K3+a87l4RVnlZZDeno=; b=l0Z3eoC+VZddpo0TdANElyFvgHv2AepVTmpDGiO4/BfrfHYYZYUiiX16vZwXrYJ1yl 9Hhlvr0I+kxbk1gMlZ64rJNh6G66yT1MS6q/I/fWF6FQsnNVlJcT59Q4Z6NQ1ZcKNt1i sj34cdhgjggTqKHAW8ZAGcNnu7Nfvzlaaz8ejVxuaLD1lusqzL12cLM/KUr3Q/OCmq2l I4JFnvMlxYR1GcM44QVY1rWfK2JAirjrWPGqRobeRJZ9SrdmedP0qXU/K3UrN05TAjVw 8CsdzE7NYQw1wvZ7xVEWt4hfmYRUA0xxI9+RL8qtVuxRtaUSZhCj0gKPEw0ssslPfQ5t DBkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="kQxjkJ/g"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q30si12002224edb.372.2019.11.27.13.00.32; Wed, 27 Nov 2019 13:00:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="kQxjkJ/g"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730937AbfK0U5m (ORCPT + 99 others); Wed, 27 Nov 2019 15:57:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:48774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730942AbfK0U5j (ORCPT ); Wed, 27 Nov 2019 15:57:39 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D5DB4217AB; Wed, 27 Nov 2019 20:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888259; bh=j6BAQHCSeUvTzCnq7OjgDnls3hqn4lnWjWlJ6zYEes8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQxjkJ/gSze9rUKfH0oLnMQ8+Dk213WcKC13e1pchcczI1LsRAoxEIsBXlLhCHqhf zBLzjr5iOFIhJfYy13/oiYh/yVgnoaZE/OhGqTlq0D6V7g0Vud9veKZ2u4pJRxdOYM IVMfbkM98W7CNITAy+NBKjnsnx9PWkXnqW45JQiw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 4.19 066/306] KVM: nVMX: reset cache/shadows when switching loaded VMCS Date: Wed, 27 Nov 2019 21:28:36 +0100 Message-Id: <20191127203119.599052282@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit b7031fd40fcc741b0f9b0c04c8d844e445858b84 ] Reset the vm_{entry,exit}_controls_shadow variables as well as the segment cache after loading a new VMCS in vmx_switch_vmcs(). The shadows/cache track VMCS data, i.e. they're stale every time we switch to a new VMCS regardless of reason. This fixes a bug where stale control shadows would be consumed after a nested VMExit due to a failed consistency check. Suggested-by: Jim Mattson Signed-off-by: Sean Christopherson Reviewed-by: Jim Mattson Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1ab4bb3d6a040..fe7fdd666f091 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -11013,6 +11013,10 @@ static void vmx_switch_vmcs(struct kvm_vcpu *vcpu, struct loaded_vmcs *vmcs) vmx->loaded_vmcs = vmcs; vmx_vcpu_load(vcpu, cpu); put_cpu(); + + vm_entry_controls_reset_shadow(vmx); + vm_exit_controls_reset_shadow(vmx); + vmx_segment_cache_clear(vmx); } /* @@ -12699,7 +12703,6 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual) vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS); vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); - vmx_segment_cache_clear(vmx); if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETING) vcpu->arch.tsc_offset += vmcs12->tsc_offset; @@ -13530,9 +13533,6 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, } vmx_switch_vmcs(vcpu, &vmx->vmcs01); - vm_entry_controls_reset_shadow(vmx); - vm_exit_controls_reset_shadow(vmx); - vmx_segment_cache_clear(vmx); /* Update any VMCS fields that might have changed while L2 ran */ vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, vmx->msr_autoload.host.nr); -- 2.20.1