* [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
@ 2012-08-30 14:38 Kent Yoder
2012-08-30 17:45 ` Dan Carpenter
0 siblings, 1 reply; 7+ messages in thread
From: Kent Yoder @ 2012-08-30 14:38 UTC (permalink / raw)
To: James Morris
Cc: linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
acpi_os_map_memory expects its return value to be in the __iomem address
space. Cast it back later when used in a memcpy to avoid the same sparse
warning there.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
---
drivers/char/tpm/tpm_acpi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
index fe3fa94..36bdcfa 100644
--- a/drivers/char/tpm/tpm_acpi.c
+++ b/drivers/char/tpm/tpm_acpi.c
@@ -49,7 +49,7 @@ int read_log(struct tpm_bios_log *log)
{
struct acpi_tcpa *buff;
acpi_status status;
- struct acpi_table_header *virt;
+ void __iomem *virt;
u64 len, start;
if (log->bios_event_log != NULL) {
@@ -102,7 +102,7 @@ int read_log(struct tpm_bios_log *log)
return -EIO;
}
- memcpy(log->bios_event_log, virt, len);
+ memcpy(log->bios_event_log, (void *)virt, len);
acpi_os_unmap_memory(virt, len);
return 0;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
2012-08-30 14:38 [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces Kent Yoder
@ 2012-08-30 17:45 ` Dan Carpenter
2012-08-30 19:21 ` Kent Yoder
0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2012-08-30 17:45 UTC (permalink / raw)
To: Kent Yoder
Cc: James Morris, linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
On Thu, Aug 30, 2012 at 09:38:41AM -0500, Kent Yoder wrote:
> acpi_os_map_memory expects its return value to be in the __iomem address
> space. Cast it back later when used in a memcpy to avoid the same sparse
> warning there.
>
> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
I can't download linux-next right now but I don't think this is the
correct fix. I don't think you can memcpy() directly from __iomem.
The static checker is warning about a valid bug which should be
addressed instead of just casted away and silenced.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
2012-08-30 17:45 ` Dan Carpenter
@ 2012-08-30 19:21 ` Kent Yoder
2012-09-02 16:30 ` Dan Carpenter
0 siblings, 1 reply; 7+ messages in thread
From: Kent Yoder @ 2012-08-30 19:21 UTC (permalink / raw)
To: Dan Carpenter
Cc: James Morris, linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
On Thu, Aug 30, 2012 at 10:45:56AM -0700, Dan Carpenter wrote:
> On Thu, Aug 30, 2012 at 09:38:41AM -0500, Kent Yoder wrote:
> > acpi_os_map_memory expects its return value to be in the __iomem address
> > space. Cast it back later when used in a memcpy to avoid the same sparse
> > warning there.
> >
> > Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
>
> I can't download linux-next right now but I don't think this is the
> correct fix. I don't think you can memcpy() directly from __iomem.
> The static checker is warning about a valid bug which should be
> addressed instead of just casted away and silenced.
I took a look at other uses of the return from acpi_os_map_memory(),
such as acpi_tb_parse_fadt(), which passes the returned pointer to
acpi_tb_create_local_fadt(), which uses ACPI_MEMCPY on it, which is just
memcpy. This code lives in drivers/acpi.
Kent
>
> regards,
> dan carpenter
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
2012-08-30 19:21 ` Kent Yoder
@ 2012-09-02 16:30 ` Dan Carpenter
2012-09-04 16:13 ` Kent Yoder
2012-09-04 16:18 ` Kent Yoder
0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2012-09-02 16:30 UTC (permalink / raw)
To: Kent Yoder
Cc: James Morris, linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
On Thu, Aug 30, 2012 at 02:21:55PM -0500, Kent Yoder wrote:
> On Thu, Aug 30, 2012 at 10:45:56AM -0700, Dan Carpenter wrote:
> > On Thu, Aug 30, 2012 at 09:38:41AM -0500, Kent Yoder wrote:
> > > acpi_os_map_memory expects its return value to be in the __iomem address
> > > space. Cast it back later when used in a memcpy to avoid the same sparse
> > > warning there.
> > >
> > > Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
> >
> > I can't download linux-next right now but I don't think this is the
> > correct fix. I don't think you can memcpy() directly from __iomem.
> > The static checker is warning about a valid bug which should be
> > addressed instead of just casted away and silenced.
>
> I took a look at other uses of the return from acpi_os_map_memory(),
> such as acpi_tb_parse_fadt(), which passes the returned pointer to
> acpi_tb_create_local_fadt(), which uses ACPI_MEMCPY on it, which is just
> memcpy. This code lives in drivers/acpi.
>
Sparse finds that bug as well. ;)
drivers/acpi/acpica/tbfadt.c:247:15: warning: incorrect type in assignment (different address spaces)
drivers/acpi/acpica/tbfadt.c:247:15: expected struct acpi_table_header *table
drivers/acpi/acpica/tbfadt.c:247:15: got void [noderef] <asn:2>*
drivers/acpi/acpica/tbfadt.c:266:30: warning: incorrect type in argument 1 (different address spaces)
drivers/acpi/acpica/tbfadt.c:266:30: expected void [noderef] <asn:2>*logical_address
drivers/acpi/acpica/tbfadt.c:266:30: got struct acpi_table_header *table
It should be memcpy_fromio() probably.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
2012-09-02 16:30 ` Dan Carpenter
@ 2012-09-04 16:13 ` Kent Yoder
2012-09-04 16:18 ` Kent Yoder
1 sibling, 0 replies; 7+ messages in thread
From: Kent Yoder @ 2012-09-04 16:13 UTC (permalink / raw)
To: Dan Carpenter
Cc: James Morris, linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
On Sun, Sep 02, 2012 at 09:30:30AM -0700, Dan Carpenter wrote:
> Sparse finds that bug as well. ;)
>
> drivers/acpi/acpica/tbfadt.c:247:15: warning: incorrect type in assignment (different address spaces)
> drivers/acpi/acpica/tbfadt.c:247:15: expected struct acpi_table_header *table
> drivers/acpi/acpica/tbfadt.c:247:15: got void [noderef] <asn:2>*
> drivers/acpi/acpica/tbfadt.c:266:30: warning: incorrect type in argument 1 (different address spaces)
> drivers/acpi/acpica/tbfadt.c:266:30: expected void [noderef] <asn:2>*logical_address
> drivers/acpi/acpica/tbfadt.c:266:30: got struct acpi_table_header *table
>
> It should be memcpy_fromio() probably.
Thanks Dan, that's clearly better. James, I'll resubmit this one
today.
Thanks,
Kent
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
2012-09-02 16:30 ` Dan Carpenter
2012-09-04 16:13 ` Kent Yoder
@ 2012-09-04 16:18 ` Kent Yoder
2012-09-12 3:12 ` James Morris
1 sibling, 1 reply; 7+ messages in thread
From: Kent Yoder @ 2012-09-04 16:18 UTC (permalink / raw)
To: James Morris
Cc: Dan Carpenter, linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
acpi_os_map_memory expects its return value to be in the __iomem address
space. Tag the variable we're using as such and use memcpy_fromio to
avoid further sparse warnings.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
---
drivers/char/tpm/tpm_acpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
index fe3fa94..56051d0 100644
--- a/drivers/char/tpm/tpm_acpi.c
+++ b/drivers/char/tpm/tpm_acpi.c
@@ -49,7 +49,7 @@ int read_log(struct tpm_bios_log *log)
{
struct acpi_tcpa *buff;
acpi_status status;
- struct acpi_table_header *virt;
+ void __iomem *virt;
u64 len, start;
if (log->bios_event_log != NULL) {
@@ -102,7 +102,7 @@ int read_log(struct tpm_bios_log *log)
return -EIO;
}
- memcpy(log->bios_event_log, virt, len);
+ memcpy_fromio(log->bios_event_log, virt, len);
acpi_os_unmap_memory(virt, len);
return 0;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces
2012-09-04 16:18 ` Kent Yoder
@ 2012-09-12 3:12 ` James Morris
0 siblings, 0 replies; 7+ messages in thread
From: James Morris @ 2012-09-12 3:12 UTC (permalink / raw)
To: Kent Yoder
Cc: Dan Carpenter, linux-kernel, linux-security-module, tpmdd-devel,
kernel-janitors, Fengguang Wu
On Tue, 4 Sep 2012, Kent Yoder wrote:
> acpi_os_map_memory expects its return value to be in the __iomem address
> space. Tag the variable we're using as such and use memcpy_fromio to
> avoid further sparse warnings.
>
> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-09-12 3:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-30 14:38 [PATCH] tpm: fix tpm_acpi sparse warning on different address spaces Kent Yoder
2012-08-30 17:45 ` Dan Carpenter
2012-08-30 19:21 ` Kent Yoder
2012-09-02 16:30 ` Dan Carpenter
2012-09-04 16:13 ` Kent Yoder
2012-09-04 16:18 ` Kent Yoder
2012-09-12 3:12 ` James Morris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).