From patchwork Mon Nov 20 13:21:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13461291 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 D3515C54E76 for ; Mon, 20 Nov 2023 13:22:32 +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: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=hdvjY1TSOfjQhOCkhPE+PodTZ/O3YKcUDMSrscRBdJg=; b=CDp7Hb8+dzp9nw oU4d5dmkXn9LQgVAjl10m1UmW+ITrckCs5Xh0KW3QnHGgcsp9/3jfnl7k9qHDazzuRZNDqsWp76A5 skUaiJb6ZiBUvUOMvwsAULVgE8ZY5q0rTU212f8w8PjVnFeB1fYlP57wGo7Ohczb7i2hb7gcdOTZ6 b5INYy0+sCea30BvdCw8hCnN0Mo5E7aa35HUfAxOw6uX81InZbuy759JvgWV56XeWMkvVjOFCtiVv poK6D7j55e9mkHCyqrvww9IEvb7bE4luaCLTu6ju++5bTV1qEo875BFpKY6P8JtukE7+Iu07Vz7so XtdR/3HEerV+VUpcLM/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r54DY-00C88W-0G; Mon, 20 Nov 2023 13:21:36 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r54DO-00C85H-1i for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 13:21:34 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c6b30aca06so53263951fa.3 for ; Mon, 20 Nov 2023 05:21:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700486484; x=1701091284; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=00OTe4FcAiUSuJtjqtOi8ICWSLOUIpkrYCIRO3OWRN0=; b=LYjpBWD1fKwutGgOhWsbjcmT4/wx4/Oc6h4qId08DD0uotvOu+m8D81ZAZ6ZoxllYK 1g5BrLmZfJQzvePjzXyi/Q8otDfl5XZFJHhJUm3wJdRUyLsWS411rjwoO5bwoSYyRwX/ W8OyaTRtKDUpa3p7KnntqmfN3VgtJfluX5csnUPIYTYkdPtYknmxBFRswGzs4LNZ4dXa myXqY6I4OsgTzncc92sxMFOHtb5CShSJmqDwzldrkc9L/XPDPBzhbHODY7Ksz6+uOemf 2b/ckhwkYxNtbARRK0az29+C/zRxymrlhK1REFwG0JyeWpxj7zU+SSWuW3JIftpUwnIO 3j+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700486484; x=1701091284; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=00OTe4FcAiUSuJtjqtOi8ICWSLOUIpkrYCIRO3OWRN0=; b=USGyX96q9CgX5evwxB1s/YL2sAHIhDiMGZAGJDuDp8UlpIEsZ1+Smzec4mLL2W9YTn b0jRXipsGyinvEr+mQkw5pwnWYVNhqQSePZInYAEciafsOmR0Ieq33U0SZhMeiwKDybw LDkfldwkVjiSm7gX5PYUO8S2+aCZ4jE+A6av/lX4cQ8hxpNB9GQbadyFHv+KK8xeFNOO sFWc2hq+WRT+VshFawSLNh/E6WQOYu2O+QQ89k0fAh0/0cXe0NAS+ghUQdrcfiubhHU1 +JJooDZxzsbk9cKaeoGB/57Zl7qIvR0G60jDtEc05Gx4eAFQ482fB8efqcMiQQ24MeoH gXmQ== X-Gm-Message-State: AOJu0YzFqWiKwzM0X7NQ1VPIMWI4QmX9d7DechEo6heS1tJzSy0x/1wz 0py+zQitkDlO3w60GquZV9MSWw== X-Google-Smtp-Source: AGHT+IFbk5UMJYvcMKicDTBiH72VTcok7g3HdKCzDToh3JFx1Lfx4PdPHkBdtNVRYifLz+n/vU90IA== X-Received: by 2002:a2e:4952:0:b0:2c5:1674:8d79 with SMTP id b18-20020a2e4952000000b002c516748d79mr4362140ljd.21.1700486483880; Mon, 20 Nov 2023 05:21:23 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:c590:a7ce:883:eba3]) by smtp.gmail.com with ESMTPSA id k18-20020a05600c0b5200b004065e235417sm17329192wmr.21.2023.11.20.05.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:21:22 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , Maximilian Luz , Alex Elder , Srini Kandagatla Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski Subject: [RESEND PATCH v5 00/12] arm64: qcom: add and enable SHM Bridge support Date: Mon, 20 Nov 2023 14:21:06 +0100 Message-Id: <20231120132118.30473-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_052126_857302_5104134A X-CRM114-Status: GOOD ( 18.06 ) 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 From: Bartosz Golaszewski Resending for the new release cycle. Dropped patches that were picked up and collected tags. --- This is pretty much another full rewrite of the SHM Bridge support series. After more on- and off-list discussions I think this time it will be close to the final thing though. We've established the need for using separate pools for SCM and QSEECOM as well as the upcoming scminvoke driver. It's also become clear that in order to be future-proof, the new allocator must be an abstraction layer of a higher level as the SHM Bridge will not be the only memory protection mechanism that we'll see upstream. Hence the rename to TrustZone Memory rather than SCM Memory allocator. Also to that end: the new allocator is its own module now and provides a Kconfig choice menu for selecting the mode of operation (currently default and SHM Bridge). Due to a high divergence from v2, I dropped all tags except for patch 1/15 which didn't change. Tested on sm8550 and sa8775p with the Inline Crypto Engine and remoteproc. v4 -> v5: - fix the return value from qcom_tzmem_init() if SHM Bridge is not supported - remove a comment that's no longer useful - collect tags v3 -> v4: - include linux/sizes.h for SZ_X macros - use dedicated RCU APIs to dereference radix tree slots - fix kerneldocs - fix the comment in patch 14/15: it's the hypervisor, not the TrustZone that creates the SHM bridge v2 -> v3: - restore pool management and use separate pools for different users - don't use the new allocator in qcom_scm_pas_init_image() as the TrustZone will create an SHM bridge for us here - rewrite the entire series again for most part v1 -> v2: - too many changes to list, it's a complete rewrite as explained above Bartosz Golaszewski (12): firmware: qcom: add a dedicated TrustZone buffer allocator firmware: qcom: scm: enable the TZ mem allocator firmware: qcom: scm: smc: switch to using the SCM allocator firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator firmware: qcom: scm: make qcom_scm_ice_set_key() use the TZ allocator firmware: qcom: scm: make qcom_scm_lmh_dcvsh() use the TZ allocator firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator firmware: qcom: qseecom: convert to using the TZ allocator firmware: qcom: scm: add support for SHM bridge operations firmware: qcom: tzmem: enable SHM Bridge support firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() arm64: defconfig: enable SHM Bridge support for the TZ memory allocator arch/arm64/configs/defconfig | 1 + drivers/firmware/qcom/Kconfig | 30 ++ drivers/firmware/qcom/Makefile | 1 + .../firmware/qcom/qcom_qseecom_uefisecapp.c | 261 +++++-------- drivers/firmware/qcom/qcom_scm-smc.c | 30 +- drivers/firmware/qcom/qcom_scm.c | 179 +++++---- drivers/firmware/qcom/qcom_scm.h | 6 + drivers/firmware/qcom/qcom_tzmem.c | 365 ++++++++++++++++++ drivers/firmware/qcom/qcom_tzmem.h | 13 + include/linux/firmware/qcom/qcom_qseecom.h | 4 +- include/linux/firmware/qcom/qcom_scm.h | 6 + include/linux/firmware/qcom/qcom_tzmem.h | 28 ++ 12 files changed, 669 insertions(+), 255 deletions(-) create mode 100644 drivers/firmware/qcom/qcom_tzmem.c create mode 100644 drivers/firmware/qcom/qcom_tzmem.h create mode 100644 include/linux/firmware/qcom/qcom_tzmem.h