From patchwork Thu Aug 13 10:43:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1344206 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=PzzVQuKf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BS3855pZSz9sPB for ; Thu, 13 Aug 2020 20:43:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B80281E39; Thu, 13 Aug 2020 12:43:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="PzzVQuKf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3140881C33; Thu, 13 Aug 2020 12:43:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1526081C33 for ; Thu, 13 Aug 2020 12:43:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-wr1-x442.google.com with SMTP id c15so4796748wrs.11 for ; Thu, 13 Aug 2020 03:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rowCZ0EkwE28g46JSDDNKCNL/RkgusNr6zS/mAnctMI=; b=PzzVQuKfVhuXYYI3DURGMs9swt4DKjNDTssDva7UcJeNidVSPteOAlhM1d2dF/veH4 KpBcdY9Gh1GFGUDJPXKqmhrEqKoDohmIvyBNgrrum2J4VGLLNk+gswFNJTIEtzTWHcJj 9eFdp1CizeUL7kQmCOGra/IFrwgqBjuSuCXsWuzAwOaESLV8elGdgZJvthBzxPP4S7dM h+SWIMY0i+Tla6Z2IPVq17Qe0Fxdc2ph8Wihr+ABNjApLb5taOFtjFN54SzGdeUDuniJ 4CXEY6Ho15FjDUzerhZGHyqjuqdknVMMW6K/aGftjP0m2NURwMgScLQaat7Ob4+hZUWx uFfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=rowCZ0EkwE28g46JSDDNKCNL/RkgusNr6zS/mAnctMI=; b=XERfhZ3qPGtlLicixWxMqvws99wonCgQNd4ybh1PZ1DDVKJPXDHAktAtI9ce5xcCLA +BSWfcwB4n9aw1ah4NC77qEdpZ6M/c+qieyb5ylcpPcQccM6MhWCTnADb7ssRf11CtC9 xEfm3aWObWlFwEeZ4d9zz8/um9k6K+jA/SHOFWrajX4GBG+gxDD3Rj80Vams53wmzGGA 9VD7Q8hweGHbo2FHVY7V8ReiIB+y+F0qyCX/ymBuZeHMn9/8gmRtjJyGOuw2JvGdt+9u mVl8ws3/RQioBCCCCbnFXvyS3dm3ioMrC0BGQHrIUKE2kdTY8kGWtSinwvnva+bLYpzj IL3g== X-Gm-Message-State: AOAM533kA0WvSFKhQXUhPzXrjf9vSKLjMyLdm75fjtpO5fupw7Rg/9F2 hxish8NVPL9GgpKZMmGejgWrrdfqmFbohw== X-Google-Smtp-Source: ABdhPJxP+leNW6GZF6eKRn76CFVqxtNAuvCNoOpGEDTy6Sqsp6C3k6m7cs25BfPW/TiLF0DnKO/Zow== X-Received: by 2002:a5d:4743:: with SMTP id o3mr3428745wrs.218.1597315404365; Thu, 13 Aug 2020 03:43:24 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id v12sm9628885wri.47.2020.08.13.03.43.23 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Aug 2020 03:43:23 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Jon Hunter , Patrick Delaunay , Simon Glass , Yann Gautier Subject: [PATCH v3] firmware: psci: Do not bind driver if U-Boot runs in EL3 Date: Thu, 13 Aug 2020 12:43:22 +0200 Message-Id: X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 --- Changes in v3: - guard for ARM64 which implements current_el(). Qemu arm was failing in CI loop there is no way to use if (CONFIG_IS_ENABLED because current_el() is not defined for arm32 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@ff170000: 0 In: serial@ff000000 Out: serial@ff000000 Err: serial@ff000000 Bootmode: LVL_SHFT_SD_MODE1 Reset reason: EXTERNAL Net: ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id eth0: ethernet@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@ff170000: 0 In: serial@ff000000 Out: serial@ff000000 Err: serial@ff000000 Bootmode: LVL_SHFT_SD_MODE1 Reset reason: EXTERNAL Net: ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id eth0: ethernet@ff0e0000 Hit any key to stop autoboot: 0 ZynqMP> ZynqMP> reset resetting ... ZynqMP> --- drivers/firmware/psci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 7d2e49fd3e3b..68953cc4f4e2 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -19,6 +19,7 @@ #include #include #include +#include #define DRIVER_NAME "psci" @@ -73,6 +74,11 @@ static int psci_probe(struct udevice *dev) { const char *method; +#if defined(CONFIG_ARM64) + if (current_el() == 3) + return -EINVAL; +#endif + method = ofnode_read_string(dev_ofnode(dev), "method"); if (!method) { pr_warn("missing \"method\" property\n");