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;