[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <966fcd7dc3b298935b4aa9b476d712eefa9fabbf.camel@intel.com>
Date: Wed, 13 Nov 2024 21:18:03 +0000
From: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To: "pbonzini@...hat.com" <pbonzini@...hat.com>, "Hansen, Dave"
<dave.hansen@...el.com>, "seanjc@...gle.com" <seanjc@...gle.com>
CC: "sean.j.christopherson@...el.com" <sean.j.christopherson@...el.com>, "Yao,
Yuan" <yuan.yao@...el.com>, "Huang, Kai" <kai.huang@...el.com>,
"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>, "Li, Xiaoyao"
<xiaoyao.li@...el.com>, "isaku.yamahata@...il.com"
<isaku.yamahata@...il.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "tony.lindgren@...ux.intel.com"
<tony.lindgren@...ux.intel.com>, "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Zhao, Yan Y" <yan.y.zhao@...el.com>, "Chatre, Reinette"
<reinette.chatre@...el.com>, "Yamahata, Isaku" <isaku.yamahata@...el.com>
Subject: Re: [PATCH v2 10/25] x86/virt/tdx: Add SEAMCALL wrappers for TDX
flush operations
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);
Powered by blists - more mailing lists