diff options
| author | Fuad Tabba <tabba@google.com> | 2026-03-06 17:02:30 +0300 |
|---|---|---|
| committer | Marc Zyngier <maz@kernel.org> | 2026-03-28 14:29:40 +0300 |
| commit | 3456943e8786d56aa2bd3f99e9ad2d735a9879c8 (patch) | |
| tree | 4e55a331907f3886199fadefdea3a1082debd662 | |
| parent | 975bad4bb21e4eea7ecc0f32f4cbbb91a9c8d48f (diff) | |
| download | linux-3456943e8786d56aa2bd3f99e9ad2d735a9879c8.tar.xz | |
KVM: arm64: Optimize early exit checks in kvm_s2_fault_pin_pfn()
Optimize the early exit checks in kvm_s2_fault_pin_pfn by grouping all
error responses under the generic is_error_noslot_pfn check first,
avoiding unnecessary branches in the hot path.
Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
| -rw-r--r-- | arch/arm64/kvm/mmu.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index fe942be061cb..74c512839e81 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1791,12 +1791,13 @@ static int kvm_s2_fault_pin_pfn(struct kvm_s2_fault *fault) fault->pfn = __kvm_faultin_pfn(fault->memslot, fault->gfn, fault->write_fault ? FOLL_WRITE : 0, &fault->writable, &fault->page); - if (fault->pfn == KVM_PFN_ERR_HWPOISON) { - kvm_send_hwpoison_signal(fault->hva, __ffs(fault->vma_pagesize)); - return 0; - } - if (is_error_noslot_pfn(fault->pfn)) + if (unlikely(is_error_noslot_pfn(fault->pfn))) { + if (fault->pfn == KVM_PFN_ERR_HWPOISON) { + kvm_send_hwpoison_signal(fault->hva, __ffs(fault->vma_pagesize)); + return 0; + } return -EFAULT; + } return 1; } |
