Skip to contentSkip to conversation

platform/x86: Add Slim Bootloader firmware update support

PATCH Superseded Jithu Joseph 2 participants 5 messages Apr 20, 2020 – Apr 23, 2020 x86 platform drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover platform/x86: Add Slim Bootloader firmware update support

Slim Bootloader(SBL) [1] is a small open-source boot firmware, designed for running on certain Intel platforms. SBL can be thought-of as fulfilling the role of a minimal BIOS implementation, i.e initializing the hardware and booting Operating System.

This driver creates sysfs interfaces which allows user space entities to trigger update of SBL firmware.

Acknowledgment: Initial draft of the driver code was authored by Maurice Ma <[email protected]>

[1] https://slimbootloader.github.io

Jithu Joseph (1):
platform/x86: Add Slim Bootloader firmware update signaling driver

 MAINTAINERS                        |   7 ++
 drivers/platform/x86/Kconfig       |  10 ++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/sbl_fwu_wmi.c | 143 +++++++++++++++++++++++++++++
 4 files changed, 161 insertions(+)
 create mode 100644 drivers/platform/x86/sbl_fwu_wmi.c

base-commit: 8f3d9f354286745c751374f5f1fcafee6b3f3136

Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 platform/x86: Add Slim Bootloader firmware update signaling driver

Slim Bootloader(SBL) [1] is a small open-source boot firmware, designed for running on certain Intel platforms. SBL can be thought-of as fulfilling the role of a minimal BIOS implementation, i.e initializing the hardware and booting Operating System.

Since SBL is not UEFI compliant, firmware update cannot be triggered using standard UEFI runtime services. Further considering performance impact, SBL doesn't look for a firmware update image on every reset and does so only when firmware update signal is asserted.

SBL exposes an ACPI-WMI device which comes up in sysfs as /sys/bus/wmi/44FADEB1xxx and this driver adds a "firmware_update_request" device attribute. This attribute normally has a value of 0 and userspace can signal SBL to update firmware, on next reboot, by writing a value of 1:

echo 1 > /sys/bus/wmi/devices/44FADEB1-B204-40F2-8581-394BBDC1B651/firmware_update_request

This driver only implements a signaling mechanism, the actual firmware update process and various details like firmware update image format, firmware image location etc are defined by SBL [2] and are not in the scope of this driver.

[1] https://slimbootloader.github.io
[2] https://slimbootloader.github.io/security/firmware-update.html

---
 MAINTAINERS                        |   7 ++
 drivers/platform/x86/Kconfig       |  10 ++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/sbl_fwu_wmi.c | 143 +++++++++++++++++++++++++++++
 4 files changed, 161 insertions(+)
 create mode 100644 drivers/platform/x86/sbl_fwu_wmi.c
MAINTAINERS +7 -0
index e64e5db31497..fb5542afff39 100644
@@ -15449,6 +15449,13 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 F:	include/linux/srcu*.h
 F:	kernel/rcu/srcu*.c
 
+SLIM BOOTLOADER (SBL) FIRMWARE UPDATE WMI DRIVER
+M:	Jithu Joseph <[email protected]>
+R:	Maurice Ma <[email protected]>
+S:	Maintained
+W:	https://slimbootloader.github.io/security/firmware-update.html
+F:	drivers/platform/x86/sbl_fwu_wmi.c
+
 SMACK SECURITY MODULE
 M:	Casey Schaufler <[email protected]>
 L:	[email protected]
drivers/platform/x86/Kconfig +10 -0
index 0ad7ad8cf8e1..aac2bae19a35 100644
@@ -114,6 +114,16 @@ config XIAOMI_WMI
 	  To compile this driver as a module, choose M here: the module will
 	  be called xiaomi-wmi.
 
