The branch main has been updated by vexeduxr:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4add1a7a46b5cb261223d1c51c94fde417cc33c0

commit 4add1a7a46b5cb261223d1c51c94fde417cc33c0
Author:     Ahmad Khalifa <vexed...@freebsd.org>
AuthorDate: 2025-07-06 19:10:58 +0000
Commit:     Ahmad Khalifa <vexed...@freebsd.org>
CommitDate: 2025-07-06 19:26:07 +0000

    amd64/efirt: always map the first page
    
    Some BIOSes tend to access physical address zero when executing runtime
    EFI functions. Map it regardless of the runtime attribute.
    
    PR:             287422
    Reviewed by:    imp, kib
    Approved by:    imp (mentor)
    Differential Revision:  https://reviews.freebsd.org/D51147
---
 sys/amd64/amd64/efirt_machdep.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sys/amd64/amd64/efirt_machdep.c b/sys/amd64/amd64/efirt_machdep.c
index 75c357f6e3df..f70e235a0150 100644
--- a/sys/amd64/amd64/efirt_machdep.c
+++ b/sys/amd64/amd64/efirt_machdep.c
@@ -190,6 +190,7 @@ efi_create_1t1_map(struct efi_md *map, int ndesc, int 
descsz)
        vm_offset_t va;
        uint64_t idx;
        int bits, i, mode;
+       bool map_pz = true;
 
        obj_1t1_pt = vm_pager_allocate(OBJT_PHYS, NULL, ptoa(1 +
            NPML4EPG + NPML4EPG * NPDPEPG + NPML4EPG * NPDPEPG * NPDEPG),
@@ -272,6 +273,22 @@ efi_create_1t1_map(struct efi_md *map, int ndesc, int 
descsz)
                        }
                }
                VM_OBJECT_WUNLOCK(obj_1t1_pt);
+               if (p->md_phys == 0)
+                       map_pz = false;
+       }
+
+       /*
+        * Some BIOSes tend to access phys 0 during efirt calls,
+        * so map it if we haven't yet.
+        */
+       if (map_pz) {
+               VM_OBJECT_WLOCK(obj_1t1_pt);
+               pte = efi_1t1_pte(0);
+               /* Assume Write-Back */
+               bits = pmap_cache_bits(kernel_pmap, VM_MEMATTR_WRITE_BACK,
+                   false) | X86_PG_RW | X86_PG_V;
+               pte_store(pte, bits);
+               VM_OBJECT_WUNLOCK(obj_1t1_pt);
        }
 
        return (true);

Reply via email to