arm64: mm: fix kdump broken with ZONE_DMA reintroduced
cover arm64: mm: fix kdump broken with ZONE_DMA reintroduced
If the memory reserved for crash dump kernel falled in ZONE_DMA32, the devices in crash dump kernel need to use ZONE_DMA will alloc fail.
Fix this by reserving low memory in ZONE_DMA if CONFIG_ZONE_DMA is enabled, otherwise, reserving in ZONE_DMA32.
Patch 1 updates the comments about the ZONE_DMA.
Patch 2 fix kdump broken.
Chen Zhou (2):
arm64: mm: update the comments about ZONE_DMA
arm64: mm: fix kdump broken with ZONE_DMA reintroduced
arch/arm64/mm/init.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 arm64: mm: update the comments about ZONE_DMA
Since patchset "arm64: Default to 32-bit wide ZONE_DMA", ZONE_DMA's size is fine-tuned. In the absence of addressing limited masters, ZONE_DMA will span the whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4, it'll only span the 30-bit address space. Update the comments.
--- arch/arm64/mm/init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm64/mm/init.c +5 -4
@@ -53,10 +53,11 @@ s64 memstart_addr __ro_after_init = -1;EXPORT_SYMBOL (memstart_addr);/* -* We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of -* memory as some devices, namely the Raspberry Pi 4, have peripherals with -* this limited view of the memory. ZONE_DMA32 will cover the rest of the 32 -* bit addressable memory area. +* We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA's size is fine-tuned. +* In the absence of addressing limited masters, ZONE_DMA will span the +* whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4, +* it'll only span the 30-bit address space. ZONE_DMA32 will cover the rest +* of the 32 bit addressable memory area. */ phys_addr_t arm64_dma_phys_limit__ro_after_init ;static phys_addr_t arm64_dma32_phys_limit__ro_after_init ;
Signature · 1 line
2.20.1
Re: [PATCH 1/2] arm64: mm: update the comments about ZONE_DMA
Quoted 8 lines · Chen Zhou
Since patchset "arm64: Default to 32-bit wide
ZONE_DMA", ZONE_DMA's size is fine-tuned. In the absence of addressing limited masters,ZONE_DMAwill span the whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4, it'll only span the 30-bit address space. Update the comments.Signed-off-by Chen Zhou <[email protected]>---
Quoted 24 lines
arch/arm64/mm/init.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)arch/arm64/mm/init.c +0
-0@@ -53,10 +53,11 @@ s64 memstart_addr __ro_after_init = -1; EXPORT_SYMBOL(memstart_addr);/*
- * We create bothZONE_DMAandZONE_DMA32.ZONE_DMAcovers the first 1G of
- * memory as some devices, namely the Raspberry Pi 4, have peripherals with
- * this limited view of the memory.ZONE_DMA32will cover the rest of the 32
- * bit addressable memory area.
+ * We create bothZONE_DMAandZONE_DMA32. ZONE_DMA's size is fine-tuned.
+ * In the absence of addressing limited masters,ZONE_DMAwill span the
+ * whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4,
+ * it'll only span the 30-bit address space.ZONE_DMA32will cover the rest
+ * of the 32 bit addressable memory area.
*/
phys_addr_tarm64_dma_phys_limit__ro_after_init;
staticphys_addr_tarm64_dma32_phys_limit__ro_after_init;
PATCH 2/2 arm64: mm: fix kdump broken with ZONE_DMA reintroduced
In reply to Chen ZhouIf the memory reserved for crash dump kernel falled in ZONE_DMA32, the devices in crash dump kernel need to use ZONE_DMA will alloc fail.
Fix this by reserving low memory in ZONE_DMA if CONFIG_ZONE_DMA is enabled, otherwise, reserving in ZONE_DMA32.
--- arch/arm64/mm/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/mm/init.c +2 -1
@@ -85,7 +85,8 @@ static void __init reserve_crashkernel(void)if (crash_base ==0 ) {/* Current arm64 boot protocol requires 2MB alignment */ - crash_base =memblock_find_in_range (0 , arm64_dma32_phys_limit, + crash_base =memblock_find_in_range (0 , + arm64_dma_phys_limit ? : arm64_dma32_phys_limit, crash_size,SZ_2M );if (crash_base ==0 ) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
Signature · 1 line
2.20.1
Hi Chen, thanks for looking at this.
Quoted 7 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Fixes bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32")
I'm not so sure this counts as a fix, if someone backports it it'll probably break things as it depends on the series that dynamically sizes DMA zones.
Quoted 2 lines
Signed-off-by Chen Zhou <[email protected]>---
Why not doing the same with CMA? You'll probably have to move the dma_contiguous_reserve() call into bootmem_init() so as to make sure that arm64_dma_phys_limit is populated.
Regards,
Nicolas
Quoted 18 lines
arch/arm64/mm/init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/mm/init.c +0
-0@@ -85,7 +85,8 @@ static void __init reserve_crashkernel(void)if (
crash_base== 0) {
/* Current arm64 boot protocol requires 2MB alignment */arch/arm64/mm/init.c +2
-1- crash_base = memblock_find_in_range(0, arm64_dma32_phys_limit, + crash_base = memblock_find_in_range(0, + arm64_dma_phys_limit ? : arm64_dma32_phys_limit,
crash_size,SZ_2M);
if (crash_base== 0) {
pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
Hi Nicolas,
Thanks for your review.
Quoted 6 lines · Nicolas Saenz Julienne
Hi Chen, thanks for looking at this.
Quoted 3 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.
Quoted 6 lines
Quoted 4 lines
Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Fixes bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32")I'm not so sure this counts as a fix, if someone backports it it'll probably break things as it depends on the series that dynamically sizes DMA zones.
I write this just because kdump is broken from this commit.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Chen Zhou <[email protected]>---
Why not doing the same with CMA? You'll probably have to move the
dma_contiguous_reserve()call intobootmem_init()so as to make sure thatarm64_dma_phys_limitis populated.
You are right, CMA also need this. I will do this in next version.
Thanks,
Chen Zhou
Quoted 23 lines
Regards,
NicolasQuoted 18 lines
arch/arm64/mm/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/mm/init.c +2
-1@@ -85,7 +85,8 @@ static void __init reserve_crashkernel(void)if (crash_base ==0 ) {/* Current arm64 boot protocol requires 2MB alignment */ - crash_base =memblock_find_in_range (0 , arm64_dma32_phys_limit, + crash_base =memblock_find_in_range (0 , + arm64_dma_phys_limit ? : arm64_dma32_phys_limit, crash_size,SZ_2M );if (crash_base ==0 ) {pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
Catalin Marinas
maintainerQuoted 5 lines · chenzhou
Quoted 4 lines · Nicolas Saenz Julienne
Quoted 3 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Fixes bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32")I'm not so sure this counts as a fix, if someone backports it it'll probably break things as it depends on the series that dynamically sizes DMA zones.
I write this just because kdump is broken from this commit.
Commit bff3b04460a8 actually fixed a regression introduced by the limited 30-bit ZONE_DMA, under the assumption that RPi4 is the only platform that cares about this. I agree a kdump kernel will fail to get memory in the low zone but it's not clear to me whether the regression you are seeing happened in 5.11-rc1 or you it's been around since 5.5.
We may have got away before because max_zone_phys() assumed an implicit DMA offset equal to the start of the DRAM (well, power of two). This assumption was removed in 5.11 by commit 791ab8b2e3db ("arm64: Ignore any DMA offsets in the max_zone_phys() calculation").
So your patch or the clean-up I posted only makes sense with the dynamic ZONE_DMA patches in 5.11-rc1. For any earlier version, I don't have any suggestion other than not enabling CONFIG_ZONE_DMA in the kdump kernel (or backporting all of Nicolas' patches).
I'll post my clean-up separately to go into 5.11 but won't have a fixes tag for bff3b04460a8.
Signature · 1 line
Catalin
Catalin Marinas
maintainerQuoted 12 lines · Nicolas Saenz Julienne
Quoted 7 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Fixes bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32")I'm not so sure this counts as a fix, if someone backports it it'll probably break things as it depends on the series that dynamically sizes DMA zones.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Chen Zhou <[email protected]>---
Why not doing the same with CMA? You'll probably have to move the
dma_contiguous_reserve()call intobootmem_init()so as to make sure thatarm64_dma_phys_limitis populated.
Do we need the arm64_dma32_phys_limit at all? I can see the (arm64_dma_phys_limit ? : arm64_dma32_phys_limit) pattern in several places but I think we can just live with the arm64_dma_phys_limit.
Also, I don't think we need any early ARCH_LOW_ADDRESS_LIMIT. It's only used by memblock_alloc_low() and that's called from swiotlb_init() after arm64_dma_phys_limit was initialised.
What about something like below (on top of you ARCH_LOW_ADDRESS_LIMIT fix but I can revert that)? I haven't tested it in all configurations yet.
arch/arm64/include/asm/processor.h +1 -2
@@ -94,8 +94,7 @@#endif /* CONFIG_ARM64_FORCE_52BIT */ extern phys_addr_t arm64_dma_phys_limit; -extern phys_addr_t arm64_dma32_phys_limit; -#define ARCH_LOW_ADDRESS_LIMIT ((arm64_dma_phys_limit ? : arm64_dma32_phys_limit) - 1) +#define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)struct debug_info {#ifdef CONFIG_HAVE_HW_BREAKPOINT
arch/arm64/mm/init.c +13 -11
@@ -59,7 +59,6 @@ EXPORT_SYMBOL(memstart_addr);* bit addressable memory area. */ phys_addr_t arm64_dma_phys_limit__ro_after_init ; -phys_addr_t arm64_dma32_phys_limit__ro_after_init ;#ifdef CONFIG_KEXEC_CORE /*
@@ -84,7 +83,7 @@ static void __init reserve_crashkernel(void)if (crash_base ==0 ) {/* Current arm64 boot protocol requires 2MB alignment */ - crash_base =memblock_find_in_range (0 , arm64_dma32_phys_limit, + crash_base =memblock_find_in_range (0 , arm64_dma_phys_limit, crash_size,SZ_2M );if (crash_base ==0 ) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
@@ -196,6 +195,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 };unsigned int __maybe_unused acpi_zone_dma_bits;unsigned int __maybe_unused dt_zone_dma_bits; +phys_addr_t dma32_phys_limit =max_zone_phys (32 );#ifdef CONFIG_ZONE_DMA acpi_zone_dma_bits =fls64 (acpi_iort_dma_get_max_cpu_address ());
@@ -205,8 +205,12 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) max_zone_pfns[ZONE_DMA ] =PFN_DOWN (arm64_dma_phys_limit);#endif #ifdef CONFIG_ZONE_DMA32 - max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (arm64_dma32_phys_limit); + max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (dma32_phys_limit); +if (!arm64_dma_phys_limit) + arm64_dma_phys_limit = dma32_phys_limit;#endif +if (!arm64_dma_phys_limit) + arm64_dma_phys_limit =PHYS_MASK +1 ; max_zone_pfns[ZONE_NORMAL ] = max;free_area_init (max_zone_pfns);
@@ -394,16 +398,9 @@ void __init arm64_memblock_init(void)early_init_fdt_scan_reserved_mem (); -if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - arm64_dma32_phys_limit =max_zone_phys (32 ); -else - arm64_dma32_phys_limit =PHYS_MASK +1 ; -reserve_elfcorehdr (); high_memory =__va (memblock_end_of_DRAM () -1 ) +1 ; - -dma_contiguous_reserve (arm64_dma32_phys_limit); }void __init bootmem_init (void )
@@ -438,6 +435,11 @@ void __init bootmem_init(void)sparse_init ();zone_sizes_init (min, max); +/* +* Reserve the CMA area after arm64_dma_phys_limit was initialised. +*/ +dma_contiguous_reserve (arm64_dma_phys_limit); +/* * request_standard_resources() depends on crashkernel's memory being * reserved, so do it here.
@@ -455,7 +457,7 @@ void __init bootmem_init(void)void __init mem_init (void ) {if (swiotlb_force ==SWIOTLB_FORCE || - max_pfn >PFN_DOWN (arm64_dma_phys_limit ? : arm64_dma32_phys_limit)) + max_pfn >PFN_DOWN (arm64_dma_phys_limit))swiotlb_init (1 );else swiotlb_force =SWIOTLB_NO_FORCE ;
Quoted 12 lines · Catalin Marinas
Quoted 11 lines · Nicolas Saenz Julienne
Quoted 7 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Fixes bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32")I'm not so sure this counts as a fix, if someone backports it it'll probably break things as it depends on the series that dynamically sizes DMA zones.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Chen Zhou <[email protected]>---
Why not doing the same with CMA? You'll probably have to move the
dma_contiguous_reserve()call intobootmem_init()so as to make sure thatarm64_dma_phys_limitis populated.Do we need the
arm64_dma32_phys_limitat all? I can see the (arm64_dma_phys_limit? :arm64_dma32_phys_limit) pattern in several places but I think we can just live with thearm64_dma_phys_limit.
Yes, arm64_dma_phys_limit is enough.
Quoted 106 lines
Also, I don't think we need any early
ARCH_LOW_ADDRESS_LIMIT. It's only used bymemblock_alloc_low()and that's called fromswiotlb_init()afterarm64_dma_phys_limitwas initialised.What about something like below (on top of you
ARCH_LOW_ADDRESS_LIMITfix but I can revert that)? I haven't tested it in all configurations yet.arch/arm64/include/asm/processor.h +1
-2@@ -94,8 +94,7 @@#endif /* CONFIG_ARM64_FORCE_52BIT */ extern phys_addr_t arm64_dma_phys_limit; -extern phys_addr_t arm64_dma32_phys_limit; -#define ARCH_LOW_ADDRESS_LIMIT ((arm64_dma_phys_limit ? : arm64_dma32_phys_limit) - 1) +#define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)struct debug_info {#ifdef CONFIG_HAVE_HW_BREAKPOINT arch/arm64/mm/init.c +13
-11@@ -59,7 +59,6 @@ EXPORT_SYMBOL(memstart_addr);* bit addressable memory area. */ phys_addr_t arm64_dma_phys_limit__ro_after_init ; -phys_addr_t arm64_dma32_phys_limit__ro_after_init ;#ifdef CONFIG_KEXEC_CORE /* @@ -84,7 +83,7 @@ static void __init reserve_crashkernel(void)if (crash_base ==0 ) {/* Current arm64 boot protocol requires 2MB alignment */ - crash_base =memblock_find_in_range (0 , arm64_dma32_phys_limit, + crash_base =memblock_find_in_range (0 , arm64_dma_phys_limit, crash_size,SZ_2M );if (crash_base ==0 ) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n",@@ -196,6 +195,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 };unsigned int __maybe_unused acpi_zone_dma_bits;unsigned int __maybe_unused dt_zone_dma_bits; +phys_addr_t dma32_phys_limit =max_zone_phys (32 );#ifdef CONFIG_ZONE_DMA acpi_zone_dma_bits =fls64 (acpi_iort_dma_get_max_cpu_address ());@@ -205,8 +205,12 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) max_zone_pfns[ZONE_DMA ] =PFN_DOWN (arm64_dma_phys_limit);#endif #ifdef CONFIG_ZONE_DMA32 - max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (arm64_dma32_phys_limit); + max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (dma32_phys_limit); +if (!arm64_dma_phys_limit) + arm64_dma_phys_limit = dma32_phys_limit;#endif +if (!arm64_dma_phys_limit) + arm64_dma_phys_limit =PHYS_MASK +1 ; max_zone_pfns[ZONE_NORMAL ] = max;free_area_init (max_zone_pfns);@@ -394,16 +398,9 @@ void __init arm64_memblock_init(void)early_init_fdt_scan_reserved_mem (); -if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - arm64_dma32_phys_limit =max_zone_phys (32 ); -else - arm64_dma32_phys_limit =PHYS_MASK +1 ; -reserve_elfcorehdr (); high_memory =__va (memblock_end_of_DRAM () -1 ) +1 ; - -dma_contiguous_reserve (arm64_dma32_phys_limit); }void __init bootmem_init (void )@@ -438,6 +435,11 @@ void __init bootmem_init(void)sparse_init ();zone_sizes_init (min, max); +/* +* Reserve the CMA area after arm64_dma_phys_limit was initialised. +*/ +dma_contiguous_reserve (arm64_dma_phys_limit); +/* * request_standard_resources() depends on crashkernel's memory being * reserved, so do it here. @@ -455,7 +457,7 @@ void __init bootmem_init(void)void __init mem_init (void ) {if (swiotlb_force ==SWIOTLB_FORCE || - max_pfn >PFN_DOWN (arm64_dma_phys_limit ? : arm64_dma32_phys_limit)) + max_pfn >PFN_DOWN (arm64_dma_phys_limit))swiotlb_init (1 );else swiotlb_force =SWIOTLB_NO_FORCE ;.
Will Deacon
maintainerQuoted 6 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.
Quoted 6 lines
Patch 1 updates the comments about the
ZONE_DMA.
Patch 2 fix kdump broken.Chen Zhou (2):
arm64: mm: update the comments aboutZONE_DMA
arm64: mm: fix kdump broken withZONE_DMAreintroduced
Please can you repost this if it is still needed after the changes that landed in -rc4?
Will
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 10 lines · Will Deacon
Quoted 9 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Patch 1 updates the comments about the
ZONE_DMA.
Patch 2 fix kdump broken.
Quoted 6 lines
Quoted 3 lines
Chen Zhou (2):
arm64: mm: update the comments aboutZONE_DMA
arm64: mm: fix kdump broken withZONE_DMAreintroducedPlease can you repost this if it is still needed after the changes that landed in -rc4?
I don't think this series is needed anymore but I'll let Chen confirm.
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Will, Catalin,
Quoted 11 lines · Catalin Marinas
Quoted 10 lines · Will Deacon
Quoted 9 lines · Chen Zhou
If the memory reserved for crash dump kernel falled in
ZONE_DMA32, the devices in crash dump kernel need to useZONE_DMAwill alloc fail.Fix this by reserving low memory in
ZONE_DMAifCONFIG_ZONE_DMAis enabled, otherwise, reserving inZONE_DMA32.Patch 1 updates the comments about the
ZONE_DMA.
Patch 2 fix kdump broken.
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Chen Zhou (2):
arm64: mm: update the comments aboutZONE_DMA
arm64: mm: fix kdump broken withZONE_DMAreintroducedPlease can you repost this if it is still needed after the changes that landed in -rc4?
I don't think this series is needed anymore but I'll let Chen confirm.
Yes, we don't need this series, Catalin has solved the issue i mentioned.
I will repost the series "support reserving crashkernel above 4G on arm64 kdump" based on the latest code.
Thanks,
Chen Zhou
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel