Re: [PATCHv5 10/12] x86/tdx: Unaccepted memory support

Kirill A. Shutemov
2022-05-11T01:17:26Z

On Fri, May 06, 2022 at 11:44:23PM +0300, Kirill A. Shutemov wrote:
> > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > > index 7021ec725dd3..e4c31dbea6d7 100644
> > > --- a/arch/x86/Kconfig
> > > +++ b/arch/x86/Kconfig
> > > @@ -885,6 +885,7 @@ config INTEL_TDX_GUEST
> > > select ARCH_HAS_CC_PLATFORM
> > > select X86_MEM_ENCRYPT
> > > select X86_MCE
> > > + select UNACCEPTED_MEMORY
> >
> > WARNING: unmet direct dependencies detected for UNACCEPTED_MEMORY
> > Depends on [n]: EFI [=y] && EFI_STUB [=y] && !KEXEC_CORE [=y]
> > Selected by [y]:
> > - INTEL_TDX_GUEST [=y] && HYPERVISOR_GUEST [=y] && X86_64 [=y] && CPU_SUP_INTEL [=y] && X86_X2APIC [=y]
> >
> > WARNING: unmet direct dependencies detected for UNACCEPTED_MEMORY
> > Depends on [n]: EFI [=y] && EFI_STUB [=y] && !KEXEC_CORE [=y]
> > Selected by [y]:
> > - INTEL_TDX_GUEST [=y] && HYPERVISOR_GUEST [=y] && X86_64 [=y] && CPU_SUP_INTEL [=y] && X86_X2APIC [=y]
>
> Ughh. Any ideas how to get around it? (Except for implementing kexec
> support right away?)

I reworked this to boot-time kexec disable.

> > Also, it doesn't need to be bool - you can simply return accept_size on
> > success and 0 on error so that you don't have an I/O argument.
>
> So on the calling side it would look like:
>
> accepted = try_accept_one(start, len, PG_LEVEL_1G)
> if (accepted) {
> start += accepted;
> continue;
> }
>
> And the similar for other levels. Is it really better?

JFYI, I've reworked it as

accepted = try_accept_one(start, len, PG_LEVEL_1G);
if (!accepted)
accepted = try_accept_one(start, len, PG_LEVEL_2M);
if (!accepted)
accepted = try_accept_one(start, len, PG_LEVEL_4K);
if (!accepted)
return false;
start += accepted;

looks good to me.

--
Kirill A. Shutemov