Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2561332ybc; Mon, 18 Nov 2019 00:43:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyon3PQLXnMEHY6u5EsHauaQqNRVR6C5jUHldP2by5V5KqW26h7uJ2iLwGWzb6/JszdzxST X-Received: by 2002:a17:906:1249:: with SMTP id u9mr25460888eja.253.1574066583983; Mon, 18 Nov 2019 00:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574066583; cv=none; d=google.com; s=arc-20160816; b=FqX5vQwRH4IdgjpzGl4/IkuO0RMGr40/NuG9JPh0664l96TfLNLLmoiCdTZHCKsski 5oGML22ZkeVMyyAN9DHiekNhoRyZR9i18W21KGKoEb2ukQ+w5DD6M7rKO5k1zYDL3Ik8 gcAgs+NmztJGq9v7JraPs8UlOU0utRzXBwrLtg9kGVfZTiQapoTeCqQZtsPNiK4rRpJJ yXW/NK2YFU93V3yLBZxsWw55TOyOJ9CGDDYJlMAQGTJApYrLABTwL947N6TkYh0mjJGq UUsTzRiKd5nH35rScqgsQdsUrz0huZwj4Wv+VFrHbX9e2iWFlmYU5X8s3VteV4+WLJNw eTQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l/4KEkLITq2bAD2Q4JLMyFpEUnZBBMmBfjgRPECjVtM=; b=cL5acwGwBIyCVTIRNOhzJPfUb49W4p3J4tNQQj0PufRTFQP6EwNs0oPifcvVmAwnu+ P6lUvK+4IaMLJluEqx67xZzuGKG+nRg+ty3evklQAaJ+QaXaB0nal/lir95avSsJPPlp pSca8Gu+7jyHroyOiS/Kll9SSmBJvlbmw63qIzTlrXbEHAII4GEs3WS5rLUQQujUGzoZ F1583S4kArY73va6/yEL0J6/ZP2S/6X/YkdVaBTFuZ7ClBQUBznBPFZMSyVHtzs0g7Zh BAS6xgOBVXGPD2PvzLQoIhySEcAstFF9vMuS4he0Z2yoGchDit6n8FTWsPzhpGAMNQEA 9Obw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=BazAFLyy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f25si10986467ejw.85.2019.11.18.00.42.40; Mon, 18 Nov 2019 00:43:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=BazAFLyy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726939AbfKRIj2 (ORCPT + 99 others); Mon, 18 Nov 2019 03:39:28 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44978 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfKRIj2 (ORCPT ); Mon, 18 Nov 2019 03:39:28 -0500 Received: by mail-wr1-f66.google.com with SMTP id f2so18327424wrs.11 for ; Mon, 18 Nov 2019 00:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l/4KEkLITq2bAD2Q4JLMyFpEUnZBBMmBfjgRPECjVtM=; b=BazAFLyy02yC+PNnAgDSZQFqJT1Orv2PdA02ZSK6GElQM4LdfBdBS6cbJzJ7vFtIOi MpaS3JUEbn4dXGOZffT/Q7WMKvsKtkjlF5gyTeRqih4u/I+WqrJEaB3+4GNLJr4KzHvF nM/KLDfoZPrjjTBuX7TvQ7/fhUZUrpQClQPstArW+3K0BX0AjWzUjhC8o67RyCJ90cYq /gxjz5ylu7K1IyOZDMEIdrun47ZjIn9YHzqWs1xY/fWT9vskRxUk5X4O+WiUORBy2Ho7 nftOUpUEt9ji6UgAr1EkwHMnHqRR3Y9EVF54v2GmCeC8aCQF+1l15jnZ0L1G4UIcjlGN 7djw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l/4KEkLITq2bAD2Q4JLMyFpEUnZBBMmBfjgRPECjVtM=; b=rAhsXfeEZzZ28c4tp7E2ukBgMFAa7sprRaE631dcqW32pxTooyTRiUAEVy6XQpSt2U kS6ph/p21Qtne4pBw1u1SEA9dkSEXY0kRO3KUrFQFRYF2nsyXJsw7kh77B6XywCrmCjI pUDBLz1lFuUxi0+RcciFkHJd9CXgxkcLk56pYx7YwJq7KWbxiVWOWEhurpBwyL5JI8/S mlsrs0fGWcijs2Q1LZgI3nBdINr3qT4GXSIjje3CJQioPhVrsdtfg9Tfxrv+0vx6UoLY +cBg8ArpTsIFh5sB7M8HW+fDz9AdeEk1mspaFiItUMUanHS/BZmLA1bePQlbb5jOZujV 0h5w== X-Gm-Message-State: APjAAAXCCn5vpQlc8rKhukFntT6HOkFNJjyLeNFkS0vhis4xu8bQ2BnX NWesO07trcJoBbMu1AvLmRoab3V3g65PxW/x X-Received: by 2002:adf:f18e:: with SMTP id h14mr10606428wro.348.1574066364683; Mon, 18 Nov 2019 00:39:24 -0800 (PST) Received: from rudolphp.9e.network (b2b-78-94-0-50.unitymedia.biz. [78.94.0.50]) by smtp.gmail.com with ESMTPSA id z14sm21700530wrl.60.2019.11.18.00.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 00:39:24 -0800 (PST) From: patrick.rudolph@9elements.com To: linux-kernel@vger.kernel.org Cc: coreboot@coreboot.org, Arthur Heymans , Patrick Rudolph , Thomas Gleixner , Allison Randal , Alexios Zavras , Greg Kroah-Hartman Subject: [Patch v2 3/3] firmware: google: Probe for a GSMI handler in firmware Date: Mon, 18 Nov 2019 09:39:00 +0100 Message-Id: <20191118083903.19311-3-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191118083903.19311-1-patrick.rudolph@9elements.com> References: <20191118083903.19311-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arthur Heymans 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 Signed-off-by: Patrick Rudolph --- drivers/firmware/google/gsmi.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 974c769b75cf..5b2011ebbe26 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -76,6 +76,7 @@ #define GSMI_CMD_LOG_S0IX_RESUME 0x0b #define GSMI_CMD_CLEAR_CONFIG 0x20 #define GSMI_CMD_HANDSHAKE_TYPE 0xC1 +#define GSMI_CMD_RESERVED 0xff /* Magic entry type for kernel events */ #define GSMI_LOG_ENTRY_TYPE_KERNEL 0xDEAD @@ -746,6 +747,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 +782,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 | GSMI_CMD_RESERVED << 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