Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2095214yba; Sun, 21 Apr 2019 23:43:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvJOqrnawO2C8euDHSHpIHjP3/ImsfSbL9WUZE3+vDw6G4NBvrDl7taP4+B4+ckOvTVR7a X-Received: by 2002:a65:480c:: with SMTP id h12mr17167874pgs.266.1555915436005; Sun, 21 Apr 2019 23:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555915435; cv=none; d=google.com; s=arc-20160816; b=cijq9zsVbQ7476DOaivy5XGAQlbA3feKaQ2f8e5TjBKfvXU03Fj0uG5xMEPuZL7KFs +C3yAhcdQmWP9SocswOLONpEtiwvL/xO7+6KebpPxDD4GysUQOsG7zVsDy28iqktlmaB pXtgyHabaRbWb8gNaalZ60dPegV3fOFLrYTFQpgVzy2lbL3lgVSmVStPigntyXPU37CV J9IgByacjJK9eUH65gP5mObCmNCRivm1mxmBNht6WISrI8SM/tVC5pCKkrGDcC0fMmTq Mzq4oH3fzMZAMMe+sSKUlduwjkJyqNKKOf7y8UKZTAGT6gJBzwTfA7jZEk7UxxAeyeQN dJ8A== 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=XBBCqyVDHw9uusQ+HxNHVh/dljCHVPmTB/3Z+mZrfzQ=; b=m6J7Qj7BYRlA3CN4boipK8CgNokiYkC0aZj4uEkM6it79aBv/fc66fY1nrxN0Vjz0m aNslAH8imPKiRof5O8BlFFvvxLwlHJ1vx6+SJVbUbNRnkak03fQRLVz6NK8NDW/mX6qz r568pL2WD/unt6qixl/pggEJApXR8m6AOv75mou3705Bp1SmCj1V0tGaT/3F7vkqL+9Q cyz+wge0PPPg5/x1gUZ9UkLPIIKFmOAdGwECY7J6EtIRNUY4rj4GnjnqbGXYBQdLmtHp lANZ1+q2ZqX+96WIKP0JnNrr5rMiGkWqxRnujxAOG0zLLdVpeJeTS4eWdVSl8GNogKAR 96Ig== 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 92si12361516plw.138.2019.04.21.23.43.41; Sun, 21 Apr 2019 23:43:55 -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 S1726906AbfDVGlv (ORCPT + 99 others); Mon, 22 Apr 2019 02:41:51 -0400 Received: from mga17.intel.com ([192.55.52.151]:59723 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbfDVGlv (ORCPT ); Mon, 22 Apr 2019 02:41:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Apr 2019 23:41:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,380,1549958400"; d="scan'208";a="225545279" Received: from xulike-server.sh.intel.com ([10.239.48.134]) by orsmga001.jf.intel.com with ESMTP; 21 Apr 2019 23:41:48 -0700 From: Like Xu To: kvm@vger.kernel.org, Paolo Bonzini Cc: Thomas Gleixner , Len Brown , linux-kernel@vger.kernel.org, like.xu@linux.intel.com Subject: [PATCH] KVM: x86: Add Intel CPUID.1F cpuid emulation support Date: Mon, 22 Apr 2019 14:40:34 +0800 Message-Id: <1555915234-2536-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 Expose Intel V2 Extended Topology Enumeration Leaf to guest only when host system has multiple software-visible die within each package. Signed-off-by: Like Xu --- arch/x86/kvm/cpuid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index fd39516..9fc14f2 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -65,6 +65,16 @@ u64 kvm_supported_xcr0(void) return xcr0; } +/* We need to check if the host cpu has multi-chip packaging technology. */ +static bool kvm_supported_intel_mcp(void) +{ + u32 eax, ignored; + + cpuid_count(0x1f, 0, &eax, &ignored, &ignored, &ignored); + + return boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && (eax != 0); +} + #define F(x) bit(X86_FEATURE_##x) int kvm_update_cpuid(struct kvm_vcpu *vcpu) @@ -426,6 +436,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, switch (function) { case 0: entry->eax = min(entry->eax, (u32)(f_intel_pt ? 0x14 : 0xd)); + entry->eax = kvm_supported_intel_mcp() ? 0x1f : entry->eax; break; case 1: entry->edx &= kvm_cpuid_1_edx_x86_features; @@ -544,6 +555,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, entry->edx = edx.full; break; } + /* function 0x1f has additional index. */ + case 0x1f: /* function 0xb has additional index. */ case 0xb: { int i, level_type; -- 1.8.3.1