Re: [PATCH v6 12/21] x86/virt/tdx: Add placeholder to construct TDMRs to cover all TDX memory regions

From: Huang, Kai
Date: Thu Nov 03 2022 - 18:08:22 EST


On Thu, 2022-11-03 at 08:05 -0700, Hansen, Dave wrote:
> Plus, max_reserved_per_tdmr is barely in double digits today.  It's a
> *LOOOOOOOOONG* way from either of those limits.  If you want to add a
> warning here, then go for it and enforce a sane value on
> max_reserved_per_tdmr.

Hi Dave,

Thanks. By "enforce a sane value on max_reserved_per_tdmr' could you be more
specific? Did you mean if we find its value is insanely big, we can change it to
a reasonable smaller value?

But I don't think we can as the TDMR_INFO is used by the TDX module, so reducing
max_reserved_per_tdmr by the kernel doesn't actually work?

Perhaps for now we can make the kernel to assume TDMR_INFO won't exceed a
reasonable value (i.e. 4K/8K/16K?) and max_tdmrs (which is 64 currently) won't
exceed a reasonable value either (i.e. 1K/512/256?), so that we can just use
alloc_pages_exact() to allocate the entire TDMR array? If kernel found either
is too big, then kernel could just fail to initialize the TDX module.