On 4/24/2025 11:08 AM, Yan Zhao wrote: [...]
+ +int tdx_sept_split_private_spt(struct kvm *kvm, gfn_t gfn, enum pg_level level, + void *private_spt) +{ + struct page *page = virt_to_page(private_spt); + int ret; + + if (KVM_BUG_ON(to_kvm_tdx(kvm)->state != TD_STATE_RUNNABLE || level != PG_LEVEL_2M, kvm)) + return -EINVAL; + + ret = tdx_sept_zap_private_spte(kvm, gfn, level, page); + if (ret <= 0) + return ret; + + tdx_track(kvm);
It may worth a helper for the zap and track code. It's the some code as what in tdx_sept_remove_private_spte(). So that they can share the code, including the bug check for HKID and the comments.
+ + return tdx_spte_demote_private_spte(kvm, gfn, level, page); +} +
[...]