Skip to content

Commit e4924ee

Browse files
ArthurHeymansgregkh
authored andcommitted
firmware: google: Probe for a GSMI handler in firmware
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 <arthur@aheymans.xyz> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Link: https://lore.kernel.org/r/20191118101934.22526-4-patrick.rudolph@9elements.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c6e7af0 commit e4924ee

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎drivers/firmware/google/gsmi.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define GSMI_CMD_LOG_S0IX_RESUME 0x0b
7777
#define GSMI_CMD_CLEAR_CONFIG 0x20
7878
#define GSMI_CMD_HANDSHAKE_TYPE 0xC1
79+
#define GSMI_CMD_RESERVED 0xff
7980

8081
/* Magic entry type for kernel events */
8182
#define GSMI_LOG_ENTRY_TYPE_KERNEL 0xDEAD
@@ -746,6 +747,7 @@ MODULE_DEVICE_TABLE(dmi, gsmi_dmi_table);
746747
static __init int gsmi_system_valid(void)
747748
{
748749
u32 hash;
750+
u16 cmd, result;
749751

750752
if (!dmi_check_system(gsmi_dmi_table))
751753
return -ENODEV;
@@ -780,6 +782,23 @@ static __init int gsmi_system_valid(void)
780782
return -ENODEV;
781783
}
782784

785+
/* Test the smihandler with a bogus command. If it leaves the
786+
* calling argument in %ax untouched, there is no handler for
787+
* GSMI commands.
788+
*/
789+
cmd = GSMI_CALLBACK | GSMI_CMD_RESERVED << 8;
790+
asm volatile (
791+
"outb %%al, %%dx\n\t"
792+
: "=a" (result)
793+
: "0" (cmd),
794+
"d" (acpi_gbl_FADT.smi_command)
795+
: "memory", "cc"
796+
);
797+
if (cmd == result) {
798+
pr_info("gsmi: no gsmi handler in firmware\n");
799+
return -ENODEV;
800+
}
801+
783802
/* Found */
784803
return 0;
785804
}

0 commit comments

Comments
 (0)