2021-03-04 06:24:19

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.9 05/10] sparc32: Limit memblock allocation to low memory

From: Andreas Larsson <[email protected]>

[ Upstream commit bda166930c37604ffa93f2425426af6921ec575a ]

Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 changed sparc32 to use
memblocks instead of bootmem, but also made high memory available via
memblock allocation which does not work together with e.g. phys_to_virt
and can lead to kernel panic.

This changes back to only low memory being allocatable in the early
stages, now using memblock allocation.

Signed-off-by: Andreas Larsson <[email protected]>
Acked-by: Mike Rapoport <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
arch/sparc/mm/init_32.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index 3b7092d9ea8f..4abe4bf08377 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -240,6 +240,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size, BOOTMEM_DEFAULT);
*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;

+ /* Only allow low memory to be allocated via memblock allocation */
+ memblock_set_current_limit(max_low_pfn << PAGE_SHIFT);
+
return max_pfn;
}

--
2.30.1


2021-03-04 09:06:08

by Andreas Larsson

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.9 05/10] sparc32: Limit memblock allocation to low memory

On 2021-03-02 12:59, Sasha Levin wrote:
> From: Andreas Larsson <[email protected]>
>
> [ Upstream commit bda166930c37604ffa93f2425426af6921ec575a ]
>
> Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 changed sparc32 to use
> memblocks instead of bootmem, but also made high memory available via
> memblock allocation which does not work together with e.g. phys_to_virt
> and can lead to kernel panic.
>
> This changes back to only low memory being allocatable in the early
> stages, now using memblock allocation.
>
> Signed-off-by: Andreas Larsson <[email protected]>
> Acked-by: Mike Rapoport <[email protected]>
> Signed-off-by: David S. Miller <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>
> ---
> arch/sparc/mm/init_32.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
> index 3b7092d9ea8f..4abe4bf08377 100644
> --- a/arch/sparc/mm/init_32.c
> +++ b/arch/sparc/mm/init_32.c
> @@ -240,6 +240,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
> reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size, BOOTMEM_DEFAULT);
> *pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
>
> + /* Only allow low memory to be allocated via memblock allocation */
> + memblock_set_current_limit(max_low_pfn << PAGE_SHIFT);
> +
> return max_pfn;
> }
>
>

This is not needed for 4.9, and will not compile, as the problem it
fixes was introduced in 4.19.

--
Andreas Larsson