The branch main has been updated by christos:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=855ade9e722a5c3f7363f5f78798bdfedadb1005

commit 855ade9e722a5c3f7363f5f78798bdfedadb1005
Author:     Christos Margiolis <chris...@freebsd.org>
AuthorDate: 2023-05-25 20:40:46 +0000
Commit:     Christos Margiolis <chris...@freebsd.org>
CommitDate: 2023-05-25 20:40:46 +0000

    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
---
 sys/cddl/dev/kinst/trampoline.c | 19 +++++++++++++------
 1 file 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);

Reply via email to