From patchwork Thu Nov 3 02:50:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279350wru; Wed, 2 Nov 2022 19:52:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7isAYd6HUbOpC1EGyo16xcDnCtnKVhCCN/xYXhuFyQa6lCzxwhQeFnjbB0ZrArs+XPpax7 X-Received: by 2002:a17:90a:4888:b0:213:d512:f034 with SMTP id b8-20020a17090a488800b00213d512f034mr21891535pjh.133.1667443929436; Wed, 02 Nov 2022 19:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443929; cv=none; d=google.com; s=arc-20160816; b=dUkCSLkYio+hVDtanrpIkojFs3JtvUqmsmlEpvfexHkOoouvqNDhy2aiQaY73mZTP/ paJFOLpRQszwWlspjrLhDodABt4y72q+P3jz4F0Ix1GDdFr4p1qLGF3nkxODxFb1rMOW uLPSeGahnYUE3O/6956IY9+DPuZV8ZpK8JNHCASl7qoOgcb34MsTxummVk5uIARChjqC OTbuiUm8NDerUwaeEiwNMbvMGlVm2kjhoJZeNiJiYvK2oIfPSeipa5jAV7mXXC43HiX3 SbFJGa3r0hTXyzWkAI9sGWv9BTJfT8lxuxuBKbcznFLLXyqgk2pEhoDj+6dzOehRlA/z yTtw== 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=QiZKwTYuoKR7ACoVwRLy4Y0eG5K9btMU7XdmHy3Ejrg=; b=g4DFdjZ0MzAqzuhejIz/uslgQ5nuLpouK550MwfWbjiONntX/YdI16cwOVlLUSzgAZ popvtXaYxybT3gac/u1YYFXbzm1SiV86S4wThLicOfUFzYBjNEjqPsWWG9Ed7n2jUnDi 5pdq1B587Od2LcUCyo+6b49EEUQeFffhnqB+RhL+rP0PvrxhYCt3CFp8vFcaGNMtY92a b7YDFKua03srSQm44vWwWJUL8DO8lFKYpgptlHzbF8LFKURObQAFu5mQ6o0FUJv6qWuB 3SkgyghL6Qfz/kDc4RyP22KG/E7WUA7BZ+W2v7knzO2q0cWVZDn4NYklTEP87Rtn67Qu 8zdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N9By31Nm; 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 x7-20020a17090a9dc700b0020d2d8c9a84si3802841pjv.137.2022.11.02.19.51.56; Wed, 02 Nov 2022 19:52:09 -0700 (PDT) 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=N9By31Nm; 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 S231266AbiKCCuv (ORCPT + 99 others); Wed, 2 Nov 2022 22:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbiKCCum (ORCPT ); Wed, 2 Nov 2022 22:50:42 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E30F11164; Wed, 2 Nov 2022 19:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443840; x=1698979840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OrIoPfAaFxyGwyJ42VnSxwQIBSLZ5vI600fUBQrgg84=; b=N9By31Nm3WrJH4uoTxmqZRHOWL7UmMZKvZD0GU50u4KGS/VV34plA72A xax5n1Z3ZeHhRRyPmX2e1bFcQv//1zpaw5ccE9ZoMIXEIGGhjwPth+1Su ZEYF1+nSK+q2NGLWf6gzV7g78vyB2orQRctRwow32ENvIKJLAJvkBvdbT Gu+GCHdwoX2apjLODBEeVJ1clXTvmnN2pP5HNlOFzn2InDhh6p6kgfcqv ujadCowDqFibpGj19/bBGdSPgk7aSZVtQFFq5DtAY4VUXeDgapDG2d2/T 0tTrsLZBDRxj04vquQCWGrbrYH/22QS+aw01nSAmZkyp6hDTtN6KUUUIf A==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="289961921" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="289961921" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:50:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047821" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047821" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:50:35 -0700 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 v2 1/8] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf Date: Thu, 3 Nov 2022 10:50:23 +0800 Message-Id: <20221103025030.78371-2-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.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?1748441685707304190?= X-GMAIL-MSGID: =?utf-8?q?1748441685707304190?= 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_DUMMY 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, 7 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 1a85e1fb0922..fbb4e7bd2288 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_DUMMY, 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 ef4775c6db01..cabe96df9555 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -305,10 +305,6 @@ #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 */ - /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ 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 3 02:50:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279666wru; Wed, 2 Nov 2022 19:53:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5urg0lrcKjQlZMBVKcBqphIeVczXPue1ThQJdL9szZA02aI08lNaLrFwRCr3fnmeB/0TVK X-Received: by 2002:a17:902:c24d:b0:186:a2d6:9f7f with SMTP id 13-20020a170902c24d00b00186a2d69f7fmr28200700plg.131.1667443986557; Wed, 02 Nov 2022 19:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443986; cv=none; d=google.com; s=arc-20160816; b=jJkneq5v8KRHQ4KkaULjy6Oe0WhB/s8VoMMrGTpFNMbhc6zV4CzwWFlhNAAEVIFL+O VlOYoqpzG1cOdRaShKga+QANCT7ApdU+aUHN3hoy8XqAcPWLwvcQavHWytGx8qRl5iXp RW0T1wdXk87eaHJ2Wrwp8aS7gMJ3EI3TdyYmshMDbFx/zbP1xUlvaM2jPLDxZjBOXwi/ pbYXqxOXY1nlxZ4prh1zkThY7B8XM/Njlb2FDMriXUhKivcpnwL8H9w5XEWJWddkQUIR lzF5hXI2OgqrJGjmmMOoIBAia8GgzMy8TxFgCsl7Q293qlDOhjl+37tr08lyrEZMsjSD 1uJg== 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=Ujx6/fJgaSHzfN5drXQbVdEKoaOJUsss2wRIU/7UUTA=; b=FiQ9KLKokK8ka8b78LZDZ2r/MFllJybsgfCtuoWWCacYy7y7ilDYN7I5Bn3vinCGiN jwxpARkSCmCpoDNjPK/2pGDT/x0Qr45rqR+YTKKPIkgAqb13V9n2DAoBb7IUfObzRR3c gZb81Od/UXoYURXenAroF4Yh+EI7UHxjOQRG72bNpEjfv63plo1DqPAy/Ur7YWvEMyJA /A2hw+olW8imA9chD89MJbBYlolFzIGt6GkxADXY/PrTvGcNDDu6F8ST2OqBxMoJppqq OqW1H0uuc6fyiXjunS5ferjehMVI6vXadAFNgdG+VjZh6cVwMdb85UUyWZlz3tDNe2/p i08Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MH0yXVKh; 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 n17-20020a170902e55100b00186b84c723bsi23565739plf.419.2022.11.02.19.52.53; Wed, 02 Nov 2022 19:53:06 -0700 (PDT) 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=MH0yXVKh; 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 S231262AbiKCCu6 (ORCPT + 99 others); Wed, 2 Nov 2022 22:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiKCCuq (ORCPT ); Wed, 2 Nov 2022 22:50:46 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F70E11158; Wed, 2 Nov 2022 19:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443845; x=1698979845; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mU95m5Erwp5k3SxNIlFspBtJjiX62AILgoyTbwZv4TE=; b=MH0yXVKhnJDtaSjphCnhzHs1x6vLmkCCix/JKaj6pNLyWjw+aM1wvQMC 82ZQH1yOrB2cUcH1zt6RDrqSED/whJrCblq53wCefBBbjbj/OtB1uu8ts xCrP5j8ZOQPXhc1Ttxdp6y+sMKg3QYQHZthUK/TTTMiu/OHpzjhlKp7td keCG/E59Sg2uakO1pffa+IidcXYGRuhiyaEqsUKjMfQOd3fT6gxJG6ref MtW49+Ou3vqbZO5fHtAhWAl2cdnvhJdjwkCCQ3PAO8KhFUV7J5HgH5HH+ n9R5/zjJOD7U0g3c7IS0iba/s+aXgZJ5hLjckA3DCLTQ0YTFYCaM82xow A==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="308289825" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="308289825" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:50:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047877" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047877" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:50:40 -0700 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 v2 2/8] x86/cpufeatures: Replace [CPUID_DUMMY] in cpuid_leafs[] with the last leaf Date: Thu, 3 Nov 2022 10:50:24 +0800 Message-Id: <20221103025030.78371-3-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.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?1748441745981526700?= X-GMAIL-MSGID: =?utf-8?q?1748441745981526700?= We now have empty feature bits in cpuid_leafs[12] CPUID_DUMMY, move the last one cpuid_leafs[19] CPUID_8000_001F_EAX to the hole and we can shorten the length of cpuid_leafs[] from current 20 to 19. Signed-off-by: Jiaxi Chen --- arch/x86/include/asm/cpufeature.h | 9 +++------ arch/x86/include/asm/cpufeatures.h | 18 +++++++++--------- arch/x86/include/asm/disabled-features.h | 3 +-- arch/x86/include/asm/required-features.h | 3 +-- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index fbb4e7bd2288..bf273d796331 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -24,14 +24,13 @@ enum cpuid_leafs CPUID_7_0_EBX, CPUID_D_1_EAX, CPUID_LNX_4, - CPUID_DUMMY, + CPUID_8000_001F_EAX, CPUID_8000_0008_EBX, CPUID_6_EAX, CPUID_8000_000A_EDX, CPUID_7_ECX, CPUID_8000_0007_EBX, CPUID_7_EDX, - CPUID_8000_001F_EAX, }; #define X86_CAP_FMT_NUM "%d:%d" @@ -93,9 +92,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ - CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 19)) #define DISABLED_MASK_BIT_SET(feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \ @@ -117,9 +115,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ - CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 19)) #define cpu_has(c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index cabe96df9555..df67a638f650 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -13,7 +13,7 @@ /* * Defines x86 CPU feature bits */ -#define NCAPINTS 20 /* N 32-bit words worth of info */ +#define NCAPINTS 19 /* N 32-bit words worth of info */ #define NBUGINTS 1 /* N 32-bit bug flags */ /* @@ -305,6 +305,14 @@ #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 */ +/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 12 */ +#define X86_FEATURE_SME (12*32+ 0) /* AMD Secure Memory Encryption */ +#define X86_FEATURE_SEV (12*32+ 1) /* AMD Secure Encrypted Virtualization */ +#define X86_FEATURE_VM_PAGE_FLUSH (12*32+ 2) /* "" VM Page Flush MSR is supported */ +#define X86_FEATURE_SEV_ES (12*32+ 3) /* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_V_TSC_AUX (12*32+ 9) /* "" Virtual TSC_AUX */ +#define X86_FEATURE_SME_COHERENT (12*32+10) /* "" AMD hardware-enforced cache coherency */ + /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ @@ -408,14 +416,6 @@ #define X86_FEATURE_CORE_CAPABILITIES (18*32+30) /* "" IA32_CORE_CAPABILITIES MSR */ #define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31) /* "" Speculative Store Bypass Disable */ -/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */ -#define X86_FEATURE_SME (19*32+ 0) /* AMD Secure Memory Encryption */ -#define X86_FEATURE_SEV (19*32+ 1) /* AMD Secure Encrypted Virtualization */ -#define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* "" VM Page Flush MSR is supported */ -#define X86_FEATURE_SEV_ES (19*32+ 3) /* AMD Secure Encrypted Virtualization - Encrypted State */ -#define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* "" Virtual TSC_AUX */ -#define X86_FEATURE_SME_COHERENT (19*32+10) /* "" AMD hardware-enforced cache coherency */ - /* * BUG word(s) */ diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h index 33d2cd04d254..192618cc0a42 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -110,7 +110,6 @@ DISABLE_ENQCMD) #define DISABLED_MASK17 0 #define DISABLED_MASK18 0 -#define DISABLED_MASK19 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) #endif /* _ASM_X86_DISABLED_FEATURES_H */ diff --git a/arch/x86/include/asm/required-features.h b/arch/x86/include/asm/required-features.h index aff774775c67..ff5e091efd2c 100644 --- a/arch/x86/include/asm/required-features.h +++ b/arch/x86/include/asm/required-features.h @@ -97,7 +97,6 @@ #define REQUIRED_MASK16 0 #define REQUIRED_MASK17 0 #define REQUIRED_MASK18 0 -#define REQUIRED_MASK19 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) #endif /* _ASM_X86_REQUIRED_FEATURES_H */ From patchwork Thu Nov 3 02:50:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279380wru; Wed, 2 Nov 2022 19:52:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7M9/L8mt6/iPli0MvRHXsw/R5+N5ViYlfEKXVPybKIHsadg2AJplm8WKoOpSTdHKGys8yP X-Received: by 2002:a63:6bc5:0:b0:460:bd9a:64b8 with SMTP id g188-20020a636bc5000000b00460bd9a64b8mr24866398pgc.257.1667443935862; Wed, 02 Nov 2022 19:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443935; cv=none; d=google.com; s=arc-20160816; b=dpO2Vo6IE2azuK1lQ5co3AGoRxT+xxAd2XMMBPpZwUkC9IZWk7OBxNs2WlvgVU8IKw +t59rM89khqamwT9yQEbRMeGlsnJdOVx27J/zmbKpaILLSm0RImoDehEKwOYW/9U8WCR L9GkCkvrByz7n4Kp2e88HJ+3gobVy8pIBEabl7CbUTQBCThHv+HaTa4KrM6883qKpX+7 Anep9uWP90/VU4xuNbrF0mdezm2FxTVjZSQWYAY/sGjSJqWQ5xupBj6h3Oq6GnsJPg5O osmDNajjaTP8x3xY1cZSnmQEnjf8tvH6w432CcNiz7NaGiWPKbzDcvpxBCjWdi8Zwnx0 lPRg== 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=BUmvlyaAJ+0J5mXuSz4d0KrllREPJR/EBIUGR8+TznpRMu1ogM408mk5a8oaUECrZv CSYS/cJmlnfhGCE59IJ8vM4ymgkzKWNUpRAe/CcRBErJsqX5/kNQ3heGG3kgstSrl/In Wpm+dsvvHbJZ05BbKDUVLiMOVUQd5u34eadBv91rTBwfNhnSv5uqjTbCpzzItmExKmCT SV3XnDh2bXQblQu0h0/P5fN1o8ioZJo1qJd4S9Uz3Om9mk0F2Pu9cZ+TdTWOHNadAMdg f+LeGbzW4JtXtOoDy6d2lKFJ/1zi7B+yCFS/JxciGOMN8Jt+V8jwR170KioVdVTqaXUS WVAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CeKtBCj0; 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 h17-20020a056a001a5100b0056cd91516b6si19851584pfv.325.2022.11.02.19.52.03; Wed, 02 Nov 2022 19:52:15 -0700 (PDT) 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=CeKtBCj0; 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 S231128AbiKCCvD (ORCPT + 99 others); Wed, 2 Nov 2022 22:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbiKCCux (ORCPT ); Wed, 2 Nov 2022 22:50:53 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EE0113EBD; Wed, 2 Nov 2022 19:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443850; x=1698979850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=taX06KsU8mQXBQxKFDkHqGSkrqNdhC3yQd3XBk1YjEY=; b=CeKtBCj0x/ogv/QsliI8isa0w0OrNf97R7JgVQSWru0J+VNhkXfuMnUd vuxWpfheD3RRYh33X5bt30twBCRssonjos2Ob1LzrYBCbG9TRfW3RsgQR rDuIRawUC7ZklcRB77qV7B1eko7Q8KZuUVwl2X8fFax27GJAvjNIrhplP G/TWEhW8vCG+ACMuaYb2BTdc8SgLMVduM/Pgh/Q5rUSPwOFGHgBM4KKOt F93FCTc+RvbCwAvyKph0O3INoLWGJh+Jxp2D02XqOB/WeIa5LJcL4sNZE M7l+Z1tZ0ELWxD4ADIypDT+5jlfo/WGoc7dZNNN7MiHR78aJJL3oCHGgk Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="308289832" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="308289832" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:50:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047890" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047890" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:50:45 -0700 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 v2 3/8] x86: KVM: Advertise CMPccXADD CPUID to user space Date: Thu, 3 Nov 2022 10:50:25 +0800 Message-Id: <20221103025030.78371-4-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.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?1748441692550791282?= X-GMAIL-MSGID: =?utf-8?q?1748441692550791282?= 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 3 02:50:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279399wru; Wed, 2 Nov 2022 19:52:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43khTcC9Py7GFD+gCsUuH+MfWy0IpwaG9dkbiEi6SkVB/edHkEMBxsyprSHDS7/Vlt+Yh5 X-Received: by 2002:a17:902:f28b:b0:186:b069:63fc with SMTP id k11-20020a170902f28b00b00186b06963fcmr28313966plc.38.1667443938165; Wed, 02 Nov 2022 19:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443938; cv=none; d=google.com; s=arc-20160816; b=q0fr0gyHwMJCxvKgdYzi4kWin6jpSYUThbJELLSWjiIbzdKhVP+9T0Ab2Ux7+KWIWs ckZEdqkvsJNIEuFKwZgcWS4OtKHzalJwytmhDbtGLZ5JTtpXAWxt3k4gyWLvD6wLWiH8 OZti/6QJb0sBjnAE+RDv4l1lATkLq2MLvQWDnd8Esl3iy0B/c+OzI4jZqQJqcpaxmMDM r/6aeEeYH6tX1V8Mu/pzR2FWRmz+QGg2kzbAA0r89pyB8478WWjIYHecb/ZkpE/276YF nAvJB08zRcO1UmP8+ANucBZ9bdzHAruI5t4WoxvuB2zU04Dw9CBnYz2RQyPh7G/ATXVD b/NQ== 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=u46dgpUWwFj3mZY98DM+qQHVPGkYacUF49vdpQeE18X/wX8/DOadfB7gDLdxMZw65i XpZpzOXMjSIHSEMt7RenriVRbgGJRlklpoNYlpouQ24ssn7r/QBFDpNnx7Eh3hZcwpH6 aJIHRUBP0ItqvX+sq7bcw5CtYTOIzFe2DtjEYtpZj4TSiPG1t+ZF8T56XjJ+TkeqxVVQ 1Esh6d3Ms05zG+AhDtEH2JCIqKcgpMAJdL/Mut4hb9qWhTzUtoeLGliqEyIJOt5C2zlu PpYC01gx+L/O3aOGkMvi/3jGYExA9Q/Z9c6wGqRRl4HakaGrqLTff+dd07VeEuORDJj+ ULiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WrcQQ9l7; 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 y38-20020a056a00182600b0053652e1c0b6si20828770pfa.12.2022.11.02.19.52.05; Wed, 02 Nov 2022 19:52:18 -0700 (PDT) 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=WrcQQ9l7; 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 S230047AbiKCCvW (ORCPT + 99 others); Wed, 2 Nov 2022 22:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231260AbiKCCu6 (ORCPT ); Wed, 2 Nov 2022 22:50:58 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E3B313E9B; Wed, 2 Nov 2022 19:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443855; x=1698979855; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lg09VbI/60vYnXZzpwRBHqC+c64eQ+EJZudgsq58kIU=; b=WrcQQ9l7ltZb7HpcXDVAO+QcAL+f83wQBO2shMQDiR/mz68mJSf/ZIyb HxpliXC3OhCwEvE9cT8epwkCDAbFO4DwR8mZ86PRzWnDO2fj4o45XON7n 7xRo7bvSsr2PzRDvMl+pSURgq6liAbmzqtyZzRJRtJXQkReo8992iY/xr TyQIhH8+rnnMjk7VKhGYleFn+HxRY/+UbSGXryaS6VrsK0Jgg7GG/RBqO 3/4tWk7iaJ7LWuDPshDP4C3t7rIDP2pTr02aVX04TiWxY6uaexG65VIuz rrb7imCSJbnIrcdommYv+XZA3BArRVHHhjwSMXZb4LR+i4cDSd7+8d6iO g==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="308289844" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="308289844" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:50:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047897" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047897" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:50:50 -0700 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 v2 4/8] x86: KVM: Advertise AMX-FP16 CPUID to user space Date: Thu, 3 Nov 2022 10:50:26 +0800 Message-Id: <20221103025030.78371-5-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.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?1748441694741250836?= X-GMAIL-MSGID: =?utf-8?q?1748441694741250836?= 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 3 02:50:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279434wru; Wed, 2 Nov 2022 19:52:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6z36LRINvT6HCbAUe2FftmQEiVok2zFi4xtqY2frxGwKIUI32CPbbjr/dDfyhxAfCO9fe9 X-Received: by 2002:a17:90a:24b:b0:213:9da2:5c98 with SMTP id t11-20020a17090a024b00b002139da25c98mr29042080pje.123.1667443944515; Wed, 02 Nov 2022 19:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443944; cv=none; d=google.com; s=arc-20160816; b=gM/EwZxtejdG2i2aF0pDMUF5DmH2dYpzMv2b6I7i9XaEcTEqpKW836p03G2RqoQdh1 xhcAJis/NDv8PmVND8fmHwvdwq11L+Kw30HHW7ZNnnF+oncqUI30+xywPj7qK6xW4S/6 989G6FCahpGMufjWl6OFUpzRqgGWrjdIe59RuLx2lJK089sRQK87lUnk/aPwKmlWk7pO l8Cs/MC89FbcC6+hqr7Gz0rSlIzS5i33gmGWMG960TyaqdMKWdw7pmj1FGfIeek7EMg8 I/diDiDKSjekTycbrJYTJs88FpxFZpbVJiCMrcL99HpuIb3qe0n5HCbnJXTqXEaXEVgS ttHA== 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=K8urFJ2BrZOGD4pTocBZsOdR3DCj9OeRJ1HDoGh71poIlsjesSrcn+PeOlVCYlX5L6 4Ai47aaKHcUYLP4WPeQaVCiaOE830M/kxV83MM4WJlJFZIKN4Z3ElLz1ECr16YQY6z9z /CchyUApC/Y6R9ta6KkfjIYGzFM6eUcmboIYYPaDwzNDRB5R9+mVTserPV8Joc55taAR KieRZeevNa3K/FPxrb3HUhb4gpu6lYxT9X/f5T+D6cIYSohBruLaXP8wx3XdK7DPoar+ lFCa4Tr8WxzTO60knRpNIvzubgvC8HntcyD5c8ymc72+jTPzFuPBpfNoGxA4tZvX4Dl/ HjkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iz/GVGE5"; 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 ji21-20020a170903325500b0017881dc6dc2si15299527plb.489.2022.11.02.19.52.11; Wed, 02 Nov 2022 19:52:24 -0700 (PDT) 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="iz/GVGE5"; 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 S231354AbiKCCvi (ORCPT + 99 others); Wed, 2 Nov 2022 22:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbiKCCvU (ORCPT ); Wed, 2 Nov 2022 22:51:20 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A271814036; Wed, 2 Nov 2022 19:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443860; x=1698979860; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qDIvJKQbDJZne66SN3OTzm4SJ9/jbIpx8cLqn7z/wuU=; b=iz/GVGE5QBtI4TYG4NahYz0/f/T7FIlc9l7j4ami0KHFb8gj9AYA/l06 Ex2pG/CNpPSc7KlrjUWAStNs6t3L4z9CZoPxdu5qTmP530fAGeZhvPLdE P6b9hcqYuJT5+T83uJXVGZAzwIzorhlZ38ebCCXCdWQzingg7upTAxq0G Kxc5MFSsMcd5nboKVQ16yUAP0N1wG7Oen3qEnbDqLGErTeoGlm4SkiKOl p9E2RxN85ttR2l0pCrGzVOQ2B1SHbxgyZhYSB8wAG66bjHxwkyQ1KbA7l IThtwJ/IGmV6/F8i8Hy+Ume8fqwlvgfEQe9CZln+BGMS9M1Jf0FW8xqby w==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="307186647" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="307186647" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:51:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047904" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047904" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:50:55 -0700 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 v2 5/8] x86: KVM: Advertise AVX-IFMA CPUID to user space Date: Thu, 3 Nov 2022 10:50:27 +0800 Message-Id: <20221103025030.78371-6-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-8.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?1748441701848184258?= X-GMAIL-MSGID: =?utf-8?q?1748441701848184258?= 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 3 02:50:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279691wru; Wed, 2 Nov 2022 19:53:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7OfrITwGbXxvgWtvJujw4R/6CewYCL08d4B0aR5AU+bzGD7QPppb/5+5P51ymIU5VFIa8F X-Received: by 2002:a17:902:e1ca:b0:186:878e:3b03 with SMTP id t10-20020a170902e1ca00b00186878e3b03mr28424694pla.95.1667443993404; Wed, 02 Nov 2022 19:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443993; cv=none; d=google.com; s=arc-20160816; b=Nnvo84Pp85ptJPRw2qiQhf45zC8K0XmwQxmG+gzgr5UNnm+24KJnQPqdAwLoVOzMaD poZ9QtepdTrGyvQqVs+iiXdi0j9yCiByTTTBSt7+88/fnYW5E/S3LjgqWZ75Iyr6Whla O9h5mzXeGsg+PtbFOQFKGUJTD2tuYmzBTYy+V8eGOVqsWrjwS68gBphSv4CwgqoOvV7p ars+XMmqiv/Vh0+7Yoe2LhSQr39ZknIw6qhRAqYQWDYMbTJlU7Jpjj3uX0cmoB23/Fhi qHzuQisPw7CiYIt7+iTgUeaCYOdmY/LNNHZ1EUMH3hCVjVt6vjjlz5TXj0DbVIfc7G4M J+9Q== 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=WR1kxkoVZD6HXLDQor9h29veNv2PYFEvtxxcMJV/TyRUD6LGGbtmqeLdRwDweezKzG NwPjGJgd/lez18pPfWuIrbwFFZMv8+Kg3pB08qZAyBSdXdHYuJblqK1CW1yWgc4EHGq8 wR72aUQu8oaabK1vOsrrSEEUgJLvYHNVSxBf3RdiH0N5tE8xO6L5NShNVqwxz4m837QA NTMP+t9ZKfV0nClaluT4c+t7u7bGmUUC5AN4ZRvL9lPqI5xxKlE0X66tiowoLT95VpsV DuauzzQFIEKyvJ5l7zYOz4m/H5aqgTA1CTQXpJIhKf6x4k6Knr3IvJeGSvncOe2r+aYm iTfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VPshaeWW; 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 d22-20020a056a0024d600b0056bffcfc30csi19680801pfv.249.2022.11.02.19.53.00; Wed, 02 Nov 2022 19:53:13 -0700 (PDT) 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=VPshaeWW; 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 S231391AbiKCCv5 (ORCPT + 99 others); Wed, 2 Nov 2022 22:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231307AbiKCCvZ (ORCPT ); Wed, 2 Nov 2022 22:51:25 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4CC715721; Wed, 2 Nov 2022 19:51:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443865; x=1698979865; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QZah9F13AjoVe9tv/CykWOC6OrnYXLMSXtZoIq5C0N0=; b=VPshaeWWC+w/wq2XqKqj43wHvKnGfJWlDgNRNLywEZjOf5JlkTscNPmC fqmbsuBHuyRMyQUQ0ekf63Iiv0r9Lv6tQjKvDSob/4KYUM0/EXg2k0BRa GBul/rjhP3vGk8afERl3pkiqV9GPR/aLdfWpmwNFk/WvsqREvZAUi8haX 4EDc7q0Sn6POS3ahaUY0VEduU0qvsiRV4K4RfSk4AugPJHtTS2Xr3eaGy /HckDOTdu/ztIpzNKKMNbhCEJKCYn4n0CmV5u0a0simbPhAfYlUvmtYbi NG5tu/GttnCvE0Y895bC1KpWVTM24EQIeWfjydLPFGUrtcIivxmzRzp3I w==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="307186654" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="307186654" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:51:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047919" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047919" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:51:00 -0700 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 v2 6/8] x86: KVM: Advertise AVX-VNNI-INT8 CPUID to user space Date: Thu, 3 Nov 2022 10:50:28 +0800 Message-Id: <20221103025030.78371-7-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-8.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?1748441752606022974?= X-GMAIL-MSGID: =?utf-8?q?1748441752606022974?= 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 3 02:50:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279715wru; Wed, 2 Nov 2022 19:53:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ml14YwZW+m/2Ix4aK6FUwW9AxZVrdV9Mf+zOoJTPTnpgfhOHHyQGqYIOs513NO98wCS4I X-Received: by 2002:a05:6a00:b41:b0:52f:59dc:75 with SMTP id p1-20020a056a000b4100b0052f59dc0075mr27912237pfo.33.1667443996891; Wed, 02 Nov 2022 19:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667443996; cv=none; d=google.com; s=arc-20160816; b=0PFFI1qqxmF3YNm1FgpWlyOB1i32ujBkka+TAwkGT5jeF3lee6A3OfugbUwKMjKiPd Bz2Iip+gugqLmzI3oss5Jh/XLvxEjPkyl85Vv8KE84juu2atq3oqEW6qw24Jd1DEw0y0 kEt4TryXLYM8MJyBZD20bvNrhsTIH/S48IDvk/oZgciTdM/xTlI2Nnno+MULwqlia09n 7HQiHqLhZHBUWHg2DhpBr7bejOO5VKdydLm1cGTUr0JHabVxJ9xn5q+mbiOS61QAoJpU 2BSn4euxf1N0g6DlNjKE9tTALhI6jaBJALt8yNJks6gtjIkKn+RFq+XcO8fj7HDh1cKb Q+0w== 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=SqqJnkEJZDKKWJjXtxUbufy0Se1aDaEFCYz+gbr80/KgIe+bWnvYfV3FzFZa0Nexm3 ZmAA7A5ftpXb+V1+c3FNT5dl8tLRhsuDTat6QqEy4CL1xyDMKV91T13Pr976+8aZDYs7 aK37Vmz5iMbwGajmUKtNH1s4EEe0pBZE4JskKNWL2W0PHo6LqpN0W0ziZKzLbJztH40u spm4hcVj3Hu40It5+UFm8BEv/w2L8EYTC6i653BO5BE3y6fWir+zUwh7iwYDJ4l2ZBRr crerUckwihz3LA+xSXVVkEHJVyOXCnhXoYTSwn0hPFhO8PhK1GZx3ptlYimqwzeP7QZ7 kqVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OxvPh9f9; 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 q24-20020a63e218000000b0043ac3ec9d9esi16996569pgh.595.2022.11.02.19.53.04; Wed, 02 Nov 2022 19:53:16 -0700 (PDT) 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=OxvPh9f9; 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 S231307AbiKCCwD (ORCPT + 99 others); Wed, 2 Nov 2022 22:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231326AbiKCCvd (ORCPT ); Wed, 2 Nov 2022 22:51:33 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49B8F16585; Wed, 2 Nov 2022 19:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443871; x=1698979871; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z3o7gjqmPQSafhqSVWDWNYduM/0WLm1c0YsgTUqZbj8=; b=OxvPh9f9UgtEKHIgGYdQJNUGNlWVXtIRz0HsUhjg3XwusXPIqx2ATPp/ BlL/BMU6yWimZOLm95L9rmAbOdGppDWXHhtcmMP99pGt3n42kMj9fDpJd c9sl4JDSW2N1LSt1n7xE9UWO2ErnmpV1h3xgk1XPWUPZdlB3OBag8EiPg yTACcoObMSK9p0cFGj9TLQeOp3K5u3LrqXFWNRHhO2tea0fE11P5jZudx iSfbTmMTRIoZCbyBX9DB6B16GplzT/Yem/9kvgSfbA0i+kBIpXJjVUzMp YmazmjBwFbXGyETaK9T/JROrke1JPcP4uaLKPVbf+RgXSLFjUPeKDYcDT w==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="289282952" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="289282952" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:51:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047930" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047930" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:51:05 -0700 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 v2 7/8] x86: KVM: Advertise AVX-NE-CONVERT CPUID to user space Date: Thu, 3 Nov 2022 10:50:29 +0800 Message-Id: <20221103025030.78371-8-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, 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?1748441756445244311?= X-GMAIL-MSGID: =?utf-8?q?1748441756445244311?= 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 3 02:50:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 14610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp279827wru; Wed, 2 Nov 2022 19:53:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GYLoB/e6EOlS5igMRiUErc2OUbRwd9bSu9zfMdxazUqWZWi8dMIBDhRZDFhmneQagZ82t X-Received: by 2002:a17:902:da8e:b0:187:5b6:1b9e with SMTP id j14-20020a170902da8e00b0018705b61b9emr28140411plx.113.1667444014558; Wed, 02 Nov 2022 19:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667444014; cv=none; d=google.com; s=arc-20160816; b=vUmlRiQUQ2OIj/KV7F/Na2PoGuMIw3fJ517tmnEeh0kNHARAILPGlfHJQeM0RWd6yt Wnd80yWyUaeCZ+Am3UUDx23Kga2scVluBrtcXKKpfc/htJabq45EtUfACbWnNsUJqmCK wwkGUJXWIpafC8pO37IW7q3h7Aj6uhl6aDjU5BZk3WORAuTZYHBilRuBkt+Xda7pHJ85 DP7G7aRVGxPKa+u3ZLZWYH4KzvvmdUzKDvz8Kjhf9ZfzREyeHibMcQfZzIEOM7MkjdoX DFAh6Ncs3S1yhGmZ+juxFc2ZbP3F3raE8Y6SXLYT8e9ti9GV6982Mi4iaiqriOnZfSoi 725g== 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=ojaoiPYqclc0i/MjTnHUSVqjDP19b17QMGIYBM1bviM6j0i+p6ECP8Tm9eHU6eDis3 KVW3HtVvGfujoqAm8DFCNeaKQ98HyFzKG7q4yicegT7kaPiacNB1AW79+ZVm2hZBQgn9 4SVwM9B5tK4GGmuk2G2gthaPI2soLdIaDXZUSHMvfAESjAmB4tHKFnRfW7Z7vRe2N4mc yk9VxEulrlhDFGIAMVQBQr/EYs3o5EfzMx6qFbm7jvQGDzDRlkdVJJyD8w+d0GGwzD1t ao/wzCJhKcqxQ4nZhDSfHn8X7TrecZCeiRyn+o8gDxgMoLhUsA32bPbIs2Ak3VqAZYg2 z6EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cEZsyvxp; 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 g30-20020a63521e000000b0046ec7beb578si18552850pgb.94.2022.11.02.19.53.21; Wed, 02 Nov 2022 19:53:34 -0700 (PDT) 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=cEZsyvxp; 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 S231359AbiKCCwY (ORCPT + 99 others); Wed, 2 Nov 2022 22:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbiKCCvy (ORCPT ); Wed, 2 Nov 2022 22:51:54 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F81F13F2F; Wed, 2 Nov 2022 19:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667443880; x=1698979880; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JwR3352mQmtvv3jNZ1XhkuwmOLMITQeiSm1roomzunE=; b=cEZsyvxplYHWJiTf93ddNqPEoTWsWua48H/ANx5El3I5/fCvHAAj86rE 65+rvWoWzRpjtTqvdJz7j4sUnp/E8HrIFc9A2tM7ks3AXxDFmnsEd+5zA TK4SgMzjjRLOUUopHP7fc4hHX6VadkD7KoOfJ4FbEtq/i4xHCRi//TRxV izx5scHctphqvbaUPD+/sNUm0pnFavrmDFjRA2hIO/Xsrdn4LidozhsBp JgNKXsWDRh5BK+OjPlrJfPTK0fMN+0+fAM7Uv1V5TX+5fTD9S/WMBh4Eb jbJO/j0TL/2oqq0smhTv4wxuaejktfu2kpl43F4A28QQnuOJQKUN8r3yX w==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="289282961" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="289282961" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 19:51:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="698047945" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="698047945" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 02 Nov 2022 19:51:10 -0700 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 v2 8/8] x86: KVM: Advertise PREFETCHIT0/1 CPUID to user space Date: Thu, 3 Nov 2022 10:50:30 +0800 Message-Id: <20221103025030.78371-9-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> References: <20221103025030.78371-1-jiaxi.chen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, 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?1748441774564600790?= X-GMAIL-MSGID: =?utf-8?q?1748441774564600790?= 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;