Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp807120yba; Fri, 26 Apr 2019 09:04:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqKeyl5Vdol4zry+cd9AMt0pKADhvUumTs/TyjOnSlLeKAnK0IejAx5Q+JUfYYAlnJZVK7 X-Received: by 2002:a17:902:a01:: with SMTP id 1mr46481661plo.36.1556294653658; Fri, 26 Apr 2019 09:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556294653; cv=none; d=google.com; s=arc-20160816; b=AhvhWwPAHSUXv9y7tNktxZ2np4M8sI3wqbbifDCtd72UWDlkOMnQE39ePgxCm+YTrr n/yLzBcZ6Ix1lH9KaNxk8cMbLJLwezrjEwYSHdEwV3KE6XX1d8RC3z4h0C3V43Eqp9LO WYi6VJ9WwKNlo5o5+7f6JftY9rV9JXpqL2JFDTGgcxQaouvmLy6bsvPmt9BUpRKgIsR9 2Hi93FeSt8mtUmfJZWzVDRf88et4z4ADVk4ML5mdezMtQ8zfTLzlE91ogvw9cId22JPJ gFqSTKc5qALdbgDWhzy+0wezn0djhYcWRKGu4XQxZZEzr3tx8g5njCPyXunBjTgg32t5 gK9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9jYsjdmRIyXqtKhnv4mGa8PENOMbUOTg8+Fe0vDVMDc=; b=PrDpqa0nDhcr2F6icYgaDUibDUdEAI1pwo0K2tsyiZRdLnuP2FQiuNaXpNK/RGED7r Ote+lfQe83aPhVYuHrdh8srmqPWyH50o4HfquUm8tSXdQJXN4y4ys8nMRLbvhF9PyMF6 AWFn1HmQJi8KAYzgSzGa/1tqMe0LfBQMhUTkOkQ0YidSKt4oivnrA5w7IG4ossBhIvEn SkDxyKNUoVoOAav3xhR7Ju8mvMoNymYV4TVYe2P8juo945VPttsLYYJo5IWunE1AUL3/ 3CLWiiAuNtykVSEdJWvJI7k0/8W+w+tjhZpouCKwLjceNlG8snU1PD5Zui46K7lnkS1A cofg== 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 h66si24204807pgc.418.2019.04.26.09.03.57; Fri, 26 Apr 2019 09:04:13 -0700 (PDT) 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 S1726410AbfDZQCq (ORCPT + 99 others); Fri, 26 Apr 2019 12:02:46 -0400 Received: from mga07.intel.com ([134.134.136.100]:27034 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbfDZQCp (ORCPT ); Fri, 26 Apr 2019 12:02:45 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 09:02:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,398,1549958400"; d="scan'208";a="134655047" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by orsmga007.jf.intel.com with ESMTP; 26 Apr 2019 09:02:45 -0700 Date: Fri, 26 Apr 2019 09:02:45 -0700 From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , kvm@vger.kernel.org, Thomas Gleixner , Xiaoyao Li , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] KVM: x86: Add Intel CPUID.1F cpuid emulation support Message-ID: <20190426160244.GA5224@linux.intel.com> References: <1556293486-8888-1-git-send-email-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556293486-8888-1-git-send-email-like.xu@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 26, 2019 at 11:44:46PM +0800, Like Xu wrote: > Add support to expose Intel V2 Extended Topology Enumeration Leaf for > some new systems with multiple software-visible die within each package. > > When CPUID executes with EAX set to 1FH, the processor returns information > about extended topology enumeration data. Software must detect the presence > of CPUID leaf 1FH by verifying (a) the highest leaf index supported by > CPUID is >= 1FH, and (b) CPUID.1FH:EBX[15:0] reports a non-zero value. Nit: When quoting the SDM, it's helpful to explicitly say so, otherwise readers may assume you're just stating your take on things. Reviewed-by: Sean Christopherson > > Co-developed-by: Xiaoyao Li > Signed-off-by: Xiaoyao Li > Signed-off-by: Like Xu > --- > > ==changelog== > v3: > - Redefine commit message and comment > > v2: > - Apply cpuid.1f check rule on Intel SDM page 3-222 Vol.2A > - Add comment to handle 0x1f anf 0xb in common code > - Reduce check time in a descending-break style > > v1: https://lkml.org/lkml/2019/4/22/28 > > arch/x86/kvm/cpuid.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index fd39516..176a67a 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -425,6 +425,11 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, > > switch (function) { > case 0: > + /* Check if the cpuid leaf 0x1f is actually implemented */ > + if (entry->eax >= 0x1f && (cpuid_ebx(0x1f) & 0x0000ffff)) { > + entry->eax = 0x1f; > + break; > + } > entry->eax = min(entry->eax, (u32)(f_intel_pt ? 0x14 : 0xd)); > break; > case 1: > @@ -544,7 +549,11 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, > entry->edx = edx.full; > break; > } > - /* function 0xb has additional index. */ > + /* > + * Per Intel's SDM, 0x1f is a superset of 0xb, thus they can be handled > + * by common code. > + */ > + case 0x1f: > case 0xb: { > int i, level_type; > > -- > 1.8.3.1 >