[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <60da8b1c-07ea-47fe-9bfd-d87bde294e3e@linux.intel.com>
Date: Mon, 17 Nov 2025 16:53:17 +0800
From: Binbin Wu <binbin.wu@...ux.intel.com>
To: Yan Zhao <yan.y.zhao@...el.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, quic_eberman@...cinc.com, michael.roth@....com,
david@...hat.com, vannapurve@...gle.com, vbabka@...e.cz,
thomas.lendacky@....com, pgonda@...gle.com, zhiquan1.li@...el.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 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"?
> + * - 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