From patchwork Mon Nov 20 13:21:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13461308 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 1A132C54FB9 for ; Mon, 20 Nov 2023 13:23:45 +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=cbVUMKxTOVgtxx i5wusQg0x3reW2OaqLJ1SjtzV8LjDF78JuPZYDXbhiO4ovzP+lRa5R5uOknFwNGcoz1ThgRrqI1l8 XzKxDUZ0PCNHQuSESpB1dcWEmeRrlv8/OwQ5/zUZ1GHTJg0Q8yB0INq5s6wcVbNutVjByS6eyNmsu EkRIlTXD0JcjIjxIjr89cvOl5jViNY11819vdR3YTFPmVuupQbgo3L5JeuRocQFLLQ6iPEzogXdNE LKZCAtBTFugz53HwqSAth/g17o3pG5B8IC929coZCS1mmElwIo349DrCnrlu0Wz+C57ZpVBUMtZm8 IBAhHlLE5yo05PvsZ/hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r54Es-00C8RB-2f; Mon, 20 Nov 2023 13:22:58 +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 1r54DY-00C88N-1c for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 13:21:52 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c5087d19a6so52751901fa.0 for ; Mon, 20 Nov 2023 05:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700486495; x=1701091295; 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=qWMlb5UHXyHrITk3ok2ZqE4e+IGwLADAxs4aTIk64I5WtMjhIMK72Z2VcBsIEw+WWs 5BSPpSUMFlkharq+mkcC+hamGUqUKjUMp2c7MppRQMrWtUHooQLiKaOPxwRXGYpLKYNe qDB9U+9a9JE+87NER4JVtSOFxLhWoFXkEypO7ziMywFXnLEP4c67BWH6cd3P4m/DGZyq 2yoDZGMPNLg66jz9EGNlqot0i6/J3p2UYjSjWPaTuIoPnjGPiX/4TBbNVWaLBRqgoyaU yLyFF+d45wFupCBDeZITATJN9k48jUi2FUHnM9MyqulemiHmDMjZ133LiSS/wgALszpZ AWCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700486495; x=1701091295; 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=qdeVbDklNY7t4LHSQyWd9VZ2xQTDNFzPB16cBjTgZknoACcT7Xks/g6KqJu52yjtej M0usJXXe5EojfzrKyxyH54xQYSR9ody6Jch1S0nmlor9rRIlUvpsan3lZmZ/vrHJiJEJ SDDFocwE+9wtAXvwTwuewu0ujkqr05VEsdZumgikqLRZjmL+wygx/em5mfNls/E1mx+N q9VEOKtQR2GBt6PJtC8XkSOHc18Qo0yZREaLuyBwREQa7rYmZR5A7dIlEi4HdQqXLt2w 6ctDkWzuP/sNg5udSOcFk5L1yHseAjWZzZxnklL57A/iWV1BH9M2QBS+1bTB/y/sQOgl NebQ== X-Gm-Message-State: AOJu0YyFl5ro5aCN052I8qpgkYxrysNyBTxhQ/NoaG1V3jBmCd+/oYMu 3rhogauInlkK1lWOIU6Qe89OkA== X-Google-Smtp-Source: AGHT+IFXdb7gzI4IMHiMj9vg7v37YVPJ3yyM6zb9TaX7RJaZc8/c+c1k+S0o3wgmpurQ4luAiGdbmQ== X-Received: by 2002:a2e:9e02:0:b0:2c8:7130:c6e5 with SMTP id e2-20020a2e9e02000000b002c87130c6e5mr4656583ljk.6.1700486495208; Mon, 20 Nov 2023 05:21:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:21:34 -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 11/12] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Mon, 20 Nov 2023 14:21:17 +0100 Message-Id: <20231120132118.30473-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231120132118.30473-1-brgl@bgdev.pl> References: <20231120132118.30473-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_052136_944552_1784C383 X-CRM114-Status: GOOD ( 13.71 ) 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);