]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: selftests: Rename translate_to_host_paddr() => translate_hva_to_hpa()
authorSean Christopherson <seanjc@google.com>
Mon, 20 Apr 2026 21:19:59 +0000 (14:19 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 20 Apr 2026 21:54:17 +0000 (14:54 -0700)
Rename arm64's translate_to_host_paddr() to translate_hva_to_hpa() and
update variable names to match, as using "vaddr" and "paddr" terminology
is super confusing due to selftests using those exact names for *guest*
addresses.

Opportunisitically drop superfluous local page_addr and paddr variables.

No functional change intended.

Link: https://patch.msgid.link/20260420212004.3938325-15-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/arm64/sea_to_user.c

index 7285eade4acfb8017e665c4ddc551c6c486e64ea..fb06b9dcb3d9a1ee3123b9bb417d00c0ce5a742f 100644 (file)
@@ -56,13 +56,11 @@ static void *einj_hva;
 static u64 einj_hpa;
 static bool far_invalid;
 
-static u64 translate_to_host_paddr(unsigned long vaddr)
+static u64 translate_hva_to_hpa(unsigned long hva)
 {
        u64 pinfo;
-       s64 offset = vaddr / getpagesize() * sizeof(pinfo);
+       s64 offset = hva / getpagesize() * sizeof(pinfo);
        int fd;
-       u64 page_addr;
-       u64 paddr;
 
        fd = open("/proc/self/pagemap", O_RDONLY);
        if (fd < 0)
@@ -77,9 +75,8 @@ static u64 translate_to_host_paddr(unsigned long vaddr)
        if ((pinfo & PAGE_PRESENT) == 0)
                ksft_exit_fail_perror("Page not present");
 
-       page_addr = (pinfo & PAGE_PHYSICAL) << MIN_PAGE_SHIFT;
-       paddr = page_addr + (vaddr & (getpagesize() - 1));
-       return paddr;
+       return ((pinfo & PAGE_PHYSICAL) << MIN_PAGE_SHIFT) +
+              (hva & (getpagesize() - 1));
 }
 
 static void write_einj_entry(const char *einj_path, u64 val)
@@ -303,7 +300,7 @@ static void vm_inject_memory_uer(struct kvm_vm *vm)
        ksft_print_msg("Before EINJect: data=%#lx\n",
                guest_data);
 
-       einj_hpa = translate_to_host_paddr((unsigned long)einj_hva);
+       einj_hpa = translate_hva_to_hpa((unsigned long)einj_hva);
 
        ksft_print_msg("EINJ_GVA=%#lx, einj_gpa=%#lx, einj_hva=%p, einj_hpa=%#lx\n",
                       EINJ_GVA, einj_gpa, einj_hva, einj_hpa);