]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Call helper for reading descriptors directly
authorOliver Upton <oupton@kernel.org>
Mon, 24 Nov 2025 19:01:48 +0000 (11:01 -0800)
committerOliver Upton <oupton@kernel.org>
Mon, 1 Dec 2025 08:44:01 +0000 (00:44 -0800)
Going through a function pointer doesn't serve much purpose when there's
only one implementation.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Tested-by: Marc Zyngier <maz@kernel.org>
Link: https://msgid.link/20251124190158.177318-7-oupton@kernel.org
Signed-off-by: Oliver Upton <oupton@kernel.org>
arch/arm64/kvm/nested.c

index 08839a320a45bbb5797c82143e325bfa1fa1378a..e4928a6a36724a44f19d14c4765649c1bec2b701 100644 (file)
@@ -124,7 +124,6 @@ int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu)
 }
 
 struct s2_walk_info {
-       int          (*read_desc)(phys_addr_t pa, u64 *desc, void *data);
        void         *data;
        u64          baddr;
        unsigned int max_oa_bits;
@@ -199,6 +198,13 @@ static int check_output_size(struct s2_walk_info *wi, phys_addr_t output)
        return 0;
 }
 
+static int read_guest_s2_desc(phys_addr_t pa, u64 *desc, void *data)
+{
+       struct kvm_vcpu *vcpu = data;
+
+       return kvm_read_guest(vcpu->kvm, pa, desc, sizeof(*desc));
+}
+
 /*
  * This is essentially a C-version of the pseudo code from the ARM ARM
  * AArch64.TranslationTableWalk  function.  I strongly recommend looking at
@@ -257,7 +263,7 @@ static int walk_nested_s2_pgd(phys_addr_t ipa,
                        >> (addr_bottom - 3);
 
                paddr = base_addr | index;
-               ret = wi->read_desc(paddr, &desc, wi->data);
+               ret = read_guest_s2_desc(paddr, &desc, wi->data);
                if (ret < 0)
                        return ret;
 
@@ -325,13 +331,6 @@ static int walk_nested_s2_pgd(phys_addr_t ipa,
        return 0;
 }
 
-static int read_guest_s2_desc(phys_addr_t pa, u64 *desc, void *data)
-{
-       struct kvm_vcpu *vcpu = data;
-
-       return kvm_read_guest(vcpu->kvm, pa, desc, sizeof(*desc));
-}
-
 static void vtcr_to_walk_info(u64 vtcr, struct s2_walk_info *wi)
 {
        wi->t0sz = vtcr & TCR_EL2_T0SZ_MASK;
@@ -364,7 +363,6 @@ int kvm_walk_nested_s2(struct kvm_vcpu *vcpu, phys_addr_t gipa,
        if (!vcpu_has_nv(vcpu))
                return 0;
 
-       wi.read_desc = read_guest_s2_desc;
        wi.data = vcpu;
        wi.baddr = vcpu_read_sys_reg(vcpu, VTTBR_EL2);