2020-02-17 05:29:40

by Alexandre Ghiti

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Alexandre Ghiti <[email protected]>
---
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


2020-02-17 05:33:04

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH] riscv: Fix range looking for kernel image memblock

On Mon, Feb 17, 2020 at 10:59 AM Alexandre Ghiti <[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.
>
> Signed-off-by: Alexandre Ghiti <[email protected]>
> ---
> 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 <[email protected]>

Regards,
Anup

2020-03-04 23:18:09

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH] riscv: Fix range looking for kernel image memblock

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.
>
> Signed-off-by: Alexandre Ghiti <[email protected]>
> ---
> 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 <[email protected]>

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