linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scatterlist: add a warning if sg_virt() is used on highmem pages
@ 2012-12-05 11:28 Sebastian Andrzej Siewior
  2012-12-05 21:46 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-12-05 11:28 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Sebastian Andrzej Siewior

sg_virt() on highmem pages won't work. This WARN_ON() should catch some
that still try.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/scatterlist.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 4bd6c06..4d4adab 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -198,6 +198,9 @@ static inline dma_addr_t sg_phys(struct scatterlist *sg)
  **/
 static inline void *sg_virt(struct scatterlist *sg)
 {
+#ifdef CONFIG_DEBUG_SG
+	WARN_ON(PageHighMem(sg_page(sg)));
+#endif
 	return page_address(sg_page(sg)) + sg->offset;
 }
 
-- 
1.7.10.4


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

* Re: [PATCH] scatterlist: add a warning if sg_virt() is used on highmem pages
  2012-12-05 11:28 [PATCH] scatterlist: add a warning if sg_virt() is used on highmem pages Sebastian Andrzej Siewior
@ 2012-12-05 21:46 ` Andrew Morton
  2012-12-06  8:47   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2012-12-05 21:46 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-kernel

On Wed,  5 Dec 2012 12:28:18 +0100
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> sg_virt() on highmem pages won't work. This WARN_ON() should catch some
> that still try.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/scatterlist.h |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 4bd6c06..4d4adab 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -198,6 +198,9 @@ static inline dma_addr_t sg_phys(struct scatterlist *sg)
>   **/
>  static inline void *sg_virt(struct scatterlist *sg)
>  {
> +#ifdef CONFIG_DEBUG_SG
> +	WARN_ON(PageHighMem(sg_page(sg)));
> +#endif
>  	return page_address(sg_page(sg)) + sg->offset;
>  }

Why won't it work?  page_address() will search the kmap table and will
search for the page.  If the caller had previously kmapped that page,
all is well.  If the caller has failed to kmap the page, sg_virt() will
return a nearly-null pointer and presumably someone will later go oops.


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

* Re: [PATCH] scatterlist: add a warning if sg_virt() is used on highmem pages
  2012-12-05 21:46 ` Andrew Morton
@ 2012-12-06  8:47   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-12-06  8:47 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On 12/05/2012 10:46 PM, Andrew Morton wrote:
>> --- a/include/linux/scatterlist.h
>> +++ b/include/linux/scatterlist.h
>> @@ -198,6 +198,9 @@ static inline dma_addr_t sg_phys(struct scatterlist *sg)
>>    **/
>>   static inline void *sg_virt(struct scatterlist *sg)
>>   {
>> +#ifdef CONFIG_DEBUG_SG
>> +	WARN_ON(PageHighMem(sg_page(sg)));
>> +#endif
>>   	return page_address(sg_page(sg)) + sg->offset;
>>   }
>
> Why won't it work?  page_address() will search the kmap table and will
> search for the page.  If the caller had previously kmapped that page,
> all is well.  If the caller has failed to kmap the page, sg_virt() will
> return a nearly-null pointer and presumably someone will later go oops.

I missed that it will work for previously mapped page. If you think
that an oops later is enough then okay, I drop this.

Sebastian

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

end of thread, other threads:[~2012-12-06  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-05 11:28 [PATCH] scatterlist: add a warning if sg_virt() is used on highmem pages Sebastian Andrzej Siewior
2012-12-05 21:46 ` Andrew Morton
2012-12-06  8:47   ` Sebastian Andrzej Siewior

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).