From patchwork Thu Jan 13 15:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Grimler X-Patchwork-Id: 12712880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 478E6C433EF for ; Thu, 13 Jan 2022 15:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8pSzX4d1BOXJp5VqcOBU8o2wU4RJGbBCVDG9Sjj0AN0=; b=xeguuhCbzPNGWq 2CPTw2uGRe7H+vVBYV57cW7xTOMTxxCSlexR7/X95WcHd20ubjrsRBNz5f2OBzFAhUCZ+nWXFkJ8Q Rr44qeyTbexYypKLbAnDoJHFnyQx710ibSJUzyU99+ZutF0GeX/8JXIVLBomktOaEFtZMSb5Io0s7 47WAcg1WPD4yDzAQc1XJXZkJc1d35G0X6Xhb7tBm7rxHbutYYfKdFhgalyroLe9I6wSjcuvtst4QE 00gs+sjCM74Rcizofu1MwbZGsKS/ywWE4iu+HnQlurYkELg+vcKyMBegqBcjeAVB+WNA9uPdlgH1x ECxb2u81SD8thkWHfrsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n82Dl-006O1g-OT; Thu, 13 Jan 2022 15:41:01 +0000 Received: from h01mx15.reliablemail.org ([173.236.5.211]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n82DU-006Nzd-4s for linux-arm-kernel@lists.infradead.org; Thu, 13 Jan 2022 15:40:45 +0000 X-Halon-Out: 29cdb84b-7487-11ec-90dc-00163c81f1a9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=grimler.se; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gypRF3e/VEsXtFI8r8PiWc3bYGtEcrqn757WrSM6/tE=; b=DY6c+z7+/g5KwsKVv6xaARPVSo rx8Bn9X6eU5TxpmBuUg3j4M4zpS343i4XhWbgM6MXQF8B5lnZumhbVfbnlB2JCzeBwuXwrGIjjsKY tsVLbbB2sqaHfU20ZXSur5I4I7/poWUGWc0fZG4lCSZdLiMopGTrjNwUHc3Vs5WO9sFrkJ937Ut2T CxWcJDiNdQTJU2EMsRXwImOpAAa6L6tOLDbRBPKm5hMrX8robEE4686iU7KtjvAC1cQmG2VuQvh3N eLWuJ24+68xnH+WjMfMnSmagbzp9UdEWYFwbx+6HnsyEGRXvpd5+lvco50E06l1hhkToaDnbpLyWm Y9SJgBUQ==; From: Henrik Grimler To: semen.protsenko@linaro.org, virag.david003@gmail.com, martin.juecker@gmail.com, cw00.choi@samsung.com, m.szyprowski@samsung.com, alim.akhtar@samsung.com, krzysztof.kozlowski@canonical.com, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Cc: Henrik Grimler Subject: [PATCH 2/3] ARM: exynos: only do SMC_CMD_CPU1BOOT call on Exynos4 Date: Thu, 13 Jan 2022 16:40:18 +0100 Message-Id: <20220113154019.74434-3-henrik@grimler.se> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220113154019.74434-1-henrik@grimler.se> References: <20220113154019.74434-1-henrik@grimler.se> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpsrv07.misshosting.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - grimler.se X-Get-Message-Sender-Via: cpsrv07.misshosting.com: authenticated_id: henrik@grimler.se X-Authenticated-Sender: cpsrv07.misshosting.com: henrik@grimler.se X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220113_074044_235939_DC3331A1 X-CRM114-Status: GOOD ( 10.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Exynos5 the call is simply ignored by most variants of the trustzone firmware. However, on some devices it instead causes the device to hang, so let's avoid the call for the SoCs where it should not be needed. To see that the call is ignored, we can look into sboot/tzsw. On most of the Exynos{4,5} devices the part of sboot/tzsw that seem to handle the secure monitor calls is quite easy to recognise, the SMC number is compared to known ones, and if equal it branches to the relevant function. In assembly this looks something like: ;-- handle_smc: 0x00000514 650070e3 cmn r0, 0x65 0x00000518 0a00000a beq loc.smc_cmd_reg 0x0000051c 010070e3 cmn r0, 1 0x00000520 6c00000a beq loc.smc_cmd_init 0x00000524 020070e3 cmn r0, 2 0x00000528 6b00000a beq loc.smc_cmd_info 0x0000052c 030070e3 cmn r0, 3 0x00000530 6e00000a beq loc.smc_cmd_sleep 0x00000534 060070e3 cmn r0, 6 0x00000538 ae00000a beq loc.smc_cmd_save_state 0x0000053c 070070e3 cmn r0, 7 0x00000540 b400000a beq loc.smc_cmd_standby 0x00000544 2b01001a bne loc.smc_return_minus1 where above example is from exynos5420-arndale-octa. As can be seen the case where r0 is 4 (i.e. SMC_CMD_CPU1BOOT) is not handled. The annotations are taken from github.com/hsnaves/exynos5410-firmware, where a large part of the exynos5410 trustzone firmware has been reverse-engineered. Signed-off-by: Henrik Grimler Tested-by: Marek Szyprowski --- Sent previously as RFC --- arch/arm/mach-exynos/firmware.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c index 2eaf2dbb8e81..2da5b60b59e2 100644 --- a/arch/arm/mach-exynos/firmware.c +++ b/arch/arm/mach-exynos/firmware.c @@ -60,8 +60,10 @@ static int exynos_cpu_boot(int cpu) /* * Exynos3250 doesn't need to send smc command for secondary CPU boot * because Exynos3250 removes WFE in secure mode. + * + * On Exynos5 devices the call is ignored by trustzone firmware. */ - if (soc_is_exynos3250()) + if (!soc_is_exynos4210() && !soc_is_exynos4412()) return 0; /*