Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp470262pxb; Thu, 19 Aug 2021 04:08:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuyAu0fIIcf9AwbYhZKx9cMlLFADZAhmjenXJp4ci16fATUi3RkJLZtkZ5syvoMRolR02m X-Received: by 2002:a92:6711:: with SMTP id b17mr9541048ilc.122.1629371285638; Thu, 19 Aug 2021 04:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629371285; cv=none; d=google.com; s=arc-20160816; b=zmdeMy4x4wqmAM4whrSwe6KAR43U2ajCFzXOm7cYFUhrfcOe0237bvB2mRIzCv6+FS EIQJMI9wIsb48V05fwuDm8I7dMIUUZW5ZIcMzNAgwjuOI3pdWDhu23v7g9JbFqVLyvf2 FyFmgQWWQGijOPRBjQ/sC4s3ZhL26U4tiMAPu7hwfQariXEEZjdKEl+SGR2p72QoQHge fvtah07t6Gl4NrBKdiN99GqS7P71p/QlLsWSJhqvqCrsFvxgOrbUxOR3o2SnXzbXX+RJ O4euaTpsorS0wYWbmqMcp49LsAgNYnIWxDbx3h0jmJ6pFEAxzEZWU6sPrztbu4gnd0za MEUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yie52tZg+WqxHuYvBvKGgC8iU9Gb61t4ktqHyTP1FX8=; b=ty9ZPP2ZbKX01LQZ86borfLa/foYfiwxl3ifyTaaMv/FPYZLyK0Hsx27ld/F1cDsjt MRiXW9V/DIn/68arkpnVc/E7/mqeSitDcTBAGBdzuNqujFK94olWuP4rhbCyrETG9GG9 ZYW06rbWmBIRG227YC/+CBnep2FLMZ9LAnhVVtTxPNRbiYlIvdOG9cxfdaFMUQpmCFNL B6QEtbTnEyBSWYL3kcdnxDGxGnIDk0O3z5CVxFaVq/DPIZIrkwnYF8DywcU2QyS8FCIk vNaLI1I8QtYdaQwwwqbNSckI8QVukQych5Gqp6/Fxsm3DrBur4FSxpqJouHJN7/e19qT 1YDA== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si2422404jaj.115.2021.08.19.04.07.52; Thu, 19 Aug 2021 04:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCq6Q3wG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238052AbhHSLHp (ORCPT + 99 others); Thu, 19 Aug 2021 07:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236149AbhHSLHo (ORCPT ); Thu, 19 Aug 2021 07:07:44 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F31CC061575 for ; Thu, 19 Aug 2021 04:07:08 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id s3so10813415ljp.11 for ; Thu, 19 Aug 2021 04:07:08 -0700 (PDT) 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=VvVfgMO+kWDPe24lESXMuc5wDM4sFDVr40uCVFkFiehs5WXzm7YLlIDMPCNbw1L5qc hF5VYcoQpjTf+xXVVQO6j981bbS0APNPFD3JqVPyiFPvGdgPpqdOjgiWjvwYFHM5BfhJ 5ga0jhpFSSQ8341J3lPh8TOzuL9Vux1XVZrDSPunnaZXZ2lIxgHnZVccXUpuhqUIj7C1 Egy+HqwyeVlJGbItFm7KpChJyHN9AeyYCPNR5QGluxUjM2Q4ey7cswZXLoJ2679942hn Bph+6FJOhbWseqNhJHqFrrdTXDUZu35hqMm9hg8z7mh77NfyoOGrU4FN/hee9bfg9ebN prLw== X-Gm-Message-State: AOAM532Jua8J3qyzhBQoebbmRGzD7tciWsaR6+VyqQYezTA8gRn3YEAs FHJsRkE1skQvLQb0oVUapjCiaSjabOMGtg== X-Received: by 2002:a2e:a288:: with SMTP id k8mr11447219lja.315.1629371226502; Thu, 19 Aug 2021 04:07:06 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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