On Tue, 2024-09-10 at 12:49 +0200, Paolo Bonzini wrote: > On 9/4/24 05:07, Rick Edgecombe wrote: > > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > > > Update TDX's hook of set_external_spte() to record pre-mapping cnt instead > > of doing nothing and returning when TD is not finalized. > > > > TDX uses ioctl KVM_TDX_INIT_MEM_REGION to initialize its initial guest > > memory. This ioctl calls kvm_gmem_populate() to get guest pages and in > > tdx_gmem_post_populate(), it will > > (1) Map page table pages into KVM mirror page table and private EPT. > > (2) Map guest pages into KVM mirror page table. In the propagation hook, > > just record pre-mapping cnt without mapping the guest page into > > private > > EPT. > > (3) Map guest pages into private EPT and decrease pre-mapping cnt. > > > > Do not map guest pages into private EPT directly in step (2), because TDX > > requires TDH.MEM.PAGE.ADD() to add a guest page before TD is finalized, > > which copies page content from a source page from user to target guest page > > to be added. However, source page is not available via common interface > > kvm_tdp_map_page() in step (2). > > > > Therefore, just pre-map the guest page into KVM mirror page table and > > record the pre-mapping cnt in TDX's propagation hook. The pre-mapping cnt > > would be decreased in ioctl KVM_TDX_INIT_MEM_REGION when the guest page is > > mapped into private EPT. > > Stale commit message; squashing all of it into patch 20 is an easy cop > out... Arh, yes this has details that are not relevant to the patch. Squashing it seems fine, but I wasn't sure about whether we actually needed this nr_premapped. It was one of the things we decided to punt a decision on in order to continue our debates on the list. So we need to pick up the debate again.