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

From: Borislav Petkov
Date: Mon Jan 17 2022 - 13:32:56 EST


On Mon, Jan 17, 2022 at 05:39:20PM +0300, Kirill A. Shutemov wrote:
> arch/x86/boot and arch/x86/boot/compressed are separate linking domains.
> boot/ uses own implementation while boot/compressed uses implementation
> from <asm/io.h>. Decopliing boot/compressed from <asm/io.h> requires hack.
> See #define _ACPI_IO_H_ below.

I am painfully aware. And the need to share code with kernel proper has
grown quite the nasties in the meantime.

So, we talked about what to do here recently and the suggestion was to
librarize common functionality so that

1. it can be shared between the two.
2. changes in the kernel proper headers do not break the boot stubs.

So, instead of yet another duplication, I think what we should do is
start growing a shared/ header namespace, i.e.,

arch/x86/include/asm/shared/

for example, and put there common, well, shared, functionality between
boot stubs and kernel proper. Stuff which is basic and generic enough so
that it can be shared by both.

That would be a prepatch.

Then, ontop, I'm wondering if it would be cleaner to have in/out
function pointers in the boot stub which are assigned by default to
those __in/__out generic shared handlers and then early_tdx_detect()
would assign to them tdx_io_{in,out} when it detects it is running as a
TDX guest.

Hmmm...?

--
Regards/Gruss,
Boris.

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