Module Name: src Committed By: jmcneill Date: Sat Dec 7 19:29:04 UTC 2024
Modified Files: src/sys/stand/efiboot: efifdt.c version src/sys/stand/efiboot/bootaa64: Makefile Log Message: efiboot: Use 1:1 PA to VA mappings for RT services. UEFI firmware on Snapdragon X Elite devices crashes when SetVirtualAddressMap is called with runtime mappings that are not 1:1. Always do this on arm64 as it won't interfere with KVA and will help us avoid avoid a very common class of firmware bugs. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/version cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/bootaa64/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.37 src/sys/stand/efiboot/efifdt.c:1.38 --- src/sys/stand/efiboot/efifdt.c:1.37 Thu Aug 15 06:15:16 2024 +++ src/sys/stand/efiboot/efifdt.c Sat Dec 7 19:29:04 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.37 2024/08/15 06:15:16 skrll Exp $ */ +/* $NetBSD: efifdt.c,v 1.38 2024/12/07 19:29:04 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -722,8 +722,9 @@ efi_fdt_create_acpifdt(void) #ifdef EFIBOOT_RUNTIME_ADDRESS static uint64_t -efi_fdt_runtime_alloc_va(uint64_t npages) +efi_fdt_runtime_alloc_va(uint64_t pa, uint64_t npages) { +#if EFIBOOT_RUNTIME_ADDRESS != 0 static uint64_t va = EFIBOOT_RUNTIME_ADDRESS; static uint64_t sz = EFIBOOT_RUNTIME_SIZE; uint64_t nva; @@ -738,6 +739,9 @@ efi_fdt_runtime_alloc_va(uint64_t npages sz -= (npages * EFI_PAGE_SIZE); return nva; +#else + return pa; +#endif } void @@ -763,7 +767,8 @@ efi_fdt_set_virtual_address_map(EFI_MEMO continue; } - md->VirtualStart = efi_fdt_runtime_alloc_va(md->NumberOfPages); + md->VirtualStart = + efi_fdt_runtime_alloc_va(md->PhysicalStart, md->NumberOfPages); switch (md->Type) { case EfiRuntimeServicesCode: Index: src/sys/stand/efiboot/version diff -u src/sys/stand/efiboot/version:1.32 src/sys/stand/efiboot/version:1.33 --- src/sys/stand/efiboot/version:1.32 Thu Aug 15 06:15:16 2024 +++ src/sys/stand/efiboot/version Sat Dec 7 19:29:04 2024 @@ -1,4 +1,4 @@ -$NetBSD: version,v 1.32 2024/08/15 06:15:16 skrll Exp $ +$NetBSD: version,v 1.33 2024/12/07 19:29:04 jmcneill Exp $ NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this file is important - make sure the entries are appended on end, last item @@ -35,3 +35,4 @@ is taken as the current. 2.12: Add userconf support. 2.13: Add Arm RT support and change Arm64 (aarch64) RT VAs. 2.14: Arm64: check cpu support for big endian kernel. +2.15: Arm64: Use 1:1 PA to VA mappings for RT services. Index: src/sys/stand/efiboot/bootaa64/Makefile diff -u src/sys/stand/efiboot/bootaa64/Makefile:1.12 src/sys/stand/efiboot/bootaa64/Makefile:1.13 --- src/sys/stand/efiboot/bootaa64/Makefile:1.12 Sat Apr 2 11:16:07 2022 +++ src/sys/stand/efiboot/bootaa64/Makefile Sat Dec 7 19:29:04 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.12 2022/04/02 11:16:07 skrll Exp $ +# $NetBSD: Makefile,v 1.13 2024/12/07 19:29:04 jmcneill Exp $ PROG= bootaa64.efi OBJFMT= binary @@ -16,8 +16,7 @@ EXTRA_SOURCES+= cache.S COPTS+= -mgeneral-regs-only -mlittle-endian -fno-jump-tables AFLAGS+= -mlittle-endian CFLAGS+= -DEFIBOOT_ALIGN=0x200000 -CFLAGS+= -DEFIBOOT_RUNTIME_ADDRESS=0x0000000200200000UL -CFLAGS+= -DEFIBOOT_RUNTIME_SIZE=0xfe00000UL +CFLAGS+= -DEFIBOOT_RUNTIME_ADDRESS=0 # 1:1 PA to VA mappings CFLAGS+= -DEFIBOOT_MODULE_MACHINE=\"evbarm\" LDFLAGS+= -EL