Re: [PATCH 10/26] x86/tdx: Support TDX guest port I/O at decompression time

From: Borislav Petkov
Date: Thu Jan 13 2022 - 08:51:59 EST


On Tue, Dec 14, 2021 at 06:02:48PM +0300, Kirill A. Shutemov wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
>
> Port IO triggers a #VE exception in TDX guests. During normal runtime,
> the kernel will handle those exceptions for any port IO.
>
> But for the early code in the decompressor, #VE cannot be used because
> the IDT needed for handling the exception is not set up.
... yet.

Well, we're setting up and IDT twice in

arch/x86/boot/compressed/idt_64.c

as early as startup_64 for SEV. And the second stage one
do_boot_stage2_vc() handles port IO too.

Can't you hook in your VE handler there too?

> Replace IN/OUT instructions with TDX IO hypercalls by defining helper
> macros __in/__out and by re-defining them in the decompressor code.
> Also, since TDX IO hypercall requires an IO size parameter, allow
> __in/__out macros to accept size as an input parameter.

Please end function/macro names with parentheses. I think in this
particular case you wanna say

"__in*()/__out*() macros"

When a function is mentioned in the changelog, either the text body or the
subject line, please use the format 'function_name()'. Omitting the
brackets after the function name can be ambiguous::

Subject: subsys/component: Make reservation_count static

reservation_count is only used in reservation_stats. Make it static.

The variant with brackets is more precise::

Subject: subsys/component: Make reservation_count() static

reservation_count() is only called from reservation_stats(). Make it
static.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette