Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp662938pxt; Thu, 5 Aug 2021 08:40:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWbnKi/TU9uajmCKSLn4Qfv14Li5jETu/kIcQmyaLbmPWBgbkNLr7lsFV6Xi5TGccglGdJ X-Received: by 2002:a05:6402:1458:: with SMTP id d24mr7454921edx.281.1628178018492; Thu, 05 Aug 2021 08:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628178018; cv=none; d=google.com; s=arc-20160816; b=y8k69yy5Ab9gP4geKS3x6qOyDa7iNZ7GwY+UyesdHsH69XxlS1sVGGEH+2Cv3PqJlZ xYOALTg9IukFXsjyHucYerzFifloFOlZpSq9QVM/4+FbTCtm0NB2CAICgLAyW4ocWerz fJIvqdOYZHiULhO0tTngp38hWW8E+oHPk/q4WnfHraB7NSUPd03WKfKVRqp2ZywL7iU4 BNxtvq17xVKjS0IkPNvJdERrU9qHhjIMaYT1tRTqzmywn4PuQFA0UMqNkRmddp5kMVDl MeozzdN8eKUQU/qz2t1o89nduB5ih2KaiGm2u637Leqd1bnFq5ZaHWFvygx0b9pkbiyB 0m6Q== 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=ogBeodT7LNwlHqF/dQK+ih/jsnw1MbVzjXzHsldN34c=; b=pLNCBjs3qNqS6KqZGwzK0e7kKox6AP8ZsuWe+/XwGM1bl9eg19lHnBy95U/vdlrhbr 1aEr9Csc1/rhSZU/fRLBgc4FxolM7MnYazo/b99k1Wy4aMRXb7sYEkIN2v0kamCx/ZTF rb7msNXioOI/X28imJfesD0lOPDsuehBg5wf25JRyrRBOQ1Z/71A5ESUPGAtNgFhp+zi JDcordF3YU7pQu53BH3yATml4xB+NSJ7+8VBZpguPp75PnqrxfIm5q/5NyEDpyXNGG53 2dmZGNVXT81xW1vYX14OyDd4df0uYR5kyxcS8TjbDLQeIW5/6C/dVWGvtqRWQlAggQhT MFAA== 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 f26si5774078ejb.537.2021.08.05.08.39.54; Thu, 05 Aug 2021 08:40:18 -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 S242156AbhHEPie (ORCPT + 99 others); Thu, 5 Aug 2021 11:38:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:36579 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242116AbhHEPi2 (ORCPT ); Thu, 5 Aug 2021 11:38:28 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10067"; a="211078968" X-IronPort-AV: E=Sophos;i="5.84,296,1620716400"; d="scan'208";a="211078968" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2021 08:38:14 -0700 X-IronPort-AV: E=Sophos;i="5.84,296,1620716400"; d="scan'208";a="512734055" 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; 05 Aug 2021 08:38:09 -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 v3 1/6] x86/feat_ctl: Add new VMX feature, Tertiary VM-Execution control Date: Thu, 5 Aug 2021 23:13:12 +0800 Message-Id: <20210805151317.19054-2-guang.zeng@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210805151317.19054-1-guang.zeng@intel.com> References: <20210805151317.19054-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 | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) 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..b264f5c43b5f 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_TERTIARY_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..4aab4def5000 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, }; @@ -22,7 +24,7 @@ enum vmx_feature_leafs { static void init_vmx_capabilities(struct cpuinfo_x86 *c) { - u32 supported, funcs, ept, vpid, ign; + u32 supported, funcs, ept, vpid, ign, low, high; BUILD_BUG_ON(NVMXINTS != 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, &low, &high); + c->vmx_capability[TERTIARY_CTLS_LOW] = low; + c->vmx_capability[TERTIARY_CTLS_HIGH] = high; + rdmsr(MSR_IA32_VMX_PINBASED_CTLS, ign, supported); rdmsr_safe(MSR_IA32_VMX_VMFUNC, &ign, &funcs); -- 2.25.1