git: 818390ce0ca5 - main - arm64: fix early devmap assertion
Mitchell Horne
mhorne at FreeBSD.org
Wed Jan 13 21:28:08 UTC 2021
The branch main has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=818390ce0ca539300dd15d7a817784f1e3f7a9b8
commit 818390ce0ca539300dd15d7a817784f1e3f7a9b8
Author: Mitchell Horne <mhorne at FreeBSD.org>
AuthorDate: 2021-01-13 18:30:50 +0000
Commit: Mitchell Horne <mhorne at FreeBSD.org>
CommitDate: 2021-01-13 21:27:44 +0000
arm64: fix early devmap assertion
The purpose of this KASSERT is to ensure that we do not run out of space
in the early devmap. However, the devmap grew beyond its initial size of
2MB in r336519, and this assertion did not grow with it.
A devmap mapping of a 1080p framebuffer requires 1920x1080 bytes, or
1.977 MB, so it is just barely able to fit without triggering the
assertion, provided no other devices are mapped before it. With the
addition of `options GDB` in GENERIC by bbfa199cbc16, the uart is now
mapped for the purposes of a debug port, before mapping the framebuffer.
The presence of both these conditions pushes the selected virtual
address just below the threshold, triggering the assertion.
To fix this, use the correct size of the devmap, defined by
PMAP_MAPDEV_EARLY_SIZE. Since this code is shared with RISC-V, define
it for that platform as well (although it is a different size).
PR: 25241
Reported by: gbe
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
---
sys/kern/subr_devmap.c | 2 +-
sys/riscv/include/vmparam.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c
index 581e85086f0f..8e07199b7f73 100644
--- a/sys/kern/subr_devmap.c
+++ b/sys/kern/subr_devmap.c
@@ -275,7 +275,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size)
if (early_boot) {
akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size);
va = akva_devmap_vaddr;
- KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE,
+ KASSERT(va >= VM_MAX_KERNEL_ADDRESS - PMAP_MAPDEV_EARLY_SIZE,
("Too many early devmap mappings"));
} else
#endif
diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h
index f3cab1074454..9580ab3e1218 100644
--- a/sys/riscv/include/vmparam.h
+++ b/sys/riscv/include/vmparam.h
@@ -235,6 +235,7 @@ extern vm_offset_t init_pt_va;
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS
+#define PMAP_MAPDEV_EARLY_SIZE (L2_SIZE * 2)
/*
* No non-transparent large page support in the pmap.
More information about the dev-commits-src-all
mailing list