From patchwork Mon Feb 5 18:28:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13546026 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 44760C4828D for ; Mon, 5 Feb 2024 18:28:59 +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=1cLLXAcvcFwiPjO/W0jhKaUo7slEnLmo9X4LPaf40G4=; b=nUnJsDyvZaLjm/ ycnPZbiK8ZkPoLT2/VsoFGRIhful7F5MigrbHjRUtFjh++k5BOBjETo20NK5RS225sP3JLlfTo3sj BYmssXG5r0rUy/7qrfzw5J2PmEqjyg50Uz++Zc6KSbvhvQGNBzHx9Xc/mqsDrmjh9Wj7vNvOqgpbR saBzELAvbjjjM3cOKbZDeFXU3J5ysQjqJmcaH/ubhicrjHp49BPY6gSqipNODBCkuftR78L2m5TPu jwBLb6VdOsdTy4SXDEvZ4dtkilcCBJH6QC9trXhvoKM7K/SbhxMjNYWwMU0ILK9vrlgu7Yb00RL+p SEXnblvRgYJ0ewqmDeUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3i2-00000004N5I-26RV; Mon, 05 Feb 2024 18:28:46 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hp-00000004Mv1-1Ol6 for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2024 18:28:34 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40fc6343bd2so30060775e9.1 for ; Mon, 05 Feb 2024 10:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707157712; x=1707762512; 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=I7SHOJjWn4ajTNVMkc896KlcCL3KSTkPo3OUGdVQzNA=; b=mFY9tVQVoZcb96pnU3l8f2k5lYSGToxGImtPzM+SgPqOrIP3REpqp84z0PpbUpU0zB APdH45KZe48dr3MWhKfSlKHnkW4aT2KEPRuoRA/DC/CXh7sIbz73sEm2QI7Rn9xi5ww7 RiWTX8dOzO8lZg2tPrtP0Us8Ej4162sJHxbjTerbS/YefQqJnnC8uZvz0mwE26Sds2Us bR0jDRQ6uwXfntf0gYpdJFVXAS77jPIGQL+MUbEYwyLHiuBJCCE7I39M+VG0UmxbxY9u 5rHhSLHLf1rAr1UKJqMT9mtv7hm3dS1HaVYePWiW/BZE3ZMRaqAkAxRWbUvzDNLD0h+2 t4jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707157712; x=1707762512; 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=I7SHOJjWn4ajTNVMkc896KlcCL3KSTkPo3OUGdVQzNA=; b=kVIYZ3CgNbqXF/7SDptv9GNTJvlyu7Od2/qJns1ZRWb22KHpnlF74zNrDI9nGHMreO S8VQ4OocHkh7al+ZPr/zz8caOCzDNQKI8mwhp5ovGgXkOm7ukk2wX4A/3osW22uPv1bg ubi4pII6tqgCPVDuubk3suxXuflanLVp/TZFsbZjEbdwG/XOQI3LkKoEwDcehOzsFeII sKQZFY/okd++LNaGUcMX0eGDXodJXlsX40m/nco4DfMRq/8rrWCiS9AqeeTQ9sNS401f yDwkiAAJCHVdatcHI4tHEOPascXrI38qHCVUEclhUKak+E0UlcMaNGH505O48Dcy/J+0 E8zQ== X-Gm-Message-State: AOJu0YwCkEZp/vbAcJ+yLQdE7LA9T3ic2psh8HUmBAivtyXC6AnnXC5H Za/D2xXB1nDoxG5CHfrEVXf1dPU794CPlPA7kzafTstK0B+GsTbSnctW3tf49jU= X-Google-Smtp-Source: AGHT+IHdz/8C3w++G3TtxRyJjaTTNdLu+sTaVnsD4pE65MfKIdmPxliBIwgVedipoXEPhMJto4XEeg== X-Received: by 2002:a5d:44c4:0:b0:33b:2884:edf2 with SMTP id z4-20020a5d44c4000000b0033b2884edf2mr235515wrr.56.1707157712083; Mon, 05 Feb 2024 10:28:32 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWFmpYMxItrm4bBmJ9+HOBf3GceWMnNDYxReZOmJvsQeVxTV8L8qfCoyq2WW8W0rkQe0S3Tp0SwVLK4x20iaG8v/aH62qitEpg2aHFmtVbe5g2QUX/uGeebRaGuZZ638Ru8/5fb54H+u97BVOzbCAlE/BiLBQCR9lPZBvPUiloZDCo/qmMWF2YUZoO3O/7nfa0vjGlWyHwxNeIDbVK93uSDykWuqFEJm4c1v6iGq6xbyMpyWQv9aOMZ+c/A20g19a13guXOt4kA3I7W2uyTbbkvWR/UrQRIV0DBySUsLA84CZI8qNyNGW5kLr6NxKfEjbXJvqjQCB5bQPL0OBOW16tMRU4r/PAwCZgkc7WrAprZ7BOP18JqTtu+pqsgC5gTuH2KoQr/wmR062h4ZUWYAfNSGfVXXcQHgnRWlS33Sp9ICZrlbGdAHN55r1IhwfKgvVPevsxbvRFxCQ21Fg5OyuHRDzPmJrE5q4Tl08XN05rzmU2Q57aUiJRCFpxK5oHg1WHpmPo9gbDXkpGyWOJz/7wmcBwP9R4YonSZxeaTEpubnKdgXynxBPxL3dBNiag141Y= Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id v15-20020a5d678f000000b0033b17e18df8sm203229wru.12.2024.02.05.10.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:28:31 -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 , Arnd Bergmann Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski , Deepti Jaggi Subject: [PATCH v7 11/12] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Mon, 5 Feb 2024 19:28:09 +0100 Message-Id: <20240205182810.58382-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205182810.58382-1-brgl@bgdev.pl> References: <20240205182810.58382-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_102833_595553_A855832F X-CRM114-Status: GOOD ( 13.92 ) 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 Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- 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);