devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630
@ 2025-06-24  2:13 Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case Dmitry Baryshkov
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Konrad Dybcio, Dmitry Baryshkov

Lenovo Yoga C630 is a WoA / WoS laptop, which uses a "standard" QSEECOM /
uefisecapp application in order to implement UEFI variables. However as
this platform has only one storage (UFS) shared between Linux and
SecureOS world, uefisecapp can not update variables directly. It
requires some additional steps in order to update variables, which are
not yet reverse engineered.

However even with the current driver it is possible to implement R/O
UEFI vars access, which e.g. lets the RTC driver to read RTC offset,
providing Linux with a correct time.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
Changes in v3:
- Picked up patches from another series, reworking the QSEECOM
  allowtable
- Added a fix for efivar_set_variable() crashing the machine if R/O UEFI
  vars are provided (Johan)
- Link to v2: https://lore.kernel.org/r/20250621-more-qseecom-v2-0-6e8f635640c5@oss.qualcomm.com
- Link to the merged series: https://lore.kernel.org/r/20241103-rework-qseecom-v1-0-1d75d4eedc1e@linaro.org/

Changes in v2:
- Added QSEECOM quirks in order to make UEFI vars r/o on C630.
- Added DT patch, specifying the use of UEFI vars for RTC offset.
- Link to v1: https://lore.kernel.org/r/20240725-more-qseecom-v1-1-a55a3553d1fe@linaro.org

---
Dmitry Baryshkov (8):
      efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case
      firmware: qcom: scm: allow specifying quirks for QSEECOM implementations
      firmware: qcom: uefisecapp: add support for R/O UEFI vars
      firmware: qcom: enable QSEECOM on Lenovo Yoga C630
      firmware; qcom: scm: enable QSEECOM on SC8280XP CRD
      firmware: qcom: scm: add modparam to control QSEECOM enablement
      firmware: qcom: scm: rework QSEECOM allowlist
      arm64: dts: qcom: sdm850-lenovo-yoga-c630: fix RTC offset info

 arch/arm64/boot/dts/qcom/pm8998.dtsi               |  2 +-
 .../boot/dts/qcom/sdm850-lenovo-yoga-c630.dts      |  4 +
 drivers/firmware/efi/vars.c                        |  2 +
 drivers/firmware/qcom/qcom_qseecom.c               |  6 +-
 drivers/firmware/qcom/qcom_qseecom_uefisecapp.c    | 18 +++-
 drivers/firmware/qcom/qcom_scm.c                   | 99 +++++++++++++---------
 include/linux/firmware/qcom/qcom_qseecom.h         |  3 +
 7 files changed, 93 insertions(+), 41 deletions(-)
---
base-commit: 5d4809e25903ab8e74034c1f23c787fd26d52934
change-id: 20240725-more-qseecom-379933b9c769

