From patchwork Wed Nov 3 09:02:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 12600435 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51087C433EF for ; Wed, 3 Nov 2021 09:04:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 217BB61101 for ; Wed, 3 Nov 2021 09:04:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 217BB61101 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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: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:In-Reply-To:References: List-Owner; bh=gi4pUGOAJpg6bRUs7qlcEZjoQaLfX72fpwp84/QgR/k=; b=4blm/AVpX1PYwE yoSnE+wIV11Tbr2c0kTnQ2f54qIpVaQRBn5tZJNVEnkstjKaKevWqNGzCgmki/zCeUYhooEKpkNeJ 9aGXhjda3DS5C1Nl+oqATCEz3yRP/GGpKxTsxwL85jIxRKJsSxytilkCEHFWEfiCFH0wB5LhPCOTq z582HxedZpdW8xr51xmrAfzkZFU5lmtK3EY12UZ0NdUI3qNIGx/eAy4VR2hiyaEZmp/I6hUV7lrPx S2/JMli8PnLwxthY4DNKnbwcCf2NzB4S3BEggFia0xOaW8eX7Jvhk93170wq8jNDt2ttUXsHdlN6c 9qR8vsS/PCLsalEZQZPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miCAy-004cYi-Qf; Wed, 03 Nov 2021 09:03:21 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miCAj-004cNY-5r for linux-arm-kernel@lists.infradead.org; Wed, 03 Nov 2021 09:03:07 +0000 Received: by mail-lj1-x232.google.com with SMTP id t11so2614170ljh.6 for ; Wed, 03 Nov 2021 02:03:02 -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=IOBd8zmaQ/o/1Os9BhWOC3FQNCJBCGeietUzMVOB0tg=; b=lkTCANroPPKqVJC2MHaOK86LkAxmqCcoPdzizhKQsu5FLX5GklvxDeJF36LAnEbriE /d0D/zPVKfsDXRgwEhutWoZmAA51U6dk3gI5+u9Lv3F0VUsAHP3Xv6RVDqszdo5BAoI1 JyoHV7aHz2FclXZTqCpT1XmaI2aQbjBVX7IWMqUmOELfd4xCE95fU/YAOAnnFLaB8Vou qoW0LDe3srMyajm/2DrskM/J8/+Zyp+W9tkYBxloCHJHnbiFEx3Sh/zw6ehmn8mjV3ED jrSVMvnb93+jMNWRO/u+Gmse7D47hIk5dz4ytn6rByjj/ZLKlnTfmVppPx4KWIcV1O42 P8kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IOBd8zmaQ/o/1Os9BhWOC3FQNCJBCGeietUzMVOB0tg=; b=xAc8aO0R2SpWfFLGB+XN9ejf+W1/yH7HY20YeH2SR8dZ0sgAc6kZtWYcT4I7n2hg+7 DB07SNjjR1HJk3CPMsneVkSV4n7Zbz2hbve6HdyCxDFpdAoxef6wVUIemYySEycrUQyB 7V65DBvw4/YrBlNGX/4b89bnGuhyjEJRE6Mi3vIQvCWSjNXeEPUDhgOWANtLTze9NvOE /dA/T10k4jhQzDWZ+W564e1RtRpt9RWUKYNso8OQhFqHAGxI6Di4Cv+LffTqCnw/hayK OETTpeYv3aEzoQl4eAC9+TAHUVQKpTyLpHhRVqbexqcjotpWC6ALDj+6UEAmlrSiU7c7 FLxw== X-Gm-Message-State: AOAM533rZXQusYhx4a3XUvhfZAPBwXLAos1isS4auqPmB3qxIeOhxcth 0yGJW5/NxywOL1bgU0bjTYq4qQ== X-Google-Smtp-Source: ABdhPJw1zrzgQqG3DycM6ORsIoM0D4GUG1DpG6pE6I48Ta4qjxKuttUcAyk2hbAKXaylJrPkGpV71w== X-Received: by 2002:a2e:a5c8:: with SMTP id n8mr43739989ljp.307.1635930181221; Wed, 03 Nov 2021 02:03:01 -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 w16sm124373lfr.233.2021.11.03.02.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 02:03:00 -0700 (PDT) From: Jens Wiklander To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, op-tee@lists.trustedfirmware.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Cc: Jerome Forissier , Etienne Carriere , Sumit Garg , Vincent Guittot , Rob Herring , Jonathan Corbet , Ard Biesheuvel , Marc Zyngier , jens.vankeirsbilck@kuleuven.be, Jens Wiklander Subject: [PATCH v8 0/6] Asynchronous notifications from secure world Date: Wed, 3 Nov 2021 10:02:49 +0100 Message-Id: <20211103090255.998070-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211103_020305_279578_4D84D006 X-CRM114-Status: GOOD ( 19.69 ) 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 Hi all, This adds support for asynchronous notifications from OP-TEE in secure world to the OP-TEE driver. This allows a design with a top half and bottom half type of driver where the top half runs in secure interrupt context and a notifications tells normal world to schedule a yielding call to do the bottom half processing. An edge-triggered interrupt is used to notify the driver that there are asynchronous notifications pending. Only the SMC based ABI of the OP-TEE driver gains asynchronous notifications. Future support for asynchronous notifications in the FF-A based ABI will rely on APIs which are expected to be provided by the FF-A driver in a not too distant future. This patchset is also available at https://git.linaro.org/people/jens.wiklander/linux-tee.git/log/?h=async_notif_v8 v7->v8: * Fixed an error in "dt-bindings: arm: optee: add interrupt property" reported by Rob's bot. * "optee: add asynchronous notifications": - Fixed a few spell errors in comments - Added a missing optee_unregister_devices() in the cleanup path of optee_probe(). - Added Sumit's Reviewed-by v6->v7: * Rebased on 4615e5a34b95 ("optee: add FF-A support") in https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git with 34f3c67b8178 ("optee: smc_abi.c: add missing #include ") cherry-picked on top. This allows to resolve the conflicts with pull request "[GIT PULL] OP-TEE FF-A for V5.16" * Factored out the interrupt handling added in "optee: add asynchronous notifications" to only go into smb_abi.c. A different approach is expected with FF-A once it has asynchronous notifications. * Addressed review comments from Sumit Garg: - Replaced 0 and 1 with the macros GIC_SPI and IRQ_TYPE_EDGE_RISING in the example in the bindings. - Replaced the magic number to optee_notif_init() with OPTEE_DEFAULT_MAX_NOTIF_VALUE in the commit "optee: separate notification functions" - Switched back to tagged error path in optee_probe() - Fixed a few nits in "optee: add asynchronous notifications" - Applied Sumit's Reviewed-by on all commits but the last, "optee: add asynchronous notifications" v5->v6: * Rebased on v5.15-rc2 * Replaced "tee: add tee_dev_open_helper() primitive" with "tee: export teedev_open() and teedev_close_context()" since it turned out that the normal teedev functions could be used instead as noted by Sumit. * Changed "optee: add asynchronous notifications" to use the exported teedev_open() and teedev_close_context() functions instead. v4->v5: * Rebased on v5.14-rc7 * Updated documentation to clarify that one interrupt may represent multiple notifications as requested. * Applied Marc's and Rob's tags v3->v4: * Clarfied the expected type of interrypt is edge-triggered, both in the normal documentation and in the DT bindings as requested. v2->v3: * Rebased on v5.14-rc2 which made the patch "dt-bindings: arm: Convert optee binding to json-schema" from the V2 patch set obsolete. * Applied Ard's Acked-by on "optee: add asynchronous notifications" v1->v2: * Added documentation * Converted optee bindings to json-schema and added interrupt property * Configure notification interrupt from DT instead of getting it from secure world, suggested by Ard Biesheuvel . Thanks, Jens Jens Wiklander (6): docs: staging/tee.rst: add a section on OP-TEE notifications dt-bindings: arm: optee: add interrupt property tee: fix put order in teedev_close_context() tee: export teedev_open() and teedev_close_context() optee: separate notification functions optee: add asynchronous notifications .../arm/firmware/linaro,optee-tz.yaml | 8 + Documentation/staging/tee.rst | 30 +++ drivers/tee/optee/Makefile | 1 + drivers/tee/optee/core.c | 2 +- drivers/tee/optee/ffa_abi.c | 6 +- drivers/tee/optee/notif.c | 125 +++++++++ drivers/tee/optee/optee_msg.h | 9 + drivers/tee/optee/optee_private.h | 28 +- drivers/tee/optee/optee_rpc_cmd.h | 31 ++- drivers/tee/optee/optee_smc.h | 75 +++++- drivers/tee/optee/rpc.c | 71 +----- drivers/tee/optee/smc_abi.c | 241 +++++++++++++++--- drivers/tee/tee_core.c | 10 +- include/linux/tee_drv.h | 14 + 14 files changed, 525 insertions(+), 126 deletions(-) create mode 100644 drivers/tee/optee/notif.c