linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>
Cc: Johan Hovold <johan@kernel.org>,
	Steev Klimaszewski <steev@kali.org>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-efi@vger.kernel.org,
	Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: [PATCH v4 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars
Date: Wed, 25 Jun 2025 01:53:22 +0300	[thread overview]
Message-ID: <20250625-more-qseecom-v4-3-aacca9306cee@oss.qualcomm.com> (raw)
In-Reply-To: <20250625-more-qseecom-v4-0-aacca9306cee@oss.qualcomm.com>

For some platforms (e.g. Lenovo Yoga C630) we don't yet know a way to
update variables in the permanent storage. However being able to read
the vars is still useful as it allows us to get e.g. RTC offset.

Add a quirk for QSEECOM specifying that UEFI variables for this platform
should be registered in read-only mode.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_qseecom_uefisecapp.c | 18 +++++++++++++++++-
 include/linux/firmware/qcom/qcom_qseecom.h      |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c
index 98a463e9774bf04f2deb0f7fa1318bd0d2edfa49..05f700dcb8cf3189f640237ff0e045564abb8264 100644
--- a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c
+++ b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c
@@ -792,6 +792,12 @@ static efi_status_t qcuefi_query_variable_info(u32 attr, u64 *storage_space, u64
 	return status;
 }
 
+static const struct efivar_operations qcom_efivars_ro_ops = {
+	.get_variable = qcuefi_get_variable,
+	.get_next_variable = qcuefi_get_next_variable,
+	.query_variable_info = qcuefi_query_variable_info,
+};
+
 static const struct efivar_operations qcom_efivar_ops = {
 	.get_variable = qcuefi_get_variable,
 	.set_variable = qcuefi_set_variable,
@@ -804,7 +810,9 @@ static const struct efivar_operations qcom_efivar_ops = {
 static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev,
 				 const struct auxiliary_device_id *aux_dev_id)
 {
+	unsigned long *quirks = aux_dev->dev.platform_data;
 	struct qcom_tzmem_pool_config pool_config;
+	const struct efivar_operations *ops;
 	struct qcuefi_client *qcuefi;
 	int status;
 
@@ -829,7 +837,15 @@ static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev,
 	if (status)
 		return status;
 
-	status = efivars_register(&qcuefi->efivars, &qcom_efivar_ops);
+	if (quirks &&
+	    *quirks & QCOM_QSEECOM_QUIRK_RO_UEFIVARS) {
+		dev_dbg(&aux_dev->dev, "R/O UEFI vars implementation\n");
+		ops = &qcom_efivars_ro_ops;
+	} else {
+		ops = &qcom_efivar_ops;
+	}
+
+	status = efivars_register(&qcuefi->efivars, ops);
 	if (status)
 		qcuefi_set_reference(NULL);
 
diff --git a/include/linux/firmware/qcom/qcom_qseecom.h b/include/linux/firmware/qcom/qcom_qseecom.h
index 3387897bf36843cccd0bd933dd562390bf674b14..8d6d660e854fdb0fabbef10ab5ee6ff23ad79826 100644
--- a/include/linux/firmware/qcom/qcom_qseecom.h
+++ b/include/linux/firmware/qcom/qcom_qseecom.h
@@ -51,4 +51,6 @@ static inline int qcom_qseecom_app_send(struct qseecom_client *client,
 	return qcom_scm_qseecom_app_send(client->app_id, req, req_size, rsp, rsp_size);
 }
 
+#define QCOM_QSEECOM_QUIRK_RO_UEFIVARS		BIT(0)
+
 #endif /* __QCOM_QSEECOM_H */

-- 
2.39.5


  parent reply	other threads:[~2025-06-24 22:53 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 22:53 [PATCH v4 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
2025-06-24 22:53 ` [PATCH v4 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case Dmitry Baryshkov
2025-06-26 10:04   ` Johan Hovold
2025-06-26 11:03     ` Dmitry Baryshkov
2025-06-26 12:51       ` Johan Hovold
2025-06-26 12:54         ` Dmitry Baryshkov
2025-06-27 12:27           ` Johan Hovold
2025-06-28 15:05             ` Dmitry Baryshkov
2025-06-30 12:15               ` Johan Hovold
2025-06-24 22:53 ` [PATCH v4 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations Dmitry Baryshkov
2025-06-24 22:53 ` Dmitry Baryshkov [this message]
2025-07-16 19:13   ` [PATCH v4 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars Bjorn Andersson
2025-07-16 21:07     ` Dmitry Baryshkov
2025-06-24 22:53 ` [PATCH v4 4/8] firmware: qcom: enable QSEECOM on Lenovo Yoga C630 Dmitry Baryshkov
2025-06-24 22:53 ` [PATCH v4 5/8] firmware; qcom: scm: enable QSEECOM on SC8280XP CRD Dmitry Baryshkov
2025-06-26 23:34   ` Konrad Dybcio
2025-06-26 23:48     ` Dmitry Baryshkov
2025-06-26 23:54     ` Konrad Dybcio
2025-06-27 12:23       ` Johan Hovold
2025-06-27 12:26         ` Konrad Dybcio
2025-06-27 12:50           ` Johan Hovold
2025-06-28 14:50             ` Dmitry Baryshkov
2025-06-30 12:16               ` Johan Hovold
2025-07-16 19:02                 ` Bjorn Andersson
2025-06-24 22:53 ` [PATCH v4 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement Dmitry Baryshkov
2025-06-26 10:11   ` Johan Hovold
2025-06-26 11:08     ` Dmitry Baryshkov
2025-06-26 12:58       ` Johan Hovold
2025-06-26 23:33         ` Dmitry Baryshkov
2025-06-27 12:46           ` Johan Hovold
2025-06-28 15:03             ` Dmitry Baryshkov
2025-06-30 12:42               ` Johan Hovold
2025-07-01 11:10                 ` Dmitry Baryshkov
2025-07-10  9:40                   ` Johan Hovold
2025-06-24 22:53 ` [PATCH v4 7/8] firmware: qcom: scm: rework QSEECOM allowlist Dmitry Baryshkov
2025-06-26  9:56   ` Johan Hovold
2025-06-26 11:09     ` Dmitry Baryshkov
2025-06-26 13:02       ` Johan Hovold
2025-06-24 22:53 ` [PATCH v4 8/8] arm64: dts: qcom: sdm850-lenovo-yoga-c630: fix RTC offset info Dmitry Baryshkov
2025-06-26 10:16   ` Johan Hovold
2025-06-26 11:10     ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250625-more-qseecom-v4-3-aacca9306cee@oss.qualcomm.com \
    --to=dmitry.baryshkov@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=ardb@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=johan@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=robh@kernel.org \
    --cc=steev@kali.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).