From patchwork Mon Sep 14 17:15:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 517507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 31D66140779 for ; Tue, 15 Sep 2015 03:15:54 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZbXM5-0008FY-Ha; Mon, 14 Sep 2015 17:15:49 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZbXM4-0008FT-Qm for tpmdd-devel@lists.sourceforge.net; Mon, 14 Sep 2015 17:15:48 +0000 X-ACL-Warn: Received: from mga09.intel.com ([134.134.136.24]) by sog-mx-1.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1ZbXM2-0002OY-Eq for tpmdd-devel@lists.sourceforge.net; Mon, 14 Sep 2015 17:15:48 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 14 Sep 2015 10:15:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,529,1437462000"; d="scan'208";a="804212761" Received: from comusca-mobl3.ger.corp.intel.com (HELO localhost) ([10.252.21.76]) by orsmga002.jf.intel.com with ESMTP; 14 Sep 2015 10:15:33 -0700 From: Jarkko Sakkinen To: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Date: Mon, 14 Sep 2015 20:15:23 +0300 Message-Id: <1442250923-19804-1-git-send-email-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.5.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1ZbXM2-0002OY-Eq Subject: [tpmdd-devel] [PATCH] tpm, tpm_crb: fix unaligned read of the command buffer address 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: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net The command buffer address is necessarily not naturally aligned. The hardware drops the entire read on some platforms and fills the address with 1's. This patch fixes the issue by splitting the read into two 32 bit reads. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_crb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index b4564b6..12bb41c 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -68,7 +68,8 @@ struct crb_control_area { u32 int_enable; u32 int_sts; u32 cmd_size; - u64 cmd_pa; + u32 cmd_pa_low; + u32 cmd_pa_high; u32 rsp_size; u64 rsp_pa; } __packed; @@ -264,7 +265,9 @@ static int crb_acpi_add(struct acpi_device *device) } memcpy_fromio(&pa, &priv->cca->cmd_pa, 8); - pa = le64_to_cpu(pa); + + pa = ((u64) le32_to_cpu(ioread32(&priv->cca->cmd_pa_high)) << 32) + + (u64) le32_to_cpu(ioread32(&priv->cca->cmd_pa_low)); priv->cmd = devm_ioremap_nocache(dev, pa, ioread32(&priv->cca->cmd_size)); if (!priv->cmd) {