Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp208992yba; Thu, 25 Apr 2019 21:33:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBizMmIAw1+JBs35+Bimaj8zvSYJUGCOtM9RHA8asX06tIwowdnGOTOwA44+dHIkvrBbsE X-Received: by 2002:aa7:8c84:: with SMTP id p4mr26223134pfd.164.1556253238441; Thu, 25 Apr 2019 21:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556253238; cv=none; d=google.com; s=arc-20160816; b=reGTf/coMg22g+QMmRpFA6htV1c+PCHrikcILwaQO99uXliqYQnANN0NXaXYF7biPO i4aiei7sbwE1ilcHwHUDClNpQXwb3Eka6CawOygrAQRm/8Ar3MkrqoSrH1Uw97L3MCtb OQ22bkhCjCviQatW8ebZ+vSun503+ruU5kRROjR2H88W/85m1NNXLm3i64S7VGzSjgnI gVtbpU5dvBkWRiMsxHYE17WCBl3PVG8Z+fXNhmKG29vGjaMSlTH+RlKEPIVHo/JfOr7p 4hl0atvUnCHer/wTW1e7hszA3dxS8zaRZSuLXfjTIxQ9Pgm0+DMJobVhh+PpS9uAEOup bXAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Eojglw2WIiSkBcKf7oBufKv+T8k6eq/Lu1Rn73lnvoQ=; b=jdjlbTg+DnW8bq2zlUeBlGeWL+AMqO1XFNwZxSZ3feHMVggHYzxZ81lLx8t9KvsNRJ 6oyfsdNVG05jZZM9TSIsGBj6RablLGrFe1/7Zbc7cKvNOb+VnMKAexmtbnjlKeHRNhLy 9u3z4MFZOrWIMp83MeNq2hCMF33zrzYZ+tbLr1pYvcHK7+gJFocFGoRRS61pP2bUT+1Z 556F5J9fRFqjWjeYE/iFdCmpkJYn93a4tm+ws4uegWgPkYU8FezV07knqm2l6QFuwHrQ bemXiTXcR6bcXQXu/nVas93R5VsP5Jd+S9QMvffnDukykUTaRCflbjMQNKWxerf2YL+4 BZBw== 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 d2si15675167pll.393.2019.04.25.21.33.41; Thu, 25 Apr 2019 21:33:58 -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 S1728233AbfDZDTO (ORCPT + 99 others); Thu, 25 Apr 2019 23:19:14 -0400 Received: from mga02.intel.com ([134.134.136.20]:27433 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbfDZDTO (ORCPT ); Thu, 25 Apr 2019 23:19:14 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2019 20:19:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,396,1549958400"; d="scan'208";a="319087374" Received: from xulike-server.sh.intel.com ([10.239.48.134]) by orsmga005.jf.intel.com with ESMTP; 25 Apr 2019 20:19:12 -0700 From: Like Xu To: kvm@vger.kernel.org Cc: Sean Christopherson , Xiaoyao Li , Paolo Bonzini , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org Subject: [PATCH v2] KVM: x86: Add Intel CPUID.1F cpuid emulation support Date: Fri, 26 Apr 2019 11:17:52 +0800 Message-Id: <1556248672-6469-1-git-send-email-like.xu@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some new systems have multiple software-visible die within each package. Add support to expose Intel V2 Extended Topology Enumeration Leaf CPUID.1F. Co-developed-by: Xiaoyao Li Signed-off-by: Xiaoyao Li Signed-off-by: Like Xu --- ==changelog== 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index fd39516..f9b529e 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,12 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, entry->edx = edx.full; break; } - /* function 0xb has additional index. */ + /* + * Intel documentation states that 0x1f and 0xb have + * identical formats and thus can be handled by common code. + * (Intel SDM Vol. 2A - Instruction Set Reference - CPUID) + */ + case 0x1f: case 0xb: { int i, level_type; -- 1.8.3.1