Re: [PATCH v14 16/22] KVM: selftests: Load per-vCPU guest stack in TDX boot parameters

From: Peter Fang

Date: Wed Aug 26 2026 - 18:19:11 EST


On Wed, Jul 22, 2026 at 11:13:21PM +0000, Lisa Wang wrote:
> From: Sagi Shahar <sagis@xxxxxxxxxx>
>
> Allocate a guest stack for each vCPU and record the GVA in the TDX boot
> parameters region to allow proper vCPU initialization.
>
> 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>
> Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>
> ---
> tools/testing/selftests/kvm/include/x86/tdx/tdx_util.h | 1 +
> tools/testing/selftests/kvm/lib/x86/processor.c | 2 ++
> tools/testing/selftests/kvm/lib/x86/tdx/tdx_util.c | 10 ++++++++++
> 3 files changed, 13 insertions(+)
>

[ ... ]

>
> +void tdx_vcpu_load_boot_parameters(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
> +{
> + struct td_boot_parameters *params =
> + addr_gpa2hva(vm, TD_BOOT_PARAMETERS_GPA);
> + struct td_per_vcpu_parameters *vcpu_params =
> + &params->per_vcpu[vcpu->id];
> +
> + vcpu_params->esp_gva = kvm_allocate_vcpu_stack(vm);

Just flagging that there is a subtle truncation here. The TDX boot code
sets esp in 32-bit mode so it has the same visibility constraint as CR3,
which has an explicit check ("vm->mmu.pgd < (1ULL << 32)").

> +}
> +
> static struct kvm_tdx_capabilities *tdx_read_capabilities(struct kvm_vm *vm)
> {
> static struct kvm_tdx_capabilities *tdx_cap;
>
> --
> 2.55.0.229.g6434b31f56-goog
>
>