Best regards,
-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-07-08  3:18   ` Ard Biesheuvel
  2025-06-24  2:13 ` [PATCH v3 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations Dmitry Baryshkov
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi

If efivar implementation doesn't provide write support, then calling
efivar_set_variable() (e.g. when PM8xxx RTC driver tries to update the
RTC offset) will crash the system. Prevent that by checking that
set_variable callback is actually provided and fail with an
EFI_WRITE_PROTECTED if it is not.

Fixes: 472831d4c4b2 ("efi: vars: Add thin wrapper around EFI get/set variable interface")
Reported-by: Johan Hovold <johan@kernel.org>
Closes: https://lore.kernel.org/r/aFlps9iUcD42vN4w@hovoldconsulting.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/efi/vars.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 3700e98697676d8e6f04f061f447391503f9abba..11c5f785c09364f61642d82416822cb2e1a027fd 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -227,6 +227,8 @@ efi_status_t efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
 	setvar = __efivars->ops->set_variable_nonblocking;
 	if (!setvar || !nonblocking)
 		 setvar = __efivars->ops->set_variable;
+	if (!setvar)
+		return EFI_WRITE_PROTECTED;
 
 	return setvar(name, vendor, attr, data_size, data);
 }

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-06-24 12:53   ` Konrad Dybcio
  2025-06-24  2:13 ` [PATCH v3 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars Dmitry Baryshkov
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi

Some of QSEECOM implementations might need additional quirks (e.g. some
of the platforms don't (yet) support read-write UEFI variables access).
Pass the quirks to the QSEECOM driver and down to individual app
drivers.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_qseecom.c |  6 +++++-
 drivers/firmware/qcom/qcom_scm.c     | 28 ++++++++++++++--------------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/firmware/qcom/qcom_qseecom.c b/drivers/firmware/qcom/qcom_qseecom.c
index 731e6d5719f9e3e9e698f5de0117540f51ebab63..aab0d61f0420c4f3d6c1a73e384195b9513f3ef9 100644
--- a/drivers/firmware/qcom/qcom_qseecom.c
+++ b/drivers/firmware/qcom/qcom_qseecom.c
@@ -36,6 +36,7 @@ static void qseecom_client_remove(void *data)
 }
 
 static int qseecom_client_register(struct platform_device *qseecom_dev,
+				   void *data,
 				   const struct qseecom_app_desc *desc)
 {
 	struct qseecom_client *client;
@@ -56,6 +57,7 @@ static int qseecom_client_register(struct platform_device *qseecom_dev,
 
 	client->aux_dev.name = desc->dev_name;
 	client->aux_dev.dev.parent = &qseecom_dev->dev;
+	client->aux_dev.dev.platform_data = data;
 	client->aux_dev.dev.release = qseecom_client_release;
 	client->app_id = app_id;
 
@@ -89,12 +91,14 @@ static const struct qseecom_app_desc qcom_qseecom_apps[] = {
 
 static int qcom_qseecom_probe(struct platform_device *qseecom_dev)
 {
+	void *data = dev_get_platdata(&qseecom_dev->dev);
 	int ret;
 	int i;
 
 	/* Set up client devices for each base application */
 	for (i = 0; i < ARRAY_SIZE(qcom_qseecom_apps); i++) {
-		ret = qseecom_client_register(qseecom_dev, &qcom_qseecom_apps[i]);
+		ret = qseecom_client_register(qseecom_dev, data,
+					      &qcom_qseecom_apps[i]);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index f63b716be5b027550ae3a987e784f0814ea6d678..fc2ed02dbd30b389b5058f5cac70c184df7ca873 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -2008,10 +2008,10 @@ static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
 	{ }
 };
 
-static bool qcom_scm_qseecom_machine_is_allowed(void)
+static bool qcom_scm_qseecom_machine_is_allowed(unsigned long *quirks)
 {
+	const struct of_device_id *match;
 	struct device_node *np;
-	bool match;
 
 	np = of_find_node_by_path("/");
 	if (!np)
@@ -2020,6 +2020,11 @@ static bool qcom_scm_qseecom_machine_is_allowed(void)
 	match = of_match_node(qcom_scm_qseecom_allowlist, np);
 	of_node_put(np);
 
+	if (match && match->data)
+		*quirks = *(unsigned long *)(match->data);
+	else
+		*quirks = 0;
+
 	return match;
 }
 
@@ -2034,6 +2039,7 @@ static void qcom_scm_qseecom_free(void *data)
 static int qcom_scm_qseecom_init(struct qcom_scm *scm)
 {
 	struct platform_device *qseecom_dev;
+	unsigned long quirks;
 	u32 version;
 	int ret;
 
@@ -2054,7 +2060,7 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
 
 	dev_info(scm->dev, "qseecom: found qseecom with version 0x%x\n", version);
 
-	if (!qcom_scm_qseecom_machine_is_allowed()) {
+	if (!qcom_scm_qseecom_machine_is_allowed(&quirks)) {
 		dev_info(scm->dev, "qseecom: untested machine, skipping\n");
 		return 0;
 	}
@@ -2063,17 +2069,11 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
 	 * Set up QSEECOM interface device. All application clients will be
 	 * set up and managed by the corresponding driver for it.
 	 */
-	qseecom_dev = platform_device_alloc("qcom_qseecom", -1);
-	if (!qseecom_dev)
-		return -ENOMEM;
-
-	qseecom_dev->dev.parent = scm->dev;
-
-	ret = platform_device_add(qseecom_dev);
-	if (ret) {
-		platform_device_put(qseecom_dev);
-		return ret;
-	}
+	qseecom_dev = platform_device_register_data(scm->dev,
+						    "qcom_qseecom", -1,
+						    &quirks, sizeof(quirks));
+	if (IS_ERR(qseecom_dev))
+		return PTR_ERR(qseecom_dev);
 
 	return devm_add_action_or_reset(scm->dev, qcom_scm_qseecom_free, qseecom_dev);
 }

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-06-24 12:53   ` Konrad Dybcio
  2025-06-24  2:13 ` [PATCH v3 4/8] firmware: qcom: enable QSEECOM on Lenovo Yoga C630 Dmitry Baryshkov
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi

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.

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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 4/8] firmware: qcom: enable QSEECOM on Lenovo Yoga C630
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
                   ` (2 preceding siblings ...)
  2025-06-24  2:13 ` [PATCH v3 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 5/8] firmware; qcom: scm: enable QSEECOM on SC8280XP CRD Dmitry Baryshkov
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Konrad Dybcio

QSEECOM driver end UEFI vars access works on the Lenovo Yoga C630. This
platform has only one storage (UFS) shared between Linux and SecureOS
world, uefisecapp can not update variables directly. It requires some
additional steps in order to update variables, which are not yet reverse
engineered.

Enable the QSEECOM device on that laptop and set up a quirk, making UEFI
vars read-only.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_scm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index fc2ed02dbd30b389b5058f5cac70c184df7ca873..dbb77c3f69ddaa931e7faa73911207a83634bda1 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -13,6 +13,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/export.h>
+#include <linux/firmware/qcom/qcom_qseecom.h>
 #include <linux/firmware/qcom/qcom_scm.h>
 #include <linux/firmware/qcom/qcom_tzmem.h>
 #include <linux/init.h>
@@ -1980,6 +1981,8 @@ int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size,
 }
 EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_send);
 
+static unsigned long qcom_qseecom_ro_uefi = QCOM_QSEECOM_QUIRK_RO_UEFIVARS;
+
 /*
  * We do not yet support re-entrant calls via the qseecom interface. To prevent
  + any potential issues with this, only allow validated machines for now.
@@ -1995,6 +1998,7 @@ static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
 	{ .compatible = "lenovo,flex-5g" },
 	{ .compatible = "lenovo,thinkpad-t14s" },
 	{ .compatible = "lenovo,thinkpad-x13s", },
+	{ .compatible = "lenovo,yoga-c630", .data = &qcom_qseecom_ro_uefi, },
 	{ .compatible = "lenovo,yoga-slim7x" },
 	{ .compatible = "microsoft,arcata", },
 	{ .compatible = "microsoft,blackrock" },

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 5/8] firmware; qcom: scm: enable QSEECOM on SC8280XP CRD
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
                   ` (3 preceding siblings ...)
  2025-06-24  2:13 ` [PATCH v3 4/8] firmware: qcom: enable QSEECOM on Lenovo Yoga C630 Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement Dmitry Baryshkov
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi

As reported by Johan, this platform also doesn't currently support
updating of the UEFI variables. In preparation to reworking match list
for QSEECOM mark this platform as supporting QSEECOM with R/O UEFI
variables.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_scm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index dbb77c3f69ddaa931e7faa73911207a83634bda1..27ef2497089e11b5a902d949de2e16b7443a2ca4 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -2005,6 +2005,7 @@ static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
 	{ .compatible = "microsoft,romulus13", },
 	{ .compatible = "microsoft,romulus15", },
 	{ .compatible = "qcom,sc8180x-primus" },
+	{ .compatible = "qcom,sc8280xp-crd", .data = &qcom_qseecom_ro_uefi, },
 	{ .compatible = "qcom,x1e001de-devkit" },
 	{ .compatible = "qcom,x1e80100-crd" },
 	{ .compatible = "qcom,x1e80100-qcp" },

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
                   ` (4 preceding siblings ...)
  2025-06-24  2:13 ` [PATCH v3 5/8] firmware; qcom: scm: enable QSEECOM on SC8280XP CRD Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-06-24 12:56   ` Konrad Dybcio
  2025-06-24  2:13 ` [PATCH v3 7/8] firmware: qcom: scm: rework QSEECOM allowlist Dmitry Baryshkov
  2025-06-24  2:13 ` [PATCH v3 8/8] arm64: dts: qcom: sdm850-lenovo-yoga-c630: fix RTC offset info Dmitry Baryshkov
  7 siblings, 1 reply; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Dmitry Baryshkov

From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

In preparation to enabling QSEECOM for the platforms rather than
individual machines provide a mechanism for the user to override default
selection. Allow users to use qcom_scm.qseecom modparam.

Setting it to 'force' will enable QSEECOM even if it disabled or not
handled by the allowlist.

Setting it to 'off' will forcibly disable the QSEECOM interface,
allowing incompatible machines to function.

Setting it to 'roefivars' will enable the QSEECOM interface, making UEFI
variables read-only.

All other values mean 'auto', trusting the allowlist in the module.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_scm.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 27ef2497089e11b5a902d949de2e16b7443a2ca4..5bf59eba2a863ba16e59df7fa2de1c50b0a218d0 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1983,9 +1983,14 @@ EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_send);
 
 static unsigned long qcom_qseecom_ro_uefi = QCOM_QSEECOM_QUIRK_RO_UEFIVARS;
 
+static char *qseecom = "auto";
+MODULE_PARM_DESC(qseecom, "Enable QSEECOM interface (force | roefivars | off | auto)");
+module_param(qseecom, charp, 0);
+
 /*
  * We do not yet support re-entrant calls via the qseecom interface. To prevent
- + any potential issues with this, only allow validated machines for now.
+ * any potential issues with this, only allow validated machines for now. Users
+ * still can manually enable or disable it via the qcom_scm.qseecom modparam.
  */
 static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
 	{ .compatible = "asus,vivobook-s15" },
@@ -2013,11 +2018,27 @@ static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
 	{ }
 };
 
-static bool qcom_scm_qseecom_machine_is_allowed(unsigned long *quirks)
+static bool qcom_scm_qseecom_machine_is_allowed(struct device *scm_dev,
+						unsigned long *quirks)
 {
 	const struct of_device_id *match;
 	struct device_node *np;
 
+	if (!strcmp(qseecom, "off")) {
+		dev_info(scm_dev, "qseecom: disabled by modparam\n");
+		return false;
+	} else if (!strcmp(qseecom, "force")) {
+		dev_info(scm_dev, "qseecom: forcibly enabled\n");
+		*quirks = 0;
+		return true;
+	} else if (!strcmp(qseecom, "roefivars")) {
+		dev_info(scm_dev, "qseecom: enabling with R/O UEFI variables\n");
+		*quirks = QCOM_QSEECOM_QUIRK_RO_UEFIVARS;
+		return true;
+	} else if (strcmp(qseecom, "auto")) {
+		dev_warn(scm_dev, "qseecom: invalid value for the modparam, ignoring\n");
+	}
+
 	np = of_find_node_by_path("/");
 	if (!np)
 		return false;
@@ -2065,7 +2086,7 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
 
 	dev_info(scm->dev, "qseecom: found qseecom with version 0x%x\n", version);
 
-	if (!qcom_scm_qseecom_machine_is_allowed(&quirks)) {
+	if (!qcom_scm_qseecom_machine_is_allowed(scm->dev, &quirks)) {
 		dev_info(scm->dev, "qseecom: untested machine, skipping\n");
 		return 0;
 	}

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 7/8] firmware: qcom: scm: rework QSEECOM allowlist
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
                   ` (5 preceding siblings ...)
  2025-06-24  2:13 ` [PATCH v3 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  2025-06-24 12:58   ` Konrad Dybcio
  2025-06-24  2:13 ` [PATCH v3 8/8] arm64: dts: qcom: sdm850-lenovo-yoga-c630: fix RTC offset info Dmitry Baryshkov
  7 siblings, 1 reply; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Dmitry Baryshkov

From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Listing individual machines in qcom_scm_qseecom_allowlist doesn't scale.
Allow it to function as allow and disallow list at the same time by the
means of the match->data and list the SoC families instead of devices.

In case a particular device has buggy or incompatible firmware user
still can disable QSEECOM by specifying qcom_scm.qseecom=off kernel
param and (in the longer term) adding machine-specific entry to the
qcom_scm_qseecom_allowlist table.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_scm.c           | 49 ++++++++++++++----------------
 include/linux/firmware/qcom/qcom_qseecom.h |  1 +
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 5bf59eba2a863ba16e59df7fa2de1c50b0a218d0..49dcb30311f9c5eae697317ec6f32ac73d81314a 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1981,6 +1981,7 @@ int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size,
 }
 EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_send);
 
+static unsigned long qcom_qseecom_disable = QCOM_QSEECOM_QUIRK_DISABLE;
 static unsigned long qcom_qseecom_ro_uefi = QCOM_QSEECOM_QUIRK_RO_UEFIVARS;
 
 static char *qseecom = "auto";
@@ -1989,32 +1990,20 @@ module_param(qseecom, charp, 0);
 
 /*
  * We do not yet support re-entrant calls via the qseecom interface. To prevent
- * any potential issues with this, only allow validated machines for now. Users
+ * any potential issues with this, only allow validated platforms for now. Users
  * still can manually enable or disable it via the qcom_scm.qseecom modparam.
+ *
+ * To disable QSEECOM for a particular machine, add compatible entry and set
+ * data to (void *)false.
  */
 static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = {
-	{ .compatible = "asus,vivobook-s15" },
-	{ .compatible = "asus,zenbook-a14-ux3407qa" },
-	{ .compatible = "asus,zenbook-a14-ux3407ra" },
-	{ .compatible = "dell,xps13-9345" },
-	{ .compatible = "hp,elitebook-ultra-g1q" },
-	{ .compatible = "hp,omnibook-x14" },
-	{ .compatible = "huawei,gaokun3" },
-	{ .compatible = "lenovo,flex-5g" },
-	{ .compatible = "lenovo,thinkpad-t14s" },
-	{ .compatible = "lenovo,thinkpad-x13s", },
 	{ .compatible = "lenovo,yoga-c630", .data = &qcom_qseecom_ro_uefi, },
-	{ .compatible = "lenovo,yoga-slim7x" },
-	{ .compatible = "microsoft,arcata", },
-	{ .compatible = "microsoft,blackrock" },
-	{ .compatible = "microsoft,romulus13", },
-	{ .compatible = "microsoft,romulus15", },
-	{ .compatible = "qcom,sc8180x-primus" },
+	{ .compatible = "qcom,sc8180x", },
+	{ .compatible = "qcom,sc8280xp", },
 	{ .compatible = "qcom,sc8280xp-crd", .data = &qcom_qseecom_ro_uefi, },
-	{ .compatible = "qcom,x1e001de-devkit" },
-	{ .compatible = "qcom,x1e80100-crd" },
-	{ .compatible = "qcom,x1e80100-qcp" },
-	{ .compatible = "qcom,x1p42100-crd" },
+	{ .compatible = "qcom,sdm845", .data = &qcom_qseecom_disable, },
+	{ .compatible = "qcom,x1e80100", },
+	{ .compatible = "qcom,x1p42100", },
 	{ }
 };
 
@@ -2046,12 +2035,22 @@ static bool qcom_scm_qseecom_machine_is_allowed(struct device *scm_dev,
 	match = of_match_node(qcom_scm_qseecom_allowlist, np);
 	of_node_put(np);
 
-	if (match && match->data)
+	if (!match) {
+		dev_info(scm_dev, "qseecom: untested machine, skipping\n");
+		return false;
+	}
+
+	if (match->data)
 		*quirks = *(unsigned long *)(match->data);
 	else
 		*quirks = 0;
 
-	return match;
+	if (*quirks & QCOM_QSEECOM_QUIRK_DISABLE) {
+		dev_info(scm_dev, "qseecom: disabled by the quirk\n");
+		return false;
+	}
+
+	return true;
 }
 
 static void qcom_scm_qseecom_free(void *data)
@@ -2086,10 +2085,8 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
 
 	dev_info(scm->dev, "qseecom: found qseecom with version 0x%x\n", version);
 
-	if (!qcom_scm_qseecom_machine_is_allowed(scm->dev, &quirks)) {
-		dev_info(scm->dev, "qseecom: untested machine, skipping\n");
+	if (!qcom_scm_qseecom_machine_is_allowed(scm->dev, &quirks))
 		return 0;
-	}
 
 	/*
 	 * Set up QSEECOM interface device. All application clients will be
diff --git a/include/linux/firmware/qcom/qcom_qseecom.h b/include/linux/firmware/qcom/qcom_qseecom.h
index 8d6d660e854fdb0fabbef10ab5ee6ff23ad79826..d48044ece20cc9ebac3357a642dc671c349d4343 100644
--- a/include/linux/firmware/qcom/qcom_qseecom.h
+++ b/include/linux/firmware/qcom/qcom_qseecom.h
@@ -52,5 +52,6 @@ static inline int qcom_qseecom_app_send(struct qseecom_client *client,
 }
 
 #define QCOM_QSEECOM_QUIRK_RO_UEFIVARS		BIT(0)
+#define QCOM_QSEECOM_QUIRK_DISABLE		BIT(1)
 
 #endif /* __QCOM_QSEECOM_H */

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 8/8] arm64: dts: qcom: sdm850-lenovo-yoga-c630: fix RTC offset info
  2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
                   ` (6 preceding siblings ...)
  2025-06-24  2:13 ` [PATCH v3 7/8] firmware: qcom: scm: rework QSEECOM allowlist Dmitry Baryshkov
@ 2025-06-24  2:13 ` Dmitry Baryshkov
  7 siblings, 0 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2025-06-24  2:13 UTC (permalink / raw)
  To: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel, Konrad Dybcio
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Konrad Dybcio

Lenovo Yoga C630 as most of the other WoA devices stores RTC offset in
the UEFI variable. Add corresponding property to the RTC device in order
to make RTC driver wait for UEFI variables to become available and then
read offset value from the corresponding variable.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 arch/arm64/boot/dts/qcom/pm8998.dtsi                 | 2 +-
 arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/pm8998.dtsi b/arch/arm64/boot/dts/qcom/pm8998.dtsi
index 3ecb330590e59a6640f833a0bf4d2c62f40de17d..50b41942b06cf1a3f43f9c754b3bf2e1eaa4d353 100644
--- a/arch/arm64/boot/dts/qcom/pm8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8998.dtsi
@@ -101,7 +101,7 @@ pm8998_adc_tm: adc-tm@3400 {
 			status = "disabled";
 		};
 
-		rtc@6000 {
+		pm8998_rtc: rtc@6000 {
 			compatible = "qcom,pm8941-rtc";
 			reg = <0x6000>, <0x6100>;
 			reg-names = "rtc", "alarm";
diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
index 8ef6db3be6e3dffe4ec819288193a183b32db8e8..c0c007ce8682cacd1cbfe816ddb975c0a099ac89 100644
--- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
@@ -592,6 +592,10 @@ sw_edp_1p2_en: pm8998-gpio9-state {
 	};
 };
 
+&pm8998_rtc {
+	qcom,uefi-rtc-info;
+};
+
 &qup_i2c10_default {
 	drive-strength = <2>;
 	bias-disable;

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations
  2025-06-24  2:13 ` [PATCH v3 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations Dmitry Baryshkov
@ 2025-06-24 12:53   ` Konrad Dybcio
  0 siblings, 0 replies; 14+ messages in thread
From: Konrad Dybcio @ 2025-06-24 12:53 UTC (permalink / raw)
  To: Dmitry Baryshkov, Bjorn Andersson, Maximilian Luz, Konrad Dybcio,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi

On 6/24/25 4:13 AM, Dmitry Baryshkov wrote:
> Some of QSEECOM implementations might need additional quirks (e.g. some
> of the platforms don't (yet) support read-write UEFI variables access).
> Pass the quirks to the QSEECOM driver and down to individual app
> drivers.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars
  2025-06-24  2:13 ` [PATCH v3 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars Dmitry Baryshkov
@ 2025-06-24 12:53   ` Konrad Dybcio
  0 siblings, 0 replies; 14+ messages in thread
From: Konrad Dybcio @ 2025-06-24 12:53 UTC (permalink / raw)
  To: Dmitry Baryshkov, Bjorn Andersson, Maximilian Luz, Konrad Dybcio,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi

On 6/24/25 4:13 AM, Dmitry Baryshkov wrote:
> 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.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement
  2025-06-24  2:13 ` [PATCH v3 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement Dmitry Baryshkov
@ 2025-06-24 12:56   ` Konrad Dybcio
  0 siblings, 0 replies; 14+ messages in thread
From: Konrad Dybcio @ 2025-06-24 12:56 UTC (permalink / raw)
  To: Dmitry Baryshkov, Bjorn Andersson, Maximilian Luz, Konrad Dybcio,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Dmitry Baryshkov

On 6/24/25 4:13 AM, Dmitry Baryshkov wrote:
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> In preparation to enabling QSEECOM for the platforms rather than
> individual machines provide a mechanism for the user to override default
> selection. Allow users to use qcom_scm.qseecom modparam.
> 
> Setting it to 'force' will enable QSEECOM even if it disabled or not
> handled by the allowlist.
> 
> Setting it to 'off' will forcibly disable the QSEECOM interface,
> allowing incompatible machines to function.
> 
> Setting it to 'roefivars' will enable the QSEECOM interface, making UEFI
> variables read-only.
> 
> All other values mean 'auto', trusting the allowlist in the module.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 7/8] firmware: qcom: scm: rework QSEECOM allowlist
  2025-06-24  2:13 ` [PATCH v3 7/8] firmware: qcom: scm: rework QSEECOM allowlist Dmitry Baryshkov
@ 2025-06-24 12:58   ` Konrad Dybcio
  0 siblings, 0 replies; 14+ messages in thread
From: Konrad Dybcio @ 2025-06-24 12:58 UTC (permalink / raw)
  To: Dmitry Baryshkov, Bjorn Andersson, Maximilian Luz, Konrad Dybcio,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ard Biesheuvel
  Cc: Johan Hovold, Steev Klimaszewski, linux-arm-msm, linux-kernel,
	devicetree, linux-efi, Dmitry Baryshkov

On 6/24/25 4:13 AM, Dmitry Baryshkov wrote:
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> Listing individual machines in qcom_scm_qseecom_allowlist doesn't scale.
> Allow it to function as allow and disallow list at the same time by the
> means of the match->data and list the SoC families instead of devices.
> 
> In case a particular device has buggy or incompatible firmware user
> still can disable QSEECOM by specifying qcom_scm.qseecom=off kernel
> param and (in the longer term) adding machine-specific entry to the
> qcom_scm_qseecom_allowlist table.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
>  drivers/firmware/qcom/qcom_scm.c           | 49 ++++++++++++++----------------
>  include/linux/firmware/qcom/qcom_qseecom.h |  1 +
>  2 files changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> index 5bf59eba2a863ba16e59df7fa2de1c50b0a218d0..49dcb30311f9c5eae697317ec6f32ac73d81314a 100644
> --- a/drivers/firmware/qcom/qcom_scm.c
> +++ b/drivers/firmware/qcom/qcom_scm.c
> @@ -1981,6 +1981,7 @@ int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size,
>  }
>  EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_send);
>  
> +static unsigned long qcom_qseecom_disable = QCOM_QSEECOM_QUIRK_DISABLE;
>  static unsigned long qcom_qseecom_ro_uefi = QCOM_QSEECOM_QUIRK_RO_UEFIVARS;
>  
>  static char *qseecom = "auto";
> @@ -1989,32 +1990,20 @@ module_param(qseecom, charp, 0);
>  
>  /*
>   * We do not yet support re-entrant calls via the qseecom interface. To prevent
> - * any potential issues with this, only allow validated machines for now. Users
> + * any potential issues with this, only allow validated platforms for now. Users
>   * still can manually enable or disable it via the qcom_scm.qseecom modparam.
> + *
> + * To disable QSEECOM for a particular machine, add compatible entry and set
> + * data to (void *)false.

needs a refresh ^

with that:

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case
  2025-06-24  2:13 ` [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case Dmitry Baryshkov
@ 2025-07-08  3:18   ` Ard Biesheuvel
  0 siblings, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2025-07-08  3:18 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Bjorn Andersson, Maximilian Luz, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Johan Hovold,
	Steev Klimaszewski, linux-arm-msm, linux-kernel, devicetree,
	linux-efi

On Tue, 24 Jun 2025 at 12:14, Dmitry Baryshkov
<dmitry.baryshkov@oss.qualcomm.com> wrote:
>
> If efivar implementation doesn't provide write support, then calling
> efivar_set_variable() (e.g. when PM8xxx RTC driver tries to update the
> RTC offset) will crash the system. Prevent that by checking that
> set_variable callback is actually provided and fail with an
> EFI_WRITE_PROTECTED if it is not.
>
> Fixes: 472831d4c4b2 ("efi: vars: Add thin wrapper around EFI get/set variable interface")
> Reported-by: Johan Hovold <johan@kernel.org>
> Closes: https://lore.kernel.org/r/aFlps9iUcD42vN4w@hovoldconsulting.com
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
>  drivers/firmware/efi/vars.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

Feel free to merge this along with the rest of the series.

> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index 3700e98697676d8e6f04f061f447391503f9abba..11c5f785c09364f61642d82416822cb2e1a027fd 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -227,6 +227,8 @@ efi_status_t efivar_set_variable_locked(efi_char16_t *name, efi_guid_t *vendor,
>         setvar = __efivars->ops->set_variable_nonblocking;
>         if (!setvar || !nonblocking)
>                  setvar = __efivars->ops->set_variable;
> +       if (!setvar)
> +               return EFI_WRITE_PROTECTED;
>
>         return setvar(name, vendor, attr, data_size, data);
>  }
>
> --
> 2.39.5
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-07-08  3:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24  2:13 [PATCH v3 0/8] firmware: qcom: enable UEFI variables on Lenovo Yoga C630 Dmitry Baryshkov
2025-06-24  2:13 ` [PATCH v3 1/8] efi: efivars: don't crash in efivar_set_variable{,_locked} in r/o case Dmitry Baryshkov
2025-07-08  3:18   ` Ard Biesheuvel
2025-06-24  2:13 ` [PATCH v3 2/8] firmware: qcom: scm: allow specifying quirks for QSEECOM implementations Dmitry Baryshkov
2025-06-24 12:53   ` Konrad Dybcio
2025-06-24  2:13 ` [PATCH v3 3/8] firmware: qcom: uefisecapp: add support for R/O UEFI vars Dmitry Baryshkov
2025-06-24 12:53   ` Konrad Dybcio
2025-06-24  2:13 ` [PATCH v3 4/8] firmware: qcom: enable QSEECOM on Lenovo Yoga C630 Dmitry Baryshkov
2025-06-24  2:13 ` [PATCH v3 5/8] firmware; qcom: scm: enable QSEECOM on SC8280XP CRD Dmitry Baryshkov
2025-06-24  2:13 ` [PATCH v3 6/8] firmware: qcom: scm: add modparam to control QSEECOM enablement Dmitry Baryshkov
2025-06-24 12:56   ` Konrad Dybcio
2025-06-24  2:13 ` [PATCH v3 7/8] firmware: qcom: scm: rework QSEECOM allowlist Dmitry Baryshkov
2025-06-24 12:58   ` Konrad Dybcio
2025-06-24  2:13 ` [PATCH v3 8/8] arm64: dts: qcom: sdm850-lenovo-yoga-c630: fix RTC offset info Dmitry Baryshkov

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).