diff mbox series

psci: put psci_method in .data section if EFI_LOADER is not enabled

Message ID 20200717142009.1.I33bddfcff61ece321e626b04e34f9b53d016d6f2@changeid
State Accepted
Commit 5cc7df7ebaccc0d02e3322a35b2dcb47951bc9ae
Delegated to: Tom Rini
Headers show
Series psci: put psci_method in .data section if EFI_LOADER is not enabled | expand

Commit Message

Patrick DELAUNAY July 17, 2020, 12:20 p.m. UTC
From: Yann Gautier <yann.gautier@st.com>

Move the variable psci_method in .data section when EFI is not
activated and the psci driver safely access it before relocation.

Without this patch the variable is located in .bss section
and the psci probe requested before relocation corrupts the device
tree (probe is requested by board_f.c::print_resetinfo()).

When EFI_LOADER is activated, this variable in already located in the
.data.efi_runtime section by __efi_runtime_data.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/firmware/psci.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Tom Rini Aug. 5, 2020, 8:27 p.m. UTC | #1
On Fri, Jul 17, 2020 at 02:20:15PM +0200, Patrick Delaunay wrote:

> From: Yann Gautier <yann.gautier@st.com>
> 
> Move the variable psci_method in .data section when EFI is not
> activated and the psci driver safely access it before relocation.
> 
> Without this patch the variable is located in .bss section
> and the psci probe requested before relocation corrupts the device
> tree (probe is requested by board_f.c::print_resetinfo()).
> 
> When EFI_LOADER is activated, this variable in already located in the
> .data.efi_runtime section by __efi_runtime_data.
> 
> Signed-off-by: Yann Gautier <yann.gautier@st.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 23cf807591..7d2e49fd3e 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -25,7 +25,11 @@ 
 #define PSCI_METHOD_HVC 1
 #define PSCI_METHOD_SMC 2
 
+#if CONFIG_IS_ENABLED(EFI_LOADER)
 int __efi_runtime_data psci_method;
+#else
+int psci_method __attribute__ ((section(".data")));
+#endif
 
 unsigned long __efi_runtime invoke_psci_fn
 		(unsigned long function_id, unsigned long arg0,