[PATCH v2 09/30] KVM: arm64: Simplify return logic in user_mem_abort()
Anshuman Khandual
anshuman.khandual at arm.com
Mon Mar 30 21:32:21 PDT 2026
On 27/03/26 5:05 PM, Marc Zyngier wrote:
> From: Fuad Tabba <tabba at google.com>
>
> With the refactoring done, the final return block of user_mem_abort()
> can be tidied up a bit more.
>
> Clean up the trailing edge by dropping the unnecessary assignment,
> collapsing the return evaluation for kvm_s2_fault_compute_prot(), and
> tail calling kvm_s2_fault_map() directly.
>
> Signed-off-by: Fuad Tabba <tabba at google.com>
> Signed-off-by: Marc Zyngier <maz at kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual at arm.com>
> ---
> arch/arm64/kvm/mmu.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 1b991300735be..e77b0b60697f6 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -2005,22 +2005,13 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
> if (ret != 1)
> return ret;
>
> - ret = 0;
> -
> ret = kvm_s2_fault_compute_prot(fault);
> - if (ret == 1) {
> - ret = 1; /* fault injected */
> - goto out_put_page;
> + if (ret) {
> + kvm_release_page_unused(fault->page);
> + return ret;
> }
> - if (ret)
> - goto out_put_page;
>
> - ret = kvm_s2_fault_map(fault, memcache);
> - return ret;
> -
> -out_put_page:
> - kvm_release_page_unused(fault->page);
> - return ret;
> + return kvm_s2_fault_map(fault, memcache);
> }
>
> /* Resolve the access fault by making the page young again. */
More information about the linux-arm-kernel
mailing list