From patchwork Thu Aug 19 11:06:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 499734 Delivered-To: patches@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp409886jab; Thu, 19 Aug 2021 04:07:07 -0700 (PDT) X-Received: by 2002:a05:6512:c12:: with SMTP id z18mr10486018lfu.354.1629371226983; Thu, 19 Aug 2021 04:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629371226; cv=none; d=google.com; s=arc-20160816; b=CCnBMmMejcyN/At/HYLpAcXk7287+qUh/9P0UqKBOeSzCmbcsWnrTSNF3BvjEzfyXG nlmK8Obe4dLncZWcJYmUMWsAZYKABPGHQx0aM4j0Abxvhu5RGY199VFH7omPGagmsGkC F3N4vT48QIrYEjECFkSRPqRMFDJFgQXQuKknYBju7U+r4xdwxPDi184bVNgNDmsEPVTB KXt5asYJGrVM0FdLx53tL/rB92vZG4GxxqiNcmPheMZ/ShsdQcr036nAIjLrgVY3qM43 KGyxXHMgEBbB+/0N27e7bINWjF3ElrIF54mXv16GnaRiM0v2iWnkDTeo2ChajjPhfmuY YvIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=yie52tZg+WqxHuYvBvKGgC8iU9Gb61t4ktqHyTP1FX8=; b=EgW15njeepS3jFFFoDg6MwNEyPGJhbH7yikAvhCvgT95pFcpZbCLlPGI54ZRKysjrV YDyueGcooOcExU8cvdb4Zqyqk+xMJ0FHJLMgVbIc73N194taxRWiRUc6Qs4NhyWsj2TF jon22J7JNpzA9xAebPGV8qTEYbC5dbl5E7iwjFxqXm4SJ6oQ16+L4Rl0z7X/kO7Ry9sf Jx8Js2+FixmAmfH/VmhHT/8sifCmL74QxZ5WbPnDkXr1b9tO29KSK/nd1R+0wojdoOnm 8DUfx5JBgIYax5GCf7y8BBoDymwy98AYWel7FQ6HeLq42HLpjVkhUQF9CmriQU+CTY+5 TYhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCq6Q3wG; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d24sor1313092ljl.72.2021.08.19.04.07.06 for (Google Transport Security); Thu, 19 Aug 2021 04:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCq6Q3wG; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yie52tZg+WqxHuYvBvKGgC8iU9Gb61t4ktqHyTP1FX8=; b=ZCq6Q3wGJTZgd7jKcUT62NlOPMkQM5DvJ4Ocenu9Df6lDUsQ7xiIxo/GN7vTT0xbYk xEAG/OHt/1Jb0U+EWC+sxIJTVHBiHt3hscm75aBXS47oBDstss5g0byzKyMPtDs2m7Lb ZSRWn/pY5rH4wWLxODdSygJmlvinpr5zNuBFlDIG6dZj91k/4iWVe1L88TnMtjEgeEtP sPeKmOb/JhCYFIdZjMpkCMd8/AA/1D43BDX1aZxYIlA1Z7pcuMZL7YXGNi1BB5p9UGkt KIbPliGSgE/lYysRkvd9aamZfKSPErQbXMbSfd5L7XGdgNeOyU/Lb95y0LNTu5Wc1kkS CniA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yie52tZg+WqxHuYvBvKGgC8iU9Gb61t4ktqHyTP1FX8=; b=gGWrt2jAikfTeN3z/m4pyrzhmb4jTsi7StrXlAALjRzIkyN3zzK/j8LH6j34t+EzsT 5qWU5OUcb+nl13Xr+uc3iS6vTFEEZ3MfQtaHS6b/c2QcNbzUDFliRZz30lh4TiXsqVLq ERNfDCXsuQ7v+8viGa+pWJruCUfU+FzQb180K2+WGqRjNdi1QeABhrpVBkGS3H1Ky5Hu f7s3uAwqs4CZbtHkVA8lXf8c5BmHRBhn9TQQhbkUL7VKVZSY9HyGyLpP+9oK18tHVif4 Xcvk5nGburvlBSOxmRhLSPDG6UOEKRxsuqinAn8k2DQq+3KU9FrCxiUDLVq95bpgLKG1 ZdnQ== X-Gm-Message-State: AOAM533iJFFVt7makYtsWnNNd8bYkKa63Bm4o6NI3Qo/PNBoO5OKmriN oQlj45eh9Go6kNAPyM5SrdUM7+ss X-Google-Smtp-Source: ABdhPJwu7laeWUKEpnEtwP3OfkEcYB1RqDLSEM45nF5toEDrqeA9cJYNPu+CBTwNvh0wbE/DwAv+lw== X-Received: by 2002:a2e:a288:: with SMTP id k8mr11447219lja.315.1629371226502; Thu, 19 Aug 2021 04:07:06 -0700 (PDT) Return-Path: Received: from jade.urgonet (h-94-254-48-165.A175.priv.bahnhof.se. [94.254.48.165]) by smtp.gmail.com with ESMTPSA id l19sm261131ljj.36.2021.08.19.04.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 04:07:06 -0700 (PDT) From: Jens Wiklander To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, op-tee@lists.trustedfirmware.org Cc: Sumit Garg , Sudeep Holla , Marc Bonnici , Jerome Forissier , sughosh.ganu@linaro.org, Jens Wiklander Subject: [PATCH v4 0/5] Add FF-A support in OP-TEE driver Date: Thu, 19 Aug 2021 13:06:50 +0200 Message-Id: <20210819110655.739318-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Hi all, This adds supports for the OP-TEE driver to communicate with secure world using FF-A [1] as transport. There is one change to the TEE subsystem with "tee: add sec_world_id to struct tee_shm" to add support for holding globally unique handle assigned by the FF-A. This is a field that I believe could useful for the AMDTEE driver too. For communication the OP-TEE message protocol is still used, but with a new type of memory reference, struct optee_msg_param_fmem, to carry the information needed by FF-A. The OP-TEE driver is refactored internally with to sets of callbacks, one for the old SMC based communication and another set with FF-A as transport. The functions relating to the SMC based ABI are moved to smc_abi.c while the FF-A based ABI is added in a ffa_abi.c. There is also a difference in how the drivers are instantiated. With the SMC based transport we have a platform driver, module_platform_driver(), today which we're keeping as is for this configuration. In a FF-A system we have a FF-A driver, module_ffa_driver(), instead. The OP-TEE driver can be compiled for both targets at the same time and it's up to runtime configuration (device tree or ACPI) to decide how it's initialized. Note that it's only the old SMC based driver instance that need device tree or ACPI to initialize. The FF-A based driver relies on the FF-A bus instead. This can be tested QEMU The repo for SPMC at S-EL1 retrieved by repo init -u https://github.com/jenswi-linaro/manifest.git -m qemu_v8.xml -b ffav4_spmc repo sync # Then checkout the branch optee_ffa_v4 from # git://git.linaro.org/people/jens.wiklander/linux-tee.git # in the linux directory To build do: cd build make toolchains make all To boot: make run-only Test with xtest, perhaps only with the command "xtest 1004" in case you're not interested in too many tests. Thanks, Jens [1] https://developer.arm.com/documentation/den0077/latest v3->v4: - Made a bit more RPC code common between the SMC and FF-A ABIs as requested by Sumit. - Replaced module_platform_driver() with module_init()/module_exit() as described in the commit "optee: isolate smc abi". - Applied Sumit's R-B for the commits "tee: add sec_world_id to struct tee_shm", "optee: simplify optee_release()", and "optee: refactor driver with internal callbacks" v2->v3: - Rebased on 5.14-rc2 which now have the FF-A patches merged - Fixed a couple bugs in optee_shm_register() and optee_shm_unregister() which where introduced in "optee: refactor driver with internal callbacks" in previous the version. - Separated SMC ABI specifics into smc_abi.c to keep it separated from the FF-A ABI functions as requested by Sumit. - Added the FF-A specifics in ffa_abi.c - Provided an implementation for optee_ffa_remove() v1->v2: - Rebased to the FF-A v7 patch - Fixed a couple of reports from kernel test robot Jens Wiklander (5): tee: add sec_world_id to struct tee_shm optee: simplify optee_release() optee: refactor driver with internal callbacks optee: isolate smc abi optee: add FF-A support drivers/tee/optee/Makefile | 7 +- drivers/tee/optee/call.c | 415 ++------- drivers/tee/optee/core.c | 685 ++------------- drivers/tee/optee/ffa_abi.c | 907 ++++++++++++++++++++ drivers/tee/optee/optee_ffa.h | 153 ++++ drivers/tee/optee/optee_msg.h | 27 +- drivers/tee/optee/optee_private.h | 162 +++- drivers/tee/optee/rpc.c | 236 +----- drivers/tee/optee/shm_pool.c | 89 -- drivers/tee/optee/shm_pool.h | 14 - drivers/tee/optee/smc_abi.c | 1299 +++++++++++++++++++++++++++++ include/linux/tee_drv.h | 7 +- 12 files changed, 2665 insertions(+), 1336 deletions(-) create mode 100644 drivers/tee/optee/ffa_abi.c create mode 100644 drivers/tee/optee/optee_ffa.h delete mode 100644 drivers/tee/optee/shm_pool.c delete mode 100644 drivers/tee/optee/shm_pool.h create mode 100644 drivers/tee/optee/smc_abi.c -- 2.31.1