Skip to contentSkip to conversation

riscv: Fix range looking for kernel image memblock

PATCH In review Alexandre Ghiti 3 participants 3 messages Feb 17, 2020 – Mar 4, 2020

Subsystems (2)
lore
Share & tools
lore

Alexandre Ghiti

author reviewer
#0 lore raw

PATCH 1/1 riscv: Fix range looking for kernel image memblock

When looking for the memblock where the kernel lives, we should check that the memory range associated to the memblock entirely comprises the kernel image and not only intersects with it.

---
 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/init.c +1 -1
index 965a8cf4829c..fab855963c73 100644
@@ -131,7 +131,7 @@ void __init setup_bootmem(void)
 	for_each_memblock(memory, reg) {
 		phys_addr_t end = reg->base + reg->size;
 
-		if (reg->base <= vmlinux_end && vmlinux_end <= end) {
+		if (reg->base <= vmlinux_start && vmlinux_end <= end) {
 			mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
 
 			/*
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Alexandre Ghiti

When looking for the memblock where the kernel lives, we should check that the memory range associated to the memblock entirely comprises the kernel image and not only intersects with it.

---
 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/init.c +1 -2
index 965a8cf4829c..fab855963c73 100644
@@ -131,7 +131,7 @@ void __init setup_bootmem(void)
        for_each_memblock(memory, reg) {
                phys_addr_t end = reg->base + reg->size;
 
-               if (reg->base <= vmlinux_end && vmlinux_end <= end) {
+               if (reg->base <= vmlinux_start && vmlinux_end <= end) {
                        mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
 
                        /*
--
Quoted 2 lines

2.20.1

Looks good to me.

Regards,
Anup

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Alexandre Ghiti
Quoted 14 lines · On Sun, 16 Feb 2020 21:28:47 PST (-0800), [email protected] wrote:

When looking for the memblock where the kernel lives, we should check that the memory range associated to the memblock entirely comprises the kernel image and not only intersects with it.

---
 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/init.c +0 -0
index 965a8cf4829c..fab855963c73 100644

arch/riscv/mm/init.c void __init setup_bootmem(void) · line 137

Quoted 8 lines
arch/riscv/mm/init.c +1 -1
@@ -131,7 +131,7 @@ void __init setup_bootmem(void)
 	for_each_memblock(memory, reg) {
 		phys_addr_t end = reg->base + reg->size;
 
-		if (reg->base <= vmlinux_end && vmlinux_end <= end) {
+		if (reg->base <= vmlinux_start && vmlinux_end <= end) {
 			mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
 
 			/*

Thanks. I'm going to target this for the next RC.