From: patrick.rudolph@9elements.com
To: linux-kernel@vger.kernel.org
Cc: coreboot@coreboot.org, patrick.rudolph@9elements.com,
Arthur Heymans <arthur@aheymans.xyz>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Allison Randal <allison@lohutok.net>,
Alexios Zavras <alexios.zavras@intel.com>
Subject: [PATCH 3/3] firmware: google: Probe for a GSMI handler in firmware
Date: Fri, 15 Nov 2019 14:48:39 +0100 [thread overview]
Message-ID: <20191115134842.17013-4-patrick.rudolph@9elements.com> (raw)
In-Reply-To: <20191115134842.17013-1-patrick.rudolph@9elements.com>
From: Arthur Heymans <arthur@aheymans.xyz>
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>
---
drivers/firmware/google/gsmi.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 974c769b75cf..a3eaa9f41125 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -746,6 +746,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 +781,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 | 0xff << 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
prev parent reply other threads:[~2019-11-15 13:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 13:48 [PATCH 0/3] firmware: google: Fix minor bugs patrick.rudolph
2019-11-15 13:48 ` [PATCH 1/3] firmware: google: Release devices before unregistering the bus patrick.rudolph
2019-11-15 20:28 ` kbuild test robot
2019-11-16 13:38 ` Greg Kroah-Hartman
2019-11-18 8:12 ` patrick.rudolph
2019-11-15 13:48 ` [PATCH 2/3] firmware: google: Unregister driver_info on failure and exit in gsmi patrick.rudolph
2019-11-16 13:39 ` Greg Kroah-Hartman
2019-11-16 13:40 ` Greg Kroah-Hartman
2019-11-18 7:59 ` patrick.rudolph
2019-11-18 8:13 ` Greg Kroah-Hartman
2019-11-15 13:48 ` patrick.rudolph [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191115134842.17013-4-patrick.rudolph@9elements.com \
--to=patrick.rudolph@9elements.com \
--cc=alexios.zavras@intel.com \
--cc=allison@lohutok.net \
--cc=arthur@aheymans.xyz \
--cc=coreboot@coreboot.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).