+config SBL_FWU_WMI
+	tristate "WMI driver for Slim Bootloader firmware update signaling"
+	depends on ACPI_WMI
+	help
+	  Say Y here if you want to be able to use the WMI interface to signal
+	  Slim Bootloader to trigger update on next reboot.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called sbl-fwu-wmi.
+
 config ACERHDF
 	tristate "Acer Aspire One temperature and fan driver"
 	depends on ACPI && THERMAL
drivers/platform/x86/Makefile +1 -0
index 53408d965874..3d53828e62d5 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_INTEL_WMI_THUNDERBOLT)	+= intel-wmi-thunderbolt.o
 obj-$(CONFIG_MXM_WMI)			+= mxm-wmi.o
 obj-$(CONFIG_PEAQ_WMI)			+= peaq-wmi.o
 obj-$(CONFIG_XIAOMI_WMI)		+= xiaomi-wmi.o
+obj-$(CONFIG_SBL_FWU_WMI)		+= sbl_fwu_wmi.o
 
 # Acer
 obj-$(CONFIG_ACERHDF)		+= acerhdf.o
drivers/platform/x86/sbl_fwu_wmi.c new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/1] platform/x86: Add Slim Bootloader firmware update signaling driver

Quoted 18 lines · Jithu Joseph

Slim Bootloader(SBL) [1] is a small open-source boot firmware, designed for running on certain Intel platforms. SBL can be thought-of as fulfilling the role of a minimal BIOS implementation, i.e initializing the hardware and booting Operating System.

Since SBL is not UEFI compliant, firmware update cannot be triggered using standard UEFI runtime services. Further considering performance impact, SBL doesn't look for a firmware update image on every reset and does so only when firmware update signal is asserted.

SBL exposes an ACPI-WMI device which comes up in sysfs as /sys/bus/wmi/44FADEB1xxx and this driver adds a "firmware_update_request" device attribute. This attribute normally has a value of 0 and userspace can signal SBL to update firmware, on next reboot, by writing a value of 1:

Quoted 6 lines

echo 1 > /sys/bus/wmi/devices/44FADEB1-B204-40F2-8581-394BBDC1B651/firmware_update_request

This driver only implements a signaling mechanism, the actual firmware update process and various details like firmware update image format, firmware image location etc are defined by SBL [2] and are not in the scope of this driver.

I have noticed that it misses ABI documentation. So, please add. Also some comments below.

...

Quoted 2 lines

[1] https://slimbootloader.github.io
[2] https://slimbootloader.github.io/security/firmware-update.html

Can you add a DocLink: tag below for the reference to the official documentation?

...

MAINTAINERS T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev · line 15457

Quoted 6 lines
MAINTAINERS +6 -0
+SLIM BOOTLOADER (SBL) FIRMWARE UPDATE WMI DRIVER
+M:     Jithu Joseph <[email protected]>
+R:     Maurice Ma <[email protected]>
+S:     Maintained
+W:     https://slimbootloader.github.io/security/firmware-update.html
+F:     drivers/platform/x86/sbl_fwu_wmi.c

I hope you run latest and greatest version of checkpatch.pl and it's okay with this section.

...

Quoted 15 lines
drivers/platform/x86/Kconfig +9 -0
@@ -114,6 +114,16 @@ config XIAOMI_WMI
          To compile this driver as a module, choose M here: the module will
          be called xiaomi-wmi.
 
+config SBL_FWU_WMI
+       tristate "WMI driver for Slim Bootloader firmware update signaling"
+       depends on ACPI_WMI
+       help
+         Say Y here if you want to be able to use the WMI interface to signal
+         Slim Bootloader to trigger update on next reboot.
+
+         To compile this driver as a module, choose M here: the module will
+         be called sbl-fwu-wmi.
 

drivers/platform/x86/Kconfig obj-$(CONFIG_INTEL_WMI_THUNDERBOLT) += intel-wmi-thunderbolt.o · line 18

