lkml.org 
[lkml]   [2021]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v2-fix-v2 2/2] x86/tdx: Ignore WBINVD instruction for TDX guest
Date
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
\
 
 \ /
  Last update: 2021-05-25 01:33    [W:2.442 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site