From patchwork Thu Jun 22 18:29:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Azhar Shaikh X-Patchwork-Id: 9805089 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 B787660386 for ; Thu, 22 Jun 2017 18:30:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0C4728710 for ; Thu, 22 Jun 2017 18:30:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEC312872D; Thu, 22 Jun 2017 18:30:01 +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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F32C728710 for ; Thu, 22 Jun 2017 18:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753625AbdFVS37 (ORCPT ); Thu, 22 Jun 2017 14:29:59 -0400 Received: from mga02.intel.com ([134.134.136.20]:38469 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753621AbdFVS37 (ORCPT ); Thu, 22 Jun 2017 14:29:59 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2017 11:29:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,373,1493708400"; d="scan'208";a="277494215" Received: from otc-chromeosbuild-0.jf.intel.com ([10.54.30.57]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2017 11:29:57 -0700 From: Azhar Shaikh To: jarkko.sakkinen@linux.intel.com, tpmdd-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, azhar.shaikh@intel.com Subject: [PATCH] tpm: Fix the ioremap() call for Braswell systems Date: Thu, 22 Jun 2017 11:29:57 -0700 Message-Id: <1498156197-180919-1-git-send-email-azhar.shaikh@intel.com> X-Mailer: git-send-email 1.9.1 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP ioremap() for Intel Braswell processors was done in tpm_tis_pnp_init(). But before this function gets called, platform driver 'tis_drv' gets registered and its probe function tpm_tis_plat_probe() is invoked, which does a TPM access. Now for Braswell processors tpm_platform_begin_xfer() will do an ioread32() without having a mapped address, which will lead to a bad I/O access warning. Hence move the ioremap() call from tpm_tis_pnp_init() to init_tis() before registering the 'tis_drv' or basically before any TPM access. Accordingly also move the iounmap() call from tpm_tis_pnp_remove() to cleanup_tis(). Signed-off-by: Azhar Shaikh --- drivers/char/tpm/tpm_tis.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 506e62ca3576..3224db80816a 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -330,12 +330,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev, else tpm_info.irq = -1; -#ifdef CONFIG_X86 - if (is_bsw()) - ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR, - ILB_REMAP_SIZE); -#endif - return tpm_tis_init(&pnp_dev->dev, &tpm_info); } @@ -359,12 +353,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev) tpm_chip_unregister(chip); tpm_tis_remove(chip); - -#ifdef CONFIG_X86 - if (is_bsw()) - iounmap(ilb_base_addr); -#endif - } static struct pnp_driver tis_pnp_driver = { @@ -472,6 +460,11 @@ static int __init init_tis(void) if (rc) goto err_force; +#ifdef CONFIG_X86 + if (is_bsw()) + ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR, + ILB_REMAP_SIZE); +#endif rc = platform_driver_register(&tis_drv); if (rc) goto err_platform; @@ -499,6 +492,10 @@ static void __exit cleanup_tis(void) pnp_unregister_driver(&tis_pnp_driver); platform_driver_unregister(&tis_drv); +#ifdef CONFIG_X86 + if (is_bsw()) + iounmap(ilb_base_addr); +#endif if (force_pdev) platform_device_unregister(force_pdev); }