From patchwork Wed Oct 11 16:27:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10000041 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 2D00260216 for ; Wed, 11 Oct 2017 16:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14CD728A7F for ; Wed, 11 Oct 2017 16:29:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 097E228AC4; Wed, 11 Oct 2017 16:29:48 +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=ham 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 A75D128A7F for ; Wed, 11 Oct 2017 16:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757528AbdJKQ3q (ORCPT ); Wed, 11 Oct 2017 12:29:46 -0400 Received: from esa6.dell-outbound.iphmx.com ([68.232.149.229]:38352 "EHLO esa6.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757511AbdJKQ1w (ORCPT ); Wed, 11 Oct 2017 12:27:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1507739272; x=1539275272; h=from:to:cc:subject:date:message-id; bh=QglEEbZdCHy3CSC6Vyf2ue/fZ7fRmaoyUq8z68viBmA=; b=WHqWgJNOhzQudU/xlk24SEwTeYljtQJTjQqi+k8tycuNEO0rG9XWXkkP UYn+MaYuqDb3+dPd+sGVKC4dGJs8kyjxkFyQ/jihk5BRgKcGVF55NKDbU 745RZnu8jOdYd+WFfdgqr01PV+bwLWFXNA3wFFXJGmf7ayEwlHnfhlame 0=; Received: from esa6.dell-outbound2.iphmx.com ([68.232.154.99]) by esa6.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 11:27:51 -0500 Received: from ausxipps301.us.dell.com ([143.166.148.223]) by esa6.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 22:27:51 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.43,362,1503378000"; d="scan'208";a="72257558" 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 , Mario Limonciello Subject: [PATCH v7 12/15] platform/x86: dell-smbios-smm: test for WSMT Date: Wed, 11 Oct 2017 11:27:38 -0500 Message-Id: <0f598e216516c511477865bc3fc39d1da1211276.1507733291.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 | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/platform/x86/dell-smbios-smm.c b/drivers/platform/x86/dell-smbios-smm.c index b003d70ef7eb..0dbd28e78803 100644 --- a/drivers/platform/x86/dell-smbios-smm.c +++ b/drivers/platform/x86/dell-smbios-smm.c @@ -26,6 +26,9 @@ static struct calling_interface_buffer *buffer; struct platform_device *platform_device; static DEFINE_MUTEX(smm_mutex); +/* When enabled this token indicates that SMM won't work */ +#define WSMT_EN_TOKEN 0x04EC + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell laptop", @@ -100,6 +103,30 @@ int dell_smbios_smm_call(struct calling_interface_buffer *input) return 0; } +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 = 0; + buffer->select = 0; + 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; @@ -113,6 +140,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; @@ -136,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;