diff options
author | Christos Margiolis <christos@FreeBSD.org> | 2023-05-25 20:40:46 +0000 |
---|---|---|
committer | Christos Margiolis <christos@FreeBSD.org> | 2023-05-25 20:40:46 +0000 |
commit | 855ade9e722a5c3f7363f5f78798bdfedadb1005 (patch) | |
tree | b7e92a64130e7bb528cd86d33645824de8c90e9c /sys/cddl | |
parent | 5a7500dab9b8480dacd5a9b70bad1541391342e4 (diff) | |
download | src-855ade9e722a5c3f7363f5f78798bdfedadb1005.tar.gz src-855ade9e722a5c3f7363f5f78798bdfedadb1005.zip |
kinst: be explicit about trampoline placement
The current implementation and comment was specific to amd64. Even
though in the case of kinst's supported architectures (RISC-V and ARM64)
VM_MIN_KERNEL_ADDRESS is equal to KERNBASE, it's better to be explicit.
Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40266
Diffstat (limited to 'sys/cddl')
-rw-r--r-- | sys/cddl/dev/kinst/trampoline.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/cddl/dev/kinst/trampoline.c b/sys/cddl/dev/kinst/trampoline.c index 5575503f60fb..75efd022fb20 100644 --- a/sys/cddl/dev/kinst/trampoline.c +++ b/sys/cddl/dev/kinst/trampoline.c @@ -68,15 +68,22 @@ kinst_trampchunk_alloc(void) sx_assert(&kinst_tramp_sx, SX_XLOCKED); +#ifdef __amd64__ /* - * Allocate virtual memory for the trampoline chunk. The returned - * address is saved in "trampaddr". To simplify population of - * trampolines, we follow the amd64 kernel's code model and allocate - * them above KERNBASE, i.e., in the top 2GB of the kernel's virtual - * address space. Trampolines must be executable so max_prot must - * include VM_PROT_EXECUTE. + * To simplify population of trampolines, we follow the amd64 kernel's + * code model and allocate them above KERNBASE, i.e., in the top 2GB of + * the kernel's virtual address space (not the case for other + * platforms). */ trampaddr = KERNBASE; +#else + trampaddr = VM_MIN_KERNEL_ADDRESS; +#endif + /* + * Allocate virtual memory for the trampoline chunk. The returned + * address is saved in "trampaddr". Trampolines must be executable so + * max_prot must include VM_PROT_EXECUTE. + */ error = vm_map_find(kernel_map, NULL, 0, &trampaddr, KINST_TRAMPCHUNK_SIZE, 0, VMFS_ANY_SPACE, VM_PROT_ALL, VM_PROT_ALL, 0); |