From patchwork Thu Nov 10 01:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp671532wru; Wed, 9 Nov 2022 17:59:44 -0800 (PST) X-Google-Smtp-Source: AMsMyM6qHp32y0xuIKr0wRTP3LPzMkjlaLVHMgnpW52GszT0yNekaaAZdA4MIclDqE6xh+rDe7l+ X-Received: by 2002:a17:907:b1c:b0:7ad:c361:422 with SMTP id h28-20020a1709070b1c00b007adc3610422mr53860449ejl.275.1668045584233; Wed, 09 Nov 2022 17:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045584; cv=none; d=google.com; s=arc-20160816; b=ygedJFFLe4hIZrTXgJqte8Jc1GAY9WLhdSxurg0s+UTbpDx4RzAQfDGW9LemJCUrHL UHFZgZeDyZXobk2kysPOABIxr7xyRo6MWQLzhAp51ShmkyRRrgeKzC9RgVrNbhCpBcrE LBp3UbCTtPsqhznDzjzlT9bFM9tT3K+XmWboKu6tjoIB47FfniVE03uLtgS7vjWK2wdU 7o+xfo2fEK6zBty8utkQq/mQUd4SPFkOncZOpo3Rjaok0wSayCw+gbbZMLfDImfkIIJV f6h70uaAQ6Lg2lhHI1fVJIKLlbiBdxqYofsCSR6a787Zgxf5Xs49MyJcXOqFgR+q4QQU MM6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g7upOlgdOZZIhADDiOe7l9zIMzxBTfDuLzqBVzKu9f0=; b=DlpytaN8VFAGOZPok6FmkQEwb8VUAV2vAZFEn6VSwxxg4DJdy1Rs1e0dEKsXdYXBMB y72QfWDTt2u38NdE400IorMBx+7xA2APD5riWzJR1qipTjRYKohyb8D9jXCqSS9YmqXa fIhYBSAy+vXGjDgObcnQseOrqniVQz3NU07w07EQ53+5BCXU+lrETccE3hV/c7KxLMbT FigB3tYEAy7Mhp8W5mv2kJRxFl2OwS16ZKtg/iHm3aCQUTgrBHETIYd7u5lbN6Oawgeb UuunD42x/J7dwXwh1WM5WlejqD2kvoTwB0pROaoQ/LgKyPOL3PgrwnUWFGhkypzm+Ypn 7a9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Rk+ydzOw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a1709064fc500b007aacd494fe9si16021692ejw.311.2022.11.09.17.59.20; Wed, 09 Nov 2022 17:59:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Rk+ydzOw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232324AbiKJB5D (ORCPT + 99 others); Wed, 9 Nov 2022 20:57:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232024AbiKJB4j (ORCPT ); Wed, 9 Nov 2022 20:56:39 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFED43055D; Wed, 9 Nov 2022 17:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045369; x=1699581369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Aa+hmfCC+4pXGPdI3/P0Vz02MWKoodX4VOXGoZFJDy4=; b=Rk+ydzOwt0QxCYnYiEJOASVSvesDc62yl8AMFqQ6qS1NujyzKM4x/RXT fYlVhn/C9UTGqbAT4vDLloRvI72cVcb3NG2wr1Xtl6dO4XC++Ro8ZMJK8 veApMTP/PmLJTt1Oew3XJatdy4bCDA2bWWHDljeZ1+5FwQcMqqE4WvW2l KlAHv0EaEld6tgq8joWg1eZS/sjh8oExvRnxHMnnD1ImaQrA67QstTn1m 82n9bORcYdzJby4zLzn7PbKi9HJKkAqHpwa5U+V7JfR4MDNzRdXTIypCm Muc29ZIMpLFuCvQNpxY4ChhdGxfnCtbOedke8KEUdSMWWScmHemw+ioQ7 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="309894472" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="309894472" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:52:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762099785" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762099785" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:52:53 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/7] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf Date: Thu, 10 Nov 2022 09:52:46 +0800 Message-Id: <20221110015252.202566-2-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072566320655687?= X-GMAIL-MSGID: =?utf-8?q?1749072566320655687?= cpuid_leaf[12] CPUID_7_1_EAX has only two bits are in use currently: - AVX-VNNI CPUID.(EAX=7,ECX=1):EAX[bit 4] - AVX512-BF16 CPUID.(EAX=7,ECX=1):EAX[bit 5] These two bits have no other kernel usages other than the guest CPUID advertisement in KVM. Given that and to save space for kernel feature bits, move these two bits to the kvm-only subleaves. The existing leaf cpuid_leafs[12] is set to CPUID_LNX_5 so future feature can pick it. This basically reverts: - commit b85a0425d805 ("Enumerate AVX Vector Neural Network instructions") - commit b302e4b176d0 ("x86/cpufeatures: Enumerate the new AVX512 BFLOAT16 instructions") - commit 1085a6b585d7 ("KVM: Expose AVX_VNNI instruction to guset") Signed-off-by: Jiaxi Chen --- arch/x86/include/asm/cpufeature.h | 2 +- arch/x86/include/asm/cpufeatures.h | 4 +--- arch/x86/kernel/cpu/common.c | 6 ------ arch/x86/kernel/cpu/cpuid-deps.c | 1 - arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 5 +++++ 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 1a85e1fb0922..b2905ddd7ab4 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -24,7 +24,7 @@ enum cpuid_leafs CPUID_7_0_EBX, CPUID_D_1_EAX, CPUID_LNX_4, - CPUID_7_1_EAX, + CPUID_LNX_5, CPUID_8000_0008_EBX, CPUID_6_EAX, CPUID_8000_000A_EDX, diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index b71f4f2ecdd5..ec468d6eaf06 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -305,9 +305,7 @@ #define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime firmware calls */ #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17) /* "" Fill RSB on VM exit when EIBRS is enabled */ -/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ -#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ -#define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */ +/* Linux-defined mapping, word 12 */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 3e508f239098..0c19c84d7ba0 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1026,12 +1026,6 @@ void get_cpu_cap(struct cpuinfo_x86 *c) c->x86_capability[CPUID_7_0_EBX] = ebx; c->x86_capability[CPUID_7_ECX] = ecx; c->x86_capability[CPUID_7_EDX] = edx; - - /* Check valid sub-leaf index before accessing it */ - if (eax >= 1) { - cpuid_count(0x00000007, 1, &eax, &ebx, &ecx, &edx); - c->x86_capability[CPUID_7_1_EAX] = eax; - } } /* Extended state features: level 0x0000000d */ diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c index c881bcafba7d..a88e0e8c39fa 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -68,7 +68,6 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_TOTAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, - { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, { X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA }, diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 7065462378e2..89f5e7f0402b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -656,7 +656,7 @@ void kvm_set_cpu_caps(void) if (boot_cpu_has(X86_FEATURE_AMD_SSBD)) kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD); - kvm_cpu_cap_mask(CPUID_7_1_EAX, + kvm_cpu_cap_init_scattered(CPUID_7_1_EAX, F(AVX_VNNI) | F(AVX512_BF16) ); diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index a19d473d0184..674de5b24f8d 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -13,6 +13,7 @@ */ enum kvm_only_cpuid_leafs { CPUID_12_EAX = NCAPINTS, + CPUID_7_1_EAX, NR_KVM_CPU_CAPS, NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS, @@ -24,6 +25,10 @@ enum kvm_only_cpuid_leafs { #define KVM_X86_FEATURE_SGX1 KVM_X86_FEATURE(CPUID_12_EAX, 0) #define KVM_X86_FEATURE_SGX2 KVM_X86_FEATURE(CPUID_12_EAX, 1) +/* Intel-defined sub-features, CPUID level 0x00000007:1 (EAX) */ +#define X86_FEATURE_AVX_VNNI KVM_X86_FEATURE(CPUID_7_1_EAX, 4) +#define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5) + struct cpuid_reg { u32 function; u32 index; From patchwork Thu Nov 10 01:52:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670392wru; Wed, 9 Nov 2022 17:55:45 -0800 (PST) X-Google-Smtp-Source: AMsMyM61kcgGkLBKGTioyVSL7ZAeQ2TrEqWsAIpUpW8mnqwJuiCSMZ6t0R11cwPhF0mZfK6qfyyF X-Received: by 2002:a17:906:8314:b0:7ad:e52c:12eb with SMTP id j20-20020a170906831400b007ade52c12ebmr2072919ejx.524.1668045344994; Wed, 09 Nov 2022 17:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045344; cv=none; d=google.com; s=arc-20160816; b=MRWGe5C66L0Vy3QXLtRQq9zfxmG6x73sDbIFCXmuYhcMPnydahiUqYeQ25cYn2nxQD 6qRlYJIotDznGYpcYkb2WwIQ3r/uhWW08DWxQ4O2/mDd+JKQP/jEvmTmGzHXwiBr44z+ ckKQvlXUQlY9MaqyaeburGpcSfQNK16k1CiJrOpBArSXpFsxW1St2C9+y+ijEDkdu9oU OD5wKMNFCOlSab3e5mVXa6KJwWPg5Vl++lIdbGGPNukZb0WHFc2AtuMfdPF7SMLPPESe gpNDh15th9IDsro18+bVAOEAPjZ6Yfkhp1EJfa2macdTQMcK5HRvN4XXlJM+WpXxim0w 4gnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gsPVaiFttmEnn6KFgDLIeMMcAr7hf+KQfMTSggAg71M=; b=gy35HXgKyO0oy9wZT2uJ3a/WrWTB/AvERpndoMMLyUqMfMxQZrR3gWWO95RgQasSgd pPMurLE8KHQTGaudrJ2371nifKWd8+odpJ2nutnd+Ilk+wk1qIP95tnU9P2dyb0/yO/I Hc1dtbPBljGnSOT+3R8XGRmYPKTmyFqLmYdGY5Hi0y0TgfecBvUCooCj12/VFU+tRTPE VKj0rzp8llIuwyyXQc8YXHMYLJ0+Y/6ynhgh36Adv+z8LKtiFF5Ls1W43PRf16EDQPkO ZkaXEJkHpAYIwoTEJNbOrLN2Wzb7aqAxizW7oiXLfuHajt2NHtz3UM37fbOVWE/5z3vi CL0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="c/aZyX/Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs16-20020a170906dc9000b0078db1343eedsi18721896ejc.774.2022.11.09.17.55.21; Wed, 09 Nov 2022 17:55:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="c/aZyX/Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231801AbiKJByl (ORCPT + 99 others); Wed, 9 Nov 2022 20:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232267AbiKJByc (ORCPT ); Wed, 9 Nov 2022 20:54:32 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FDFC27B35; Wed, 9 Nov 2022 17:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045270; x=1699581270; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=taX06KsU8mQXBQxKFDkHqGSkrqNdhC3yQd3XBk1YjEY=; b=c/aZyX/QBQk1sSFG1gsj6d1Ab/BOnOsxZsr94Ee0X0xB1MhK9VHSmuCS tI7tjQ26NcCsNQY/hnJQQpaqn90qHHKuQcXUR56StmRqfzzUvBsV4U1Wb LPa/I4WF4DXDfHBYGGjwnUbl7r1kK298mtlVVIxLYzf3vGHi9qITjOpa7 iMie5KBENr7gPIAX4Oj+KyjfaejKaXBNe+mf2UhsEySaAiKYq9dhoBp8D RVQoWpfR6L6DnqL8pkDD7Bw2Qk0Bz/+xd4p1w2dImoOuhfCZqbbcLkwU8 t/KLwSgHBvJ9Ukb7i4J0Vt4c8wLZNHtQ65hXtYu7ZY7X5RYIa1L4Ht/e/ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="397475871" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="397475871" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:53:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762099833" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762099833" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:52:59 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/7] x86: KVM: Advertise CMPccXADD CPUID to user space Date: Thu, 10 Nov 2022 09:52:47 +0800 Message-Id: <20221110015252.202566-3-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072315472615703?= X-GMAIL-MSGID: =?utf-8?q?1749072315472615703?= CMPccXADD is a new set of instructions in the latest Intel platform Sierra Forest. This new instruction set includes a semaphore operation that can compare and add the operands if condition is met, which can improve database performance. The bit definition: CPUID.(EAX=7,ECX=1):EAX[bit 7] This CPUID is exposed to userspace. Besides, there is no other VMX control for this instruction. Signed-off-by: Jiaxi Chen --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 89f5e7f0402b..b388ef52f8c8 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -657,7 +657,7 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD); kvm_cpu_cap_init_scattered(CPUID_7_1_EAX, - F(AVX_VNNI) | F(AVX512_BF16) + F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) ); kvm_cpu_cap_mask(CPUID_D_1_EAX, diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 674de5b24f8d..24f570ddb225 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -28,6 +28,7 @@ enum kvm_only_cpuid_leafs { /* Intel-defined sub-features, CPUID level 0x00000007:1 (EAX) */ #define X86_FEATURE_AVX_VNNI KVM_X86_FEATURE(CPUID_7_1_EAX, 4) #define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5) +#define X86_FEATURE_CMPCCXADD KVM_X86_FEATURE(CPUID_7_1_EAX, 7) struct cpuid_reg { u32 function; From patchwork Thu Nov 10 01:52:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670544wru; Wed, 9 Nov 2022 17:56:17 -0800 (PST) X-Google-Smtp-Source: AMsMyM6GOJ5+C9RKlqyn3KxCW572rVDrtPr2lt0zmre8SNLR+ZHYLSEi/ynh47IzO8Hwq8leYYnk X-Received: by 2002:a17:907:78ca:b0:7ad:b284:1357 with SMTP id kv10-20020a17090778ca00b007adb2841357mr2150293ejc.149.1668045377863; Wed, 09 Nov 2022 17:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045377; cv=none; d=google.com; s=arc-20160816; b=MHp/+WxRIS4BglJnjC4Y2GbAIZQVxXuTSEtWjPM1Lu2HMW34hoU+N5k4vrnU96yw7I 4vVKikN0uz23HWN6zU2L9IFHp6RbLcsqAL3wJdBCS4WIPVn9CcvddsfWvIKqJ41Uo1JZ BNyVlUaYOUY+QqfgNAg+viVKJH4qMkD5Z2QmhW16R8uByjEuJg47NY1INzpG0FLkScBb 4dE3fmtDOW4Vv2LEDdQDQKUL0vGSlcMvKPKsbn/LzdI84p11Og7ikb2xy7JNm4IKtmIG SocFdyInCxFLznwNCgsAyxiCFsmta171r0sTyAWAUo3n7V56QBDnyAi5RqmiWt1cHwIR GG2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j5kQmQFCW3a2dby/HLvCAWWojZpQKECcy5eN3j0RNM8=; b=kL1/XdoKc8FbSe+vK5yFZ1EJEJLcbkiDebk48IgNniiPQWDQgzJHPY9pp1lCI2pITP 6pCH5ZfMR4mSDhsGPCUNLfJUgGwST1aHfOZdS3KSsNyRdBAlYakBUbmYxZgkKhwTqrGQ Ma9QeoNRqRqVRXbBIz5fbx5cJGINNQrx5ar5DvRK15QOHWgjjx5y/C+VKFrw8SV55K8o rQ/OnvteT13orH+HTUSXE+PiLFwI7EyEK6LzVIqRfHGLPITz6EbtYbws+L1X4riY9LWa iXkwLCMp3RdYHZgLvWqC+9ICBCbz3ggDMDrjATUl8FjWKryKKXSCeL/Lx/BeEKzVxx9S TARg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EJ5g+K8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a1709061f5500b0077d1df3967asi11844704ejk.563.2022.11.09.17.55.55; Wed, 09 Nov 2022 17:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EJ5g+K8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232445AbiKJByw (ORCPT + 99 others); Wed, 9 Nov 2022 20:54:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbiKJByj (ORCPT ); Wed, 9 Nov 2022 20:54:39 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1756A636E; Wed, 9 Nov 2022 17:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045279; x=1699581279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lg09VbI/60vYnXZzpwRBHqC+c64eQ+EJZudgsq58kIU=; b=EJ5g+K8UCkL3crMRMmrLlFZ2rtYqPI/JW83lMSR+65pe1vwJ/i0vOkdQ A3vN24L915r4I5L8P7yQ34hX+LUJ2yyax4jZfsriWwV5fFNKJjVqNhtpK o9kGMdXpyjF0Oywve/TFNgo/fId5lcos+YXxf37a+U4hsVIFZPTXnfZi2 smF+QqyZjbcH7pzjAwrmGy7honNSv4t3+/YsBtqgnPZsroN6sJS9O2BD0 LJHu+j6kbRTjHyz4aiK/mGccpF+kF1Bw3ssj/kIss+na5thWdJF31TGUm wpacCh20lRPrubhKzROQp23d43c6uS70Zx2pVV4SriQeZXUoRSc/OS/Dk Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="308803587" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="308803587" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:53:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762099904" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762099904" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:53:04 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/7] x86: KVM: Advertise AMX-FP16 CPUID to user space Date: Thu, 10 Nov 2022 09:52:48 +0800 Message-Id: <20221110015252.202566-4-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072350308965850?= X-GMAIL-MSGID: =?utf-8?q?1749072350308965850?= Latest Intel platform Granite Rapids has introduced a new instruction - AMX-FP16, which performs dot-products of two FP16 tiles and accumulates the results into a packed single precision tile. This instrucion needs no additional enabling on top of the existing kernel AMX enabling. AMX-FP16 adds FP16 capability and also allows a FP16 GPU trained model to run faster without loss of accuracy or added SW overhead. The bit definition: CPUID.(EAX=7,ECX=1):EAX[bit 21] This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction. Signed-off-by: Jiaxi Chen --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index b388ef52f8c8..19ef02d5b11b 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -657,7 +657,7 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD); kvm_cpu_cap_init_scattered(CPUID_7_1_EAX, - F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) + F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) | F(AMX_FP16) ); kvm_cpu_cap_mask(CPUID_D_1_EAX, diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 24f570ddb225..05fd43ebd226 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -29,6 +29,7 @@ enum kvm_only_cpuid_leafs { #define X86_FEATURE_AVX_VNNI KVM_X86_FEATURE(CPUID_7_1_EAX, 4) #define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5) #define X86_FEATURE_CMPCCXADD KVM_X86_FEATURE(CPUID_7_1_EAX, 7) +#define X86_FEATURE_AMX_FP16 KVM_X86_FEATURE(CPUID_7_1_EAX, 21) struct cpuid_reg { u32 function; From patchwork Thu Nov 10 01:52:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670703wru; Wed, 9 Nov 2022 17:56:53 -0800 (PST) X-Google-Smtp-Source: AMsMyM5ky+oZYtAs/2/7glZU05l0KIZc2B8ZomLBZxoC6kzDHlZ9eos3puqJzLJK9oJ1RTSLPk+d X-Received: by 2002:a65:4c82:0:b0:43b:ed47:48e0 with SMTP id m2-20020a654c82000000b0043bed4748e0mr1542377pgt.363.1668045413384; Wed, 09 Nov 2022 17:56:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045413; cv=none; d=google.com; s=arc-20160816; b=pP3CMrHnh1cKBcSUXlCkYSgy8vHAm/+P8GxGuBx4njX9f/F8OzBowHei2VW8QZXFmT 1URYWPuItM91P0martbcSF7qUCX7cSoAfiYT3dJKke2VDMJeWGT/Mu7F16vwCC6DFICd a9aqfqhUim0YOuqXJKOFyqiXv942rU5aadcIMEtxNZxECv2tasoCpRklPOwLuRPtMJGX 0I4poWC7TWshuj6WGLQUvhv8BG+S3wXs+obQSMv0nN3MgfSQMnQLsYOrzYMYKU2i2zYd mjsI31/IWZblKFNVsgPeZfNITFJZJ6015xwNh1n0PjW5/tfsS+PODBmo6JOuhJei6Gnq CKgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3H3qdmjDezs9rEcSpYjKeE9iSXi5TkRF8IRhTMJwFmw=; b=BVWH+QX4m/+KH29nf3bx8dmNXpGaLN6Tp8c8I4xuLL0u4ErYNxdmtjSMj8ENwSx0Xv vgfo2eL+mwjf6reE7Rpb7nFFvlL4GlT/+3/W5s7cYBiG7sttUerel9Mq7IJuMzzk1s+b qawGeMZjMzgfmqnfYtaoYQbyJYkd0B1HPUS5KUOjjymr2P0RBOcQzcmqQJ0kdfNjkVFK nYv7CtbZ7DatMnLtZSoEBXeMlWOsNoMoIk0/UfrVVxeQUfXyQI/G1HZuVZVw9V9YSYsP A1AVLQ+YCcJzVTiqcG4a0vQHUceS5LGNjDFQr3gfLTwAni2gV8EmSmcMu2gQECCG/i11 m1aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PEat++Pq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a63d148000000b004619662fb00si5950568pgj.245.2022.11.09.17.56.39; Wed, 09 Nov 2022 17:56:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PEat++Pq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232463AbiKJBy5 (ORCPT + 99 others); Wed, 9 Nov 2022 20:54:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbiKJByk (ORCPT ); Wed, 9 Nov 2022 20:54:40 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4F47C771; Wed, 9 Nov 2022 17:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045279; x=1699581279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qDIvJKQbDJZne66SN3OTzm4SJ9/jbIpx8cLqn7z/wuU=; b=PEat++PqzwwhwL/oJTfhwuxQpHyLWy5SKkTaUHSiKgnIIeysjCS0yvtD 3Ib5WlxOPCIMIyb/jscrEQff407y2XF1ncIUGfzk75ByyB9KmWkIuehWS R3Fw76AfjSz4RkO41cNtKjTuxG/TJfJA6ipmoDyMYvm8PYEzfQjJAUu+N EjSUqKF3qfYID0QLFVAcu9TGo1OoJwjl4/4J82udD8IWtXZFJPG6eBBoO 5CaEtA+zDZnNz7cpmm+VhfwgLYBGwJV++mQDajPNSK7N7I1wahOaW6t3N lPVF1t40+OO495WlHbh5FcvzhLdtaGhwRxe1YEJ1PNoqFMzXriSv2+dus A==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="308803599" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="308803599" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:53:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762099995" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762099995" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:53:12 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/7] x86: KVM: Advertise AVX-IFMA CPUID to user space Date: Thu, 10 Nov 2022 09:52:49 +0800 Message-Id: <20221110015252.202566-5-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072387075193779?= X-GMAIL-MSGID: =?utf-8?q?1749072387075193779?= AVX-IFMA is a new instruction in the latest Intel platform Sierra Forest. This instruction packed multiplies unsigned 52-bit integers and adds the low/high 52-bit products to Qword Accumulators. The bit definition: CPUID.(EAX=7,ECX=1):EAX[bit 23] This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction. Signed-off-by: Jiaxi Chen --- arch/x86/kvm/cpuid.c | 3 ++- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 19ef02d5b11b..e84c6216a72c 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -657,7 +657,8 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD); kvm_cpu_cap_init_scattered(CPUID_7_1_EAX, - F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) | F(AMX_FP16) + F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) | F(AMX_FP16) | + F(AVX_IFMA) ); kvm_cpu_cap_mask(CPUID_D_1_EAX, diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 05fd43ebd226..954c0ceb1e90 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -30,6 +30,7 @@ enum kvm_only_cpuid_leafs { #define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5) #define X86_FEATURE_CMPCCXADD KVM_X86_FEATURE(CPUID_7_1_EAX, 7) #define X86_FEATURE_AMX_FP16 KVM_X86_FEATURE(CPUID_7_1_EAX, 21) +#define X86_FEATURE_AVX_IFMA KVM_X86_FEATURE(CPUID_7_1_EAX, 23) struct cpuid_reg { u32 function; From patchwork Thu Nov 10 01:52:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670632wru; Wed, 9 Nov 2022 17:56:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM78X4cGIIes4uCG3oextPLlupi2GalGMotFhAEdyJ5EvwVIMcggLKGl0dGyvGbrfm9hsAhJ X-Received: by 2002:a63:2b41:0:b0:46e:9364:eb07 with SMTP id r62-20020a632b41000000b0046e9364eb07mr54001770pgr.46.1668045395915; Wed, 09 Nov 2022 17:56:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045395; cv=none; d=google.com; s=arc-20160816; b=1E0yZyVv8NJlkS225fB2+Clb9f3SV3xKiEkpZsK6vXCqYIcEk6sJZdq8ZFs/yG7k4p W6mAkW5k4/K4gMklrbunTi5kmlVJHoputrO/9crzkzJIBGEGC7yoWPoDmGeLG+aemFNO 1UsxUyzYXfo/LUJG46yWSoA+xYp9gR3X0lCHF7Mf7zLWalQKtdJ9zMZaQDnECDgIHj1/ QyaKpqKE5ej5DM1ZWGQOZFWQeEXv1YY+Xrzl9U3WxYJnuWEMYtaRqwi8aQVpqqA5n/hg wR4moZTp2Dq1++M8l9C0D68OUvRHXRqCxe1PDyCaeeRwQewDDgPac3rHsRWDciom6Yk6 9X0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hTw+jb4iRb0MJYCDEyEUxV167FGqorP9Oa7HKRA8mHc=; b=K1ggb0ZwETjDEBVhLt+ti7KLssobXqUo1FTmI41K7riatazKBkpGNwpJxRSZZON9lw lk5mlMHK4htagUh9NTgbvfMenoZAf/9tgdwXrreLHQyTdO2ylBO6o38SO64CTxFIdIh5 Te6KhJwYhG60ig9g/htKxlYoVjb0NVLUWyNO0WN+S1kuJK3DoC6LBrnUylCta4dx5JHj 8/7Ht2plqY0uEKbg0rX0fbjs+GmKVcheJWFoDM43xaJ6r88BEAkdzACSw6sX9WB3/8Ic hDXal646hzVh5WojwlIK7jxLdCNgtzuVEswewG/aC6jrCzGRpSX6RoQ8YDz2YQLiY7+k zO+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UD1ZT3Cf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a17090311d000b00186658e50desi23295913plh.465.2022.11.09.17.56.22; Wed, 09 Nov 2022 17:56:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UD1ZT3Cf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232452AbiKJByz (ORCPT + 99 others); Wed, 9 Nov 2022 20:54:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232402AbiKJByn (ORCPT ); Wed, 9 Nov 2022 20:54:43 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 941E410561; Wed, 9 Nov 2022 17:54:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045280; x=1699581280; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QZah9F13AjoVe9tv/CykWOC6OrnYXLMSXtZoIq5C0N0=; b=UD1ZT3Cf1XXKoxzRzWj0xcu9uCPZPM46qHKKY+QP7lAIDXzyY0q2eCKy YFZ5kTzFqti+hn2KlhId9tkTL0+G/spB2g7NYSiOCB8wvH/rP5VqXb1d5 Ik0CIb6giZN1n+KulWpyzvA5xoCS3a1dcvM/+gaMWHBLaAKwjB/N+nxlr 6QQmFAsGWSMEAG//1Dl36brdnPvNLq8wvV1V1Wj2syA3zqB9LjHKf2lLc 4IlOM9BBeqe1xfuyPEQa4gtSmrK6S/G3/kjUeYVGJg6ZWi0qirumpjTq0 RPOLF+h8ao8nk/DnlUNE+K5LT1wk7CtWoYMMuwrrCohbVftKEHT+nC/+9 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="308803616" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="308803616" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:53:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762100061" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762100061" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:53:18 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/7] x86: KVM: Advertise AVX-VNNI-INT8 CPUID to user space Date: Thu, 10 Nov 2022 09:52:50 +0800 Message-Id: <20221110015252.202566-6-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072368702797041?= X-GMAIL-MSGID: =?utf-8?q?1749072368702797041?= AVX-VNNI-INT8 is a new set of instructions in the latest Intel platform Sierra Forest, aims for the platform to have superior AI capabilities. This instruction multiplies the individual bytes of two unsigned or unsigned source operands, then adds and accumulates the results into the destination dword element size operand. The bit definition: CPUID.(EAX=7,ECX=1):EDX[bit 4] This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction. Signed-off-by: Jiaxi Chen --- arch/x86/kvm/cpuid.c | 5 ++++- arch/x86/kvm/reverse_cpuid.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index e84c6216a72c..06dacf71ff9c 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -661,6 +661,9 @@ void kvm_set_cpu_caps(void) F(AVX_IFMA) ); + kvm_cpu_cap_init_scattered(CPUID_7_1_EDX, + F(AVX_VNNI_INT8)); + kvm_cpu_cap_mask(CPUID_D_1_EAX, F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd ); @@ -914,9 +917,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) goto out; cpuid_entry_override(entry, CPUID_7_1_EAX); + cpuid_entry_override(entry, CPUID_7_1_EDX); entry->ebx = 0; entry->ecx = 0; - entry->edx = 0; } break; case 0xa: { /* Architectural Performance Monitoring */ diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 954c0ceb1e90..819b4e0b13a3 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -14,6 +14,7 @@ enum kvm_only_cpuid_leafs { CPUID_12_EAX = NCAPINTS, CPUID_7_1_EAX, + CPUID_7_1_EDX, NR_KVM_CPU_CAPS, NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS, @@ -32,6 +33,9 @@ enum kvm_only_cpuid_leafs { #define X86_FEATURE_AMX_FP16 KVM_X86_FEATURE(CPUID_7_1_EAX, 21) #define X86_FEATURE_AVX_IFMA KVM_X86_FEATURE(CPUID_7_1_EAX, 23) +/* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ +#define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4) + struct cpuid_reg { u32 function; u32 index; @@ -56,6 +60,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_7_1_EAX] = { 7, 1, CPUID_EAX}, [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, + [CPUID_7_1_EDX] = { 7, 1, CPUID_EDX}, }; /* From patchwork Thu Nov 10 01:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670432wru; Wed, 9 Nov 2022 17:55:51 -0800 (PST) X-Google-Smtp-Source: AMsMyM7qRU//iK6L/KmCO3q1vMzZHoutVk4TfNbsZFRZkB9ro16JIjDxPRD9dEfFVekTO9DlVQ4/ X-Received: by 2002:aa7:c748:0:b0:462:1e07:1f82 with SMTP id c8-20020aa7c748000000b004621e071f82mr1408131eds.394.1668045351796; Wed, 09 Nov 2022 17:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045351; cv=none; d=google.com; s=arc-20160816; b=ekXwfXUv2SLrLrOccq7idInK8LP7S4b5vuO5BoHUprrSBvsK/x1A6UslFirok3UrnI NdDmHkJP5dP8XiluVD6hnFji3tY1x3bmcopLQtt959FKiuyG9iMiEi8XbBZvYjEalNPJ GNRJm6lM2YcQuPsJYOFeq8VvvACWc6/9VjhghUyRCSO53xRx9GbOznfuqxO5BZEnBfas TUQbcTG57c00mE2Y6RLg6z0dTcum7+DxAumI+3zAxdvhty6mXc4obRPEuJMVYuD0Kw7g 9P8iObYWwtrFsJXlRX82HYjaxAZQkoUjlvK5yqfVjR9RS0eZiV22+zBV4CDRC74dsq1H kCIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DIoa8MeAdP+7TVfO9UE8ZLzHjSCluj1i4wLI2YwRfuc=; b=Z8d6RH270OSDVgdoI+N1UIVRVd0fvWCk9d4PNhF02AfhAYwy57ujl6r4P4dpmCpq1A IWmaZQWUj1pEPd8R4xe8L53MZ3e7Y1tuXJdzaBaWl7Iptj0VTbX8FD7UVJgjiShbMxhi cNReLdQ7wP3gSC8D/koI+e63BgId5hlhZwgTCKiE8UI2iHUr5JIvQa23nZenEDjSeXWl pWXr/oyaVlG9irPV78L3RLKMnQRm5QakspWgOVe5wAUx4ennldn/0IVm3sn8vxPM5kW2 bXHldwExzDLXEFXMYDxvNtDVo2nyUdnvhQFtjKZvvkj2iiH8KjDBG253O75qv3rf2BZt VJpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BNlxJha0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb31-20020a1709071c9f00b00782a33f2850si15799286ejc.736.2022.11.09.17.55.28; Wed, 09 Nov 2022 17:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BNlxJha0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232428AbiKJByp (ORCPT + 99 others); Wed, 9 Nov 2022 20:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232288AbiKJByc (ORCPT ); Wed, 9 Nov 2022 20:54:32 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C831258; Wed, 9 Nov 2022 17:54:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045269; x=1699581269; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z3o7gjqmPQSafhqSVWDWNYduM/0WLm1c0YsgTUqZbj8=; b=BNlxJha04mKZj+TUDTo8Jvg1Mx2fDcl0GPcmfe0ET6SSEhfIdxMKHX8m y5fbx3+xbsb6bSVRHr+W4BCyWU5YcPFvmQlov9GZrRutTEqxKBlMkliS7 7WaZNUvMU6K/oAU6wmV2fp55YQmj89NTHjBwzXRJfG1YcKJuqYeIrDCcY WCHwV7wXC0gZfYTdBG/A5j656KAytLCps3kSGznSyrJVWS4O4agl53ISr nncnyCarjV9qktnKqWfLpqviXIdUy5o3kgSve0GjGqKGB1xUBsi0Ls2lV 9z3UFzlSzSpMMp7XtdQQr4xaQ97Be47OxXiC2pSgO45Wa+00zbL3iyfoN w==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="311180007" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="311180007" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:53:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762100093" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762100093" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:53:24 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/7] x86: KVM: Advertise AVX-NE-CONVERT CPUID to user space Date: Thu, 10 Nov 2022 09:52:51 +0800 Message-Id: <20221110015252.202566-7-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072322429194548?= X-GMAIL-MSGID: =?utf-8?q?1749072322429194548?= AVX-NE-CONVERT is a new set of instructions which can convert low precision floating point like BF16/FP16 to high precision floating point FP32, and can also convert FP32 elements to BF16. This instruction allows the platform to have improved AI capabilities and better compatibility. The bit definition: CPUID.(EAX=7,ECX=1):EDX[bit 5] This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction. Signed-off-by: Jiaxi Chen --- arch/x86/kvm/cpuid.c | 3 ++- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 06dacf71ff9c..47ac2a502d91 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -662,7 +662,8 @@ void kvm_set_cpu_caps(void) ); kvm_cpu_cap_init_scattered(CPUID_7_1_EDX, - F(AVX_VNNI_INT8)); + F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) + ); kvm_cpu_cap_mask(CPUID_D_1_EAX, F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 819b4e0b13a3..b8addd85b062 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -35,6 +35,7 @@ enum kvm_only_cpuid_leafs { /* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ #define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4) +#define X86_FEATURE_AVX_NE_CONVERT KVM_X86_FEATURE(CPUID_7_1_EDX, 5) struct cpuid_reg { u32 function; From patchwork Thu Nov 10 01:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 17915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670944wru; Wed, 9 Nov 2022 17:57:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM68rtfs8eRSHxzUWn/cvkNHvI2LdLuT77JQI7ffB0heIPyaohXfhUuUE4jiaXhG2QY35JsT X-Received: by 2002:a05:6402:1f13:b0:461:e0b5:8402 with SMTP id b19-20020a0564021f1300b00461e0b58402mr1446216edb.189.1668045469701; Wed, 09 Nov 2022 17:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045469; cv=none; d=google.com; s=arc-20160816; b=zFyclEAGO7Z2hD7cwP6fTi5GtuNUrg1GM6ZMDfBcD5ZknN+TC4Q/i5g+ULe2ucZy52 CbYyWVPXBl25a1LMqFzQR75NR+fE6k+o5XQlLjBlr46kzmm77hQnUkKJjZUBifhLsnpq H70VQh4AC2eIFf/U7HEcg+gk2cjBwPv/Oi43US87FymgWrxzQWlT9rpkrk0al61UXpfs AAwzGf+K4m2aS+2sdG3am3xvFEaMtRVq1YzW/a1QnNIsIbRQk2my5wbgTlnX2uqnw4Jg XEPsB+xlzHpSoNOHQNLpTd+CJHYEgk1o//G6xWVXLmIbQ0kaeDlehSRGfNzANwnEjFLP JObg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=689gOnNwF1I1WcvuchsQJjQxVaFZQbDkDtUkG7iXrm0=; b=G2XuSh4oYHkMxxgHh/AZaw62oXWNVUAezkh1rU6KRp60nN/s+lY5TF0VIBMdIjrswz FZ2CW3Pc25ajEIWVYzWiTpr/hMyIERmITF+03mw+jx2RaC1674HQr+mSMEoomd3sQOfE dgn7lsGec+2vzVMwWy4X0qTGIE+zPcjcAUL90zWuHy7gSLCkYgpnjLGnoi0NF7skwUs9 xtQKyEJsxSR5qkB7ZoaiWhAXKL04WoKjpx6hpWVuUXJCEwB+PQLGUfhtfvrTfLY3q55P 67D+/8lXmitY80Nk3yJ9sU+DMMIaqDuHBN2d/swuMA35TerIsZ0x7j9E+E/c3PP+ZfY2 UeXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZXfVE4Yb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd10-20020a1709069b8a00b007ae4c686a4dsi20833193ejc.649.2022.11.09.17.57.27; Wed, 09 Nov 2022 17:57:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZXfVE4Yb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232542AbiKJBzU (ORCPT + 99 others); Wed, 9 Nov 2022 20:55:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbiKJBy6 (ORCPT ); Wed, 9 Nov 2022 20:54:58 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3541A29CB7; Wed, 9 Nov 2022 17:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668045297; x=1699581297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JwR3352mQmtvv3jNZ1XhkuwmOLMITQeiSm1roomzunE=; b=ZXfVE4Yb05m6NPFUCyDK6lApk9Au3uFRXaqPRw3PcRBn7gLzb4/ypK37 gXsqU4Rqta/XCPceGJ3Uk/hfHMGfC93jQptBayxaqXd9SuShtxqyN79sz R95Ueb8jHURgnvG63OpUTYMZPYqYWdZbKPYrXg1mC2om3gnJ3jZ9FKSwk T8LUsS7bw1G7ZvsN/1oJFI6wZsIC6XuacsO9gtiAsGVJtcfynbuHZ/dQT soUprHNdHjlQ0SGLjy1RC1KHcoSzS/DUV2bhkN1cnbdnn8NsUtGrZM17/ /IUeSPhzi2JtHV3okZCDwMRAdxhBviKWhPybOQp591qf+mB5d5t7z9WqN g==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="294522235" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="294522235" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 17:53:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="762100153" X-IronPort-AV: E=Sophos;i="5.96,152,1665471600"; d="scan'208";a="762100153" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2022 17:53:30 -0800 From: Jiaxi Chen To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, ndesaulniers@google.com, alexandre.belloni@bootlin.com, peterz@infradead.org, jpoimboe@kernel.org, chang.seok.bae@intel.com, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, jmattson@google.com, sandipan.das@amd.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, fenghua.yu@intel.com, keescook@chromium.org, nathan@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 7/7] x86: KVM: Advertise PREFETCHIT0/1 CPUID to user space Date: Thu, 10 Nov 2022 09:52:52 +0800 Message-Id: <20221110015252.202566-8-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> References: <20221110015252.202566-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072446050369945?= X-GMAIL-MSGID: =?utf-8?q?1749072446050369945?= Latest Intel platform Granite Rapids has introduced a new instruction - PREFETCHIT0/1, which moves code to memory (cache) closer to the processor depending on specific hints. The bit definition: CPUID.(EAX=7,ECX=1):EDX[bit 14] This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction. Signed-off-by: Jiaxi Chen --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 47ac2a502d91..9021a80b3553 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -662,7 +662,7 @@ void kvm_set_cpu_caps(void) ); kvm_cpu_cap_init_scattered(CPUID_7_1_EDX, - F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) + F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) | F(PREFETCHITI) ); kvm_cpu_cap_mask(CPUID_D_1_EAX, diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index b8addd85b062..884aebe7b3c2 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -36,6 +36,7 @@ enum kvm_only_cpuid_leafs { /* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ #define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4) #define X86_FEATURE_AVX_NE_CONVERT KVM_X86_FEATURE(CPUID_7_1_EDX, 5) +#define X86_FEATURE_PREFETCHITI KVM_X86_FEATURE(CPUID_7_1_EDX, 14) struct cpuid_reg { u32 function;