Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756981AbeAIOYB (ORCPT + 1 other); Tue, 9 Jan 2018 09:24:01 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:37588 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752397AbeAIOX6 (ORCPT ); Tue, 9 Jan 2018 09:23:58 -0500 Date: Tue, 9 Jan 2018 09:23:42 -0500 From: Konrad Rzeszutek Wilk To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, rkrcmar@redhat.com, liran.alon@oracle.com, jmattson@google.com, aliguori@amazon.com, thomas.lendacky@amd.com, dwmw@amazon.co.uk, bp@alien8.de, x86@kernel.org Subject: Re: [PATCH 7/8] x86/svm: Set IBPB when running a different VCPU Message-ID: <20180109142342.GE18661@char.us.oracle.com> References: <20180109120311.27565-1-pbonzini@redhat.com> <20180109120311.27565-8-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180109120311.27565-8-pbonzini@redhat.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8768 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1801090203 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 09, 2018 at 01:03:09PM +0100, Paolo Bonzini wrote: > From: Tom Lendacky > > Set IBPB (Indirect Branch Prediction Barrier) when the current CPU is > going to run a VCPU different from what was previously run. Nested > virtualization uses the same VMCB for the second level guest, but the > L1 hypervisor should be using IBRS to protect itself. > > Signed-off-by: Tom Lendacky > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/svm.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 934a21e02e03..97126c2bd663 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -289,6 +289,7 @@ struct amd_svm_iommu_ir { > module_param(vgif, int, 0444); > > static bool __read_mostly have_spec_ctrl; > +static bool __read_mostly have_ibpb_support; > > static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); > static void svm_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa); > @@ -540,6 +541,7 @@ struct svm_cpu_data { > struct kvm_ldttss_desc *tss_desc; > > struct page *save_area; > + struct vmcb *current_vmcb; > }; > > static DEFINE_PER_CPU(struct svm_cpu_data *, svm_data); > @@ -1151,6 +1153,11 @@ static __init int svm_hardware_setup(void) > pr_info("kvm: SPEC_CTRL available\n"); > else > pr_info("kvm: SPEC_CTRL not available\n"); > + have_ibpb_support = have_spec_ctrl || cpu_has_ibpb_support(); > + if (have_ibpb_support) > + pr_info("kvm: IBPB_SUPPORT available\n"); > + else > + pr_info("kvm: IBPB_SUPPORT not available\n"); pr_info("kvm: IBPB_SUPPORT %s available" .. you know :-)