From patchwork Mon Oct 9 15:34:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413940 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 A2AD9E95A9F for ; Mon, 9 Oct 2023 15:35:52 +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=Z02Y8zJZtGEKOXf+eNiXuz1dPKqyNuOinz+VMxnntU0=; b=2Jud5JLSa45rc6 QsRaBFky5HZhQZINwoMC8qaVMTOgQiW3s1PM9qRfaQ8Bx4PS1Oq0zvtpac7R40wlriZWepHWBEAmu 7ziGH7jhidAq1S2oqpRuTYblTatGEskIxb01d65uV8w0+//sbo82acv4SETKP9esYABnfStFlBl6j 1WQzEN9BEzw+psQDFYcTC8MwT8WQMcQ+1YQ2/E7kzbGZ0fEf6V2vEcMEkm2cKpR6n6K60SXq5X/3I hlAzMBSI2+xq2qaKrnzXyAQ4H/Bqmkq9RQfEDeWLwPWN3ABNK8sQoINaPtesj6V0VufrA1YWSk48G 600uKeQVGbpHYipJkJUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHy-00B4MB-2R; Mon, 09 Oct 2023 15:35:22 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHb-00B44M-0k for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:35:02 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-317c3ac7339so4265659f8f.0 for ; Mon, 09 Oct 2023 08:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865698; x=1697470498; 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=yU/L4mkVh98Gvp/+ieSh1ph2o5TQmVYw2ScTJAizm9U=; b=ZFI94Zk/vO+5eXW+y4LfWKQdCiKcqnthYW3y6kNZxmCVXQShOg97eFAzwWkIIudAqJ l7yt2VT80dMlPA0V0m3RxPzrjuF/UGhnBloj4JgjVDujHf0rpeW+8cwUW13dpjTbwgSn L7avXoLhfRSX8nOTgsDUOaqZMpaakaPQzoBYBN9OkMDde8BCxcoicKEQJlEk+jBMiHDm FHk2/8/bTrdUwknGvetwrUs6R42DJ/LY2GIpOY78c0OLI6FBjilovnMf1umk8BBbkM8b y4CQgMWlncrd9rpKGdFFMdQH94Yuml7G0vtYegnGC5ioByk9O/Wvep37xYjF3thX2epb ppsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865698; x=1697470498; 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=yU/L4mkVh98Gvp/+ieSh1ph2o5TQmVYw2ScTJAizm9U=; b=KSndru0i5BEw3JXCBJ46JUgWxp+GLbwW5zKfPrR3z5sHnRpTR3Cn4/wck9q+fYWWiD D3rDQyyfPcUmpjdFH/DOhfpov5ZqCbgEsAAm7upX9n6f9RovSL07bByy2aA5GzfQUMww 1z/YcyOmIbaKTq92Weo0J9blTWspMphJqgx1OT4lUFsF0BiXaeyc/bgh3VYKDPi/+BnL 68xezczf4+dv3JLgAGA7wnI0WxirO9OKi5GUYkXva7K8VqL7GmE94J32xNKJooBhsowN AifjnWyNxpr64Z9cSJJh5faZviwG5ecoDELNeNw8mw1kvh3Stc9QjYVZxj2xo55+70YN ibxQ== X-Gm-Message-State: AOJu0YxVw2vg71xmN15sYIhBPHUQOoGA8SUS5b3s20324TZM2ISuK8qX eShyu9FyT+tB2JQRs20NkiUdLw== X-Google-Smtp-Source: AGHT+IHYcrsYv1nA5MYThjpwSuTukqOWDTcfUOtrCI/nJyTGzDEIOg2pbtM2LIVFV2JlyVtYlvoKQg== X-Received: by 2002:a5d:54cf:0:b0:31f:ffd1:6cf4 with SMTP id x15-20020a5d54cf000000b0031fffd16cf4mr12817049wrv.12.1696865697570; Mon, 09 Oct 2023 08:34:57 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f20d:2959:7545:e99f]) by smtp.gmail.com with ESMTPSA id b3-20020adff243000000b0031431fb40fasm10016521wrp.89.2023.10.09.08.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:57 -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 v3 14/15] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Mon, 9 Oct 2023 17:34:26 +0200 Message-Id: <20231009153427.20951-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009153427.20951-1-brgl@bgdev.pl> References: <20231009153427.20951-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_083459_286022_57382A23 X-CRM114-Status: GOOD ( 14.07 ) 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 TM mem allocator. Signed-off-by: Bartosz Golaszewski --- 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..8a2475ced10a 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 TrustZone 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);