Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1097459pxv; Thu, 22 Jul 2021 22:42:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY6PnrA/IHJcmosfI2qNL8TfpbvYkY8L6Wja1rv2zjiCpafnD/UOQ5uzWZZQYgxNpnv8As X-Received: by 2002:a02:ca58:: with SMTP id i24mr2675976jal.101.1627018939032; Thu, 22 Jul 2021 22:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627018939; cv=none; d=google.com; s=arc-20160816; b=RStpOmOfU4F3a3Fl2+pJOlFeir9waj73WZKON+joBc5FPSzmzuQoPaQAJjHNOO3CF8 aqVBmwFPPLz+DXPQfQDn7UFoXpj/GdALQVWsH3rNmUGl1tTwcn1khvcQuBDgPgNrJpxg z/fY9RkP/OE4b0ekhl9DGheS0ZEYY1rq7IKL6BuUHG6lgREqw/9uO4v9HkOaJcuSoqZ7 rhPkzmEuslVt3a04BLhAFfVHJQb6wF3D7GkqizKJOwQMMPIV/ejt0Eq2rzyQZ8ekd1rJ mxc8UoX5Ft0EizAzx5VqXO3K6qf1VwJW5i8sBYp23Nv7RiopClZ72mxQhvKdJXtGJPiE iWzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=HHRcKRXpEI1Oebmigl3M/J9/usyUaA7k4D2R3fCFW9k=; b=OcNvZfzwBdbWZknjExOXtuobBteCjlcEs1LyY/gCMPEv2S7PQevw18VoOr8eykp1ad XYvkIvviUB8VR8hyx0Ht5M+aB0K/hJGqNfHa0PJAMlB8B9omTlZmKKoqQgp9eVBT4/g7 ltq4A9KElEM3z1ZmXtDBuFwnfSfqPOdZh/12YkYAWlFvXQmHqrw0+xhllVtA6P0Pv4jf iKJxRXs8F9n3nm0oKciLIPQeDJxBHG/+pyz9GNumcEGcRACCnxKM5NKbMp3kvJusLQTE f4SteCqz4wA0NExxSbemd/xRhJesMMeJaE1WcZF3+NCgCw+G/p+Gr+xO4NZ/QIipltle vc2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si32207577jae.125.2021.07.22.22.42.08; Thu, 22 Jul 2021 22:42:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233789AbhGWFAp (ORCPT + 99 others); Fri, 23 Jul 2021 01:00:45 -0400 Received: from mga17.intel.com ([192.55.52.151]:23861 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233712AbhGWFAl (ORCPT ); Fri, 23 Jul 2021 01:00:41 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10053"; a="192086797" X-IronPort-AV: E=Sophos;i="5.84,263,1620716400"; d="scan'208";a="192086797" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 22:41:15 -0700 X-IronPort-AV: E=Sophos;i="5.84,263,1620716400"; d="scan'208";a="502383452" Received: from arthur-vostro-3668.sh.intel.com ([10.239.13.1]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2021 22:41:10 -0700 From: Zeng Guang To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, Dave Hansen , Tony Luck , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , Kai Huang Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Robert Hu , Gao Chao , Zeng Guang , Robert Hoo Subject: [PATCH v2 1/6] x86/feat_ctl: Add new VMX feature, Tertiary VM-Execution control Date: Fri, 23 Jul 2021 13:16:21 +0800 Message-Id: <20210723051626.18364-2-guang.zeng@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210723051626.18364-1-guang.zeng@intel.com> References: <20210723051626.18364-1-guang.zeng@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Hoo New VMX capability MSR IA32_VMX_PROCBASED_CTLS3 conresponse to this new VM-Execution control field. And it is 64bit allow-1 semantics, not like previous capability MSRs 32bit allow-0 and 32bit allow-1. So with Tertiary VM-Execution control field introduced, 2 vmx_feature leaves are introduced, TERTIARY_CTLS_LOW and TERTIARY_CTLS_HIGH. Signed-off-by: Robert Hoo Signed-off-by: Zeng Guang --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/include/asm/vmxfeatures.h | 3 ++- arch/x86/kernel/cpu/feat_ctl.c | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index a7c413432b33..3df26e27b554 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -919,6 +919,7 @@ #define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x0000048f #define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490 #define MSR_IA32_VMX_VMFUNC 0x00000491 +#define MSR_IA32_VMX_PROCBASED_CTLS3 0x00000492 /* VMX_BASIC bits and bitmasks */ #define VMX_BASIC_VMCS_SIZE_SHIFT 32 diff --git a/arch/x86/include/asm/vmxfeatures.h b/arch/x86/include/asm/vmxfeatures.h index d9a74681a77d..27e76eeca05b 100644 --- a/arch/x86/include/asm/vmxfeatures.h +++ b/arch/x86/include/asm/vmxfeatures.h @@ -5,7 +5,7 @@ /* * Defines VMX CPU feature bits */ -#define NVMXINTS 3 /* N 32-bit words worth of info */ +#define NVMXINTS 5 /* N 32-bit words worth of info */ /* * Note: If the comment begins with a quoted string, that string is used @@ -43,6 +43,7 @@ #define VMX_FEATURE_RDTSC_EXITING ( 1*32+ 12) /* "" VM-Exit on RDTSC */ #define VMX_FEATURE_CR3_LOAD_EXITING ( 1*32+ 15) /* "" VM-Exit on writes to CR3 */ #define VMX_FEATURE_CR3_STORE_EXITING ( 1*32+ 16) /* "" VM-Exit on reads from CR3 */ +#define VMX_FEATURE_TER_CONTROLS (1*32 + 17) /* "" Enable Tertiary VM-Execution Controls */ #define VMX_FEATURE_CR8_LOAD_EXITING ( 1*32+ 19) /* "" VM-Exit on writes to CR8 */ #define VMX_FEATURE_CR8_STORE_EXITING ( 1*32+ 20) /* "" VM-Exit on reads from CR8 */ #define VMX_FEATURE_VIRTUAL_TPR ( 1*32+ 21) /* "vtpr" TPR virtualization, a.k.a. TPR shadow */ diff --git a/arch/x86/kernel/cpu/feat_ctl.c b/arch/x86/kernel/cpu/feat_ctl.c index da696eb4821a..2e0272d127e4 100644 --- a/arch/x86/kernel/cpu/feat_ctl.c +++ b/arch/x86/kernel/cpu/feat_ctl.c @@ -15,6 +15,8 @@ enum vmx_feature_leafs { MISC_FEATURES = 0, PRIMARY_CTLS, SECONDARY_CTLS, + TERTIARY_CTLS_LOW, + TERTIARY_CTLS_HIGH, NR_VMX_FEATURE_WORDS, }; @@ -42,6 +44,13 @@ static void init_vmx_capabilities(struct cpuinfo_x86 *c) rdmsr_safe(MSR_IA32_VMX_PROCBASED_CTLS2, &ign, &supported); c->vmx_capability[SECONDARY_CTLS] = supported; + /* + * For tertiary execution controls MSR, it's actually a 64bit allowed-1. + */ + rdmsr_safe(MSR_IA32_VMX_PROCBASED_CTLS3, &ign, &supported); + c->vmx_capability[TERTIARY_CTLS_LOW] = ign; + c->vmx_capability[TERTIARY_CTLS_HIGH] = supported; + rdmsr(MSR_IA32_VMX_PINBASED_CTLS, ign, supported); rdmsr_safe(MSR_IA32_VMX_VMFUNC, &ign, &funcs); -- 2.25.1