On Wed, Mar 06, 2024 at 04:30:58PM -0800, David Matlack <dmatlack@xxxxxxxxxx> wrote: > On 2024-03-01 09:28 AM, isaku.yamahata@xxxxxxxxx wrote: > > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > > > Wire KVM_MAP_MEMORY ioctl to kvm_mmu_map_tdp_page() to populate guest > > memory. > > > > Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > --- > > arch/x86/kvm/x86.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 49 insertions(+) > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 3b8cb69b04fa..6025c0e12d89 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -4660,6 +4660,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) > > case KVM_CAP_VM_DISABLE_NX_HUGE_PAGES: > > case KVM_CAP_IRQFD_RESAMPLE: > > case KVM_CAP_MEMORY_FAULT_INFO: > > + case KVM_CAP_MAP_MEMORY: > > r = 1; > > break; > > case KVM_CAP_EXIT_HYPERCALL: > > @@ -5805,6 +5806,54 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, > > } > > } > > > > +int kvm_arch_vcpu_pre_map_memory(struct kvm_vcpu *vcpu) > > +{ > > + return kvm_mmu_reload(vcpu); > > +} > > Why is the here and not kvm_arch_vcpu_map_memory()? We can push down kvm_mmu_relaod into kvm_arch_vcpu_map_memory() under gpa loop. Probably the inefficiency won't matter. kvm_mmu_realod() loop on gpa kvm_arch_vcpu_map_memory() => loop on gpa kvm_arch_vcpu_map_memory() kvm_mmu_reload() -- Isaku Yamahata <isaku.yamahata@xxxxxxxxxxxxxxx>