Re: [RFC v2-fix-v4 1/1] x86/tdx: Skip WBINVD instruction for TDX guest

From: Kuppuswamy, Sathyanarayanan
Date: Wed Jun 09 2021 - 00:54:33 EST




On 6/8/21 9:40 PM, Andi Kleen wrote:

KVM only turns it into a noop if there is no VT-d, because with VT-d you
might need it to turn mappings into uncached and vice versa.
Wow, I found the kvm_arch_register_noncoherent_dma() stuff.  That's horrifying.  What's it for?  e

e.g. if you want to run a GPU it really needs some uncached memory. Same is true for other more complex devices.

Now modern Linux of course will be preferring CLFLUSH instead for the conversion, but there are old versions that preferred WBINVD.

I don't think it's a DoS, as long as you're not too picky about latencies on the host.

-Andi


Currently we use prot_guest_has(PR_GUEST_DISABLE_WBINVD)) check for disabling the wbinvd()
usage (which can be selectively enabled for tested guests).

Is it alright to generalize it with boot_cpu_has(X86_FEATURE_HYPERVISOR) without
verify it?




--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer