From patchwork Sat Oct 14 05:32:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10006229 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA6AC6037E for ; Sat, 14 Oct 2017 05:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A03C4290AF for ; Sat, 14 Oct 2017 05:34:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9503A290D1; Sat, 14 Oct 2017 05:34:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CCCA290AF for ; Sat, 14 Oct 2017 05:34:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753815AbdJNFeQ (ORCPT ); Sat, 14 Oct 2017 01:34:16 -0400 Received: from esa4.dell-outbound.iphmx.com ([68.232.149.214]:59321 "EHLO esa4.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753537AbdJNFdD (ORCPT ); Sat, 14 Oct 2017 01:33:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1507959183; x=1539495183; h=from:to:cc:subject:date:message-id; bh=p4mPNSvNgf+5WWT4mR/fGAjT2SMpPqw2l95AWD32EfI=; b=o9+nBek2Enk33ypuTZ9NUYbY9YSjaLT/cS4sIHm3BhxPqe/0FJbaAzqE cUOGNEAnbLT05GyjOxrM74L+J6+aMsqbW05Zt3vL1OuchIQstEodvFrnO UoSoq8CKUtUoarll9pZDtsEFVpBDb75nFb53V6EpIuOa/9W1zmtSFB7HE Q=; Received: from esa6.dell-outbound2.iphmx.com ([68.232.154.99]) by esa4.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2017 00:33:00 -0500 Received: from ausxippc110.us.dell.com ([143.166.85.200]) by esa6.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2017 11:33:00 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.43,374,1503378000"; d="scan'208";a="562232203" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, Andy Lutomirski , quasisec@google.com, pali.rohar@gmail.com, rjw@rjwysocki.net, mjg59@google.com, hch@lst.de, Greg KH , Alan Cox , Mario Limonciello Subject: [PATCH v8 11/15] platform/x86: dell-smbios-smm: test for WSMT Date: Sat, 14 Oct 2017 00:32:49 -0500 Message-Id: <652a47850d3bd966845ffeec7e49efdd03da1e80.1507958847.git.mario.limonciello@dell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 bd5a63a4aa15..5a03a3ea51e0 100644 --- a/drivers/platform/x86/dell-smbios-smm.c +++ b/drivers/platform/x86/dell-smbios-smm.c @@ -101,6 +101,31 @@ int dell_smbios_smm_call(struct calling_interface_buffer *input) return 0; } +/* When enabled this indicates that SMM won't work */ +static int test_wsmt_enabled(void) +{ + struct calling_interface_token *token; + + /* if token doesn't exist, SMM will work */ + token = dell_smbios_find_token(WSMT_EN_TOKEN); + if (!token) + return 0; + + /* if token exists, try to access over SMM */ + buffer->class = CLASS_TOKEN_READ; + buffer->select = SELECT_TOKEN_STD; + memset(buffer, 0, sizeof(struct calling_interface_buffer)); + buffer->input[0] = token->location; + dell_smbios_smm_call(buffer); + + /* if lookup failed, we know WSMT was enabled */ + if (buffer->output[0] != 0) + return 1; + + /* query token status if it didn't fail */ + return (buffer->output[1] == token->value); +} + static int __init dell_smbios_smm_init(void) { int ret; @@ -114,6 +139,13 @@ static int __init dell_smbios_smm_init(void) dmi_walk(find_cmd_address, NULL); + ret = test_wsmt_enabled(); + pr_debug("WSMT enable test: %d\n", ret); + if (ret) { + ret = -ENODEV; + goto fail_wsmt; + } + platform_device = platform_device_alloc("dell-smbios", 1); if (!platform_device) { ret = -ENOMEM; @@ -137,6 +169,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 8df330abeb5d..db6a16e5f87c 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;