Re: [RFC v2-fix 1/1] x86/tdx: Handle in-kernel MMIO

From: Dave Hansen
Date: Tue May 18 2021 - 12:24:33 EST


On 5/18/21 9:10 AM, Andi Kleen wrote:
> I'm not aware of any other places that would do MMIO without using the
> standard io.h macros, although it might happen in theory on x86 (but
> would likely break on some other architectures)

Can we please connect all of the dots and turn this into a coherent
changelog?

* In-kernel MMIO is handled via exceptions (#VE) and instruction
cracking
* Arbitrary MMIO instructions are not handled (and would result in...)
* The limited set of MMIO instructions that are handled are known and
come from the io.h macros, ultimately build_mmio_read/write().
* This approach is also used for SEV-ES???
* Some x86 code that avoids the MMIO code is known to exist (APIC).
But, this code is not used in TDX guests

BTW, in perusing arch/x86/include/asm/io.h, I was reminded of movdir64b.
That seems like one we'd want to take care of sooner rather than later.
Or, do we expect the first folks who expose a movdir64b-using driver to
TDX to go and update this code?

Also, the sev_key_active() stuff in there makes me nervous. Does this
scheme work with these:

> static inline void outs##bwl(int port, const void *addr, unsigned long count) \
> static inline void ins##bwl(int port, void *addr, unsigned long count) \

?