From mboxrd@z Thu Jan 1 00:00:00 1970 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 AE611C79FB6 for ; Thu, 10 Sep 2026 01:07:38 +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=UQNC+nvpWvvv4IOn/ercxFTIOBsuBsKKyehq20FJmYU=; b=rTNvj7QgY0NJsh EFbe/IePwjKju+EAuZMrAfiqecj733j9bjzk0xx3bnUHHexh0rsUkXF5gDSgGxlirV0onC4z7ofdU LKY6q5bn8rFr2t6Gq+w/AfqcG9mNRVDWXXAap66BSTg4VASzTiZLYZ7ovbgzVCKQW1mivJrN7PEJ/ rFaNKvQ3BhX5niebWE6g6TVZBF+GOVBLEGj0FDg/7Kf282NVDOMAupCjceMPd1aVzogVh08+MtcjP KWfOEIzGWqAhg6ERJtHr/3myEVggIgnt4Sx+XdY1RGeAemKfIjdKUOr1+DzNYzAenDyzoqXQEzccc eobSvzcJDQ/SyRAoSF6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4TGA-0000000D9zz-1iZO; Thu, 10 Sep 2026 01:07:26 +0000 Received: from mail-norwayeastazon11013046.outbound.protection.outlook.com ([40.107.159.46] helo=OSPPR02CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4TG8-0000000D9yr-1MoG for linux-riscv@lists.infradead.org; Thu, 10 Sep 2026 01:07:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zF04ZuWWrI5Fsy9QLU42oG7VKYrjPQWtfVHw06hSxzv5O0br3QASSrAwSlb7PqQpanyeDp/xLzvvKwmGlAzADd2osfouWDOd8noOcwjDCH3TOkjFG/XHv5puqjDR50kO4CXFkWRxRWz5qAbfLbRpdbjvy6aJST7CgFUg00sBVDpHADN5K/eWXK0fgy0Dr8F3WMoBpe5TiAU8RVFtiDsmH3QyHsN8eWGIeCtcOkC+gniQZKX+QrrgCnnO3WqHy6vB5P1n1IBMMtXo/VP33WtLynK1WkIpBe9pM4ImI5CGhMZ4dh5CPIn0dV4Al2Bs21ktOaAATXqxM2pUkOB2k3nXTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D6y89+xMjeRtb8fCd6GgEbugywJry8uMqjJxY4/BrP8=; b=Ipv7zeq5Gj7dBmwwQfTkev+QF9F2BfK8kecMXrkdNUbFXAvm260gbmPbUo+MWGyWZ7elZEba4lbq/mwusecNqGOOweyIf12HIX1X/XFXcaazJrA/iCHura9jhLr3BsMHlwvEHUPWtgW6LGgU3TKr208rFE6+n9HXNUJHhGhXkkW2560dtvBoznca3ji6OUJvgkZyBJtg/Y3wO/LKAwma+fxOw5zIrxkTe5Aziyv/uVMxYjidZKQK7MYEAmddXrBRmPBJqy73CIDiMealGOxI/QDPtkmcQvb1uHZx/5p2INB20x4srM0Ux2B0nog7Kc7YfdWerxWgiQ9D3YAds4AGyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D6y89+xMjeRtb8fCd6GgEbugywJry8uMqjJxY4/BrP8=; b=loRZd+I3jt4nWgtCpGwpGhj2ukhi2AYF5uViT438xrg6LkuQ1ScOE/kvV5hjWq8eKPlX7y9uvZ4vIDOUet81wObwAiAYzstq272OHwjV2tXporWukpd4o74wc1/b3nalYUerKUssYRTaIcQdwOZd6ha9AC3NZ+A/n9yvw2j6pYnm05aFzyqpmiFXgu2/zHL4RmDZp2WUFcXwDcY02P4wbpXKFsbiHnMqRaUNE/tDovk2Egffa994513ZLmw+EWa3vZZUQi+o6pbFIt0zb3kr6MRqwzNTU2tejsoenbXiv9cUaeDRa+V70HwqydqTuETBuUYfW1IwUQ8OS3cK9bMxSA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA3PR04MB11203.eurprd04.prod.outlook.com (2603:10a6:102:4ab::13) by GV2PR04MB11739.eurprd04.prod.outlook.com (2603:10a6:150:2fc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.7; Thu, 10 Sep 2026 01:07:18 +0000 Received: from PA3PR04MB11203.eurprd04.prod.outlook.com ([fe80::80e9:ab1c:dbc4:6930]) by PA3PR04MB11203.eurprd04.prod.outlook.com ([fe80::80e9:ab1c:dbc4:6930%3]) with mapi id 15.21.0406.005; Thu, 10 Sep 2026 01:07:18 +0000 From: marouene.boubakri@oss.nxp.com To: Jens Wiklander , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jassi Brar , Jonathan Corbet Cc: Sumit Garg , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, Marouene Boubakri Subject: [RFC PATCH v1 2/6] tee: optee: select the SMC ABI conduit from the firmware node match data Date: Thu, 10 Sep 2026 03:20:53 +0200 Message-Id: <20260910012057.106966-3-marouene.boubakri@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260910012057.106966-1-marouene.boubakri@oss.nxp.com> References: <20260910012057.106966-1-marouene.boubakri@oss.nxp.com> X-ClientProxiedBy: PH8PR15CA0024.namprd15.prod.outlook.com (2603:10b6:510:2d2::9) To PA3PR04MB11203.eurprd04.prod.outlook.com (2603:10a6:102:4ab::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA3PR04MB11203:EE_|GV2PR04MB11739:EE_ X-MS-Office365-Filtering-Correlation-Id: a97823e2-7d59-4dfb-a47b-08df0ed7dbe4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|19092799006|366016|7416014|376014|23010399003|6133799003|18002099003|22082099003|56012099006|10067099003|5023799004|11063799006; X-Microsoft-Antispam-Message-Info: SN3Oy+vzIc929JLSzp5iIiTLOmcefY/CcpRrQlHOptrnuwIYjNxxirua8hyg7IYnJ1ceE16A59w1ZorDZcQtApw6WeqNTD4yWq6ZH98ZsoMoHayY5QOn9vARYRSUk0AjgQK52+5eeS+shT2zBJ5PBziyKdVOGZyiiI/mIoME1ynQaX5/VFeOB83+z5GmkzZ4/pLR58zdwEKpVUbemeggh/1L4EpCi7uTm7i99qY0nqaRyInkvByuOydGsT843YNvGuQ/l5OTgkEZqSyTS6YnMGFcTqeUiRQcRV/0c1SCSJIDWPlaNEl/yNN62zUDsmt6IPj8JwkUg0pJfVIhMsB6JHfrTSgpj1UX9YkDkBVh6AcUCg+VszlYVvXdtLRGjw9HaLnveyPJay8sb0576Amb37BFplarlgD6mtF1p2S4jg5CTCSNpeMoO4pp6GqzS5tW37+n5POfXEtMpKnbggRMh2N3ELlmI3rdOXSSQyn2SYd72392cHs9fIrdRcMNNYEFiWVy5tjmHDwh7AWSrcDaxGIJpkWsS9zpMGCZCPTatiqpjaxgfn8DIJQCym2n1UfKzCbtC5hGzq2eCL5ySF2fHFFyEIj6IAC8hFWLKsX6WXD7QvHhaI9AsIP+yKA+LHjpHuX8W33wymeDpH9ziYKUcP8rwFV0GJYg17Xc2dRb2i0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA3PR04MB11203.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(19092799006)(366016)(7416014)(376014)(23010399003)(6133799003)(18002099003)(22082099003)(56012099006)(10067099003)(5023799004)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?AbUrKUgc/VDZ7Rk6xYfFq5XDh0fxupF3GoWi1FID4oHzc2c0jbsLCT7jk7Vo?= =?us-ascii?Q?GMNpWFVBC1T+uv9VYqHJnjnJAqxgECabSOzHc0GXWUEu0I9iuywjF3GDpWgs?= =?us-ascii?Q?xbew6+54qbAco2Dh/4BS2/7thppajZRaFhAbO9nzH7b/RtLXdeG8lEDiIq0Q?= =?us-ascii?Q?VZyAQg5O12edNLv6QuCSHs0jgA5Usa6XpLvPOQRtBr4dezTxW0wcTV5+7Qql?= =?us-ascii?Q?g/JcyK/+CijZFi3+QgWU7Sd87i5azdFK76TECt/or1QQHsPqHKn3OxuJeCAS?= =?us-ascii?Q?ccwJt1OdHAafCxP7rOcWkJpL4ssSdwBYHlU8gfG68MaHhwSriyRWJKmAVO+O?= =?us-ascii?Q?knnG1EMobGLK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= =?us-ascii?Q?IpoqkJu7rOe7NLhMUFEQVq292pbQaVE52c5M9ojKUrURxnPgCgFaC0N+oZ5A?= =?us-ascii?Q?jeNJAhU22QoG9q6DqeUJmb89gJZgs9BeQGt9tCKTBgz6scyVzWk/IAhSTPth?= =?us-ascii?Q?AsDlX5DIQZrmJ0Sx0WzYTeHF4UJNKUzrTIcvUNuWwnWbLqG+BOdnrU2Z1mcH?= =?us-ascii?Q?mKuENT/uP88odKIUJ7BKHAuOhxl/QapNvB2S/saSxljBVLh8FcNj0HWgr+Cb?= =?us-ascii?Q?gjfxFeyHRmzghpV2CuNPlu1VLW8u74MoubvjhlonN+bWUrF6z3+qGz+AfH6b?= =?us-ascii?Q?wXNkgoPe4hF5jnpHyqLgtGkFx/2JqDm/YoaMWD5+hNRJssBkYBkIkQVyg0eJ?= =?us-ascii?Q?xpZsZ1kScTKHvYB+i8AyxRQ5lG+g41mgawOsqPWKdt/6Gr70b3/zO95biMin?= =?us-ascii?Q?nv+V3NNuWQoydmpgmpOOFHqJ7KFe63xldSH4PBX8iE6paD46182OWV1WJPow?= =?us-ascii?Q?nzGa6ne81DrEmwRoqg7PmCMybgu2TeH391SvfBVP6wvzE/QzKZcYEmZYY3oo?= X-MS-Exchange-AntiSpam-MessageData-1: 476KDskKwWZF9w== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a97823e2-7d59-4dfb-a47b-08df0ed7dbe4 X-MS-Exchange-CrossTenant-AuthSource: PA3PR04MB11203.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2026 01:07:18.0905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xl2Lj1hEe356kDfGWCn5s6plaLpg3EmSXTDgi6YTVSQsaztZo578yF7eAcVf3Jycj//Nxbo1/IRL7VCbEoWJYEQtzZUD6UbImuxFn+oXx2hkBENqUy/7WGePDA/C8plAi/XFgQXMap2lLkm85lIRsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR04MB11739 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260909_180724_372287_202F9D60 X-CRM114-Status: GOOD ( 16.96 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Marouene Boubakri The SMC ABI is defined in terms of register arguments and return values and does not depend on how they reach secure world: smc_abi.c already abstracts the conduit behind optee_invoke_fn, only its selection is hard-wired to the SMCCC "method" property of the "linaro,optee-tz" node. Introduce struct optee_smc_conduit carried by the match data of the firmware node, move the SMCCC specific wrappers and the "method" property parsing into the SMCCC conduit and build that conduit only when the architecture provides SMCCC (__arm_smccc_hvc() has no stub when CONFIG_HAVE_ARM_SMCCC is not set). This prepares for a conduit that carries the SMC ABI over RISC-V RPMI messages. No functional change on Arm. Signed-off-by: Marouene Boubakri --- drivers/tee/optee/smc_abi.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c index b8a2bdac3..221939f72 100644 --- a/drivers/tee/optee/smc_abi.c +++ b/drivers/tee/optee/smc_abi.c @@ -1464,6 +1464,20 @@ optee_config_shm_memremap(optee_invoke_fn *invoke_fn, void **memremaped_shm) return rc; } +/* + * struct optee_smc_conduit - conduit used to invoke the SMC ABI + * @init: probes the conduit and returns the function invoking the + * SMC ABI through it, or an ERR_PTR() on failure + * + * The SMC ABI is defined in terms of register arguments and return values + * (see optee_smc.h) but does not depend on how they reach secure world. A + * conduit is selected by the compatible string of the OP-TEE firmware node. + */ +struct optee_smc_conduit { + optee_invoke_fn *(*init)(struct device *dev); +}; + +#ifdef CONFIG_HAVE_ARM_SMCCC /* Simple wrapper functions to be able to use a function pointer */ static void optee_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3, @@ -1483,7 +1497,7 @@ static void optee_smccc_hvc(unsigned long a0, unsigned long a1, arm_smccc_hvc(a0, a1, a2, a3, a4, a5, a6, a7, res); } -static optee_invoke_fn *get_invoke_func(struct device *dev) +static optee_invoke_fn *optee_smccc_conduit_init(struct device *dev) { const char *method; @@ -1503,6 +1517,11 @@ static optee_invoke_fn *get_invoke_func(struct device *dev) return ERR_PTR(-EINVAL); } +static const struct optee_smc_conduit optee_smccc_conduit = { + .init = optee_smccc_conduit_init, +}; +#endif + /* optee_remove - Device Removal Routine * @pdev: platform device information struct * @@ -1728,6 +1747,7 @@ static int optee_protmem_pool_init(struct optee *optee) static int optee_probe(struct platform_device *pdev) { + const struct optee_smc_conduit *conduit; optee_invoke_fn *invoke_fn; struct tee_shm_pool *pool = ERR_PTR(-EINVAL); struct optee *optee = NULL; @@ -1741,7 +1761,11 @@ static int optee_probe(struct platform_device *pdev) u32 sec_caps; int rc; - invoke_fn = get_invoke_func(&pdev->dev); + conduit = device_get_match_data(&pdev->dev); + if (!conduit) + return -ENODEV; + + invoke_fn = conduit->init(&pdev->dev); if (IS_ERR(invoke_fn)) return PTR_ERR(invoke_fn); @@ -1956,7 +1980,9 @@ static int optee_probe(struct platform_device *pdev) } static const struct of_device_id optee_dt_match[] = { - { .compatible = "linaro,optee-tz" }, +#ifdef CONFIG_HAVE_ARM_SMCCC + { .compatible = "linaro,optee-tz", .data = &optee_smccc_conduit }, +#endif {}, }; MODULE_DEVICE_TABLE(of, optee_dt_match); -- 2.43.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv