raspberrypi: reserve first two pages in efi memory map
PATCH 1/1 raspberrypi: reserve first two pages in efi memory map
From: Kyle Evans <[email protected]>
The psci stub provided by Raspberry Pi is around 5k in size, thus residing in the first two pages of memory. Without this reservation, the next stage or OS assume they're free to use the second page and may get catastrophic results from clobbering it.
--- board/raspberrypi/rpi/rpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
board/raspberrypi/rpi/rpi.c +2 -2
@@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)lcd_dt_simplefb_add_node (blob);#ifdef CONFIG_EFI_LOADER -/* Reserve the spin table */ -efi_add_memory_map (0 ,1 ,EFI_RESERVED_MEMORY_TYPE ,0 ); +/* Reserve the first two pages for spin table/psci stub. */ +efi_add_memory_map (0 ,2 ,EFI_RESERVED_MEMORY_TYPE ,0 );#endif return 0 ;
Signature · 1 line
2.25.1
PATCH 1/1 raspberrypi: reserve first two pages in efi memory map
Quoted 18 lines · kevans at FreeBSD.org
From: Kyle Evans <[email protected]>
The psci stub provided by Raspberry Pi is around 5k in size, thus residing in the first two pages of memory. Without this reservation, the next stage or OS assume they're free to use the second page and may get catastrophic results from clobbering it.
Signed-off-by Kyle Evans <[email protected]>Cc Matthias Brugger <[email protected]>--- board/raspberrypi/rpi/rpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)board/raspberrypi/rpi/rpi.c +0
-0
board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, bd_t *bd) · line 492
Quoted 7 lines
board/raspberrypi/rpi/rpi.c +2
-2@@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)lcd_dt_simplefb_add_node (blob);#ifdef CONFIG_EFI_LOADER -/* Reserve the spin table */ -efi_add_memory_map (0 ,1 ,EFI_RESERVED_MEMORY_TYPE ,0 ); +/* Reserve the first two pages for spin table/psci stub. */ +efi_add_memory_map (0 ,2 ,EFI_RESERVED_MEMORY_TYPE ,0 );
Is this that changed recently or was the memory reservation wrong from the beginning?
Reagrds,
Matthias
Quoted 4 lines
board/raspberrypi/rpi/rpi.c +0
-0#endif return 0 ;
PATCH 1/1 raspberrypi: reserve first two pages in efi memory map
Quoted 24 lines · Matthias Brugger
Quoted 20 lines · kevans at FreeBSD.org
From: Kyle Evans <[email protected]>
The psci stub provided by Raspberry Pi is around 5k in size, thus residing in the first two pages of memory. Without this reservation, the next stage or OS assume they're free to use the second page and may get catastrophic results from clobbering it.
Signed-off-by Kyle Evans <[email protected]>Cc Matthias Brugger <[email protected]>--- board/raspberrypi/rpi/rpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)board/raspberrypi/rpi/rpi.c +0
-0@@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)lcd_dt_simplefb_add_node (blob);
Quoted 9 lines
board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, bd_t *bd) · line 492
Quoted 5 lines
board/raspberrypi/rpi/rpi.c +2
-2#ifdef CONFIG_EFI_LOADER -/* Reserve the spin table */ -efi_add_memory_map (0 ,1 ,EFI_RESERVED_MEMORY_TYPE ,0 ); +/* Reserve the first two pages for spin table/psci stub. */ +efi_add_memory_map (0 ,2 ,EFI_RESERVED_MEMORY_TYPE ,0 );Is this that changed recently or was the memory reservation wrong from the beginning?
As far as I can tell it just wasn't quite accounted for in the initial reservation -- Linux presumably uses spin-table as described in the DTS, where-as FreeBSD opts for PSCI instead since it's available. I don't have a good intuition for who else may be using PSCI for RPi; we may be in the minority.
FWIW, /memreserve/ in the upstream (raspberrypi/firmware) DTB also do not account for PSCI stubs -- I've filed an issue[1] there, as well.
Thanks,
Kyle Evans
PATCH 1/1 raspberrypi: reserve first two pages in efi memory map
Quoted 42 lines · Kyle Evans
Quoted 24 lines · Matthias Brugger
Quoted 20 lines · kevans at FreeBSD.org
From: Kyle Evans <[email protected]>
The psci stub provided by Raspberry Pi is around 5k in size, thus residing in the first two pages of memory. Without this reservation, the next stage or OS assume they're free to use the second page and may get catastrophic results from clobbering it.
Signed-off-by Kyle Evans <[email protected]>Cc Matthias Brugger <[email protected]>--- board/raspberrypi/rpi/rpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)board/raspberrypi/rpi/rpi.c +0
-0@@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)lcd_dt_simplefb_add_node (blob);Quoted 9 lines
board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, bd_t *bd) · line 492
Quoted 5 lines
board/raspberrypi/rpi/rpi.c +2
-2#ifdef CONFIG_EFI_LOADER -/* Reserve the spin table */ -efi_add_memory_map (0 ,1 ,EFI_RESERVED_MEMORY_TYPE ,0 ); +/* Reserve the first two pages for spin table/psci stub. */ +efi_add_memory_map (0 ,2 ,EFI_RESERVED_MEMORY_TYPE ,0 );Is this that changed recently or was the memory reservation wrong from the beginning?
As far as I can tell it just wasn't quite accounted for in the initial reservation -- Linux presumably uses spin-table as described in the DTS, where-as FreeBSD opts for PSCI instead since it's available. I don't have a good intuition for who else may be using PSCI for RPi; we may be in the minority.
Quoted 8 lines
FWIW, /memreserve/ in the upstream (raspberrypi/firmware) DTB also do not account for PSCI stubs -- I've filed an issue[1] there, as well.
Thanks,
Kyle Evans
Upon further examination, it looks like I've managed to confuse myself and we're using our own stub derived from the upstream spintable stuff... let's disregard this patch, I'll look into rolling up a new one as both upstream implementation and ours should pass the required reservation size through to U-Boot via x1.