From patchwork Fri Oct 13 11:48:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420790 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 3CD03CDB47E for ; Fri, 13 Oct 2023 11:49:56 +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=GgZ5gu4gKTb5h9s1aYb9usuBCKON9dFKqc/SbuZmlOk=; b=I5/IuWvaXNUHyt C4ZEuSelI4z7mEtJ+rKuSw/aLqAMQ5TJe/NPyai1glkT0VNgoD0d6PLlMK44q5JaE6cPiEVK+wcBo E4HS0mHbO4uz+jKXpOBwA/VBfM35dBiJXh9fN+vFK38gd7KHRRlg8rt9I5LKz58SPFI9t3D22Y7Nw Kd3YNb0MQUZrnddsEZX/TrGMR0PwBfWBxLfugQ+soyXd67OgbxdV/HqEdlRVPDs+f3VR7DKnnxIzM EV46qYnIeJO+kCu/fG7IBrKEmD6VMVZpJH8uvgukIQqAtVV64ZIlk3zzway9TbhtWmNj+e3BqqA3g X80t/V0qTjQqrkR70lOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfc-003Lne-0N; Fri, 13 Oct 2023 11:49:32 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LX0-1o for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:11 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40572aeb6d0so20608315e9.1 for ; Fri, 13 Oct 2023 04:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197747; x=1697802547; 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=f9Heyw2bPG0qaWUlPboXZ9YrcRBEbXtxsdZV2np9Ptk=; b=CRHtzEOCk2dnqCTy/f9OIg8yK0FUq/Bq4QsYXCZ9hqCjSrOqy2Dijx4WW1aAESE5Ky TE5S8GUepVkdLU+lM0PLzLptvz9f2dugLaTDcJo1wdllpKKJYU/Ep6QUD8X4fJmW36tk vxpxXswSaKeqgaeIFNZ9r7oObup6Nfe1Rqu/aqyHjnY8gt1z+Allo4N1GPJR5doMavVq dl96Oo+Mm6tZ78g9Fi6Iz7VQFv2JU1jChAwo6NkKsoTpUTsGnYCnTC/F7mo6EBUH4LXa 8gtJA6pWrSyCFka1Ps0hwBOnZQW3nqjAWbmDeq2T8yUv9IkLzeHtB4LLIafaLe7NS+3h eepg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197747; x=1697802547; 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=f9Heyw2bPG0qaWUlPboXZ9YrcRBEbXtxsdZV2np9Ptk=; b=tL2JWDNYijvoizhJ9dEQNSMcTH2cXzOFf7qOfNNY3r2zjYk9e/W0gVZnXHSKuQ2V/k 4szi8X5NuzJ9OmTaeuXFNy2MkyiS30Z10hqQG10Shh2ppZiM/Rra+xcs3+dSxvwtZc0a P6o1bvY54MtmRx3fH3TZN388XaKo5pHzmPsbU6KXVaKgklg6XkaCRdjSgBFgeX8DRfFH DdAahIqgdlUr0iVQs+tW4FGeq2+7JeOe4mjj7WkeqI4RcKOsd8wX7qGFZR7cGuvjXduc dgpexuDFie2Sey0rkQlVb0jnUijzCUtLrLYIKO3c1MDF0Nq3Jf8TW5aOCw/ebkaLgUoD TfjQ== X-Gm-Message-State: AOJu0Yz0DJM0mSX1BTDnJ4O89/cDKXlzXzUmQQZN/H3vWF/rxvtHRk1d SQrEfvxaV+OErc7/a+wAj/aeIg== X-Google-Smtp-Source: AGHT+IEnwo69CmHD5Qs5HcqhGzB/4dWNJStokIatU7263uXLolybJc7B7UGHuPytZ5oFSbz9IMF4RQ== X-Received: by 2002:a05:600c:3b18:b0:407:536d:47ae with SMTP id m24-20020a05600c3b1800b00407536d47aemr9754099wms.38.1697197747308; Fri, 13 Oct 2023 04:49:07 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:06 -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 v4 14/15] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Fri, 13 Oct 2023 13:48:42 +0200 Message-Id: <20231013114843.63205-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044908_602343_3E9CBB9C X-CRM114-Status: GOOD ( 13.86 ) 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 --- 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);