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;