From patchwork Fri Nov 25 12:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxi Chen X-Patchwork-Id: 2233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3994884wrr; Fri, 25 Nov 2022 04:59:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf476iMc/jxARB57+k7g+tBefy8Ttjv1kv6304yTPZ3lSTa7TQdawPEK9TMJEJMx9JBzr1A2 X-Received: by 2002:a05:6402:4445:b0:468:eef6:a83c with SMTP id o5-20020a056402444500b00468eef6a83cmr34691139edb.191.1669381152887; Fri, 25 Nov 2022 04:59:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669381152; cv=none; d=google.com; s=arc-20160816; b=c1iJ3kCH0dJYyAs6ppP+zVsgx/bHB92j+79m7xld0MAdZA/Noo+7GL3cdFE554IJuu Qf/PDckd4Ld77FKjmWlZ42OsTGyP/XrraRn7YFX0ZkAjEX82dcgptAmDKkFDdKx68Rrw noPJahOAY/SGTMfJ7NHRrBuvxY6kGoPE0CCTDABjzvGhvtBJD9TBJSmemD5OKzKdlSOz B9/iiAtrPIQnRT5kSOQJXg75oSBTwjj2RUurZHZ2Momda1xvMB3hk+TYosxUODca/6ZX 6bvSOyPZyzlbpJ2uM3gFgeaC3UenLMiyjmnFKUWrwOgY7mOZ440A4mmoh322OIkAthjv FCZw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=vNwOkCNjQB+wJ5PtPHfIw9hClcVyCoBt2H+kL8iG3+M=; b=v9KoGuYMs3w65BnfO9G26z0SUoH1ee39cCPapwoUuCPzMcMh8/PoApJn+ndObzQaNX m4NoqA/cxQYa522uejIa1IN/xkHJRdUmmIlryrOnccXNbA638+KEWgx8vCI0JnCYgxnn OzP3IXWfqh2eMYdfDqLtZMm/bH5JfhymFYmdGUT4vT9iz7oz54gwkE3p/+Xu6TXAdGir 0Q6tphfoqPaa9Qs0qMD6xOiroQP51Wl0T20zFoThLF/E34oBdC/Xdm4EALHk722NbF6c GdjaGBMe4ZEwbNB9SlnqHcCEi0W2rae3dLaAT3jPZIuPWJaOVyxrrAJbUYHxcidp3nfA 8+WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K7rmQtJ+; 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 g16-20020a50d0d0000000b00469a9a595f6si3493431edf.552.2022.11.25.04.58.49; Fri, 25 Nov 2022 04:59: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=K7rmQtJ+; 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 S229563AbiKYM6k (ORCPT + 99 others); Fri, 25 Nov 2022 07:58:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiKYM6i (ORCPT ); Fri, 25 Nov 2022 07:58:38 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7D127903; Fri, 25 Nov 2022 04:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669381117; x=1700917117; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xP1nfhyQ8FOkPUPmd5LvYYecrF3SJgmtl4GzeuHjbw8=; b=K7rmQtJ+UFh8Oq49zTHoeazt5MgGdXhwM3ss1q1fhbTq0Eus9RBIIzF7 iEDC/RkRz/jB+ytnad6Q7Rdq+csKrrCphO5m5Ij+FhU9QX/oiBk0UWB3g 1FI1MYAvEOV2VCxRz1pV8bEmcDvBW2m/TrPNhAKGK88rDCdZFbCBHAPfv 83LFerGesxLEmfCFVVtNGpQPOerVLFVdxZW+BsI3UGw7a/z1FYyYMyL13 Tq365YB1lSB4hM4U4IteDNixWDv2D57ij13XWqP7wb7oLH29VJDeuMzfQ E3hJEg1U95c1D6zCZ4EseEdo3pfQlDSWGUmC5ukl05JK/DMLB1CYp/Lg/ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="314513166" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="314513166" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2022 04:58:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="706061194" X-IronPort-AV: E=Sophos;i="5.96,193,1665471600"; d="scan'208";a="706061194" 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:32 -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 0/8] x86: KVM: Advertise CPUID of new Intel platform instructions to user space Date: Fri, 25 Nov 2022 20:58:37 +0800 Message-Id: <20221125125845.1182922-1-jiaxi.chen@linux.intel.com> X-Mailer: git-send-email 2.25.1 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?1750473011677003286?= X-GMAIL-MSGID: =?utf-8?q?1750473011677003286?= Latest Intel platform Granite Rapids/Sierra Forest has introduced below new instructions and CPUIDs: - CMPccXADD CPUID.(EAX=7,ECX=1):EAX[bit 7] - AMX-FP16 CPUID.(EAX=7,ECX=1):EAX[bit 21] - AVX-IFMA CPUID.(EAX=7,ECX=1):EAX[bit 23] - AVX-VNNI-INT8 CPUID.(EAX=7,ECX=1):EDX[bit 4] - AVX-NE-CONVERT CPUID.(EAX=7,ECX=1):EDX[bit 5] - PREFETCHITI CPUID.(EAX=7,ECX=1):EDX[bit 14] Details can be found in recent Intel ISE (Instruction Set Extensions)[1]. These features bits are on two CPUID leafs: CPUID_7_1_EAX and CPUID_7_1_EDX. CPUID_7_1_EAX is an expected-dense leaf and some of its bits have kernel usages, therefore give bits on this leaf an X86_FEATURE definition in kernel. However, CPUID_7_1_EDX is dense and none of its bits have truly kernel usages for the moment. Given that, move CPUID_7_1_EDX to be a KVM-only leaf and plus an x86_FEATURE definition for bits on this leaf to direct them to the KVM entry. This patch series advertises KVM support of these CPUIDs to host userspace. For all of these features, there are no new VMX controls or additional host enabling required for guests to use them. [1] Intel ISE: https://cdrdv2.intel.com/v1/dl/getContent/671368 v5: - Modify some inaccurate descriptions in the changelogs. - Address some naming-confusing problems for adding KVM-only leaves, including renaming function and adding comments. v4: https://lore.kernel.org/kvm/20221118141509.489359-1-jiaxi.chen@linux.intel.com/ - Put CPUID_7_1_EAX back to cpuid_leaf[], considering more bits will be defined in the future for this leaf. v3: https://lore.kernel.org/kvm/20221110015252.202566-1-jiaxi.chen@linux.intel.com/ - Remain CPUID_8000_001F_EAX in the last leaf of cpuid_leaf[] - Replace CPUID_7_1_EAX with CPUID_LNX_5, waiting for future new CPUIDs v2: https://lore.kernel.org/kvm/20221103025030.78371-1-jiaxi.chen@linux.intel.com/ - Remove vague descriptions in the changelogs, including pronouns and "this patch" kind of things. - Move the two CPUIDs of cpuid_leaf[12] CPUID_7_1_EAX to KVM-only subleaves. - Replace cpuid_leaf[12] CPUID_7_1_EAX with the last leaf CPUID_8000_001F_EAX to shorten array length. - Change the newly-added CPUID leaf [CPUID_7_1_EDX] in v1 into KVM-only subleaves. v1: https://lore.kernel.org/kvm/20221019084734.3590760-1-jiaxi.chen@linux.intel.com/ Chang S. Bae (1): x86: KVM: Advertise AMX-FP16 CPUID to user space Jiaxi Chen (5): x86: KVM: Advertise CMPccXADD CPUID to user space x86: KVM: Advertise AVX-IFMA CPUID to user space KVM: x86: Advertise AVX-VNNI-INT8 CPUID to user space KVM: x86: Advertise AVX-NE-CONVERT CPUID to user space KVM: x86: Advertise PREFETCHIT0/1 CPUID to user space Sean Christopherson (2): KVM: x86: Add BUILD_BUG_ON() to detect bad usage of "scattered" flags KVM: x86: Update KVM-only leaf handling to allow for 100% KVM-only leafs arch/x86/include/asm/cpufeatures.h | 3 +++ arch/x86/kvm/cpuid.c | 25 ++++++++++++++++++------- arch/x86/kvm/reverse_cpuid.h | 25 ++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 10 deletions(-) base-commit: 094226ad94f471a9f19e8f8e7140a09c2625abaa