Skip to content

Commit 7998abe

Browse files
charlie-rivospalmer-dabbelt
authored andcommitted
RISC-V: mm: Document mmap changes
The behavior of mmap is modified with this patch series, so explain the changes to the mmap hint address behavior. Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/20230809232218.849726-5-charlie@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 26eee2b commit 7998abe

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Documentation/riscv/vm-layout.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,25 @@ RISC-V Linux Kernel SV57
133133
ffffffff00000000 | -4 GB | ffffffff7fffffff | 2 GB | modules, BPF
134134
ffffffff80000000 | -2 GB | ffffffffffffffff | 2 GB | kernel
135135
__________________|____________|__________________|_________|____________________________________________________________
136+
137+
138+
Userspace VAs
139+
--------------------
140+
To maintain compatibility with software that relies on the VA space with a
141+
maximum of 48 bits the kernel will, by default, return virtual addresses to
142+
userspace from a 48-bit range (sv48). This default behavior is achieved by
143+
passing 0 into the hint address parameter of mmap. On CPUs with an address space
144+
smaller than sv48, the CPU maximum supported address space will be the default.
145+
146+
Software can "opt-in" to receiving VAs from another VA space by providing
147+
a hint address to mmap. A hint address passed to mmap will cause the largest
148+
address space that fits entirely into the hint to be used, unless there is no
149+
space left in the address space. If there is no space available in the requested
150+
address space, an address in the next smallest available address space will be
151+
returned.
152+
153+
For example, in order to obtain 48-bit VA space, a hint address greater than
154+
:code:`1 << 47` must be provided. Note that this is 47 due to sv48 userspace
155+
ending at :code:`1 << 47` and the addresses beyond this are reserved for the
156+
kernel. Similarly, to obtain 57-bit VA space addresses, a hint address greater
157+
than or equal to :code:`1 << 56` must be provided.

0 commit comments

Comments
 (0)