From patchwork Wed Oct 6 07:15:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 12538769 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 DD5BEC433F5 for ; Wed, 6 Oct 2021 07:18:21 +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 B119F61100 for ; Wed, 6 Oct 2021 07:18:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B119F61100 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=HIE36G3QyalVzbyJgP8SKARFrJaH4rZw+udLEyxNQiE=; b=WVgqx9FWhznouy 7A4lTKqQIR1Zn7NdHxwHrDpOf6hBe3T1MrltVnwk0tV2TWQu2NN3TaXYY8ULaqo3r+rY7lYqxTT0W eZEZVaHtew/lcJ2Vtty4R5O6M0Mf1se9a/vZcZ/YuG4Bggs17u10UOcdTNwm/F5gSxGkb5ciGWqnt hOazkSlw8cTKc+kbDcpWk+9QD5C2Ac3xWKQuJUQ7+dLdkMmkiZ+Eb5eEvqbqT+hAg4DFEZ1VASFRs DgqXQmvI0hlnohRhJI9kzt8ed2wHUUHfid7wISFwdC77WUTHAK0BwHKr8zy/K8zQrU5WzK2+zgbhm wRYSZdXC8y+dsMCaJMWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mY19p-00DAXF-Cy; Wed, 06 Oct 2021 07:16:05 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mY19i-00DAVY-BZ for linux-arm-kernel@lists.infradead.org; Wed, 06 Oct 2021 07:15:59 +0000 Received: by mail-lf1-x129.google.com with SMTP id i4so6399217lfv.4 for ; Wed, 06 Oct 2021 00:15:57 -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=AKrh6jeg1+D2CUT4DyWcA9w76ozKBLfI8b6gpIDDpCY=; b=jlvFw1VyiUIGeXyBbQ9knQIXcxkL5XR1d87HM6bU+T3TKIwdXnnumNjfeQaX1d878T svv3scwdLS4dmAva4UIVS5EK12PD74qGcJ652OscGWQNjBkuAhLvcdubUBVqPWpiC3VI jhCmorePoM8uiIS2+Cu6GdwuJcx1eCQ9hpHMNsyi4arUZbX2dCNVCm3/cbkH4f8hDrGa 7Dlf6EqmJ+v6doctL4CnV4sN6f8We+sz5hu6w/zdGmU+YUbXKpWyJoQ+ZfIIY9YzN2br iE/CQRmOgCbFlFOzyF6uRhd3BEV1iJp+OKQUIqi2lkWSk6jlXgYeraLdeSBPkuCyPp1H d5FQ== 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=AKrh6jeg1+D2CUT4DyWcA9w76ozKBLfI8b6gpIDDpCY=; b=nbvMC02moG3OSqKMvGPXlbNCa8Hw2OJ1oZjg22gvY345ABPe2tO+3Ff/qHQdb299r4 2W4Sld5+v3iVbrZJYFLtK76UC+5n/iZfEV+q4oiFSXCdeN8p64RJhxFSleQJwlKC+VmN pRuuHzKNf6ILsnLy4luoSTBv4oFuCXVPYWXfVCqkVNW1I4Z9mTSEOK1jg1yaAStrVnMa XulZi4bEsvQcB5t80lgWm0Od9WmW4/mNrUofz2+D83XXM+FgiBh1CIpMygmBvwJaWYlq PgUehM2fxeuLEoMOoxmFY+GHptyJmfq/npBpNoxF/ielSGb+d+apJsUhwIbStkLOasDf FfNw== X-Gm-Message-State: AOAM5301s6tzmpP/ZQsXLtWG3Lx1cVRdPo00uflbeWkV+b9gtYAFT8E/ OGwF+/G3zNUePi13sWGQrZgO4w== X-Google-Smtp-Source: ABdhPJxX+Sqcew6GyVwEuZ8oDl53IzGhaBx4xrF1wNs0tSxodxjwllEsfBZ5NsFHcMMU+iWWjE3zCQ== X-Received: by 2002:a05:651c:1039:: with SMTP id w25mr26709368ljm.440.1633504556692; Wed, 06 Oct 2021 00:15:56 -0700 (PDT) Received: from jade.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y7sm960376lfk.143.2021.10.06.00.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 00:15:56 -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 Wiklander Subject: [PATCH v6 0/6] Asynchronous notifications from secure world Date: Wed, 6 Oct 2021 09:15:40 +0200 Message-Id: <20211006071546.2540920-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-20211006_001558_422853_4861960B X-CRM114-Status: GOOD ( 14.95 ) 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. The documentation and DT bindings patches are now well reviewed, but the patches with code would do with some more attention. 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 | 7 + Documentation/staging/tee.rst | 30 +++ drivers/tee/optee/Makefile | 1 + drivers/tee/optee/call.c | 27 +++ drivers/tee/optee/core.c | 87 +++++-- drivers/tee/optee/notif.c | 226 ++++++++++++++++++ drivers/tee/optee/optee_msg.h | 9 + drivers/tee/optee/optee_private.h | 23 +- drivers/tee/optee/optee_rpc_cmd.h | 31 +-- drivers/tee/optee/optee_smc.h | 75 +++++- drivers/tee/optee/rpc.c | 73 +----- drivers/tee/tee_core.c | 10 +- include/linux/tee_drv.h | 14 ++ 13 files changed, 496 insertions(+), 117 deletions(-) create mode 100644 drivers/tee/optee/notif.c