[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRrmRx5lmaUX+h6y@yzhao56-desk.sh.intel.com>
Date: Mon, 17 Nov 2025 17:09:27 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Binbin Wu <binbin.wu@...ux.intel.com>
CC: <pbonzini@...hat.com>, <seanjc@...gle.com>,
<linux-kernel@...r.kernel.org>, <kvm@...r.kernel.org>, <x86@...nel.org>,
<rick.p.edgecombe@...el.com>, <dave.hansen@...el.com>, <kas@...nel.org>,
<tabba@...gle.com>, <ackerleytng@...gle.com>, <michael.roth@....com>,
<david@...hat.com>, <vannapurve@...gle.com>, <vbabka@...e.cz>,
<thomas.lendacky@....com>, <pgonda@...gle.com>, <fan.du@...el.com>,
<jun.miao@...el.com>, <ira.weiny@...el.com>, <isaku.yamahata@...el.com>,
<xiaoyao.li@...el.com>, <chao.p.peng@...el.com>
Subject: Re: [RFC PATCH v2 09/23] KVM: x86/tdp_mmu: Add split_external_spt
hook called during write mmu_lock
On Mon, Nov 17, 2025 at 04:53:17PM +0800, Binbin Wu wrote:
>
>
> On 8/7/2025 5:43 PM, Yan Zhao wrote:
> [...]
> > /**
> > * handle_removed_pt() - handle a page table removed from the TDP structure
> > *
> > @@ -765,12 +778,20 @@ static u64 tdp_mmu_set_spte(struct kvm *kvm, int as_id, tdp_ptep_t sptep,
> > handle_changed_spte(kvm, as_id, gfn, old_spte, new_spte, level, false);
> > /*
> > - * Users that do non-atomic setting of PTEs don't operate on mirror
> > - * roots, so don't handle it and bug the VM if it's seen.
> > + * Propagate changes of SPTE to the external page table under write
> > + * mmu_lock.
> > + * Current valid transitions:
> > + * - present leaf to !present.
> > + * - present non-leaf to !present.
>
> Nit:
> Maybe add a small note to limit the scenario, such as "after releasing the HKID"
> or "during the TD teardown"?
I'm not sure if we need that level of detail.
e.g., for case "present leaf to !present", it's before releasing the HKID w/o
patch [1], but can be after the HKID w/ patch [1].
[1] https://lore.kernel.org/all/20250729193341.621487-6-seanjc@google.com/
> > + * - present leaf to present non-leaf (splitting)
> > */
> > if (is_mirror_sptep(sptep)) {
> > - KVM_BUG_ON(is_shadow_present_pte(new_spte), kvm);
> > - remove_external_spte(kvm, gfn, old_spte, level);
> > + if (!is_shadow_present_pte(new_spte))
> > + remove_external_spte(kvm, gfn, old_spte, level);
> > + else if (is_last_spte(old_spte, level) && !is_last_spte(new_spte, level))
> > + split_external_spt(kvm, gfn, old_spte, new_spte, level);
> > + else
> > + KVM_BUG_ON(1, kvm);
> > }
> > return old_spte;
>
Powered by blists - more mailing lists