Re: [PATCH 3/7] KVM: x86/mmu: Extract __kvm_mmu_do_page_fault()

From: Isaku Yamahata
Date: Wed Apr 17 2024 - 15:47:47 EST


On Wed, Apr 17, 2024 at 11:34:46AM -0400,
Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:

> From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
>
> Extract out __kvm_mmu_do_page_fault() from kvm_mmu_do_page_fault(). The
> inner function is to initialize struct kvm_page_fault and to call the fault
> handler, and the outer function handles updating stats and converting
> return code. KVM_MAP_MEMORY will call the KVM page fault handler.

To clarify to no update vcpu.stat, let me update the last sentence.

KVM_MAP_MEMORY will call the KVM page fault handler without vcpu stat that
doesn't make sense for pre-population because pre-population (outside TDX) has
the purpose of avoiding page faults


> This patch makes the emulation_type always set irrelevant to the return
> code. kvm_mmu_page_fault() is the only caller of kvm_mmu_do_page_fault(),
> and references the value only when PF_RET_EMULATE is returned. Therefore,
> this adjustment doesn't affect functionality.

For the technical correctness, let me mention about NULL emulation_type.
I added "," and "with non-NULL emulation_type" to the second sentence.
https://lore.kernel.org/all/621c260399a05338ba6d034e275e19714ad3665c.camel@xxxxxxxxx/

This patch makes the emulation_type always set, irrelevant to the return
code. kvm_mmu_page_fault() is the only caller of kvm_mmu_do_page_fault() with
non-NULL emulation_type and references the value only when PF_RET_EMULATE is
returned. Therefore, this adjustment doesn't affect functionality.

--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>