Quoted 4 lines
drivers/platform/x86/Kconfig +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_INTEL_WMI_THUNDERBOLT)   += intel-wmi-thunderbolt.o
 obj-$(CONFIG_MXM_WMI)                  += mxm-wmi.o
 obj-$(CONFIG_PEAQ_WMI)                 += peaq-wmi.o
 obj-$(CONFIG_XIAOMI_WMI)               += xiaomi-wmi.o
+obj-$(CONFIG_SBL_FWU_WMI)              += sbl_fwu_wmi.o

I didn't get an ordering schema in above files.
Shouldn't be rather alphasort?

...

drivers/platform/x86/sbl_fwu_wmi.c line 95

Quoted 13 lines
drivers/platform/x86/sbl_fwu_wmi.c new file +12 -0
+static ssize_t firmware_update_request_store(struct device *dev,
+                                            struct device_attribute *attr,
+                                            const char *buf, size_t count)
+{
+       bool val;
+       int ret;
+
+       ret = kstrtobool(buf, &val);
+       if (ret)
+               return ret;
+
 
+       ret = set_fwu_request(dev, val ? 1 : 0);

Hmm... If you are going to extend this, why not to pass integer directly? (And thus take one from user)

drivers/platform/x86/sbl_fwu_wmi.c line 101

Quoted 7 lines
drivers/platform/x86/sbl_fwu_wmi.c new file +6 -0
+       if (ret)
+               return ret;
+
+       return count;
+}
 
+

Extra blank line.

drivers/platform/x86/sbl_fwu_wmi.c line 108

Quoted 8 lines
drivers/platform/x86/sbl_fwu_wmi.c new file +7 -0
+static DEVICE_ATTR_RW(firmware_update_request);
+
+static struct attribute *firmware_update_attrs[] = {
+       &dev_attr_firmware_update_request.attr,
+       NULL
+};
 
+

Extra blank line.

Quoted 1 line

+ATTRIBUTE_GROUPS(firmware_update);

...

Quoted 1 line

+MODULE_DEVICE_TABLE(wmi, sbl_fwu_wmi_id_table);

Move it closer to the table structure.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH 1/1] platform/x86: Add Slim Bootloader firmware update signaling driver

Hi Andy,

Appreciate your valuable feedback. I think I understood most of your comments but I need clarification regarding the last comment in this reply.

Quoted 12 lines · Andy Shevchenko

On Mon, Apr 20, 2020 at 10:50 PM Jithu Joseph <[email protected]

Quoted 10 lines

wrote:

This driver only implements a signaling mechanism, the actual firmware
update process and various details like firmware update image format,
firmware image location etc are defined by SBL [2] and are not in the
scope of this driver.

Quoted 2 lines

I have noticed that it misses ABI documentation. So, please add. Also some comments below.

I will add one via a new Documentation/ABI/testing/sysfs-platform-sbl- fwu-wmi file

Quoted 8 lines

...

Quoted 2 lines

[1] https://slimbootloader.github.io
[2] https://slimbootloader.github.io/security/firmware-update.html

Can you add a DocLink: tag below for the reference to the official documentation?

I wasnt aware of this tag. Will add this.

Quoted 13 lines

...

Quoted 7 lines
MAINTAINERS +5 -0
+SLIM BOOTLOADER (SBL) FIRMWARE UPDATE WMI DRIVER
+M:     Jithu Joseph <[email protected]>
+R:     Maurice Ma <[email protected]>
+S:     Maintained
+W:     

https://slimbootloader.github.io/security/firmware-update.html
+F: drivers/platform/x86/sbl_fwu_wmi.c

I hope you run latest and greatest version of checkpatch.pl and it's okay with this section.

Yes it was fine, chekpatch.pl was merely asking to update the MAINTAINERS file. And the ordering of the section matches with that of parse-maintainers.pl

Quoted 21 lines

...

Quoted 18 lines
(quoted diff) +0 -0
@@ -114,6 +114,16 @@ config XIAOMI_WMI
          To compile this driver as a module, choose M here: the

module will
be called xiaomi-wmi.

