rpi: bcm2712: Extend DRAM mapping to 16 GiB
Subsystems (4)
PATCH 1/1 rpi: bcm2712: Extend DRAM mapping to 16 GiB
The bcm2712 memory map only covers the first 1 GiB of DRAM, but Pi 5 models ship with up to 16 GiB. Accesses above 1 GiB fault because the range is not present in the MMU page tables.
Allocations above 1 GiB used to be blocked at the lmb layer because memory above ram_top was reserved as no-overwrite. Commit 0efb6bc3e36d ("lmb: Reinstate access to memory above ram_top") removed that reservation, so callers like tftp now route allocations into the unmapped range and trigger a fault.
Extend the first DRAM entry to 16 GiB to cover the largest addressable range for any production Pi 5 model. Smaller models are unaffected because aarch64 only faults on actual access of unbacked memory, and no peripheral region lies between 1 GiB and 64 GiB on this SoC (peripherals start at 0x1000000000).
---
arch/arm/mach-bcm283x/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-bcm283x/init.c +2 -2
@@ -69,10 +69,10 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = {static struct mm_region bcm2712_mem_map[MEM_MAP_MAX_ENTRIES ] = { { -/* First 1GB of DRAM */ +/* DRAM, up to the 16 GiB maximum supported by Pi 5 models */ .virt =0x00000000UL , .phys =0x00000000UL , - .size =0x40000000UL , + .size =0x400000000UL , .attrs =PTE_BLOCK_MEMTYPE (MT_NORMAL ) |PTE_BLOCK_INNER_SHARE }, {
---
base-commit: 3cdd19089f1b1b7cd08530f33ff4708abcfd426c
branch: rpi-us
Signature · 1 line
2.43.0
Hi Simon,
Thanks for this.
Quoted 11 lines · Simon Glass
The bcm2712 memory map only covers the first 1 GiB of DRAM, but Pi 5 models ship with up to 16 GiB. Accesses above 1 GiB fault because the range is not present in the MMU page tables.
Allocations above 1 GiB used to be blocked at the lmb layer because memory above
ram_topwas reserved as no-overwrite. Commit0efb6bc3e36d("lmb: Reinstate access to memory aboveram_top") removed that reservation, so callers like tftp now route allocations into the unmapped range and trigger a fault.
Quoted 5 lines
Extend the first DRAM entry to 16 GiB to cover the largest addressable range for any production Pi 5 model. Smaller models are unaffected because aarch64 only faults on actual access of unbacked memory, and no peripheral region lies between 1 GiB and 64 GiB on this SoC (peripherals start at
0x1000000000).
So a couple of questions:
1) Do we need to do this for the Pi4 (bcm2711) too? It's currently at ~4Gb.
2) On the bcm2711 it sits at just under 4gb, initially that was 4Gb-16Mb AFAICT (917a1e9a78fe) and then it was reduced in a followup commit (c44b3f523c48) because of overlap with "device's IO area"
3) why doesn't the rpi5 have the overlap issues?
Peter
Quoted 31 lines
Fixes 0efb6bc3e36d ("lmb: Reinstate access to memory above ram_top")Signed-off-by Simon Glass <[email protected]>---
arch/arm/mach-bcm283x/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-bcm283x/init.c +2
-3@@ -69,10 +69,10 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = {static struct mm_region bcm2712_mem_map[MEM_MAP_MAX_ENTRIES ] = { { -/* First 1GB of DRAM */ +/* DRAM, up to the 16 GiB maximum supported by Pi 5 models */ .virt =0x00000000UL , .phys =0x00000000UL , - .size =0x40000000UL , + .size =0x400000000UL , .attrs =PTE_BLOCK_MEMTYPE (MT_NORMAL ) |PTE_BLOCK_INNER_SHARE }, { ---base-commit:
3cdd19089f1b1b7cd08530f33ff4708abcfd426c
branch: rpi-us--
2.43.0
Quoted 23 lines · Peter Robinson
Hi Simon,
Thanks for this.
Quoted 11 lines · Simon Glass
The bcm2712 memory map only covers the first 1 GiB of DRAM, but Pi 5 models ship with up to 16 GiB. Accesses above 1 GiB fault because the range is not present in the MMU page tables.
Allocations above 1 GiB used to be blocked at the lmb layer because memory above
ram_topwas reserved as no-overwrite. Commit0efb6bc3e36d("lmb: Reinstate access to memory aboveram_top") removed that reservation, so callers like tftp now route allocations into the unmapped range and trigger a fault.Quoted 5 lines
Extend the first DRAM entry to 16 GiB to cover the largest addressable range for any production Pi 5 model. Smaller models are unaffected because aarch64 only faults on actual access of unbacked memory, and no peripheral region lies between 1 GiB and 64 GiB on this SoC (peripherals start at
0x1000000000).
Quoted 6 lines
So a couple of questions:
1) Do we need to do this for the Pi4 (bcm2711) too? It's currently at ~4Gb.
2) On the bcm2711 it sits at just under 4gb, initially that was 4Gb-16Mb AFAICT (917a1e9a78fe) and then it was reduced in a followup commit (c44b3f523c48) because of overlap with "device's IO area"
3) why doesn't the rpi5 have the overlap issues?
Also at least on a 1Gb RPi5 it's still crashing for me.
Quoted 33 lines
Peter
Quoted 31 lines
Fixes 0efb6bc3e36d ("lmb: Reinstate access to memory above ram_top")Signed-off-by Simon Glass <[email protected]>---
arch/arm/mach-bcm283x/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-bcm283x/init.c +2
-3@@ -69,10 +69,10 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = {static struct mm_region bcm2712_mem_map[MEM_MAP_MAX_ENTRIES ] = { { -/* First 1GB of DRAM */ +/* DRAM, up to the 16 GiB maximum supported by Pi 5 models */ .virt =0x00000000UL , .phys =0x00000000UL , - .size =0x40000000UL , + .size =0x400000000UL , .attrs =PTE_BLOCK_MEMTYPE (MT_NORMAL ) |PTE_BLOCK_INNER_SHARE }, { ---base-commit:
3cdd19089f1b1b7cd08530f33ff4708abcfd426c
branch: rpi-us--
2.43.0