On Tue, 2024-11-12 at 17:11 -0800, Dave Hansen wrote: > On 10/30/24 12:00, Rick Edgecombe wrote: > > +u64 tdh_vp_flush(u64 tdvpr) > > +{ > > + struct tdx_module_args args = { > > + .rcx = tdvpr, > > + }; > > + > > + return seamcall(TDH_VP_FLUSH, &args); > > +} > > +EXPORT_SYMBOL_GPL(tdh_vp_flush); > > This also just isn't looking right. The 'tdvpr' is a _thing_. It has a > type and it came back from some _other_ bit of the same type. > > So, in the worst case, this could be: > > struct tdvpr { > u64 tdvpr_paddr; > }; > > u64 tdh_vp_flush(struct tdvpr *tdpr) > { > ... > > But just passing around physical addresses and then having this things > stick it right in to seamcall() doesn't seem like the best we can do. Earlier you mentioned passing pointers instead of PA's. Could we have something like the below? It turns out the KVM code has to go through extra steps to translate between PA and VA on its side. So if we keep it a VA in KVM and let the SEAMCALL wrappers translate to PA, it actually simplifies the KVM code. Or keep the VA in the struct. diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 01409a59224d..1f48813ade33 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -137,7 +137,7 @@ u64 tdh_vp_create(u64 tdr, u64 tdvpr); u64 tdh_mng_rd(u64 tdr, u64 field, u64 *data); u64 tdh_mr_extend(u64 tdr, u64 gpa, u64 *rcx, u64 *rdx); u64 tdh_mr_finalize(u64 tdr); -u64 tdh_vp_flush(u64 tdvpr); +u64 tdh_vp_flush(void *tdvpr); u64 tdh_mng_vpflushdone(u64 tdr); u64 tdh_mng_key_freeid(u64 tdr); u64 tdh_mng_init(u64 tdr, u64 td_params, u64 *rcx); diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 2a8997eb1ef1..d456e0b0b90c 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -1785,10 +1785,10 @@ u64 tdh_mr_finalize(u64 tdr) } EXPORT_SYMBOL_GPL(tdh_mr_finalize); -u64 tdh_vp_flush(u64 tdvpr) +u64 tdh_vp_flush(void *tdvpr) { struct tdx_module_args args = { - .rcx = tdvpr, + .rcx = __pa(tdvpr), }; return seamcall(TDH_VP_FLUSH, &args);