Re: [PATCH 2/2] x86/virt/tdx: Use PFN directly for unmapping guest private memory

From: Yan Zhao

Date: Thu Apr 09 2026 - 03:36:09 EST


On Tue, Apr 07, 2026 at 08:44:10AM +0800, Yan Zhao wrote:
> On Sat, Apr 04, 2026 at 08:39:00AM +0200, Paolo Bonzini wrote:
> > On 3/19/26 09:56, Yan Zhao wrote:
> > > On Thu, Mar 19, 2026 at 04:56:10PM +0800, Xiaoyao Li wrote:
> > > > So why not considering option 2?
> > > >
> > > > 2. keep tdx_quirk_reset_page() as-is for the cases of
> > > > tdx_reclaim_page() and tdx_reclaim_td_control_pages() that have the
> > > > struct page. But only change tdx_sept_remove_private_spte() to use
> > > > tdx_quirk_reset_paddr() directly.
> > > >
> > > > It will need export tdx_quirk_reset_paddr() for KVM. I think it will be OK?
> > > I don't think it's necessary. But if we have to export an extra API, IMHO,
> > > tdx_quirk_reset_pfn() is better than tdx_quirk_reset_paddr(). Otherwise,
> > > why not only expose tdx_quirk_reset_paddr()?
> >
> > That works for me, it seems the cleanest.
> Hi Paolo,
> To avoid misunderstanding: you think only exporting tdx_quirk_reset_paddr() is
> the cleanest, right? :)
Could I rename tdx_quirk_reset_page() to tdx_quirk_phymem_page_reset() and only
export tdx_quirk_phymem_page_reset()?

The "phymem_page" is similar to that in tdh_phymem_page_wbinvd_hkid(), indicating
it's operating on physical memory of page size, so it does not confuse people
even though it takes PFN as input. Another benefit is that callers have no need
to specify size, which is always PAGE_SIZE.