git: 0625715977d9 - stable/13 - Only return a mapped address from efi_phys_to_kva

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Tue, 03 May 2022 14:04:48 UTC
The branch stable/13 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=0625715977d9cb125299b2b9b364842ef250887e

commit 0625715977d9cb125299b2b9b364842ef250887e
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2022-04-09 11:43:08 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2022-05-03 14:04:04 +0000

    Only return a mapped address from efi_phys_to_kva
    
    On some hardware the EFI system table is not in memory mapped in the
    DMAP section. Rather than panic the kernel check if it is mapped and
    return a failure if not from efi_phys_to_kva.
    
    Reported by:    kevans
    Differential Revision: https://reviews.freebsd.org/D34858
    
    (cherry picked from commit f3ef799f564515b58a24a328739a4c749a02b110)
---
 sys/arm64/arm64/efirt_machdep.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/arm64/efirt_machdep.c b/sys/arm64/arm64/efirt_machdep.c
index 717b6cc86e17..343235a7d255 100644
--- a/sys/arm64/arm64/efirt_machdep.c
+++ b/sys/arm64/arm64/efirt_machdep.c
@@ -150,10 +150,17 @@ efi_1t1_l3(vm_offset_t va)
 vm_offset_t
 efi_phys_to_kva(vm_paddr_t paddr)
 {
+	vm_offset_t vaddr;
 
-	if (!PHYS_IN_DMAP(paddr))
-		return (0);
-	return (PHYS_TO_DMAP(paddr));
+	if (PHYS_IN_DMAP(paddr)) {
+		vaddr = PHYS_TO_DMAP(paddr);
+		if (pmap_klookup(vaddr, NULL))
+			return (vaddr);
+	}
+
+	/* TODO: Map memory not in the DMAP */
+
+	return (0);
 }
 
 /*