Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755305AbeAILBl (ORCPT + 1 other); Tue, 9 Jan 2018 06:01:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46760 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752212AbeAILBi (ORCPT ); Tue, 9 Jan 2018 06:01:38 -0500 Subject: Re: [PATCH 4/7] kvm: vmx: Set IBPB when running a different VCPU To: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jmattson@google.com, aliguori@amazon.com, thomas.lendacky@amd.com, dwmw@amazon.co.uk, bp@alien8.de, Tim Chen References: <1515434925-10250-1-git-send-email-pbonzini@redhat.com> <1515434925-10250-5-git-send-email-pbonzini@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Tue, 9 Jan 2018 12:01:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1515434925-10250-5-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 09 Jan 2018 11:01:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 08.01.2018 19:08, Paolo Bonzini wrote: > From: Tim Chen > > Ensure an IBPB (Indirect branch prediction barrier) before every VCPU > switch. > > Signed-off-by: Tim Chen > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/vmx.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index d00bcad7336e..bf127c570675 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -2375,6 +2375,8 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) { > per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs; > vmcs_load(vmx->loaded_vmcs->vmcs); > + if (have_spec_ctrl) > + wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB); > } > > if (!already_loaded) { > @@ -4029,6 +4031,13 @@ static void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) > free_vmcs(loaded_vmcs->vmcs); > loaded_vmcs->vmcs = NULL; > WARN_ON(loaded_vmcs->shadow_vmcs != NULL); > + > + /* > + * The VMCS could be recycled, causing a false negative in > + * vmx_vcpu_load; block speculative execution. > + */ > + if (have_spec_ctrl) > + wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB); > } > > static void vmx_nested_free_vmcs02(struct vcpu_vmx *vmx) > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb