Re: [PATCH 10/13] x86/virt/tdx: Add SEAMCALL wrappers to remove a TD private page

Dave Hansen
2025-01-07T22:13:19Z

On 1/6/25 22:43, Yan Zhao wrote:
> +u64 tdh_phymem_page_wbinvd_hkid(struct page *page, u16 hkid)
> +{
> + struct tdx_module_args args = {};
> +
> + args.rcx = page_to_phys(page) | ((hpa_t)hkid << boot_cpu_data.x86_phys_bits);

I've seen this idiom enough times. You need a helper:

u64 mk_keyed_paddr(struct page *page, u64 keyid)
{
u64 ret;

ret = page_to_phys(page);
/* KeyID bits are just above the physical address bits: */
ret |= keyid << boot_cpu_data.x86_phys_bits;

return ret;
}

Although I'm also debating a bit what the typing on 'keyid' should be.
Right now it's quite tied to the physical address width, but that's not
fundamental to TDX. It could absolutely change in the future.