Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2645915ybc; Mon, 18 Nov 2019 02:25:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyoaLW217H+xYYXpsIRYpcSJr4Kqyk2AWWAdsslFOZsfr8+t/1kCZv3sQcB3nW8fPJM8gcG X-Received: by 2002:a17:906:8319:: with SMTP id j25mr24812410ejx.170.1574072710285; Mon, 18 Nov 2019 02:25:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574072710; cv=none; d=google.com; s=arc-20160816; b=bZa7i3MHP2b4mRYnehzGshVCxL1wDddgi9m9DR1LMk7x26QZuj+HXRm4vNUmi7gpMk 6lQbHIf6clIIsqUrn0yguUoXJaR59jzuC80kGY2x/dSMt1THhTRBU1mdmmdBb1di7m0+ Z5j5SozQqiEvln82YmBWEXA+Ce0lASMa39PrZxrL3lDz7FVZWNETV/Rp4HgKE5MsANhd UtnCQz2B/0Nv3OZQzcA1PUJiwCyYwcSg1N43khsbXgF3VeR7eVkbi4smKsJUgLB3aMKt fPBSbTd7qdRCQjs2BnScwxwvRnM8+2lzawPf8iRPxzt5BqjmiU+qllZ+J5St9sb7VrJR xO+g== 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=aIG1Xs8CximUshNbJxyPtBPvFKjMVJbgnvYEwuyYulk=; b=zuLG6hOY+70q14CvAFIzkX/5w+95VbSfdv7qYY4ma50rcRDYI2fY7BgIn6yIqu/hOa dqo/9yeY0jf/ERaeMfmNvy35MChLh8vglAH84Z4Z8TiFERub6AzlebCmy/iMxyA1V0Jx MpihtNX7lih07Sd28rlfnyLy7hN4VYyUtwsnpTAuysNsQeRSluo41uXCXGUmHb1h7pCi RU6QXFuZv770MlAKuNxqFLC6mgZ7Ejcdl6hN5xkcLeU1R49cxpvi79Y4EdsS4dLV7Bsy nyHl111Q5lXwpxF2zbDeptZHSUzxcAH5sUu23yxg/YdXVUhji24bVd5dpOi/Eaz5N1Ax hmFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=f+I6TTus; 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 o22si4508440ejr.78.2019.11.18.02.24.47; Mon, 18 Nov 2019 02:25:10 -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=f+I6TTus; 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 S1726814AbfKRKUB (ORCPT + 99 others); Mon, 18 Nov 2019 05:20:01 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42884 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbfKRKUB (ORCPT ); Mon, 18 Nov 2019 05:20:01 -0500 Received: by mail-wr1-f67.google.com with SMTP id a15so18721198wrf.9 for ; Mon, 18 Nov 2019 02:19:58 -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=aIG1Xs8CximUshNbJxyPtBPvFKjMVJbgnvYEwuyYulk=; b=f+I6TTusrhAY+d8zDvsW6jwhr4o3NBdDCpVDnHlk7Xeao//1HsuBCmUKwMlv98y6uT 0p31Zx4T/uuA6abVzMfXF8fBo/8wdCvVUDBA5fI091Q7x3uQFL3QN/5Q5rhefqRx2+kX r6ICtK/lYal5xdxn7THRquofYsDYCWyx9jNQbgBJAGR7tgIX1ZSUniZo5lt0WNi4Mkcp SaiXkad658ezrWJtR4ThFLZHP49WW2ZpgbpHiWjf3pLZ1du6Loza7iQto7gr1Ml83/zu v1UXD72JdwuBKf1nwniYX+c6EsKeHUgDVqy3W+5psLmdQneCa5uQRqVxQGqEQdnSaekf JI2A== 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=aIG1Xs8CximUshNbJxyPtBPvFKjMVJbgnvYEwuyYulk=; b=QUpHuaPAjBpaW6QRdSOObVp4+CQwXmV8ljiUlGkRsFgPZwJn/+ie+TJ1bZRnkrl7GX +M5d7PT8SsMHaQU4emQF/s/5oKlePBKtOBdP/x0WTHD+ZjEIysPkHcWiV6Z2MwWnBmZO tR2Qt6HbcAw72iWDQLbkySpO+2CdO66QXFU+QgejZG5Wndljw4FKVCmXoKhYc+/q5Hy4 VDsXcRMOAUi9RiQomsawEho29nyJAyCQURsHtw+KGre81AZb8mEvgbNHQkdmfSDYXht0 7XLJl2in6cJpeFYEoLU24Zgoj5Ni0+Prw5NtY6QAwwXLHtA5kpODF1S2MdDDYzrZ63lf 9xMQ== X-Gm-Message-State: APjAAAVtVNr2g4wTL/pyk1Jss1qjOA2OcGyw9vV3bmtHj9gOafUXr79E 0OiCB036qQCQTWrtRX6nfhR7+MMJLp0QZ1CT X-Received: by 2002:a5d:4a85:: with SMTP id o5mr30430983wrq.109.1574072397612; Mon, 18 Nov 2019 02:19:57 -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 t134sm20766740wmt.24.2019.11.18.02.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 02:19:56 -0800 (PST) From: patrick.rudolph@9elements.com To: linux-kernel@vger.kernel.org Cc: coreboot@coreboot.org, Arthur Heymans , Patrick Rudolph , Allison Randal , Alexios Zavras , Greg Kroah-Hartman , Thomas Gleixner Subject: [PATCH v3 3/3] firmware: google: Probe for a GSMI handler in firmware Date: Mon, 18 Nov 2019 11:19:31 +0100 Message-Id: <20191118101934.22526-4-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191118101934.22526-1-patrick.rudolph@9elements.com> References: <20191118101934.22526-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 --- -v2: Add missing s-o-b and add define for reserved command. -v3: No changes. --- 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