Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3295201pxj; Tue, 1 Jun 2021 01:49:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM+RpLN5G6hrv+OdDuYALFuV0VPWNNURBF6wCtNT2o44i4M5QOF+J+Ynal6Dq15ll7WAag X-Received: by 2002:a05:6638:d09:: with SMTP id q9mr24372425jaj.32.1622537377737; Tue, 01 Jun 2021 01:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622537377; cv=none; d=google.com; s=arc-20160816; b=iQQNxZGbn6eyiOTgSMgfEYy2S8uXt0T8kSIDjlObV4WnGBNbd3kVsZyLk3PtgQFfdt 5uQsOp2PS/yO2yQjyudCy3cQwbmdUOm4XyE4TWqh7m6MIx2wiVtpbtUHPv6cFE9UPXYR 77REElv3tPIgy4Fj++f4UyJLxTO3AaFfoYxArRWVuDEiRlFN0pKFqeRi33SUGWD0G9sU ZAYwWcPFDF9IvC7os7VDJpKJpn6RUzAUQxPqxVW+I3476uOZaIV9dHZIntJriAd4C8g5 ID02wQY6h13XUf86IVbGFyaHdeZXWki7Nclp8ngez1UKjQxOejnXUsEai7SiSVLh+VMS gMxg== 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:ironport-sdr:ironport-sdr; bh=PvuMItwnDa3+a5rz1mR7HCTMsqSKiBcI+P7Yodhipuk=; b=FJmYKvFOlAvml4PJt3PaS7Ri2I7AYLcktWZi3Wvn5AUiQzwK4Ak46MuO0HIVXdm0ck YU8e3I7dYHIxtvHstx0SDZQbYy28stoCMl/ctMg3QdUQmXjDYinTEirpZnxcgYgn+OT6 EgBaXJMbyZel272WV5RMF5i5c/lOCB4BRyt3AMHcPMGZuSLwHfAtHwd8ZTdUyBFfjkuw HWf/riDHPJFeG6JuUHLIs6Zm9r0yYR0jfnpQRI0Me2oyd/OakwoWMvOlB1423ExCSu34 FtG3qqvxeD13deF9vVTvIy1x5w+lhQewh6PSrCOYdiRZfWyOg0OwTMz13wvzVeCI9inw i5Jw== 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 f11si6339859jaj.69.2021.06.01.01.49.24; Tue, 01 Jun 2021 01:49:37 -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 S233627AbhFAIt7 (ORCPT + 99 others); Tue, 1 Jun 2021 04:49:59 -0400 Received: from mga07.intel.com ([134.134.136.100]:45164 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbhFAItr (ORCPT ); Tue, 1 Jun 2021 04:49:47 -0400 IronPort-SDR: U0QLAR54HIrT+qM5d/F/dVbE+B/bkChOXf4iqi+YG/mmCCbQ4qqmE1iPRXaUf8iQmg85fQ9VUj Jxhxr+AO6mcQ== X-IronPort-AV: E=McAfee;i="6200,9189,10001"; a="267381315" X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="267381315" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 01:48:06 -0700 IronPort-SDR: wtZFw+9ZFYGi9KXP1aqOz0IQ7/xnh+uD9uVdP9BQPptp/tewJDplL53oPV7sPEnXEoriltzMxi n2tbmrpVf9rQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="437967768" Received: from sqa-gate.sh.intel.com (HELO robert-ivt.tsp.org) ([10.239.48.212]) by orsmga007.jf.intel.com with ESMTP; 01 Jun 2021 01:48:03 -0700 From: Robert Hoo To: pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com, robert.hu@intel.com, robert.hu@linux.intel.com Subject: [PATCH 03/15] x86/feat_ctl: Add new VMX feature, Tertiary VM-Execution control and LOADIWKEY Exiting Date: Tue, 1 Jun 2021 16:47:42 +0800 Message-Id: <1622537274-146420-4-git-send-email-robert.hu@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1622537274-146420-1-git-send-email-robert.hu@linux.intel.com> References: <1622537274-146420-1-git-send-email-robert.hu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a new VMX capability MSR IA32_VMX_PROCBASED_CTLS3. All 64 bits of this MSR define capability bits for the new tertiary VM-Exec control so two new 32-bit vmx_feature leaves are needed to record all the capabilities. The 2 new VMX features: Tertiary VM-Execution control is enumerated by bit 17 of existing Primary VM-Execution control. LOADIWKEY Exiting is enumerated by bit 0 of this new tertiary VM-Exec control, which designates if guest running 'loadiwkey' instruction will cause VM-Exit. Signed-off-by: Robert Hoo Reviewed-by: Tony Luck Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/include/asm/vmxfeatures.h | 6 +++++- arch/x86/kernel/cpu/feat_ctl.c | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index f8e7878..dd103c2 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -915,6 +915,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 d9a7468..c0b2f63 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 */ @@ -85,4 +86,7 @@ #define VMX_FEATURE_ENCLV_EXITING ( 2*32+ 28) /* "" VM-Exit on ENCLV (leaf dependent) */ #define VMX_FEATURE_BUS_LOCK_DETECTION ( 2*32+ 30) /* "" VM-Exit when bus lock caused */ +/* Tertiary Processor-Based VM-Execution Controls, word 3 */ +#define VMX_FEATURE_LOADIWKEY_EXITING (3*32 + 0) /* "" VM-Exit on LOADIWKey */ + #endif /* _ASM_X86_VMXFEATURES_H */ diff --git a/arch/x86/kernel/cpu/feat_ctl.c b/arch/x86/kernel/cpu/feat_ctl.c index da696eb..2e0272d 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); -- 1.8.3.1