Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1059888pxv; Fri, 16 Jul 2021 00:14:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzffwS2T3DbMHpNyA5TXFTCL0tA897020treJJNj2xpDaqKtqL59/LcJLhb/Z7lcAnlrrK X-Received: by 2002:a17:906:30d8:: with SMTP id b24mr10203860ejb.358.1626419693512; Fri, 16 Jul 2021 00:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626419693; cv=none; d=google.com; s=arc-20160816; b=fBZpj5V+xjeErx8EjOFm5kyvsx2ZLFijU3AL1KU9IlxRr433FJCI/y1SjYjbhGGuWj yg/YVGuPsV4bcTW5/QdEaME+oyKxNuZotr2LVEwIkwQQrHlcH9h8PUTVOlw1JwSM+Ri7 3knG5J4mbFO7JJXMe+gHYv6+SKPmDbZieIMdtn62jOHR2FT2rPvIj12PTNfnOkao0M0N h296dbQPKRBioPyRnN3lG+s/SRvNYGjNS54rVnOOZyVB+ahy1m+HOPq0LCHUuybRydwe ST2wynww85ksMUNRGmcjRxpQurvtTQEQrZtPfzfzvl8SzFCwYZa7QfpCqhiuZwIUuS+V FO/Q== 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=c5bQaMnFigzeeaO/e88q002r1BVwSolpi/uwpRUuvNpItidf0aO7tPdmXgkB6ICr5i QWw79WnxGtohnU5bMq4tKFxBc5UNrl4rnf5gfw+wU5U1AxT/spcxTrZTR9AVuof8dnym U93UbCVh7qRhEWrcL4uBomN6Sh2KSeY7abM31X15tqyW/gw02Xoeg7Kk6sPKBMwg4f7W nXox/w6k7mJPQ7e43N/NV61JKqOlPMY2nsKrkCpmftubDPADGJ9ozq197MxX8SfXrpiv 4AfyQXV2zmiHb+DLjOAhn5EH9xg045m3o4rtALgZCr1PbCiWmND7d3kFJVth3RTZQ8ho 2IOw== 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 f20si7986627edx.35.2021.07.16.00.14.31; Fri, 16 Jul 2021 00:14:53 -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 S235689AbhGPHQV (ORCPT + 99 others); Fri, 16 Jul 2021 03:16:21 -0400 Received: from mga07.intel.com ([134.134.136.100]:40483 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbhGPHQU (ORCPT ); Fri, 16 Jul 2021 03:16:20 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10046"; a="274512958" X-IronPort-AV: E=Sophos;i="5.84,244,1620716400"; d="scan'208";a="274512958" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2021 00:13:25 -0700 X-IronPort-AV: E=Sophos;i="5.84,244,1620716400"; d="scan'208";a="506374962" Received: from arthur-vostro-3668.sh.intel.com ([10.239.13.1]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2021 00:13:20 -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 1/6] x86/feat_ctl: Add new VMX feature, Tertiary VM-Execution control Date: Fri, 16 Jul 2021 14:48:03 +0800 Message-Id: <20210716064808.14757-2-guang.zeng@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716064808.14757-1-guang.zeng@intel.com> References: <20210716064808.14757-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