Skip to content

Commit 2116988

Browse files
charlie-rivospalmer-dabbelt
authored andcommitted
riscv: mm: Do not restrict mmap address based on hint
The hint address should not forcefully restrict the addresses returned by mmap as this causes mmap to report ENOMEM when there is memory still available. Signed-off-by: Charlie Jenkins <[email protected]> Fixes: b5b4287 ("riscv: mm: Use hint address in mmap if available") Fixes: add2cc6 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") Closes: https://lore.kernel.org/linux-kernel/ZbxTNjQPFKBatMq+@ghost/T/#mccb1890466bf5a488c9ce7441e57e42271895765 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 83dae72 commit 2116988

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

arch/riscv/include/asm/processor.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,14 @@
1414

1515
#include <asm/ptrace.h>
1616

17-
/*
18-
* addr is a hint to the maximum userspace address that mmap should provide, so
19-
* this macro needs to return the largest address space available so that
20-
* mmap_end < addr, being mmap_end the top of that address space.
21-
* See Documentation/arch/riscv/vm-layout.rst for more details.
22-
*/
2317
#define arch_get_mmap_end(addr, len, flags) \
2418
({ \
25-
unsigned long mmap_end; \
26-
typeof(addr) _addr = (addr); \
27-
if ((_addr) == 0 || is_compat_task() || \
28-
((_addr + len) > BIT(VA_BITS - 1))) \
29-
mmap_end = STACK_TOP_MAX; \
30-
else \
31-
mmap_end = (_addr + len); \
32-
mmap_end; \
19+
STACK_TOP_MAX; \
3320
})
3421

3522
#define arch_get_mmap_base(addr, base) \
3623
({ \
37-
unsigned long mmap_base; \
38-
typeof(addr) _addr = (addr); \
39-
typeof(base) _base = (base); \
40-
unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \
41-
if ((_addr) == 0 || is_compat_task() || \
42-
((_addr + len) > BIT(VA_BITS - 1))) \
43-
mmap_base = (_base); \
44-
else \
45-
mmap_base = (_addr + len) - rnd_gap; \
46-
mmap_base; \
24+
base; \
4725
})
4826

4927
#ifdef CONFIG_64BIT

0 commit comments

Comments
 (0)