Messages in this thread Patch in this message | | | From | Kuppuswamy Sathyanarayanan <> | Subject | [RFC v2-fix-v2 2/2] x86/tdx: Ignore WBINVD instruction for TDX guest | Date | Mon, 24 May 2021 16:32:11 -0700 |
| |
Functionally only DMA devices can notice a side effect from WBINVD's cache flushing. But, TDX does not support DMA, because DMA typically needs uncached access for MMIO, and the current TDX module always sets the IgnorePAT bit, which prevents that.
So handle the WBINVD instruction as nop. Currently, we did not include any warning for WBINVD handling because ACPI reboot code uses it. This is the same behavior as KVM. It only allows WBINVD in a guest when the guest supports VT-d (=DMA), but just handles it as a nop if it doesn't .
If TDX ever gets DMA support, a hypercall will be added to implement it similar to AMD-SEV. But current TDX does not support direct DMA.
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> ---
Changes since RFC v2: * Fixed commit log as per review comments. * Removed WARN_ONCE for WBINVD #VE support.
arch/x86/kernel/tdx.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c index 3800c7cbace3..21dec5bfc88e 100644 --- a/arch/x86/kernel/tdx.c +++ b/arch/x86/kernel/tdx.c @@ -511,6 +511,12 @@ int tdg_handle_virtualization_exception(struct pt_regs *regs, case EXIT_REASON_EPT_VIOLATION: ve->instr_len = tdg_handle_mmio(regs, ve); break; + case EXIT_REASON_WBINVD: + /* + * Non coherent DMA is not supported in TDX guest. + * So ignore WBINVD and treat it nop. + */ + break; case EXIT_REASON_MONITOR_INSTRUCTION: case EXIT_REASON_MWAIT_INSTRUCTION: /* -- 2.25.1
| |