RE: [RFC PATCH 02/15] x86/tdx: Add TDCM hypercall wrapper for TDX Connect

From: Duan, Zhenzhong

Date: Tue Oct 27 2026 - 02:08:35 EST




>-----Original Message-----
>From: Li, Xiaoyao <xiaoyao.li@xxxxxxxxx>
>Subject: Re: [RFC PATCH 02/15] x86/tdx: Add TDCM hypercall wrapper for TDX
>Connect
>
>On 10/27/2026 11:28 AM, Duan, Zhenzhong wrote:
>>>> Abstract the underlying leaf call and pass the shared buffer physical
>>>> address as a decrypted mapping. Add a runtime page alignment check
>>>> for the buffer to enforce correct usage.
>>> This doesn't match the implementation. The code only WARNs instead of
>>> enforcing
>>> correct usage.
>> You mean below code?
>>
>> static void tdx_devsec_unlock(struct pci_tsm *tsm)
>> {
>> struct tdx_devsec *tdevsec = to_tdx_devsec(tsm);
>> struct device_evidence *evidence = tsm->evidence;
>>
>> if (WARN_ON(tdx_tdi_unbind_dev(tdevsec)))
>> return;
>>
>> I think the unlock() callback should be defined with a return value so
>> userspace could catch the error.
>
>No. I meant just the code of tdx_hcall_tdcm()
>
>+u64 tdx_hcall_tdcm(u16 devid, void *buf, size_t size, u8 vector)
>+{
>+ WARN_ON_ONCE(!PAGE_ALIGNED(buf) || !PAGE_ALIGNED(size));
>+
>+ return _tdx_hypercall(TDVMCALL_TDCM, devid,
>cc_mkdec(virt_to_phys(buf)), size,
>vector);
>+}
>
>it warns on the unaligned buf and size, but the unaligned data are still
>consumed.

The caller has guaranteed gpa and size are 4KB aligned. Meanwhile GHCI spec
requires passing 4KB aligned gpa and size, that means if we don't, the
hypercall will return failure. So maybe we can drop it?