linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@dell.com>
To: dvhart@infradead.org, Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	platform-driver-x86@vger.kernel.org,
	Andy Lutomirski <luto@kernel.org>,
	quasisec@google.com, pali.rohar@gmail.com, rjw@rjwysocki.net,
	mjg59@google.com, hch@lst.de, Greg KH <greg@kroah.com>,
	Alan Cox <gnomes@lxorguk.ukuu.org.uk>,
	Mario Limonciello <mario.limonciello@dell.com>
Subject: [PATCH v11 11/15] platform/x86: dell-smbios-smm: test for WSMT
Date: Fri, 20 Oct 2017 12:40:26 -0500	[thread overview]
Message-ID: <4d949817a32f20f77ae9e2419f2261f806a9acc4.1508515469.git.mario.limonciello@dell.com> (raw)
In-Reply-To: <cover.1508515469.git.mario.limonciello@dell.com>
In-Reply-To: <cover.1508515469.git.mario.limonciello@dell.com>

WSMT is as an attestation to the OS that the platform won't
modify memory outside of pre-defined areas.

If a platform has WSMT enabled in BIOS setup, SMM calls through
dcdbas will fail.  The only way to access platform data in these
instances is through the WMI SMBIOS calling interface.

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Reviewed-by: Edward O'Callaghan <quasisec@google.com>
---
 drivers/platform/x86/dell-smbios-smm.c | 33 +++++++++++++++++++++++++++++++++
 drivers/platform/x86/dell-smbios.h     |  2 ++
 2 files changed, 35 insertions(+)

diff --git a/drivers/platform/x86/dell-smbios-smm.c b/drivers/platform/x86/dell-smbios-smm.c
index 53eabb14fb48..0c21a8adb91f 100644
--- a/drivers/platform/x86/dell-smbios-smm.c
+++ b/drivers/platform/x86/dell-smbios-smm.c
@@ -102,6 +102,32 @@ int dell_smbios_smm_call(struct calling_interface_buffer *input)
 	return 0;
 }
 
+/* When enabled this indicates that SMM won't work */
+static bool test_wsmt_enabled(void)
+{
+	struct calling_interface_token *wsmt;
+
+	/* if token doesn't exist, SMM will work */
+	wsmt = dell_smbios_find_token(WSMT_EN_TOKEN);
+	if (!wsmt)
+		return false;
+
+	/* If token exists, try to access over SMM but set a dummy return.
+	 * - If WSMT disabled it will be overwritten by SMM
+	 * - If WSMT enabled then dummy value will remain
+	 */
+	buffer->class = CLASS_TOKEN_READ;
+	buffer->select = SELECT_TOKEN_STD;
+	memset(buffer, 0, sizeof(struct calling_interface_buffer));
+	buffer->input[0] = wsmt->location;
+	buffer->output[0] = 99;
+	dell_smbios_smm_call(buffer);
+	if (buffer->output[0] == 99)
+		return true;
+
+	return false;
+}
+
 static int __init dell_smbios_smm_init(void)
 {
 	int ret;
@@ -115,6 +141,12 @@ static int __init dell_smbios_smm_init(void)
 
 	dmi_walk(find_cmd_address, NULL);
 
+	if (test_wsmt_enabled()) {
+		pr_debug("Disabling due to WSMT enabled\n");
+		ret = -ENODEV;
+		goto fail_wsmt;
+	}
+
 	platform_device = platform_device_alloc("dell-smbios", 1);
 	if (!platform_device) {
 		ret = -ENOMEM;
@@ -138,6 +170,7 @@ static int __init dell_smbios_smm_init(void)
 fail_platform_device_add:
 	platform_device_put(platform_device);
 
+fail_wsmt:
 fail_platform_device_alloc:
 	free_page((unsigned long)buffer);
 	return ret;
diff --git a/drivers/platform/x86/dell-smbios.h b/drivers/platform/x86/dell-smbios.h
index 079776421b46..956fe9304ed7 100644
--- a/drivers/platform/x86/dell-smbios.h
+++ b/drivers/platform/x86/dell-smbios.h
@@ -44,6 +44,8 @@
 #define KBD_LED_AUTO_100_TOKEN	0x02F6
 #define GLOBAL_MIC_MUTE_ENABLE	0x0364
 #define GLOBAL_MIC_MUTE_DISABLE	0x0365
+#define WSMT_EN_TOKEN		0x04EC
+#define WSMT_DIS_TOKEN		0x04ED
 
 struct notifier_block;
 
-- 
2.14.1

  parent reply	other threads:[~2017-10-20 17:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 17:40 [PATCH v11 00/15] Introduce support for Dell SMBIOS over WMI Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 01/15] platform/x86: wmi: Add new method wmidev_evaluate_method Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 02/15] platform/x86: dell-wmi: increase severity of some failures Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 03/15] platform/x86: dell-wmi: clean up wmi descriptor check Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 04/15] platform/x86: dell-wmi: don't check length returned Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 05/15] platform/x86: dell-wmi-descriptor: split WMI descriptor into it's own driver Mario Limonciello
2017-10-30 11:46   ` Pali Rohár
2017-10-30 13:32     ` Mario.Limonciello
2017-10-31 23:31       ` Darren Hart
2017-11-01  8:19         ` Pali Rohár
2017-11-01 16:42           ` Mario.Limonciello
2017-10-20 17:40 ` [PATCH v11 06/15] platform/x86: wmi: Don't allow drivers to get each other's GUIDs Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 07/15] platform/x86: dell-smbios: only run if proper oem string is detected Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 08/15] platform/x86: dell-smbios: Add a sysfs interface for SMBIOS tokens Mario Limonciello
2017-10-30 11:56   ` Pali Rohár
2017-10-30 13:36     ` Mario.Limonciello
2017-10-31 15:24       ` Darren Hart
2017-10-20 17:40 ` [PATCH v11 09/15] platform/x86: dell-smbios: Introduce dispatcher for SMM calls Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 10/15] platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver Mario Limonciello
2017-10-20 17:40 ` Mario Limonciello [this message]
2017-10-20 17:40 ` [PATCH v11 12/15] platform/x86: dell-smbios: Add filtering support Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 13/15] platform/x86: wmi: create userspace interface for drivers Mario Limonciello
2017-10-20 17:40 ` [PATCH v11 14/15] platform/x86: dell-smbios-wmi: introduce userspace interface Mario Limonciello
2017-10-28 13:18   ` Darren Hart
2017-11-01  0:27   ` Edward O'Callaghan
2017-11-01 16:15     ` Mario.Limonciello
2017-10-20 17:40 ` [PATCH v11 15/15] tools/wmi: add a sample for dell smbios communication over WMI Mario Limonciello

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=4d949817a32f20f77ae9e2419f2261f806a9acc4.1508515469.git.mario.limonciello@dell.com \
    --to=mario.limonciello@dell.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=greg@kroah.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mjg59@google.com \
    --cc=pali.rohar@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=quasisec@google.com \
    --cc=rjw@rjwysocki.net \
    /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).