From patchwork Sat Jun 11 01:55:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Swierk X-Patchwork-Id: 9170931 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 6A3AE607D9 for ; Sat, 11 Jun 2016 01:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C7B327D07 for ; Sat, 11 Jun 2016 01:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 513CC28325; Sat, 11 Jun 2016 01:56:31 +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 090C527D07 for ; Sat, 11 Jun 2016 01:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbcFKBzU (ORCPT ); Fri, 10 Jun 2016 21:55:20 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:33668 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751871AbcFKBzT (ORCPT ); Fri, 10 Jun 2016 21:55:19 -0400 Received: by mail-pf0-f174.google.com with SMTP id y124so28318678pfy.0 for ; Fri, 10 Jun 2016 18:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skyportsystems.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O4Tj0NWSO0mM9Wc38e0Qdulxf5bmpMgM+DvBuc00hZk=; b=APmzmJFskiUcMN5dce5ykm98WovhWeBL3EXPlBmO5vsQnssPrp/19ILpguqSnlhxMZ mR4drbAIDr3Q8QEvVMOIt6eKScGIBVQ7zlGyj3tNPOCAk72dc2MzX6UFsHpdCe6BGfJ0 m2QIFH+cMaaNc9Y6A4qwhakp20RhDUHbtB9do= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O4Tj0NWSO0mM9Wc38e0Qdulxf5bmpMgM+DvBuc00hZk=; b=JzjjdSYshdrZlEMqEFCcqMa3DPsOdej12UaYTTivCPQNkWRzWcIxuJznMiXDuJepjT f/+MCtF1WuozYyqoCJhSiEOlZhgxlYJX2vIp9KIyVZTL6DfuS512Jh9ysrDuT4lBEvpD NqRu1MbrMebCkGQVm52spaNVmqtnwueuiMUGV4z57yD/ACLaO9fX+vQo/aC4YcZXi21M ig4tlvb4tVeK/oUj8Hd0VBbJM7SbdiCz1AzRsjlKS5Fi6N/Aaz37aM8spsFzhExXBNv/ C/MYxVSjKY7YmZqWv/6loK5OEB0UFpZRJKsHOIuEgRZpYT3pGPx/sG6U8fc6yiIAuNGw 8AGw== X-Gm-Message-State: ALyK8tL6R/s9cZmDPVCJ4y/1K5Ab5IEZKGHO9jQmVVuds0bEbGcB0ngS1ZpuZEnpJRr/reEY X-Received: by 10.98.72.150 with SMTP id q22mr5497353pfi.122.1465610118212; Fri, 10 Jun 2016 18:55:18 -0700 (PDT) Received: from eswierk-sc.localdomain (67-207-112-138.static.wiline.com. [67.207.112.138]) by smtp.gmail.com with ESMTPSA id i89sm335594pfi.22.2016.06.10.18.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 18:55:17 -0700 (PDT) From: Ed Swierk To: tpmdd-devel@lists.sourceforge.net Cc: eswierk@skyportsystems.com, stefanb@us.ibm.com, jarkko.sakkinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, jgunthorpe@obsidianresearch.com Subject: [PATCH v6 1/5] tpm_tis: Improve reporting of IO errors Date: Fri, 10 Jun 2016 18:55:03 -0700 Message-Id: <1465610107-87762-2-git-send-email-eswierk@skyportsystems.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465610107-87762-1-git-send-email-eswierk@skyportsystems.com> References: <1465426818-89356-1-git-send-email-eswierk@skyportsystems.com> <1465610107-87762-1-git-send-email-eswierk@skyportsystems.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Mysterious TPM behavior can be difficult to track down through all the layers of software. Add error messages for conditions that should never happen. Also include the manufacturer ID along with other chip data printed during init. Signed-off-by: Ed Swierk Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 65f7eec..088fa86 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -299,6 +299,8 @@ static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count) expected = be32_to_cpu(*(__be32 *) (buf + 2)); if (expected > count) { + dev_err(chip->pdev, "Response too long (wanted %zd, got %d)\n", + count, expected); size = -EIO; goto out; } @@ -366,6 +368,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) &chip->vendor.int_queue, false); status = tpm_tis_status(chip); if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) { + dev_err(chip->pdev, "Chip not accepting %zd bytes\n", + len - count); rc = -EIO; goto out_err; } @@ -378,6 +382,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) &chip->vendor.int_queue, false); status = tpm_tis_status(chip); if ((status & TPM_STS_DATA_EXPECT) != 0) { + dev_err(chip->pdev, "Chip not accepting last byte\n"); rc = -EIO; goto out_err; } @@ -689,8 +694,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); chip->vendor.manufacturer_id = vendor; - dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n", + dev_info(dev, "%s TPM (manufacturer-id 0x%X, device-id 0x%X, rev-id %d)\n", (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2", + chip->vendor.manufacturer_id, vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0))); if (!itpm) {