[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ad9b3b96-324a-4661-b43e-0b31cb7a7b51@intel.com>
Date: Mon, 20 Oct 2025 08:43:12 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>, linux-kernel@...r.kernel.org,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, "Kirill A. Shutemov" <kas@...nel.org>,
Rick Edgecombe <rick.p.edgecombe@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>, Kai Huang <kai.huang@...el.com>,
Isaku Yamahata <isaku.yamahata@...el.com>,
Vishal Annapurve <vannapurve@...gle.com>, Thomas Huth <thuth@...hat.com>,
Adrian Hunter <adrian.hunter@...el.com>, linux-coco@...ts.linux.dev,
kvm@...r.kernel.org, Farrah Chen <farrah.chen@...el.com>
Subject: Re: [PATCH] x86/virt/tdx: Use precalculated TDVPR page physical
address
On 10/20/25 08:25, Sean Christopherson wrote:
>>> @@ -1583,7 +1578,7 @@ u64 tdh_vp_addcx(struct tdx_vp *vp, struct page *tdcx_page)
>>> {
>>> struct tdx_module_args args = {
>>> .rcx = page_to_phys(tdcx_page),
>>> - .rdx = tdx_tdvpr_pa(vp),
>>> + .rdx = vp->tdvpr_pa,
>>> };
>> I'm kinda dense normally and my coffee hasn't kicked in yet. What
>> clearly does not work there?
> Relying on struct page to provide type safety.
>
>> Yeah, vp->tdvpr_pa is storing a physical address as a raw u64 and not a
>> 'struct page'. That's not ideal. But it's also for a pretty good reason.
> Right, but my point is that regradless of the justification, every exception to
> passing a struct page diminishes the benefits of using struct page in the first
> place.
Yeah, I'm in total agreement with you there.
But I don't think there's any type scheme that won't have exceptions or
other downsides.
u64's are really nice for prototyping because you can just pass those
suckers around anywhere and the compiler will never say a thing. But we
know the downsides of too many plain integer types getting passed around.
Sparse-enforced address spaces are pretty nifty, but they can get messy
around the edges of the subsystem where the type is used. You end up
with lots of ugly force casts there to bend the compiler to your will.
'struct page *' isn't perfect either. As we saw, you can't get from it
to a physical address easily in noinstr code. It doesn't work everywhere
either.
So I dunno. Sounds like there is no shortage of imperfect ways skin this
cat. Yay, engineering!
But, seriously, if you're super confident that a sparse-enforced address
space is the way to go, it's not *that* hard to go look at it. TDX isn't
that big. I can go poke at it for a bit.
Powered by blists - more mailing lists