Message ID | 20240203091214.411862-10-zhao1.liu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-50987-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp971687dyc; Sat, 3 Feb 2024 03:36:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYU7TnS4xB74z3p4Xp50QntwztRS9y8041Ho0HozIlZ7LM4ASkJxxswpgYkaX6Sf3NKcG+ X-Received: by 2002:a05:6402:322:b0:560:29aa:f4a5 with SMTP id q2-20020a056402032200b0056029aaf4a5mr439111edw.37.1706960209008; Sat, 03 Feb 2024 03:36:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706960208; cv=pass; d=google.com; s=arc-20160816; b=hjjlmxzbipQDSgn72+9rYKzgGZ77kP/jVzObXxawi/BmeF+Mi3O290Ul/NNETq0bDr nw0F3/Cbaw34bDoN49JM2I6PM69kL8EVHAOobvNcI0D0aBBVOPNQ21jyxcSTEi/XK45J 6clDzj1on1M6SwpdUzObY2SWY8uqivgIkbcIb/wSSGRocWykMvSspXqMj9stUL5CjVcr R/oBVM9Tyh/6EkKLpmi9YY3frPR+k2p8YQb7cVlI9/4qIoond8WEBRXGZEeYnQWpaeJC Db3aofIHAYGAl6whqrIL77Vhfdn6aAKVcucANCivZ8rQ3WCL+62XNsH5TPsjHTdJuolW k6/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/qyMegXaBT8e7AJDJKNhDJg45byYuAHqwqJERBXHOmE=; fh=R0+iWjMXXrH7vBXqhzwt/7bo6wqS5MrQFUdIPw9er64=; b=GL6HKjAoB2rwv+XZjndr4igBSxKplG2CnXd5MU8F1ewC54+BoWVZJrKFgxQ7sx73ii 3BjVZxjeT93GbCFTtXQPH0Zn8ccA0rgVt5aFVx/M8FkKHMY7WMtqLUcvRPVH3pbDgU1b tOwWR26sTypIcmFR4Jpn7kZbM8MNy2Dza1vBjQLiXMsjwiquW3NjcKDLk1gAIfStel/F MI0rq+lo3bxTVhvBpH7/AaWqPyjMSUuupmOaaNIXCf/8zceiDYFd+Z0WhXyEQ6/9HFC7 +xbLUCBfOzKk97Cj2JBpvMTu+Or/FZIRtRMX3NbPckKt1MIMVOIVtQMrm28kFSGgDN7w 2p7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lcGpilDs; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50987-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50987-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCUZIovkAFge967dZXTAwplbtsqzsctDOKlruruf+eg8VkSSVkNKxhZKoTs7WvDXKgk+xO/iJZ3i7nfoPAI8DGXx1DAXuw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bc25-20020a056402205900b0055feed5f94fsi1528717edb.400.2024.02.03.03.36.48 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 03:36:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50987-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lcGpilDs; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50987-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50987-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4C28E1F2A37E for <ouuuleilei@gmail.com>; Sat, 3 Feb 2024 09:03:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E72A45F85C; Sat, 3 Feb 2024 09:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lcGpilDs" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE03B5F57F; Sat, 3 Feb 2024 09:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706950839; cv=none; b=AXAmzWwC/DEsCtXhMAtwZmBq4Up3PW52ysFlqaKlbCTHKCQO+HT6EIvjIaMc31jhk7rbt3tUqGkjx4rFF+5oJWVyBEuJ4+O4dQLYtXk75zWf4y5E/9zV48RLrflnBy2yW2JrLZyq18qAsoJmflpwNJIvzx9SksjAdo+YBB0ZoQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706950839; c=relaxed/simple; bh=UAl/onYRs7BB51ytgYE6qoZNfSltN0H9mc+OMwUe7do=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VUNwnOFY3xo24S60n2th706DYvuOAT49F6NeNrhZxrW4vHHv9AJGP0TLh2XgZUwJMxVz1G89eRP4MXBAr7P71rCoTVm2iGbAaw9LJ92y11GNO9HD+0UBwXYlMkjf3Q5WP+NFUrzX7RfUT4n8NU1poaYkNed8AheeqXZp886Ephs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lcGpilDs; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706950838; x=1738486838; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UAl/onYRs7BB51ytgYE6qoZNfSltN0H9mc+OMwUe7do=; b=lcGpilDsIvPVGUbBZqsiAWieRMn5NP+/YQv8j8BzFaaRxpY3x/oM9nlP jZecC9uxuFxaM1gB/c1zfVSnbo3HpXz3HvAS4r9Odhb1g3bclBRGgXNOw smS0jitA+DYM1HNezy9EPomRwpnRU8kLTX1yBrePN55xje/0UB93iZuCQ EkOg47uzCvqFrVtqgiBaoRtBLY3ChNcBDMBxe9Z7Yv4HLCTV+HSVvhkSB y/PukPFsi0qjgnzJuNwiimuyyvNpNwK07g3E2uS4Anv9GUx1jgy4SBjS9 eviMi5IZflCxcVnhzGs/gcn5rZg4fmADgVomk/IIwnl9myXn1Ll6CUohT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="4131970" X-IronPort-AV: E=Sophos;i="6.05,240,1701158400"; d="scan'208";a="4131970" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2024 01:00:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,240,1701158400"; d="scan'208";a="291279" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa009.fm.intel.com with ESMTP; 03 Feb 2024 01:00:31 -0800 From: Zhao Liu <zhao1.liu@linux.intel.com> To: Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com>, "Rafael J . Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H . Peter Anvin" <hpa@zytor.com>, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>, Len Brown <len.brown@intel.com>, Zhang Rui <rui.zhang@intel.com>, Zhenyu Wang <zhenyu.z.wang@intel.com>, Zhuocheng Ding <zhuocheng.ding@intel.com>, Dapeng Mi <dapeng1.mi@intel.com>, Yanting Jiang <yanting.jiang@intel.com>, Yongwei Ma <yongwei.ma@intel.com>, Vineeth Pillai <vineeth@bitbyteword.org>, Suleiman Souhlal <suleiman@google.com>, Masami Hiramatsu <mhiramat@google.com>, David Dai <davidai@google.com>, Saravana Kannan <saravanak@google.com>, Zhao Liu <zhao1.liu@intel.com> Subject: [RFC 09/26] KVM: x86: cpuid: Define CPUID 0x06.eax by kvm_cpu_cap_mask() Date: Sat, 3 Feb 2024 17:11:57 +0800 Message-Id: <20240203091214.411862-10-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240203091214.411862-1-zhao1.liu@linux.intel.com> References: <20240203091214.411862-1-zhao1.liu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789877508318571798 X-GMAIL-MSGID: 1789877508318571798 |
Series |
Intel Thread Director Virtualization
|
|
Commit Message
Zhao Liu
Feb. 3, 2024, 9:11 a.m. UTC
From: Zhao Liu <zhao1.liu@intel.com> PTS, HFI, and ITD feature bits are to be specified in kvm_cpu_caps and depend on Host support. Define kvm_cpu_caps[CPUID_6_EAX] with kvm_cpu_cap_mask() and use this 0x06 cap feature to set the 0x06 leaf of the guest. Currently, only ARAT is supported in 0x06.eax. Although ARAT is not available on all CPUs with VMX support[1], commit e453aa0f7e7b ("KVM: x86: Allow ARAT CPU feature") always sets ARAT for Guest because the APIC timer is emulated. Explicitly check ARAT in __do_cpuid_func() and make sure this feature bit is always set. [1]: https://lore.kernel.org/kvm/1523455369.20087.16.camel@intel.com/ Tested-by: Yanting Jiang <yanting.jiang@intel.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> --- 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 829bb9c6516f..d8cfae17cc92 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -628,6 +628,10 @@ void kvm_set_cpu_caps(void) 0 /* HTT */ | F(ACC) | 0 /* Reserved, PBE */ ); + kvm_cpu_cap_mask(CPUID_6_EAX, + F(ARAT) + ); + kvm_cpu_cap_mask(CPUID_7_0_EBX, F(FSGSBASE) | F(SGX) | F(BMI1) | F(HLE) | F(AVX2) | F(FDP_EXCPTN_ONLY) | F(SMEP) | F(BMI2) | F(ERMS) | F(INVPCID) | @@ -964,7 +968,12 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) } break; case 6: /* Thermal management */ - entry->eax = 0x4; /* allow ARAT */ + cpuid_entry_override(entry, CPUID_6_EAX); + + /* Always allow ARAT since APICs are emulated. */ + if (!kvm_cpu_cap_has(X86_FEATURE_ARAT)) + entry->eax |= 0x4; + entry->ebx = 0; entry->ecx = 0; entry->edx = 0;