Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2211260rdb; Mon, 20 Nov 2023 05:23:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IG95/4FkYjylqpHFCCExkhlaYSxJChPlJTyblw9xPH/MW8WOt7BR48Y2xNf6RE8LcaXBeHB X-Received: by 2002:a17:903:41cc:b0:1cc:32ae:4afd with SMTP id u12-20020a17090341cc00b001cc32ae4afdmr6500823ple.46.1700486611937; Mon, 20 Nov 2023 05:23:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700486611; cv=none; d=google.com; s=arc-20160816; b=oJ6qr6JDMM69/3NID3wUR587TmTbdomSAQgDenMNPJgZXDxOFKzhKxWjYbeV5nQGAy bIelKZSoZ7l88Grob+G71I8U2dtUw6aIIROLrAVMpkIe0J50hvXw9szTqqhByR/SIbl+ qSD8NkAwI7l9z7JTwIQZEt/SC8liYIptV4XaGfOWtGIRCEbak8jWDEjRabZqMPJrQnlb +IEZMbDUVSGfbXHiR+f7w2wySalCy74Ss5sjJ5Gi4KXtEots7pbOZTOGOqXvV1QkhQRs +zVcmLVLwE2VIM49bTDOsX/ldSPr+WRXoW+fSXaN4Zpweh4j+WHSqNGbJ9sGOD61Wr2e ftxw== 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=00OTe4FcAiUSuJtjqtOi8ICWSLOUIpkrYCIRO3OWRN0=; fh=lirm1ccAeXZZB1cIo+N1DqklpgcFmD/vJ7PCWNIL0HU=; b=jIlrKLt/hYR9QX0ZtyDe65aptjH/6Nlq8RDDi7W+merBY5visWxc1ErpFQdYG/OPMr j45XVlqJuqlOR8NkNgqHjBhfhY1IMBo807+8JkGqgUnRj471aLJwFWgWEOD0oXX/RbZ4 r8xcTbGGziOay76vVkBNZ05j1nd/qpSblQ3nVP5y32BhyAi1c0rnUTKUzkEY1dBJScOR yZs8xvjYoFTL9oWWXlmWlC3T0240+8gAbL73/fRQgFXpitEMbHvpXzCSFuL2xkCNItA0 AnrzXEkwcv25Ds2fK31NiChoqNGltAdvOj+9GhnMf/IYfvISMD02vQhDu7eA1gbBAR0D L3LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=nMtzf7Mx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d7-20020a170903230700b001c5f80bf574si6053413plh.487.2023.11.20.05.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:23:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=nMtzf7Mx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2E8C280702CD; Mon, 20 Nov 2023 05:21:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbjKTNVb (ORCPT + 99 others); Mon, 20 Nov 2023 08:21:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjKTNVa (ORCPT ); Mon, 20 Nov 2023 08:21:30 -0500 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 D80C7129 for ; Mon, 20 Nov 2023 05:21:25 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c4fdf94666so53232261fa.2 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=vger.kernel.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=nMtzf7MxkfPbqkFXNHelq2fV90g4ROA7zUupJLYZgAVEmpaq71JMfmjD8A39LLA72x olGIKBzHFzOfs1YzZLX/t9Xb/lq9DadoVTQjkL98QisA0iLmx3VHK+12DMSLKaC/yiOR lKpjIxIOdZFSD7npns6LZXnSohNUlg3I6PGPhRXNfeTHpg1QPIKIKMmwCrKT3yKtymgL rdB3FG+S24Gp4sxElSZRjexLYQs7XYw3DVkMeGsjCKsO7RVW+SIPESc1OYfgGWH3bP5o G0utyyQJ+4EhpuM4UZ3Z3s6xoM16b3XYBVMHXPKvE1s6B2aUReFuiZXP0jLZb1WdVvHf 6UYw== 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=tfJfB8WIp5bRUk67HXT1mGySgIbb2JhAD0xq+/8/U0fJM+zUE4VLb0AH97FV2UB2ir QPW/h2s0zU6PYcUmcQVJwU7DQY7DMcf3WSHDFZcImWYxi/RBOc6zqN5wRPeCIEP1VzSt ka33n+/Guy/d/jrC9yzW+YiMAKAMXthO/V1muKWe2KxUuq2cYEtKOo28pQ9S2V4sSviR r+AiOxOxbpKR4DdCQxSrCwtlzvhZwt4SeI2P4x+hlgwiXBew7mA1K9/Wc0Qe0La2BnCv vhSjQhstlEkQG3ZZgg7kAzWOtFF/UiACsNejK3PlwvSyV7YADErQ5aFpsE8cVSA8/CXv Zirw== X-Gm-Message-State: AOJu0YyVYmKIsqtUoM1/IlljPbtmNJbNiY0tqPCFilIipsjnhOePeMJ6 +p2jBKO9BByWmSg51UhdLBSA29ssNzI+OQqyork= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 05:21:48 -0800 (PST) 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 -- 2.40.1