riscv: Fix range looking for kernel image memblock
diff mbox series

Message ID 20200217052847.3174-1-alex@ghiti.fr
State Accepted
Commit a160eed4b783d7b250a32f7e5787c9867abc5686
Headers show
Series
  • riscv: Fix range looking for kernel image memblock
Related show

Commit Message

Alex Ghiti Feb. 17, 2020, 5:28 a.m. UTC
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.

Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anup Patel Feb. 17, 2020, 5:31 a.m. UTC | #1
On Mon, Feb 17, 2020 at 10:59 AM Alexandre Ghiti <alex@ghiti.fr> 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.
>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---
>  arch/riscv/mm/init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 965a8cf4829c..fab855963c73 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -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);
>
>                         /*
> --
> 2.20.1
>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup
Palmer Dabbelt March 4, 2020, 11:16 p.m. UTC | #2
On Sun, 16 Feb 2020 21:28:47 PST (-0800), alex@ghiti.fr 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.
>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---
>  arch/riscv/mm/init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 965a8cf4829c..fab855963c73 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -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);
>
>  			/*

Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>

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

Patch
diff mbox series

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 965a8cf4829c..fab855963c73 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -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);
 
 			/*