From: Patrick Rudolph <[email protected]>
This patch series fixes 3 independent bugs in the google firmware
drivers.
Patch 1-2 do proper cleanup at kernel module unloading.
Patch 3 adds a check if the optional GSMI SMM handler is actually
present in the firmware and responses to the driver.
Changes in v2:
- Add missing return statement
- Add s-o-b on GSMI patches
- Add define for reserved GSMI command
Changes in v3:
- Cosmetic changes only
Arthur Heymans (2):
firmware: google: Unregister driver_info on failure and exit in gsmi
firmware: google: Probe for a GSMI handler in firmware
Patrick Rudolph (1):
firmware: google: Release devices before unregistering the bus
drivers/firmware/google/coreboot_table.c | 7 +++++++
drivers/firmware/google/gsmi.c | 25 ++++++++++++++++++++++++
2 files changed, 32 insertions(+)
--
2.21.0
From: Arthur Heymans <[email protected]>
Currently this driver is loaded if the DMI string matches coreboot
and has a proper smi_command in the ACPI FADT table, but a GSMI handler in
SMM is an optional feature in coreboot.
So probe for a SMM GSMI handler before initializing the driver.
If the smihandler leaves the calling argument in %eax in the SMM save state
untouched that generally means the is no handler for GSMI.
Signed-off-by: Arthur Heymans <[email protected]>
Signed-off-by: Patrick Rudolph <[email protected]>
---
-v2:
Add missing s-o-b and add define for reserved command.
-v3:
No changes.
---
drivers/firmware/google/gsmi.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 974c769b75cf..5b2011ebbe26 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -76,6 +76,7 @@
#define GSMI_CMD_LOG_S0IX_RESUME 0x0b
#define GSMI_CMD_CLEAR_CONFIG 0x20
#define GSMI_CMD_HANDSHAKE_TYPE 0xC1
+#define GSMI_CMD_RESERVED 0xff
/* Magic entry type for kernel events */
#define GSMI_LOG_ENTRY_TYPE_KERNEL 0xDEAD
@@ -746,6 +747,7 @@ MODULE_DEVICE_TABLE(dmi, gsmi_dmi_table);
static __init int gsmi_system_valid(void)
{
u32 hash;
+ u16 cmd, result;
if (!dmi_check_system(gsmi_dmi_table))
return -ENODEV;
@@ -780,6 +782,23 @@ static __init int gsmi_system_valid(void)
return -ENODEV;
}
+ /* Test the smihandler with a bogus command. If it leaves the
+ * calling argument in %ax untouched, there is no handler for
+ * GSMI commands.
+ */
+ cmd = GSMI_CALLBACK | GSMI_CMD_RESERVED << 8;
+ asm volatile (
+ "outb %%al, %%dx\n\t"
+ : "=a" (result)
+ : "0" (cmd),
+ "d" (acpi_gbl_FADT.smi_command)
+ : "memory", "cc"
+ );
+ if (cmd == result) {
+ pr_info("gsmi: no gsmi handler in firmware\n");
+ return -ENODEV;
+ }
+
/* Found */
return 0;
}
--
2.21.0