Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp790326yba; Fri, 26 Apr 2019 08:47:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkpjpbNb+zR0jVEb9Jz6bxiaqZLMv0bJn4mzwVMdk/jSZOOnKExS5SpOZitNGwblfCJcDO X-Received: by 2002:a63:6fcd:: with SMTP id k196mr43847839pgc.238.1556293648324; Fri, 26 Apr 2019 08:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556293648; cv=none; d=google.com; s=arc-20160816; b=w1LISleDzet0lwUE3i3gKSr2W7dpnK/dQKfIV2Rcsq7Py0Nf/dwBjO2Z86n7WTz0QW szdLR9O2ST9Nyb7fm0nlpqys3zAYUu5wfyuOEUTkCVjQkSKLjit5Ni1n+QsQzbfskV/K iHVlsfIn3/1hvQL24NIcB/zg8HDT4giisVlFOKU3Kyw0bOxtU7irzvd+zuWqyNkrVHSB YzELpJqumIJsZp0aKaHD6uvR9SfaCpvmJiNTI9bYuQ7S7WGcgg/9v1eOwWJ5XcUOrBz5 tS4VBTluLDqrGs5ZalNPFBExDQUS28X1VgYjqQlPBlPMRVxkByBg6SeVULdR62pi5tPC hSiw== 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=Jar2+c+4RuAlVeJDITezz8ipW2NlsDplHNm4vMAl9Mc=; b=G1ahBFVwGV0eli2z+o/pd6J3lBW5Gy3KWXCTK136XvdTqPKHfIjzNkK6OfNCZ9s00j SrJEN8b4DxNnXmg0FUXGS3g59Uu9lTCpmvIoYy6GFQSRXW2ssFAS48REqLy40B0Bw5F9 NF6E1AyPC5kYzHhpElnlPelE83pgyJOcIio5Tg3F8mYO7gZrCiWRkbuu3gpBiDLyl18U UxEfWu5rTMTVSyqjGGHooFLF4X1KxE31sn+57pRDkOKVn07jykHYjgPv2KHONFRC83il v1+7aGfA9+sG5r8ywtMe24/WsUHKzd0YyBIoknYypl67a3MlovMYg02tAuxRABe3VVOb VbfA== 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 p185si6862736pgp.566.2019.04.26.08.47.12; Fri, 26 Apr 2019 08:47:28 -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 S1726597AbfDZPqH (ORCPT + 99 others); Fri, 26 Apr 2019 11:46:07 -0400 Received: from mga05.intel.com ([192.55.52.43]:60041 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbfDZPqH (ORCPT ); Fri, 26 Apr 2019 11:46:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 08:46:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,398,1549958400"; d="scan'208";a="341089197" Received: from xulike-server.sh.intel.com ([10.239.48.134]) by fmsmga006.fm.intel.com with ESMTP; 26 Apr 2019 08:46:05 -0700 From: Like Xu To: Paolo Bonzini , kvm@vger.kernel.org Cc: Thomas Gleixner , Sean Christopherson , Xiaoyao Li , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org Subject: [PATCH v3] KVM: x86: Add Intel CPUID.1F cpuid emulation support Date: Fri, 26 Apr 2019 23:44:46 +0800 Message-Id: <1556293486-8888-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 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. 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