[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0994611acde70db0ee57910e6874708916f6cda7.camel@intel.com>
Date: Mon, 19 May 2025 05:06:01 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "Annapurve, Vishal" <vannapurve@...gle.com>
CC: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>, "seanjc@...gle.com"
<seanjc@...gle.com>, "bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>, "mingo@...hat.com" <mingo@...hat.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"tglx@...utronix.de" <tglx@...utronix.de>, "pbonzini@...hat.com"
<pbonzini@...hat.com>, "Zhao, Yan Y" <yan.y.zhao@...el.com>, "Yamahata,
Isaku" <isaku.yamahata@...el.com>, "kvm@...r.kernel.org"
<kvm@...r.kernel.org>, "linux-coco@...ts.linux.dev"
<linux-coco@...ts.linux.dev>
Subject: Re: [RFC, PATCH 11/12] KVM: TDX: Reclaim PAMT memory
On Wed, 2025-05-14 at 08:21 -0700, Vishal Annapurve wrote:
> On Tue, May 13, 2025 at 6:12 PM Huang, Kai <kai.huang@...el.com> wrote:
> >
> >
> >
> > On 3/05/2025 1:08 am, Kirill A. Shutemov wrote:
> > > The PAMT memory holds metadata for TDX-protected memory. With Dynamic
> > > PAMT, PAMT_4K is allocated on demand. The kernel supplies the TDX module
> > > with a few pages that cover 2M of host physical memory.
> > >
> > > PAMT memory can be reclaimed when the last user is gone. It can happen
> > > in a few code paths:
> > >
> > > - On TDH.PHYMEM.PAGE.RECLAIM in tdx_reclaim_td_control_pages() and
> > > tdx_reclaim_page().
> > >
> > > - On TDH.MEM.PAGE.REMOVE in tdx_sept_drop_private_spte().
> > >
> > > - In tdx_sept_zap_private_spte() for pages that were in the queue to be
> > > added with TDH.MEM.PAGE.ADD, but it never happened due to an error.
> > >
> > > Add tdx_pamt_put() in these code paths.
> >
> > IMHO, instead of explicitly hooking tdx_pamt_put() to various places, we
> > should just do tdx_free_page() for the pages that were allocated by
> > tdx_alloc_page() (i.e., control pages, SEPT pages).
> >
> > That means, IMHO, we should do PAMT allocation/free when we actually
> > *allocate* and *free* the target TDX private page(s). I.e., we should:
>
> I think it's important to ensure that PAMT pages are *only* allocated
> for a 2M range if it's getting mapped in EPT at 4K granularity.
> Physical memory allocation order can be different from the EPT mapping
> granularity.
Agreed. Thanks.
I still think all control pages and secure EPT pages can just use
tdx_{alloc|free}_page() though (because we always alloc and use them in 4K
granularity).
Powered by blists - more mailing lists