Skip to contentSkip to conversation

] efibc: Replace variable set function in notifier call

efi boot control [email protected] 2 participants 3 messages Jun 12, 2019 – Jun 21, 2019 EFI

lore
Share & tools
lore
#0 lore raw

From: Tian Baofeng <[email protected]>

Replace the variable set function from "efivar_entry_set" to "efivar_entry_set_safe" in efibc panic notifier.
In safe function parameter "block" will set to false
and will call "efivar_entry_set_nonblocking"to set efi variables. efivar_entry_set_nonblocking is guaranteed to
not block and is suitable for calling from crash/panic handlers. In UEFI android platform, when warm reset happens,
with this change, efibc will not block the reboot process. Otherwise, set variable will call queue work and send to other offlined cpus then cause another panic, finally will cause reboot failure.

---
 drivers/firmware/efi/efibc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/firmware/efi/efibc.c +7 -5
index 61e099826cbb..35dccc88ac0a 100644
@@ -43,11 +43,13 @@ static int efibc_set_variable(const char *name, const char *value)
 	efibc_str_to_str16(value, (efi_char16_t *)entry->var.Data);
 	memcpy(&entry->var.VendorGuid, &guid, sizeof(guid));
 
-	ret = efivar_entry_set(entry,
-			       EFI_VARIABLE_NON_VOLATILE
-			       | EFI_VARIABLE_BOOTSERVICE_ACCESS
-			       | EFI_VARIABLE_RUNTIME_ACCESS,
-			       size, entry->var.Data, NULL);
+	ret = efivar_entry_set_safe(entry->var.VariableName,
+				    entry->var.VendorGuid,
+				    EFI_VARIABLE_NON_VOLATILE
+				    | EFI_VARIABLE_BOOTSERVICE_ACCESS
+				    | EFI_VARIABLE_RUNTIME_ACCESS,
+				    false, size, entry->var.Data);
+
 	if (ret)
 		pr_err("failed to set %s EFI variable: 0x%x\n",
 		       name, ret);
Signature · 1 line
2.21.0
#1 lore raw

Hi, Reviewers and all

Could you help review below changes? and let me know your opinion.

Jeremy, could you help add Matt Fleming into the loop to review this change?

Thanks
Tim

-----Original Message-----
From: Tian, Baofeng
Sent: Wednesday, June 12, 2019 4:18 PM
To: [email protected]; [email protected]; Compostella, Jeremy <[email protected]>; Tan, Ming <[email protected]>; Zhuang, Qihua <[email protected]>
Cc: Tian, Baofeng <[email protected]>; Luo, XinanX <[email protected]>
Subject: [[efi boot control]] efibc: Replace variable set function in notifier call

From: Tian Baofeng <[email protected]>

Replace the variable set function from "efivar_entry_set" to "efivar_entry_set_safe" in efibc panic notifier.
In safe function parameter "block" will set to false and will call "efivar_entry_set_nonblocking"to set efi variables. efivar_entry_set_nonblocking is guaranteed to not block and is suitable for calling from crash/panic handlers.
In UEFI android platform, when warm reset happens, with this change, efibc will not block the reboot process. Otherwise, set variable will call queue work and send to other offlined cpus then cause another panic, finally will cause reboot failure.

---
 drivers/firmware/efi/efibc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/firmware/efi/efibc.c +7 -5
@@ -43,11 +43,13 @@ static int efibc_set_variable(const char *name, const char *value)
 	efibc_str_to_str16(value, (efi_char16_t *)entry->var.Data);
 	memcpy(&entry->var.VendorGuid, &guid, sizeof(guid));
 
-	ret = efivar_entry_set(entry,
-			       EFI_VARIABLE_NON_VOLATILE
-			       | EFI_VARIABLE_BOOTSERVICE_ACCESS
-			       | EFI_VARIABLE_RUNTIME_ACCESS,
-			       size, entry->var.Data, NULL);
+	ret = efivar_entry_set_safe(entry->var.VariableName,
+				    entry->var.VendorGuid,
+				    EFI_VARIABLE_NON_VOLATILE
+				    | EFI_VARIABLE_BOOTSERVICE_ACCESS
+				    | EFI_VARIABLE_RUNTIME_ACCESS,
+				    false, size, entry->var.Data);
+
 	if (ret)
 		pr_err("failed to set %s EFI variable: 0x%x\n",
 		       name, ret);

--
2.21.0

#2 lore raw
In reply to [email protected]
Quoted 14 lines · On Wed, 12 Jun 2019 at 10:20, <[email protected]> wrote:

From: Tian Baofeng <[email protected]>

Replace the variable set function from "efivar_entry_set" to "efivar_entry_set_safe" in efibc panic notifier.
In safe function parameter "block" will set to false
and will call "efivar_entry_set_nonblocking"to set efi variables. efivar_entry_set_nonblocking is guaranteed to
not block and is suitable for calling from crash/panic handlers. In UEFI android platform, when warm reset happens,
with this change, efibc will not block the reboot process. Otherwise, set variable will call queue work and send to other offlined cpus then cause another panic, finally will cause reboot failure.

Quoted 2 lines

Queued as a fix in efi/urgent

Thanks

Quoted 30 lines
---
 drivers/firmware/efi/efibc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/firmware/efi/efibc.c +7 -6
index 61e099826cbb..35dccc88ac0a 100644
@@ -43,11 +43,13 @@ static int efibc_set_variable(const char *name, const char *value)
        efibc_str_to_str16(value, (efi_char16_t *)entry->var.Data);
        memcpy(&entry->var.VendorGuid, &guid, sizeof(guid));
 
-       ret = efivar_entry_set(entry,
-                              EFI_VARIABLE_NON_VOLATILE
-                              | EFI_VARIABLE_BOOTSERVICE_ACCESS
-                              | EFI_VARIABLE_RUNTIME_ACCESS,
-                              size, entry->var.Data, NULL);
+       ret = efivar_entry_set_safe(entry->var.VariableName,
+                                   entry->var.VendorGuid,
+                                   EFI_VARIABLE_NON_VOLATILE
+                                   | EFI_VARIABLE_BOOTSERVICE_ACCESS
+                                   | EFI_VARIABLE_RUNTIME_ACCESS,
+                                   false, size, entry->var.Data);
+
        if (ret)
                pr_err("failed to set %s EFI variable: 0x%x\n",
                       name, ret);
--

2.21.0