Skip to content

Commit 427a648

Browse files
yamahatabonzini
authored andcommitted
KVM: TDX: Require TDP MMU, mmio caching and EPT A/D bits for TDX
Disable TDX support when TDP MMU or mmio caching or EPT A/D bits aren't supported. As TDP MMU is becoming main stream than the legacy MMU, the legacy MMU support for TDX isn't implemented. TDX requires KVM mmio caching. Without mmio caching, KVM will go to MMIO emulation without installing SPTEs for MMIOs. However, TDX guest is protected and KVM would meet errors when trying to emulate MMIOs for TDX guest during instruction decoding. So, TDX guest relies on SPTEs being installed for MMIOs, which are with no RWX bits and with VE suppress bit unset, to inject VE to TDX guest. The TDX guest would then issue TDVMCALL in the VE handler to perform instruction decoding and have host do MMIO emulation. TDX also relies on EPT A/D bits as EPT A/D bits have been supported in all CPUs since Haswell. Relying on it can avoid RWX bits being masked out in the mirror page table for prefaulted entries. Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Co-developed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Co-developed-by: Yan Zhao <yan.y.zhao@intel.com> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> --- Requested by Sean at [1]. [1] https://lore.kernel.org/kvm/Zva4aORxE9ljlMNe@google.com/ Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent e0fbb3b commit 427a648

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static bool __ro_after_init tdp_mmu_allowed;
110110
#ifdef CONFIG_X86_64
111111
bool __read_mostly tdp_mmu_enabled = true;
112112
module_param_named(tdp_mmu, tdp_mmu_enabled, bool, 0444);
113+
EXPORT_SYMBOL_GPL(tdp_mmu_enabled);
113114
#endif
114115

115116
static int max_huge_page_level __read_mostly;

arch/x86/kvm/vmx/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "x86_ops.h"
55
#include "vmx.h"
6+
#include "mmu.h"
67
#include "nested.h"
78
#include "pmu.h"
89
#include "posted_intr.h"

arch/x86/kvm/vmx/tdx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,16 @@ int __init tdx_bringup(void)
15341534
if (!enable_tdx)
15351535
return 0;
15361536

1537+
if (!enable_ept) {
1538+
pr_err("EPT is required for TDX\n");
1539+
goto success_disable_tdx;
1540+
}
1541+
1542+
if (!tdp_mmu_enabled || !enable_mmio_caching || !enable_ept_ad_bits) {
1543+
pr_err("TDP MMU and MMIO caching and EPT A/D bit is required for TDX\n");
1544+
goto success_disable_tdx;
1545+
}
1546+
15371547
if (!cpu_feature_enabled(X86_FEATURE_MOVDIR64B)) {
15381548
pr_err("tdx: MOVDIR64B is required for TDX\n");
15391549
goto success_disable_tdx;

0 commit comments

Comments
 (0)