lkml.org 
[lkml]   [2019]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 5/5] RISC-V: Fix memory reservation in setup_bootmem()
Date
Currently, the setup_bootmem() reserves memory from RAM start to the
kernel end. This prevents us from exploring ways to use the RAM below
(or before) the kernel start hence this patch updates setup_bootmem()
to only reserve memory from the kernel start to the kernel end.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
arch/riscv/mm/init.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 2e2f2567964c..99b42380d17d 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -18,6 +18,8 @@
#include <asm/pgtable.h>
#include <asm/io.h>

+extern char _start[];
+
static void __init zone_sizes_init(void)
{
unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
@@ -93,15 +95,17 @@ void __init setup_bootmem(void)

/* Find the memory region containing the kernel */
for_each_memblock(memory, reg) {
- phys_addr_t vmlinux_end = __pa(_end);
+ phys_addr_t vmlinux_end = __pa(&_end);
+ phys_addr_t vmlinux_start = __pa(&_start);
phys_addr_t end = reg->base + reg->size;

if (reg->base <= vmlinux_end && vmlinux_end <= end) {
/*
- * Reserve from the start of the region to the end of
+ * Reserve from the start of the kernel to the end of
* the kernel
*/
- memblock_reserve(reg->base, vmlinux_end - reg->base);
+ memblock_reserve(vmlinux_start,
+ vmlinux_end - vmlinux_start);
mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
}
}
@@ -177,7 +181,6 @@ struct mapping_ops {

static inline void *__load_addr(void *ptr, uintptr_t load_pa)
{
- extern char _start;
uintptr_t va = (uintptr_t)ptr;
uintptr_t sz = (uintptr_t)(&_end) - (uintptr_t)(&_start);

--
2.17.1
\
 
 \ /
  Last update: 2019-03-21 10:48    [W:0.137 / U:2.076 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site