From patchwork Wed Mar 29 07:43:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vandrovec X-Patchwork-Id: 9651005 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 81750602BE for ; Wed, 29 Mar 2017 07:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72F46283B9 for ; Wed, 29 Mar 2017 07:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67A4B2845B; Wed, 29 Mar 2017 07:58:39 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1000C28456 for ; Wed, 29 Mar 2017 07:58:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ct8V2-00069a-Jh; Wed, 29 Mar 2017 07:58:36 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ct8V1-00069U-4B for tpmdd-devel@lists.sourceforge.net; Wed, 29 Mar 2017 07:58:35 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of vmware.com designates 208.91.0.190 as permitted sender) client-ip=208.91.0.190; envelope-from=petr@vmware.com; helo=EX13-EDG-OU-002.vmware.com; Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1ct8V0-0003nQ-7K for tpmdd-devel@lists.sourceforge.net; Wed, 29 Mar 2017 07:58:35 +0000 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 29 Mar 2017 00:42:39 -0700 Received: from petr-dev3.eng.vmware.com (petr-dev2.eng.vmware.com [10.20.93.186]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 6B43640172; Wed, 29 Mar 2017 00:43:26 -0700 (PDT) Received: by petr-dev3.eng.vmware.com (Postfix, from userid 884) id 64D2CA00211; Wed, 29 Mar 2017 00:43:26 -0700 (PDT) Date: Wed, 29 Mar 2017 00:43:26 -0700 From: Petr Vandrovec To: Peter Huewe Message-ID: <20170329074326.jxeoxtn4tbjjwcl2@petr-dev3.eng.vmware.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170306 (1.8.0) Received-SPF: None (EX13-EDG-OU-002.vmware.com: petr@vmware.com does not designate permitted sender hosts) X-Headers-End: 1ct8V0-0003nQ-7K Cc: tpmdd-devel@lists.sourceforge.net Subject: [tpmdd-devel] [PATCH 2/4] Read TCG log from TPM2 table X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP From: Petr Vandrovec Latest draft of TPM 2 ACPI specification added TCG log start/length to the TPM2 ACPI table. So Linux kernel can now read it without having to get involved with boot loader, same way TPM1/TCPA tables work. Signed-off-by: Petr Vandrovec --- drivers/char/tpm/tpm_acpi.c | 70 ++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c index 169edf3ce86d..e48b1503220c 100644 --- a/drivers/char/tpm/tpm_acpi.c +++ b/drivers/char/tpm/tpm_acpi.c @@ -48,46 +48,62 @@ struct acpi_tcpa { /* read binary bios log */ int tpm_read_log_acpi(struct tpm_chip *chip) { - struct acpi_tcpa *buff; acpi_status status; void __iomem *virt; u64 len, start; struct tpm_bios_log *log; - if (chip->flags & TPM_CHIP_FLAG_TPM2) - return -ENODEV; - - log = &chip->log; - /* Unfortuntely ACPI does not associate the event log with a specific * TPM, like PPI. Thus all ACPI TPMs will read the same log. */ if (!chip->acpi_dev_handle) return -ENODEV; - /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ - status = acpi_get_table(ACPI_SIG_TCPA, 1, - (struct acpi_table_header **)&buff); - - if (ACPI_FAILURE(status)) - return -ENODEV; - - switch(buff->platform_class) { - case BIOS_SERVER: - len = buff->server.log_max_len; - start = buff->server.log_start_addr; - break; - case BIOS_CLIENT: - default: - len = buff->client.log_max_len; - start = buff->client.log_start_addr; - break; - } - if (!len) { - dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__); - return -EIO; + if (chip->flags & TPM_CHIP_FLAG_TPM2) { + struct acpi_table_tpm2 *buff; + + /* Find TPM2 entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ + status = acpi_get_table(ACPI_SIG_TPM2, 1, + (struct acpi_table_header **)&buff); + + if (ACPI_FAILURE(status) || buff->header.length < ACPI_TPM2_SIZE_WITH_LOG) + return -ENODEV; + + len = buff->minimum_log_length; + start = buff->log_address; + if (!len) { + dev_warn(&chip->dev, "%s: TPM2 log area empty\n", __func__); + return -EIO; + } + } else { + struct acpi_tcpa *buff; + + /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ + status = acpi_get_table(ACPI_SIG_TCPA, 1, + (struct acpi_table_header **)&buff); + + if (ACPI_FAILURE(status)) + return -ENODEV; + + switch(buff->platform_class) { + case BIOS_SERVER: + len = buff->server.log_max_len; + start = buff->server.log_start_addr; + break; + case BIOS_CLIENT: + default: + len = buff->client.log_max_len; + start = buff->client.log_start_addr; + break; + } + if (!len) { + dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__); + return -EIO; + } } + log = &chip->log; + /* malloc EventLog space */ log->bios_event_log = kmalloc(len, GFP_KERNEL); if (!log->bios_event_log)