On Tue, Apr 01, 2025 at 09:01:31AM -0400, Xiaoyao Li wrote:
> Date: Tue,  1 Apr 2025 09:01:31 -0400
> From: Xiaoyao Li <xiaoyao...@intel.com>
> Subject: [PATCH v8 21/55] i386/tdx: Track RAM entries for TDX VM
> X-Mailer: git-send-email 2.34.1
> 
> The RAM of TDX VM can be classified into two types:
> 
>  - TDX_RAM_UNACCEPTED: default type of TDX memory, which needs to be
>    accepted by TDX guest before it can be used and will be all-zeros
>    after being accepted.
> 
>  - TDX_RAM_ADDED: the RAM that is ADD'ed to TD guest before running, and
>    can be used directly. E.g., TD HOB and TEMP MEM that needed by TDVF.
> 
> Maintain TdxRamEntries[] which grabs the initial RAM info from e820 table
> and mark each RAM range as default type TDX_RAM_UNACCEPTED.
> 
> Then turn the range of TD HOB and TEMP MEM to TDX_RAM_ADDED since these
> ranges will be ADD'ed before TD runs and no need to be accepted runtime.
> 
> The TdxRamEntries[] are later used to setup the memory TD resource HOB
> that passes memory info from QEMU to TDVF.
> 
> Signed-off-by: Xiaoyao Li <xiaoyao...@intel.com>
> Acked-by: Gerd Hoffmann <kra...@redhat.com>
> ---

[snip]

>  static void tdx_finalize_vm(Notifier *notifier, void *unused)
>  {
>      TdxFirmware *tdvf = &tdx_guest->tdvf;
>      TdxFirmwareEntry *entry;
>  
> +    tdx_init_ram_entries();
> +
>      for_each_tdx_fw_entry(tdvf, entry) {
>          switch (entry->type) {
>          case TDVF_SECTION_TYPE_BFV:
> @@ -166,12 +273,16 @@ static void tdx_finalize_vm(Notifier *notifier, void 
> *unused)
>                               entry->type);
>                  exit(1);
>              }
> +            tdx_accept_ram_range(entry->address, entry->size);

It's better to catch & report the failure case here.

>              break;

Others LGTM,

Reviewed-by: Zhao Liu <zhao1....@intel.com>



Reply via email to