From nobody Tue Apr 28 05:05:44 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2CD2C43334 for ; Mon, 6 Jun 2022 14:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240155AbiFFO6T (ORCPT ); Mon, 6 Jun 2022 10:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240136AbiFFO6R (ORCPT ); Mon, 6 Jun 2022 10:58:17 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F56303884 for ; Mon, 6 Jun 2022 07:58:16 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 3468BFF805; Mon, 6 Jun 2022 14:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1654527495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdBrGx50GRyG3r2iXeGYuM3SEahX/F4l92MvsJio2dM=; b=XjnSLokHGUTArERJGLhtnibxg1snnzGnkfsUyoYRX1v6AXZ579VkSnaJeFqbCxavsH59FE hoN2tHLT15aPFGvDMKLWnq3k91TEvChLVd7n+hy+SeNhARtA12dmbQxIxroSK5xLsuEMTw lRa/PLirgi5mMeMJuPpHQqKEtrpMG41QKxldxoAxxC6CbxNLDBq0tt9Hpd0UMCa/tx7hiA K988esjV4EZjhGdP5b9+AKVC6+bTQFRKSi0PfEVAAxHJPZ10BSqxfgISOx6b50+LU81EA6 uPG6AX1icU4zK+e/4qqSJG+lNTZQFePgbjABkaZ9fmh3qkHpVCguqiaxKwRerQ== From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: Russell King , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Petazzoni Subject: [PATCH 1/2] ARM: at91: add sam_linux_is_in_normal_world() function Date: Mon, 6 Jun 2022 16:57:00 +0200 Message-Id: <20220606145701.185552-2-clement.leger@bootlin.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220606145701.185552-1-clement.leger@bootlin.com> References: <20220606145701.185552-1-clement.leger@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add sam_linux_is_in_normal_world() which allows to know if Linux is running in the normal world or not. This function is used by code which needs to differentiate the world in which Linux is running. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- arch/arm/mach-at91/sam_secure.c | 6 ++++++ arch/arm/mach-at91/sam_secure.h | 1 + 2 files changed, 7 insertions(+) diff --git a/arch/arm/mach-at91/sam_secure.c b/arch/arm/mach-at91/sam_secur= e.c index 2a01f7a7d13f..1ec8c8b9d119 100644 --- a/arch/arm/mach-at91/sam_secure.c +++ b/arch/arm/mach-at91/sam_secure.c @@ -27,6 +27,12 @@ struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u3= 2 arg1) return res; } =20 +bool sam_linux_is_in_normal_world(void) +{ + /* If optee has been detected, then we are running in normal world */ + return optee_available; +} + void __init sam_secure_init(void) { struct device_node *np; diff --git a/arch/arm/mach-at91/sam_secure.h b/arch/arm/mach-at91/sam_secur= e.h index 1e7d8b20ba1e..6d8c01f9c5f0 100644 --- a/arch/arm/mach-at91/sam_secure.h +++ b/arch/arm/mach-at91/sam_secure.h @@ -14,5 +14,6 @@ =20 void __init sam_secure_init(void); struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1); +bool sam_linux_is_in_normal_world(void); =20 #endif /* SAM_SECURE_H */ --=20 2.36.1 From nobody Tue Apr 28 05:05:44 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AD82C43334 for ; Mon, 6 Jun 2022 14:58:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240171AbiFFO6Y (ORCPT ); Mon, 6 Jun 2022 10:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240148AbiFFO6S (ORCPT ); Mon, 6 Jun 2022 10:58:18 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD9B0140A6 for ; Mon, 6 Jun 2022 07:58:17 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id D8D91FF808; Mon, 6 Jun 2022 14:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1654527496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SMDzIUH01c9Xmou891SUin6Y2SHspdo6jDEEnRQIDZg=; b=BhZLT0bNjLOlGCma7K7u9yCrwmEdw+TSDMwUUXqotxtjL2P+p1/MVVB9D1jDWuLOn2iyT0 gP1xiXcT/gw6lYTUDScsWG2WkRk8nkFmQfqiWBQnLuPTV/s+8Xdvv59A9CqFXT3TO5Z59o qk7SEqx+On9gOSAzKwIFmYy27GLwxLPfaGRu/OOM1UsTdnXjjmarbbRMfgpxPao6F5/rvS 3AcH2+ZpEH/k/m1G+o+rUe2I7MMlFspjTTAtzFw99PbZUQmTRSTsNW/liLVDMIbe4eLsNA SvqRX1NE3ZExU2v6lRR3vKZxyuSVOrHGdwAfqO9taenTtS9xCs4N0jEDoFxLGw== From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: Russell King , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Petazzoni Subject: [PATCH 2/2] ARM: at91: setup outer cache .write_sec() callback if needed Date: Mon, 6 Jun 2022 16:57:01 +0200 Message-Id: <20220606145701.185552-3-clement.leger@bootlin.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220606145701.185552-1-clement.leger@bootlin.com> References: <20220606145701.185552-1-clement.leger@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running under OP-TEE, the L2 cache is configured by OP-TEE and the sam platform code does not allow any modification yet. Setup a dummy .write_sec() callback to avoid triggering exceptions when Linux tries to modify the L2 cache configuration. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- arch/arm/mach-at91/sama5.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/arm/mach-at91/sama5.c b/arch/arm/mach-at91/sama5.c index de5dd28b392e..d1a9e940a785 100644 --- a/arch/arm/mach-at91/sama5.c +++ b/arch/arm/mach-at91/sama5.c @@ -9,13 +9,27 @@ #include #include =20 +#include #include #include +#include #include =20 #include "generic.h" #include "sam_secure.h" =20 +static void sama5_l2c310_write_sec(unsigned long val, unsigned reg) +{ + /* OP-TEE configures the L2 cache and does not allow modifying it yet */ +} + +static void __init sama5_secure_cache_init(void) +{ + sam_secure_init(); + if (sam_linux_is_in_normal_world()) + outer_cache.write_sec =3D sama5_l2c310_write_sec; +} + static void __init sama5_dt_device_init(void) { of_platform_default_populate(NULL, NULL, NULL); @@ -30,6 +44,7 @@ static const char *const sama5_dt_board_compat[] __initco= nst =3D { DT_MACHINE_START(sama5_dt, "Atmel SAMA5") /* Maintainer: Atmel */ .init_machine =3D sama5_dt_device_init, + .init_early =3D sama5_secure_cache_init, .dt_compat =3D sama5_dt_board_compat, MACHINE_END =20 @@ -41,6 +56,7 @@ static const char *const sama5_alt_dt_board_compat[] __in= itconst =3D { DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5") /* Maintainer: Atmel */ .init_machine =3D sama5_dt_device_init, + .init_early =3D sama5_secure_cache_init, .dt_compat =3D sama5_alt_dt_board_compat, .l2c_aux_mask =3D ~0UL, MACHINE_END @@ -60,6 +76,7 @@ static const char *const sama5d2_compat[] __initconst =3D= { DT_MACHINE_START(sama5d2, "Atmel SAMA5") /* Maintainer: Atmel */ .init_machine =3D sama5d2_init, + .init_early =3D sama5_secure_cache_init, .dt_compat =3D sama5d2_compat, .l2c_aux_mask =3D ~0UL, MACHINE_END --=20 2.36.1