From patchwork Fri Nov 25 12:58:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 25999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3995421wrr; Fri, 25 Nov 2022 05:00:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf65rvNDlntAt4XoW+NjbQF47nUQi2Y3LCds5nQZ4Tn8jfZEDgjIQtd/j3nnjEZyErW7aLjs X-Received: by 2002:a62:e702:0:b0:573:38f0:c910 with SMTP id s2-20020a62e702000000b0057338f0c910mr18711221pfh.52.1669381212592; Fri, 25 Nov 2022 05:00:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669381212; cv=none; d=google.com; s=arc-20160816; b=aPm0GIbs1c/4c6YfgGUz9a345rK0X6EzkhOWvcPNZWc0+/6mPsvEGHR9ilt0JX+dHP 0PYkTOiMOnnDHb5Bl+VxuBqvYF4TcxlSx9+5Z/ZBu/7AQ5zs5rEvHNuBeBN3QYZ82KXo FjQAvl+RSf3ACYIvI1zrICEd6btd/Hlwg5ZDeNOIzh6TbCl8/+WNSg8s68h3iqD1KaTA W9ZiAZW8k9mGp8K0NmmPdYapUcwhrNWtb8IIEMFNHCwKEd/tCD64g0XbPMBdt1LKcYYa xIW0PUDnKP5Y8B9gk0RAi0sl4D6sMlFumcFFxC8IHp0A3DgnPHqqzKReOZ8t7HLMJEud 6gfw== 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=WfJ4ndE3lLd9GccZz3ObXlaED2XpkTCXebkw3Rxp4uM=; b=eylXeYijjZT/BXMRiYbaYdO+F2zt6JF57HzQ9fCg9x3FZNppG60vVzZbWyv8qzmb3k 78ObeSMRT+oOM1ytQEXJ74tUOyipnlP5oH+K0297Pxfv2l8cP5Ij8jE9xre56XSg0Rk5 9ntIWrJcA3JY6yC59zc+csjKBL0cOK17ednQt7pDze5T6r33xIRLPYu+9PZicxy6TlhG /KT61nzcL9b0xV9/5Ey1GQ0f4wfZpY5CnaIZlq23v3F0A+WrkvXxy9Y0S+Xw52xpzsRx S5tQiqeE+hl2goaV5O6HC3osAJX7QihD/YNdXsNrONxEskXIEje53tz28oUNphsEMt5M v6tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j0RotfVV; 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 l191-20020a6388c8000000b004772afcec3asi3900269pgd.263.2022.11.25.04.59.58; Fri, 25 Nov 2022 05:00:12 -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=j0RotfVV; 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 S229731AbiKYM7m (ORCPT + 99 others); Fri, 25 Nov 2022 07:59:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiKYM7M (ORCPT ); Fri, 25 Nov 2022 07:59:12 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D599528E2F; Fri, 25 Nov 2022 04:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381142; x=1700917142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v4fej//7FpkGY53wVCQwPqHO2iJNyMNdkMs+y+xX9pI=; b=j0RotfVV9pC3r9m9PGRVJ4i4RKhevmsXfYUTNUNbOx9Yp1znoeK1HYa0 M7vm0lqBlb/Yskyu4tHQI8yiQLEm+rkuCsQtIV8V9ODAz2S/VxW50cLus WF5GqRLkAsoUGYrqMiU+mmYYkgm2GfFVf3D5EwL/rWf9QxD45SRk8qs9b aqOMNug0hMUL0haVCi1ivEGurgD80H8tYD6gBgH627QxmDwZVd6DJecrx QWpryQFtZcXQXp4s2pDSCkU7Eeguw2z7gJCjK/GWmKhoZW9LRqHdyoE9U lg5irSsn+CkdsEqebn8Dr00+HMUzekAJF5kefUWPkfOs3IMktRj5RFchT g==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="341381295" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="341381295" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 04:59:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706061282" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706061282" Received: from jiaxichen-precision-3650-tower.sh.intel.com ([10.239.159.75]) by fmsmga008.fm.intel.com with ESMTP; 25 Nov 2022 04:58:57 -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 v5 5/8] x86: KVM: Advertise AVX-IFMA CPUID to user space Date: Fri, 25 Nov 2022 20:58:42 +0800 Message-Id: <20221125125845.1182922-6-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221125125845.1182922-1-jiaxi.chen@linux.intel.com> References: <20221125125845.1182922-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1750473073941838072?= X-GMAIL-MSGID: =?utf-8?q?1750473073941838072?= 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] AVX-IFMA is on an expected-dense CPUID leaf and some other bits on this leaf have kernel usages. Given that, define this feature bit like X86_FEATURE_ in kernel. Considering AVX-IFMA itself has no truly kernel usages and /proc/cpuinfo has too much unreadable flags, hide this one in /proc/cpuinfo. Advertise AVX-IFMA to KVM userspace. This is safe because there are no new VMX controls or additional host enabling required for guests to use this feature. Signed-off-by: Jiaxi Chen Acked-by: Borislav Petkov --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kvm/cpuid.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 20059dc33d24..1419c4e04d45 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -310,6 +310,7 @@ #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */ #define X86_FEATURE_CMPCCXADD (12*32+ 7) /* "" CMPccXADD instructions */ #define X86_FEATURE_AMX_FP16 (12*32+21) /* "" AMX fp16 Support */ +#define X86_FEATURE_AVX_IFMA (12*32+23) /* "" Support for VPMADD52[H,L]UQ */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 0e04d1138bca..8612cddd9838 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -663,7 +663,8 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD); kvm_cpu_cap_mask(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,