@@ -133,3 +133,25 @@ RISC-V Linux Kernel SV57
133
133
ffffffff00000000 | -4 GB | ffffffff7fffffff | 2 GB | modules, BPF
134
134
ffffffff80000000 | -2 GB | ffffffffffffffff | 2 GB | kernel
135
135
__________________|____________|__________________|_________|____________________________________________________________
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