(quoted diff) +2 -0
+config SBL_FWU_WMI
+       tristate "WMI driver for Slim Bootloader firmware update

signaling"

drivers/platform/x86/Kconfig +3 -0
+       depends on ACPI_WMI
+       help
+         Say Y here if you want to be able to use the WMI

interface to signal

drivers/platform/x86/Kconfig +3 -0
+         Slim Bootloader to trigger update on next reboot.
+
+         To compile this driver as a module, choose M here: the

module will

drivers/platform/x86/Kconfig +1 -0
+         be called sbl-fwu-wmi.
@@ -15,6 +15,7 @@ obj-$(CONFIG_INTEL_WMI_THUNDERBOLT)   += intel-
Quoted 8 lines
Quoted 5 lines

wmi-thunderbolt.o

 obj-$(CONFIG_MXM_WMI)                  += mxm-wmi.o
 obj-$(CONFIG_PEAQ_WMI)                 += peaq-wmi.o
 obj-$(CONFIG_XIAOMI_WMI)               += xiaomi-wmi.o
+obj-$(CONFIG_SBL_FWU_WMI)              += sbl_fwu_wmi.o

I didn't get an ordering schema in above files.
Shouldn't be rather alphasort?

Looks like there is an ordering within the wmi related files, so I will move mine in between PEAQ_WMI and XIAOMI_WMI .

Quoted 12 lines

...

Quoted 9 lines
(quoted diff) +2 -0
+static ssize_t firmware_update_request_store(struct device *dev,
+                                            struct

device_attribute *attr,
+ const char *buf,
size_t count)

drivers/platform/x86/sbl_fwu_wmi.c new file +4 -0
+{
+       bool val;
+       int ret;
+
Quoted 8 lines

drivers/platform/x86/sbl_fwu_wmi.c line 95

Quoted 5 lines
drivers/platform/x86/sbl_fwu_wmi.c new file +5 -0
+       ret = kstrtobool(buf, &val);
+       if (ret)
+               return ret;
+
+       ret = set_fwu_request(dev, val ? 1 : 0);

Hmm... If you are going to extend this, why not to pass integer directly? (And thus take one from user)

We have also been thinking about extensibility …

So I will modify the code to allow any u32 input by the user to be passed down via wmi_set_block(), though 0 and 1 will be the only inputs documented in the ABI today.( Or did you still mean to error out if the user input is something other than 0 or 1 ?)

Thanks
Jithu

#4 lore raw

Re: [PATCH 1/1] platform/x86: Add Slim Bootloader firmware update signaling driver

On Thu, Apr 23, 2020 at 5:08 AM Jithu Joseph <[email protected]> wrote:

...

Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +2 -0
+static ssize_t firmware_update_request_store(struct device *dev,
+                                            struct

device_attribute *attr,
+ const char *buf,
size_t count)

drivers/platform/x86/sbl_fwu_wmi.c new file +4 -0
+{
+       bool val;
+       int ret;
+
Quoted 8 lines

drivers/platform/x86/sbl_fwu_wmi.c line 95

Quoted 5 lines
drivers/platform/x86/sbl_fwu_wmi.c new file +5 -0
+       ret = kstrtobool(buf, &val);
+       if (ret)
+               return ret;
+
+       ret = set_fwu_request(dev, val ? 1 : 0);

Hmm... If you are going to extend this, why not to pass integer directly? (And thus take one from user)

Quoted 6 lines

We have also been thinking about extensibility …

So I will modify the code to allow any u32 input by the user to be passed down via wmi_set_block(), though 0 and 1 will be the only inputs documented in the ABI today.( Or did you still mean to error out if the user input is something other than 0 or 1 ?)

I think the best approach is to allow to parse integer input (kstrtouint() is good enough) and return -ERANGE for values > 1. Also put a comment before that check why is done like this (some justification that interface may be extended in the future or so), and pass integer value directly to set_fwu_request().

Signature · 2 lines
With Best Regards,
Andy Shevchenko