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;