Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2361040imb; Mon, 4 Mar 2019 03:12:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxlNZqcbr/qK199w0JmGAS/nUStZQKqAYkqT+mm+09ahtTRzf03jRgGe1IePYs0DE6P9AqA X-Received: by 2002:a63:814a:: with SMTP id t71mr18297234pgd.257.1551697945258; Mon, 04 Mar 2019 03:12:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551697945; cv=none; d=google.com; s=arc-20160816; b=b7m1LKaibQzC3PrcetT3aoL9ZSkVWAHif1vNqcBRiJBUGQJslxNF44LIUXKVVmcEus a+p5NAkMhO43DrKdIqdv2gB8CjR0+JrzdB/vinrNBbQgRb/6j+WbkgU2HhxpQxzYRR5Q CSP8A8q5uhhGgvHTjvxJqHoDOZWtvbT+znLPUgC0bAEbpuUT8uERIGo7NqTlDKbTy8Dp //DLro8ZTr3nHrb7KGNfXBSUOMU6O3MwahbPDRqn4Cga6kTrIAYbjRJAY5JV9lZRaCHE L67cyJHoW4YwKF7I5igFJZtpFJ29H7D0CGCRRYnKTRNrROpFCQ5pl9WWhxuo1qD/VnL+ MzAw== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=TjImXgzJiyBmIWCZG4tCldGkpF3z5KZd4Gc1ETwdxLU=; b=spNR+bXnShhA2Y14nhwNxkew/OuBSNiSVsViOoKy17ZhnQwCQ3eFrS6Hewgr95FT/f vUfRbUEigb2G4jkDiHrtJnZbLrGiWFuJhY8N0B2CtqdsH9xjsKkgpAvlOLG41J9quatf EIl/m05ocByvelup/o5LY/zavndp+Kug0r/PcmvxrdKA13Z9SLOg/Vfr9JFkv8MyVTRm Pi/H0j9sWoflbGNaxrN34ZFZQIzcFhcFrVPYsrgwl3HGnPQnR3+dcqueSpqZSCEgWnoX CeoG/IoAMap6RgJUYq4Yd3og4aMnjmNwJiLwkLDk8cuDC4+joV+go4U3grdZzdypjf1M J7Cg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q36si5078660pgk.143.2019.03.04.03.12.09; Mon, 04 Mar 2019 03:12:25 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbfCDLKJ (ORCPT + 99 others); Mon, 4 Mar 2019 06:10:09 -0500 Received: from mga02.intel.com ([134.134.136.20]:61172 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfCDLKJ (ORCPT ); Mon, 4 Mar 2019 06:10:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 03:10:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,439,1544515200"; d="scan'208";a="151846217" Received: from lxy-dell.sh.intel.com ([10.239.159.147]) by fmsmga001.fm.intel.com with ESMTP; 04 Mar 2019 03:10:03 -0800 Message-ID: <08b44b2b7aede11a350f234768d5c17f8445984e.camel@linux.intel.com> Subject: Re: [PATCH v4 15/17] kvm: x86: Report CORE_CAPABILITY on GET_SUPPORTED_CPUID From: Xiaoyao Li To: Paolo Bonzini , Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Dave Hansen , Ashok Raj , Peter Zijlstra , Ravi V Shankar Cc: linux-kernel , x86 , kvm@vger.kernel.org Date: Mon, 04 Mar 2019 19:10:06 +0800 In-Reply-To: <79b659fb-1c16-463d-aa74-f1b3d8a9db5d@redhat.com> References: <1551494711-213533-1-git-send-email-fenghua.yu@intel.com> <1551494711-213533-16-git-send-email-fenghua.yu@intel.com> <697ee0bd-a5f6-7712-017e-455eed5bc185@redhat.com> <79b659fb-1c16-463d-aa74-f1b3d8a9db5d@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-2.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-03-04 at 11:49 +0100, Paolo Bonzini wrote: > On 04/03/19 11:47, Xiaoyao Li wrote: > > On Mon, 2019-03-04 at 09:38 +0100, Paolo Bonzini wrote: > > > On 02/03/19 03:45, Fenghua Yu wrote: > > > > From: Xiaoyao Li > > > > > > > > In the latest Intel SDM, CPUID.(EAX=7H,ECX=0):EDX[30] will enumerate > > > > the presence of the IA32_CORE_CAPABILITY MSR. > > > > > > > > Update GET_SUPPORTED_CPUID to expose this feature bit to user space, so > > > > that user space know this bit can be enabled in CPUID. > > > > > > > > Signed-off-by: Xiaoyao Li > > > > --- > > > > arch/x86/kvm/cpuid.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > > > > index c07958b59f50..e0e17b9c65da 100644 > > > > --- a/arch/x86/kvm/cpuid.c > > > > +++ b/arch/x86/kvm/cpuid.c > > > > @@ -410,7 +410,8 @@ static inline int __do_cpuid_ent(struct > > > > kvm_cpuid_entry2 > > > > *entry, u32 function, > > > > /* cpuid 7.0.edx*/ > > > > const u32 kvm_cpuid_7_0_edx_x86_features = > > > > F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | > > > > - F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | > > > > F(INTEL_STIBP); > > > > + F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | > > > > F(CORE_CAPABILITY) | > > > > + F(INTEL_STIBP); > > > > > > This should be enabled always if > > > boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT), > > > since the MSR is emulated. This way, guests can always rely on > > > IA32_CORE_CAPABILITY_MSR and it won't have to rely on the FMS > > > (which means nothing inside a guest). > > > > > > Paolo > > > > Hi, Paolo > > Do you mean that we don't need this here, but to add the handling below? > > > > static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 * entry, u32 > > function, > > ... > > switch (function) { > > ... > > case 7: { > > ... > > if (index ==0) { > > ... > > if(boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) > > entry->edx |= F(CORE_CAPABILITY); > > } > > ... > > ... > > } > > ... > > } > > Yes, exactly. > > Paolo Like you said before, I think we don't need the condition judgment "if(boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT))", but to set F(CORE_CAPABILITY) always for guest since MSR_IA32_CORE_CAPABILITY is emulated. And we should set the right emulated value of MSR_IA32_CORE_CAPABILITY for guest in function kvm_get_core_capability() based on whether boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) just as you commented in the next patch. Xiaoyao > > > > /* all calls to cpuid_count() should be made on the same cpu */ > > > > get_cpu(); > > > > > > > > > > > >