Re: [PATCHv4 12/30] x86/tdx: Detect TDX at early kernel decompression time

Dave Hansen
2022-02-24T20:44:16Z

On 2/24/22 07:56, Kirill A. Shutemov wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> The early decompression code does port I/O for its console output. But,
> handling the decompression-time port I/O demands a different approach
> from normal runtime because the IDT required to support #VE based port
> I/O emulation is not yet set up. Paravirtualizing I/O calls during
> the decompression step is acceptable because the decompression code size is
> small enough and hence patching it will not bloat the image size a lot.

It's not the *decompression* code size that matters. It's that there
aren't a lot of call sites to the I/O instructions. Right?

> To support port I/O in decompression code, TDX must be detected before
> the decompression code might do port I/O. Detect whether the kernel runs
> in a TDX guest.
>
> Add an early_is_tdx_guest() interface to query the cached TDX guest
> status in the decompression code.

Nit: I was a bit surprised by the minor cpuid() munging and the new
shared/tdx.h header. They look sane, but you can reduce reviewer
surprise by adding a sentence or two of changelog material.

> The actual port I/O paravirtualization will come later in the series.
>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Dave Hansen <dave.hansen@linux.intel.com>