Re: [PATCH v12 21/23] KVM: selftests: Add wrapper for TDX MMIO from guest

From: Ira Weiny

Date: Fri Oct 31 2025 - 10:19:17 EST


Sagi Shahar wrote:
> Add utility function to issue MMIO TDCALL from TDX guests.

Some detail from the spec would be nice here.

[snip]

> diff --git a/tools/testing/selftests/kvm/lib/x86/tdx/tdx.c b/tools/testing/selftests/kvm/lib/x86/tdx/tdx.c
> new file mode 100644
> index 000000000000..f9c1acd5b30c
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/lib/x86/tdx/tdx.c
> @@ -0,0 +1,23 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include "tdx/tdcall.h"
> +#include "tdx/tdx.h"
> +
> +#define TDG_VP_VMCALL 0
> +
> +#define TDG_VP_VMCALL_VE_REQUEST_MMIO 48
> +
> +uint64_t tdg_vp_vmcall_ve_request_mmio_write(uint64_t address, uint64_t size,

Size is limited to specific values. An enum would help here to self
document/limit issues.

enum mmio_write_size {
MMIO_SIZE_1B,
MMIO_SIZE_2B,
MMIO_SIZE_4B,
MMIO_SIZE_8B
};

Ira

[snip]