All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] firmware: psci: Do not bind driver if U-Boot runs in EL3
@ 2020-08-12  7:20 Michal Simek
  0 siblings, 0 replies; only message in thread
From: Michal Simek @ 2020-08-12  7:20 UTC (permalink / raw)
  To: u-boot

There is no reason to bind psci driver if U-Boot runs in EL3 because
SMC/HVC instructions can't be called. That's why detect this state and
don't let user to crash from prompt by performing reset or poweroff
commands (if enabled).

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Add missing asm/system.h header

Maybe there is a better way how to do it. Maybe do it in probe instead of
bind. Feel free to comment but this doesn't look right behavior.

Before:

U-Boot SPL 2020.10-rc2-00032-gede802a09435 (Aug 12 2020 - 09:17:01 +0200)
PMUFW:	v1.1
Loading new PMUFW cfg obj (2024 bytes)
EL Level:	EL3
Multiboot:	0
Trying to boot from MMC2
spl: could not initialize mmc. error: -19
Trying to boot from MMC1
spl_load_image_fat_os: error reading image u-boot.bin, err - -2

U-Boot 2020.10-rc2-00032-gede802a09435 (Aug 12 2020 - 09:17:01 +0200)

Model: ZynqMP ZCU104 RevC
Board: Xilinx ZynqMP
DRAM:  2 GiB
PMUFW:	v1.1
EL Level:	EL3
Chip ID:	zu7e
Multiboot:	0
WDT:   Started with servicing (60s timeout)
NAND:  0 MiB
MMC:   mmc at ff170000: 0
In:    serial at ff000000
Out:   serial at ff000000
Err:   serial at ff000000
Bootmode: LVL_SHFT_SD_MODE1
Reset reason:	EXTERNAL
Net:
ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id
eth0: ethernet at ff0e0000
Hit any key to stop autoboot:  0
ZynqMP> reset
resetting ...
"Synchronous Abort" handler, esr 0x5e000000
elr: 0000000008000194 lr : 0000000008000220 (reloc)
elr: 000000007fec9194 lr : 000000007fec9220
x0 : 0000000084000009 x1 : 0000000000000000
x2 : 0000000000000000 x3 : 0000000000000000
x4 : 0000000000000000 x5 : 0000000000000000
x6 : 0000000000000000 x7 : 0000000000000000
x8 : 000000007deaedb0 x9 : 000000000000000c
x10: 00000000000007c4 x11: 000000007deae92c
x12: 0000000000000006 x13: 000000000001869f
x14: 000000007deaedb0 x15: 0000000000000002
x16: 000000007ff2b20c x17: 0000000000000000
x18: 000000007deb8db0 x19: 0000000000000000
x20: 000000007ffb0ae0 x21: 0000000000000000
x22: 000000007debc600 x23: 0000000000000001
x24: 000000007ffc8158 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 000000007debc640 x29: 000000007deaeaf0

Code: 00000000 f9020000 00000000 d4000003 (f94003e4)
Resetting CPU ...

 ### ERROR ### Please RESET the board ###

After:

U-Boot SPL 2020.10-rc2-00033-g952b21dcb4b3 (Aug 12 2020 - 09:18:56 +0200)
PMUFW:	v1.1
Loading new PMUFW cfg obj (2024 bytes)
EL Level:	EL3
Multiboot:	0
Trying to boot from MMC2
spl: could not initialize mmc. error: -19
Trying to boot from MMC1
spl_load_image_fat_os: error reading image u-boot.bin, err - -2

U-Boot 2020.10-rc2-00033-g952b21dcb4b3 (Aug 12 2020 - 09:18:56 +0200)

Model: ZynqMP ZCU104 RevC
Board: Xilinx ZynqMP
DRAM:  2 GiB
PMUFW:	v1.1
EL Level:	EL3
Chip ID:	zu7e
Multiboot:	0
WDT:   Started with servicing (60s timeout)
NAND:  0 MiB
MMC:   mmc at ff170000: 0
In:    serial at ff000000
Out:   serial at ff000000
Err:   serial at ff000000
Bootmode: LVL_SHFT_SD_MODE1
Reset reason:	EXTERNAL
Net:
ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id
eth0: ethernet at ff0e0000
Hit any key to stop autoboot:  0
ZynqMP>
ZynqMP> reset
resetting ...
ZynqMP>

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

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 7d2e49fd3e3b..e6425e8ffcf4 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/printk.h>
 #include <linux/psci.h>
+#include <asm/system.h>
 
 #define DRIVER_NAME "psci"
 
@@ -73,6 +74,9 @@ static int psci_probe(struct udevice *dev)
 {
 	const char *method;
 
+	if (current_el() == 3)
+		return -EINVAL;
+
 	method = ofnode_read_string(dev_ofnode(dev), "method");
 	if (!method) {
 		pr_warn("missing \"method\" property\n");
-- 
2.28.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-12  7:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12  7:20 [PATCH v2] firmware: psci: Do not bind driver if U-Boot runs in EL3 Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.