From patchwork Mon Nov 27 14:15:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13469728 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 5D4DBC0755A for ; Mon, 27 Nov 2023 14:17:33 +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=u8O9cc3Ge5SpTeHaN+G1mHjSQ/17LaIm4pJn7aHclDU=; b=VVVrIzkmdLUPsr qcF/M9vx0SEZFjOSKG4Rxr9c/LArXTMFqnTci6JySL8lCK9qX/UEPTogR7njTJJ7WYfQ8A8VU2086 OlwaE1jO0/lhfpDfkhs2dALOij6f2DjZY6vsbumXKVPvVLbi6/i0Fxfpu43syUv3yhzcsnWDOLOSK iO4el7YebNqjhmhl8pfKArB9eMqOAFcKcu6cicegi21ULZcb4fYrkEYteO2k88JPwtaDl/kzVsyVC wXSzZGEEYvJw3Y+qPds9kj6ef17UQU5pZtv+jtAFn+348IgB5PrKPcdAbfhfq1woRcbtATy1PTg+C LOpwPq7ajn8NJ92YOaUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7cQ2-002fYK-1R; Mon, 27 Nov 2023 14:17:02 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPT-002fMj-0U for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 14:16:28 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c9947f488fso27363281fa.2 for ; Mon, 27 Nov 2023 06:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701094585; x=1701699385; 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=M4fo0VIV7uqzpyPDAWdX5Jk/6XQkZo9JW17PTbGLI2E=; b=CY/PWlqSNSkZvQQteHHY71JXgpuUcY7rOB2sCcob8tr4wN24yoI1+dG1Zj9SvIZTlq Etj4RNNYW8I3nk0mDMOlxt8yTjmrupmECogtlTjFicGQ9MIaIP96SRINY6nBzcbou6Os scuvOPgUVmAw3e78vBF/6QX01rDIhxrZ1tO4JZ+QJ7pL+7ZTxAFa759oJRFbNsMlNC0N NC0s8Z542gAo5GXBJxYAO4ZZ9ZNK0JOUymezIjFAMo++rEW692di55Bx9nLxmD8XRizh 9WDkbECkXQ/tKO3eNBoeUHwJMNoxZ4e6C1EQCOXg5W2fF/padPbjmWZnEbATwNzTf1qX aNmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094585; x=1701699385; 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=M4fo0VIV7uqzpyPDAWdX5Jk/6XQkZo9JW17PTbGLI2E=; b=oPbcGR0Xu+5L07Xjs+doTwHrF4qB7ipLtSPl71JNdjbpcEUNCHZmZmHaMiZGFdmmD4 UqCYVSH2SsnBgVCEBMe8qYnR5j849pb45VwXMt4DNw6smEk+FeyAGUoKU9qV0uTgVUBF 4N9w0KWGQfQPszBOcCFZVHbSqrJX/Xy1IK3HXAHkTGB9RrhOaRs3s8mQRHb32nFV+oOF w9xOHM/s2Enja7MCJ6VSzoOKaOWis6zy7xu51Kfp98P+YZRyYBUgo0q+ZcsBd5EV6wrj ptmTjtGc9pciLpVBfgxml1cauYnEMF4oaUsDMtrw61TYz+2KaaPx0Qx5d4Rpo1xoRTRb 9fig== X-Gm-Message-State: AOJu0Yw3lUeSCAbF5IDcDlLSZFpWmNlUVI8m1eM2VoPXpkQi1jDKJSKA JBhh3q9qh0Phjv5mjTLAZ20YBA== X-Google-Smtp-Source: AGHT+IE4q3cN3fNNKCJN0/rwHtASmaX4mdUnjMTHPVaZwS7nJPgA+zX7NazFQnJHsHbeV+bI2LGPTw== X-Received: by 2002:a2e:a7cd:0:b0:2c9:a09a:dde0 with SMTP id x13-20020a2ea7cd000000b002c9a09adde0mr3080219ljp.28.1701094584920; Mon, 27 Nov 2023 06:16:24 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:bf33:77c7:8131:5e64]) by smtp.gmail.com with ESMTPSA id be7-20020a05600c1e8700b00405442edc69sm14658830wmb.14.2023.11.27.06.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:16:23 -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: [PATCH v6 12/13] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Mon, 27 Nov 2023 15:15:59 +0100 Message-Id: <20231127141600.20929-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127141600.20929-1-brgl@bgdev.pl> References: <20231127141600.20929-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_061627_509364_7224DDFD X-CRM114-Status: GOOD ( 13.94 ) 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);