Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933137AbeAHTYN (ORCPT + 1 other); Mon, 8 Jan 2018 14:24:13 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:53516 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932979AbeAHTYJ (ORCPT ); Mon, 8 Jan 2018 14:24:09 -0500 Message-ID: <5A53C547.60901@ORACLE.COM> Date: Mon, 08 Jan 2018 21:23:51 +0200 From: Liran Alon User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 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 Subject: Re: [PATCH 4/7] kvm: vmx: Set IBPB when running a different VCPU References: <1515434925-10250-1-git-send-email-pbonzini@redhat.com> <1515434925-10250-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1515434925-10250-5-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8768 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801080275 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 08/01/18 20: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: Liran Alon