All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-22 18:29 ` Azhar Shaikh
  0 siblings, 0 replies; 11+ messages in thread
From: Azhar Shaikh @ 2017-06-22 18:29 UTC (permalink / raw)
  To: jarkko.sakkinen, tpmdd-devel
  Cc: linux-kernel, linux-security-module, azhar.shaikh

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 <azhar.shaikh@intel.com>
---
 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);
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-22 18:29 ` Azhar Shaikh
  0 siblings, 0 replies; 11+ messages in thread
From: Azhar Shaikh @ 2017-06-22 18:29 UTC (permalink / raw)
  To: linux-security-module

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 <azhar.shaikh@intel.com>
---
 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);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems
  2017-06-22 18:29 ` Azhar Shaikh
@ 2017-06-22 20:20   ` Jason Gunthorpe
  -1 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-06-22 20:20 UTC (permalink / raw)
  To: Azhar Shaikh
  Cc: jarkko.sakkinen, tpmdd-devel, linux-security-module, linux-kernel

On Thu, Jun 22, 2017 at 11:29:57AM -0700, Azhar Shaikh wrote:
> 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 <azhar.shaikh@intel.com>
>  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
> +++ 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

The iounmap needs to be in the goto unwind for init_tis as well, surely?

>  	rc = platform_driver_register(&tis_drv);
>  	if (rc)
>  		goto err_platform;

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-22 20:20   ` Jason Gunthorpe
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2017-06-22 20:20 UTC (permalink / raw)
  To: linux-security-module

On Thu, Jun 22, 2017 at 11:29:57AM -0700, Azhar Shaikh wrote:
> 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 <azhar.shaikh@intel.com>
>  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
> +++ 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

The iounmap needs to be in the goto unwind for init_tis as well, surely?

>  	rc = platform_driver_register(&tis_drv);
>  	if (rc)
>  		goto err_platform;

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems
  2017-06-22 20:20   ` Jason Gunthorpe
  (?)
@ 2017-06-22 20:50     ` Shaikh, Azhar
  -1 siblings, 0 replies; 11+ messages in thread
From: Shaikh, Azhar @ 2017-06-22 20:50 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: jarkko.sakkinen, tpmdd-devel, linux-security-module, linux-kernel



> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgunthorpe@obsidianresearch.com]
> Sent: Thursday, June 22, 2017 1:20 PM
> To: Shaikh, Azhar <azhar.shaikh@intel.com>
> Cc: jarkko.sakkinen@linux.intel.com; tpmdd-devel@lists.sourceforge.net;
> linux-security-module@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell
> systems
> 
> On Thu, Jun 22, 2017 at 11:29:57AM -0700, Azhar Shaikh wrote:
> > 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 <azhar.shaikh@intel.com>
> > 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
> > +++ 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
> 
> The iounmap needs to be in the goto unwind for init_tis as well, surely?
> 

Yes! Should have checked before...

> >  	rc = platform_driver_register(&tis_drv);
> >  	if (rc)
> >  		goto err_platform;
> 
> Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-22 20:50     ` Shaikh, Azhar
  0 siblings, 0 replies; 11+ messages in thread
From: Shaikh, Azhar @ 2017-06-22 20:50 UTC (permalink / raw)
  To: linux-security-module



> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgunthorpe at obsidianresearch.com]
> Sent: Thursday, June 22, 2017 1:20 PM
> To: Shaikh, Azhar <azhar.shaikh@intel.com>
> Cc: jarkko.sakkinen at linux.intel.com; tpmdd-devel at lists.sourceforge.net;
> linux-security-module at vger.kernel.org; linux-kernel at vger.kernel.org
> Subject: Re: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell
> systems
> 
> On Thu, Jun 22, 2017 at 11:29:57AM -0700, Azhar Shaikh wrote:
> > 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 <azhar.shaikh@intel.com>
> > 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
> > +++ 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
> 
> The iounmap needs to be in the goto unwind for init_tis as well, surely?
> 

Yes! Should have checked before...

> >  	rc = platform_driver_register(&tis_drv);
> >  	if (rc)
> >  		goto err_platform;
> 
> Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-22 20:50     ` Shaikh, Azhar
  0 siblings, 0 replies; 11+ messages in thread
From: Shaikh, Azhar @ 2017-06-22 20:50 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: jarkko.sakkinen, tpmdd-devel, linux-security-module, linux-kernel



> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgunthorpe@obsidianresearch.com]
> Sent: Thursday, June 22, 2017 1:20 PM
> To: Shaikh, Azhar <azhar.shaikh@intel.com>
> Cc: jarkko.sakkinen@linux.intel.com; tpmdd-devel@lists.sourceforge.net;
> linux-security-module@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell
> systems
> 
> On Thu, Jun 22, 2017 at 11:29:57AM -0700, Azhar Shaikh wrote:
> > 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 <azhar.shaikh@intel.com>
> > 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
> > +++ 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
> 
> The iounmap needs to be in the goto unwind for init_tis as well, surely?
> 

Yes! Should have checked before...

> >  	rc = platform_driver_register(&tis_drv);
> >  	if (rc)
> >  		goto err_platform;
> 
> Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] tpm: Fix the ioremap() call for Braswell systems
  2017-06-22 18:29 ` Azhar Shaikh
