Re: [PATCH v15 10/23] KVM: selftests: Set up TDX boot parameters region
From: Binbin Wu
Date: Fri Oct 09 2026 - 22:47:23 EST
On 10/2/2026 3:37 AM, Lisa Wang wrote:
> From: Sagi Shahar <sagis@xxxxxxxxxx>
>
> Allocate memory for TDX boot parameters and define the utility functions
> necessary to fill this memory with the boot parameters.
>
> Co-developed-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
> Signed-off-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
> Signed-off-by: Sagi Shahar <sagis@xxxxxxxxxx>
> Signed-off-by: Lisa Wang <wyihan@xxxxxxxxxx>
One nit below and the issue pointed by the sashiko.
Otherwise,
Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>
[...]
> +void tdx_vm_setup_boot_parameters_region(struct kvm_vm *vm, u32 nr_runnable_vcpus)
> +{
> + size_t boot_params_size = sizeof(struct td_boot_parameters) +
> + nr_runnable_vcpus * sizeof(struct td_per_vcpu_parameters);
> + int npages = DIV_ROUND_UP(boot_params_size, PAGE_SIZE);
> + const u64 gmem_flags = 0;
> + gpa_t gpa;
> +
> + vm_mem_add(vm, VM_MEM_SRC_SHMEM, TD_BOOT_PARAMETERS_GPA,
> + TD_BOOT_PARAMETERS_SLOT, npages,
> + KVM_MEM_GUEST_MEMFD, -1, 0, gmem_flags);
> + gpa = vm_phy_pages_alloc(vm, npages, TD_BOOT_PARAMETERS_GPA, TD_BOOT_PARAMETERS_SLOT);
> + TEST_ASSERT(gpa == TD_BOOT_PARAMETERS_GPA, "Failed vm_phy_pages_alloc\n");
Nit: the tailing newline can be dropped.
> +
> + virt_map(vm, TD_BOOT_PARAMETERS_GPA, TD_BOOT_PARAMETERS_GPA, npages);
> +}
> +