On Wed, Dec 16, 2020 at 12:00:38AM +0100, Mark Kettenis wrote: > > Date: Tue, 15 Dec 2020 21:21:37 +0100 > > From: Alexander Bluhm <alexander.bl...@gmx.net> > > > > On Tue, Dec 15, 2020 at 06:57:03PM +0100, Mark Kettenis wrote: > > > Does the diff below fix this? > > > > I can reproduce the panic and your diff fixes it. > > > > Usually my regress machines do not trigger it as I do not install > > firmware. fw_update and reboot makes it crash. > > > > bluhm > > Thanks. This is committed now. However, there may be other case > where we use uvm_km_valloc() early on that will trip over the kernel > lock assertion that mpi@ added in uvm_km_pgremove(). Ideally we > should get rid of all the uvm_km_free() calls in the kernel.
Here are a couple of relatively easy ones, applying changes from r1.86 of amd64's acpi_machdep.c to i386 and arm64. I've tested i386 but it turns out I don't have any arm64 machines with acpi. Index: arch/arm64/arm64/acpi_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/arm64/arm64/acpi_machdep.c,v retrieving revision 1.10 diff -u -p -u -p -r1.10 acpi_machdep.c --- arch/arm64/arm64/acpi_machdep.c 6 Dec 2020 21:19:55 -0000 1.10 +++ arch/arm64/arm64/acpi_machdep.c 18 Dec 2020 00:23:01 -0000 @@ -74,7 +74,8 @@ acpi_map(paddr_t pa, size_t len, struct { paddr_t pgpa = trunc_page(pa); paddr_t endpa = round_page(pa + len); - vaddr_t va = uvm_km_valloc(kernel_map, endpa - pgpa); + vaddr_t va = (vaddr_t)km_alloc(endpa - pgpa, &kv_any, &kp_none, + &kd_nowait); if (va == 0) return (ENOMEM); @@ -97,7 +98,7 @@ void acpi_unmap(struct acpi_mem_map *handle) { pmap_kremove(handle->baseva, handle->vsize); - uvm_km_free(kernel_map, handle->baseva, handle->vsize); + km_free((void *)handle->baseva, handle->vsize, &kv_any, &kp_none); } int Index: arch/i386/i386/acpi_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/i386/i386/acpi_machdep.c,v retrieving revision 1.74 diff -u -p -u -p -r1.74 acpi_machdep.c --- arch/i386/i386/acpi_machdep.c 21 Jul 2020 03:48:06 -0000 1.74 +++ arch/i386/i386/acpi_machdep.c 18 Dec 2020 00:23:01 -0000 @@ -117,7 +117,8 @@ acpi_map(paddr_t pa, size_t len, struct { paddr_t pgpa = trunc_page(pa); paddr_t endpa = round_page(pa + len); - vaddr_t va = uvm_km_valloc(kernel_map, endpa - pgpa); + vaddr_t va = (vaddr_t)km_alloc(endpa - pgpa, &kv_any, &kp_none, + &kd_nowait); if (va == 0) return (ENOMEM); @@ -140,7 +141,7 @@ void acpi_unmap(struct acpi_mem_map *handle) { pmap_kremove(handle->baseva, handle->vsize); - uvm_km_free(kernel_map, handle->baseva, handle->vsize); + km_free((void *)handle->baseva, handle->vsize, &kv_any, &kp_none); } int