[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e3f91c2cac772b58603bf4831e1b25cd261edeaa.camel@intel.com>
Date: Fri, 9 May 2025 01:06:05 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>
CC: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>, "seanjc@...gle.com"
<seanjc@...gle.com>, "x86@...nel.org" <x86@...nel.org>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>, "bp@...en8.de"
<bp@...en8.de>, "mingo@...hat.com" <mingo@...hat.com>, "Zhao, Yan Y"
<yan.y.zhao@...el.com>, "tglx@...utronix.de" <tglx@...utronix.de>,
"pbonzini@...hat.com" <pbonzini@...hat.com>, "kvm@...r.kernel.org"
<kvm@...r.kernel.org>, "linux-coco@...ts.linux.dev"
<linux-coco@...ts.linux.dev>, "Yamahata, Isaku" <isaku.yamahata@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC, PATCH 02/12] x86/virt/tdx: Allocate reference counters for
PAMT memory
On Thu, 2025-05-08 at 16:03 +0300, kirill.shutemov@...ux.intel.com wrote:
> On Mon, May 05, 2025 at 11:05:12AM +0000, Huang, Kai wrote:
> >
> > > +static atomic_t *pamt_refcounts;
> > > +
> > > static enum tdx_module_status_t tdx_module_status;
> > > static DEFINE_MUTEX(tdx_module_lock);
> > >
> > > @@ -1035,9 +1038,108 @@ static int config_global_keyid(void)
> > > return ret;
> > > }
> > >
> > > +atomic_t *tdx_get_pamt_refcount(unsigned long hpa)
> > > +{
> > > + return &pamt_refcounts[hpa / PMD_SIZE];
> > > +}
> > > +EXPORT_SYMBOL_GPL(tdx_get_pamt_refcount);
> >
> > It's not quite clear why this function needs to be exported in this patch. IMO
> > it's better to move the export to the patch which actually needs it.
> >
> > Looking at patch 5, tdx_pamt_get()/put() use it, and they are in KVM code. But
> > I think we should just put them here in this file. tdx_alloc_page() and
> > tdx_free_page() should be in this file too.
> >
> > And instead of exporting tdx_get_pamt_refcount(), the TDX core code here can
> > export tdx_alloc_page() and tdx_free_page(), providing two high level helpers to
> > allow the TDX users (e.g., KVM) to allocate/free TDX private pages. How PAMT
> > pages are allocated is then hidden in the core TDX code.
>
> We would still need tdx_get_pamt_refcount() to handle case when we need to
> bump refcount for page allocated elsewhere.
Hmm I am not sure I am following this. What "page allocated" are you referring
to? I am probably missing something, but if the caller wants a TDX page then it
should just call tdx_alloc_page() which handles refcount bumping internally.
No?
Powered by blists - more mailing lists