From patchwork Tue Oct 17 09:27:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13424904 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 595ABCDB482 for ; Tue, 17 Oct 2023 09:28:48 +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:References:In-Reply-To: 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: List-Owner; bh=IbGHoXEQQWoGlYBNT+5nQGBkU8DavJiIGxXksvNw/d0=; b=wRYBwbqt/s3Vnp k7QNOvx1CFSo3PBJ83HnGeyK7HznKk24ASR6hnfqOVKG8OyGJX+lPt7iGTtahF1ltb0R6bUwvL02I tPCTBdFcIHVXch0eWDC5TVbaT6LcUamKWXBQtIDU7W8pwA75D4A0b1LGjO/1ohETg4vyxq9abTISY 6jANuCWHdvT5ug9XBTXkwt/1AOdQ312Y+B4nPzc0DtzoY2Vu64sg9Ze9CkSwcIQ72uma466gFnMVk Fakp2dt8GpiVbXnPF1bc78zlBe26z6+w96Fnw+vDP27dcwYD0IFQC4XZQdiZhPd3rp/liWfjN7/j+ SsPx6taqSwX2E1uTPSvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsgN6-00BoYu-2B; Tue, 17 Oct 2023 09:28:16 +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 1qsgMp-00BoM7-28 for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2023 09:28:00 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40572aeb73cso54389275e9.3 for ; Tue, 17 Oct 2023 02:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697534876; x=1698139676; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TRiqTWR7MnlroI7LNrhzEhXqnAUPFNJNh2JMipiQfFk=; b=fICGg3BfQXumOoU7+QDhC0MNToyvBGAzjD2BYszpOKS1ZPHLjMXKNhnbhPBqZ7Wd9A lRpL7mp6jO2VjslshXTZEP025BrWtvdg5C97aK3UbG6eNE+yVoNk+HaYSOG7d958X9IU antyYblhlj/OWcnymGELMZUBn3C48PcHbizwzR20JkLAZf2jfuX6YAb6b4XekvSVGidM yFRDZrjWoqO1Lu7kFSQJBkA9ceaOO3v6iKpISio+AiyZPfbxTSBUhMRIdKXt+P0/eq47 FJ25qpu/SEIuv/g88xyLYml0FcnRMBrFuigi6BVWTbi7E0dToeQFMVP58W8cR+ZAWuvf fHdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697534876; x=1698139676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TRiqTWR7MnlroI7LNrhzEhXqnAUPFNJNh2JMipiQfFk=; b=llpZ2LIbHiZ5AWLyTFDG3HRtVg/XoVrl40hKZz4NqETRRHynDIZjraPEsc4QFxoMr0 1/D/F+3mMgjvLqYBF6ufxJa37/W1j73CJfdxQJP+36A1Enioe7CfqXaxkMz2lZmWz3YY L/Ayc2t+lbwP398v5kuBibCa2J7DWZ1bgHHLWhz1H/hCONXVNj6u8glu5Q2fPAdT4oJ+ NVIy+Hlz0RwirL3gtJTCn7IJfa13dqxHt5qWTUavfZ2h8+TN/EAQ4nVwWpr2YeAsufN1 XPlqVS4LmFq2ba+0piOGKniOmGwwB+lxZ72QYLA7Uu6yMMxtSjpyKzuNwokZsov9OEBk Riyg== X-Gm-Message-State: AOJu0Yx2BiWCRYZ65SEaNMhFA0dnxmD8zUaQIWYNmX43GPKlIIqA+SSE eg/hV0hXabT2vvdrTe3C0OlK3Q== X-Google-Smtp-Source: AGHT+IGjspsLXt3H2qeoIgJzZ6DxWYAR62nF3gpeS0HTcDZVahX430zrbmWpRwlot6FZMDHGBE9/TA== X-Received: by 2002:a05:600c:4f02:b0:401:a0b1:aef6 with SMTP id l2-20020a05600c4f0200b00401a0b1aef6mr1409569wmq.2.1697534875913; Tue, 17 Oct 2023 02:27:55 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f1ee:b000:ce90:ed14]) by smtp.gmail.com with ESMTPSA id j5-20020a05600c1c0500b003fe1c332810sm9460787wms.33.2023.10.17.02.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:27:55 -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 v5 14/15] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Tue, 17 Oct 2023 11:27:31 +0200 Message-Id: <20231017092732.19983-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017092732.19983-1-brgl@bgdev.pl> References: <20231017092732.19983-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231017_022759_699232_AF5DFC4C X-CRM114-Status: GOOD ( 13.58 ) 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 The "memory protection" mechanism mentioned in the comment is the SHM Bridge. This is also the reason why we do not convert this call to using the TZ memory allocator. Signed-off-by: Bartosz Golaszewski Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s --- drivers/firmware/qcom/qcom_scm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 839773270a21..7ba5cff6e4e7 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -563,9 +563,13 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size, struct qcom_scm_res res; /* - * During the scm call memory protection will be enabled for the meta - * data blob, so make sure it's physically contiguous, 4K aligned and - * non-cachable to avoid XPU violations. + * During the SCM call the hypervisor will make the buffer containing + * the program data into an SHM Bridge. This is why we exceptionally + * must not use the TrustZone memory allocator here as - depending on + * Kconfig - it may already use the SHM Bridge mechanism internally. + * + * If we pass a buffer that is already part of an SHM Bridge to this + * call, it will fail. */ mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, GFP_KERNEL);