From patchwork Fri Oct 13 11:48:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420784 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 83F7ECDB482 for ; Fri, 13 Oct 2023 11:49:35 +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=XX5k+Y2HYBIF1Xq/6XqX6CCtTby4S+JKOEn2r3wLi+o=; b=hu8dDJadksSr3j rsfVQpto+AvfB6kqpkwkD2W5P2O5RGUAJEjUnveFtme7/hWpVsHnbr+EAhl7luyOd1MCFvQT5+W12 XZXiZaLzP9x0MouHwzTzEonIgAqZgBMJI1ifVpoMj5UArgwfQjsXQnCKr6l3q0NICvGpGNJ7MGFe6 M0n77548uP/NSX5FMy21bhQ4H01+wzUaHc64jFM58J5zaHI0JS+Q/8yYNVNShF4js/gjahEirW4TF NfNrJ4V3OzYLiilcVMAqhSstNcHzxGCYRnGfJ7s0PCddRIQEs04l+Ku3Soj6spYSzLjurjtupY7SB UHSWGWy52qXcOmIlfLeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfC-003LV8-2B; Fri, 13 Oct 2023 11:49:06 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf4-003LOy-0R for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:48:59 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-405497850dbso20764405e9.0 for ; Fri, 13 Oct 2023 04:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197733; x=1697802533; 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=2gi1dKzgbLyY2SGQKC/6ay+pgQCsg2LD4vhB0IMddqs=; b=A71jm2A1BNfh4M9vrmPojNGEV64rHiEeum7TPCGH03CaFvzKgIxPWJPitC/y1nilQs TKm5gT1kwJByM8IgJ3servoqVVsRgwXfQTrBTyCOrhvnFc1BPXsqmq5jL/VZK0naw0g6 XPFT/AMA2/bheS3CeyZrD6WdUBWwdyP9cNkKxPLKeBqA0B0rw7Y/4FQLgYjM5C1XyL9r h7fm4mSCQqAd8IxUp37cjJ3Y5R7n5RQSYPAxXZVxb+PJXFzNL/Y+cnG+sA3HLTIpZS0/ Bx0UO8Zk5ydAKlufjxQBBSmLCD1W7Pd7y0xByh3mYo/ZA/0erE9tfD+6npvZowfRxm6f Cj3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197733; x=1697802533; 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=2gi1dKzgbLyY2SGQKC/6ay+pgQCsg2LD4vhB0IMddqs=; b=auvU30fiPQqe+cKQZ4n3nV2rXEMrD3AooUWOGhpTDtV45w2RN3eGB2pd0zy7YsppFS RvcpX7s4c9bb1jldEnZL7IQDLovTHkDQQnkPJJBHzbg5HTgCrox+dwL+qk7u00gdD00q 0ZHWHMffRUa6gZ7ax9DmjdHnVx0MyymI+5XNp70qKIbYn9I1qryGx0QUsshbbnRqjNNF ytO0uOw1kdI7ElNFXsXo7okRlRr22gOmVnylIg14PqFSgdymX//FYrOZBXyG1JVML6ni 3XknQWdAf5UBTZ79mhPuwSrjC8fZpCV+qheOZnhIvNGEslZABW3hZT8XImlIgV9Mn8eF uoig== X-Gm-Message-State: AOJu0Yz5pa0bzRi2wtzKCj3wKVYe1jlK8WQ8RhF0lUGTVZFvxPn3W9Vd EHBLtYviXBBT21CvK2NBz2yN7A== X-Google-Smtp-Source: AGHT+IFWbMSJLaS2e62akmpbNVQl02Sa0VSNKRFr/iE/hQFrd9xJFWfWuGkaE7IwS+onu+pa4TFjGg== X-Received: by 2002:adf:f28b:0:b0:321:67f4:8bd7 with SMTP id k11-20020adff28b000000b0032167f48bd7mr22133317wro.32.1697197732611; Fri, 13 Oct 2023 04:48:52 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48:52 -0700 (PDT) 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: [PATCH v4 00/15] arm64: qcom: add and enable SHM Bridge support Date: Fri, 13 Oct 2023 13:48:28 +0200 Message-Id: <20231013114843.63205-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044858_174945_E53299C0 X-CRM114-Status: GOOD ( 18.04 ) 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 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. 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 (15): firmware: qcom: move Qualcomm code into its own directory firmware: qcom: scm: add a missing forward declaration for struct device firmware: qcom: scm: remove unneeded 'extern' specifiers 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 MAINTAINERS | 4 +- arch/arm64/configs/defconfig | 1 + drivers/firmware/Kconfig | 48 +-- drivers/firmware/Makefile | 5 +- drivers/firmware/qcom/Kconfig | 86 +++++ drivers/firmware/qcom/Makefile | 10 + drivers/firmware/{ => qcom}/qcom_qseecom.c | 0 .../{ => qcom}/qcom_qseecom_uefisecapp.c | 261 +++++-------- drivers/firmware/{ => qcom}/qcom_scm-legacy.c | 0 drivers/firmware/{ => qcom}/qcom_scm-smc.c | 28 +- drivers/firmware/{ => qcom}/qcom_scm.c | 179 +++++---- drivers/firmware/{ => qcom}/qcom_scm.h | 21 +- 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 ++ 17 files changed, 746 insertions(+), 313 deletions(-) create mode 100644 drivers/firmware/qcom/Kconfig create mode 100644 drivers/firmware/qcom/Makefile rename drivers/firmware/{ => qcom}/qcom_qseecom.c (100%) rename drivers/firmware/{ => qcom}/qcom_qseecom_uefisecapp.c (84%) rename drivers/firmware/{ => qcom}/qcom_scm-legacy.c (100%) rename drivers/firmware/{ => qcom}/qcom_scm-smc.c (91%) rename drivers/firmware/{ => qcom}/qcom_scm.c (93%) rename drivers/firmware/{ => qcom}/qcom_scm.h (88%) 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 Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s