@ 2017-06-22 21:32   ` Azhar Shaikh
  -1 siblings, 0 replies; 11+ messages in thread
From: Azhar Shaikh @ 2017-06-22 21:32 UTC (permalink / raw)
  To: jarkko.sakkinen, tpmdd-devel
  Cc: linux-kernel, linux-security-module, azhar.shaikh

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() after all TPM access are completed.

Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
---
Changes from v1:
- Do error handling in init_ts().
- Update the commit message.

 drivers/char/tpm/tpm_tis.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 506e62ca3576..d97ce22267fb 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;
@@ -490,6 +483,10 @@ static int __init init_tis(void)
 err_platform:
 	if (force_pdev)
 		platform_device_unregister(force_pdev);
+#ifdef CONFIG_X86
+	if (is_bsw())
+		iounmap(ilb_base_addr);
+#endif
 err_force:
 	return rc;
 }
@@ -499,6 +496,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);
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-22 21:32   ` Azhar Shaikh
  0 siblings, 0 replies; 11+ messages in thread
From: Azhar Shaikh @ 2017-06-22 21:32 UTC (permalink / raw)
  To: linux-security-module

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() after all TPM access are completed.

Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
---
Changes from v1:
- Do error handling in init_ts().
- Update the commit message.

 drivers/char/tpm/tpm_tis.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 506e62ca3576..d97ce22267fb 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;
@@ -490,6 +483,10 @@ static int __init init_tis(void)
 err_platform:
 	if (force_pdev)
 		platform_device_unregister(force_pdev);
+#ifdef CONFIG_X86
+	if (is_bsw())
+		iounmap(ilb_base_addr);
+#endif
 err_force:
 	return rc;
 }
@@ -499,6 +496,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);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] tpm: Fix the ioremap() call for Braswell systems
  2017-06-22 21:32   ` Azhar Shaikh
@ 2017-06-28 22:11     ` Jarkko Sakkinen
  -1 siblings, 0 replies; 11+ messages in thread
From: Jarkko Sakkinen @ 2017-06-28 22:11 UTC (permalink / raw)
  To: Azhar Shaikh; +Cc: tpmdd-devel, linux-kernel, linux-security-module

On Thu, Jun 22, 2017 at 02:32:01PM -0700, Azhar Shaikh wrote:
> 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() after all TPM access are completed.
> 
> Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

> ---
> Changes from v1:
> - Do error handling in init_ts().
> - Update the commit message.
> 
>  drivers/char/tpm/tpm_tis.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 506e62ca3576..d97ce22267fb 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;
> @@ -490,6 +483,10 @@ static int __init init_tis(void)
>  err_platform:
>  	if (force_pdev)
>  		platform_device_unregister(force_pdev);
> +#ifdef CONFIG_X86
> +	if (is_bsw())
> +		iounmap(ilb_base_addr);
> +#endif
>  err_force:
>  	return rc;
>  }
> @@ -499,6 +496,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);
>  }
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] tpm: Fix the ioremap() call for Braswell systems
@ 2017-06-28 22:11     ` Jarkko Sakkinen
  0 siblings, 0 replies; 11+ messages in thread
From: Jarkko Sakkinen @ 2017-06-28 22:11 UTC (permalink / raw)
  To: linux-security-module

On Thu, Jun 22, 2017 at 02:32:01PM -0700, Azhar Shaikh wrote:
> 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() after all TPM access are completed.
> 
> Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

> ---
> Changes from v1:
> - Do error handling in init_ts().
> - Update the commit message.
> 
>  drivers/char/tpm/tpm_tis.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 506e62ca3576..d97ce22267fb 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;
> @@ -490,6 +483,10 @@ static int __init init_tis(void)
>  err_platform:
>  	if (force_pdev)
>  		platform_device_unregister(force_pdev);
> +#ifdef CONFIG_X86
> +	if (is_bsw())
> +		iounmap(ilb_base_addr);
> +#endif
>  err_force:
>  	return rc;
>  }
> @@ -499,6 +496,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);
>  }
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-06-28 22:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22 18:29 [PATCH] tpm: Fix the ioremap() call for Braswell systems Azhar Shaikh
2017-06-22 18:29 ` Azhar Shaikh
2017-06-22 20:20 ` [tpmdd-devel] " Jason Gunthorpe
2017-06-22 20:20   ` Jason Gunthorpe
2017-06-22 20:50   ` Shaikh, Azhar
2017-06-22 20:50     ` Shaikh, Azhar
2017-06-22 20:50     ` Shaikh, Azhar
2017-06-22 21:32 ` [PATCH v2] " Azhar Shaikh
2017-06-22 21:32   ` Azhar Shaikh
2017-06-28 22:11   ` Jarkko Sakkinen
2017-06-28 22:11     ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.