* [PATCH] nommu: reimplement remap_pfn_range() to simply return 0
@ 2011-06-20 5:22 Bob Liu
2011-06-20 6:59 ` Daniel Glöckner
0 siblings, 1 reply; 4+ messages in thread
From: Bob Liu @ 2011-06-20 5:22 UTC (permalink / raw)
To: akpm
Cc: linux-mm, gerg, dhowells, lethal, gerg, walken, daniel-gl,
uclinux-dist-devel, geert, Bob Liu
Function remap_pfn_range() means map physical address pfn<<PAGE_SHIFT to
user addr.
For nommu arch it's implemented by vma->vm_start = pfn << PAGE_SHIFT which is
wrong acroding the original meaning of this function.
Some driver developer using remap_pfn_range() with correct parameter will get
unexpected result because vm_start is changed.
It should be implementd just like addr = pfn << PAGE_SHIFT which is meanless
on nommu arch, so this patch just make it simply return 0.
Reported-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
include/linux/mm.h | 10 ++++++++++
mm/nommu.c | 8 --------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9670f71..017c32f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1526,8 +1526,18 @@ static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
#endif
struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr);
+
+#ifdef CONFIG_MMU
int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
unsigned long pfn, unsigned long size, pgprot_t);
+#else
+static inline int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
+ unsigned long pfn, unsigned long size, pgprot_t prot)
+{
+ return 0;
+}
+#endif
+
int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *);
int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
unsigned long pfn);
diff --git a/mm/nommu.c b/mm/nommu.c
index 1fd0c51..01cf6e0 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1813,14 +1813,6 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
return NULL;
}
-int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
- unsigned long to, unsigned long size, pgprot_t prot)
-{
- vma->vm_start = vma->vm_pgoff << PAGE_SHIFT;
- return 0;
-}
-EXPORT_SYMBOL(remap_pfn_range);
-
int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
unsigned long pgoff)
{
--
1.6.3.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] nommu: reimplement remap_pfn_range() to simply return 0
2011-06-20 5:22 [PATCH] nommu: reimplement remap_pfn_range() to simply return 0 Bob Liu
@ 2011-06-20 6:59 ` Daniel Glöckner
2011-06-20 7:51 ` Bob Liu
2011-06-20 12:04 ` [uclinux-dist-devel] " Mike Frysinger
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Glöckner @ 2011-06-20 6:59 UTC (permalink / raw)
To: Bob Liu
Cc: akpm, linux-mm, gerg, dhowells, lethal, gerg, walken,
uclinux-dist-devel, geert
On Mon, Jun 20, 2011 at 01:22:13PM +0800, Bob Liu wrote:
> Function remap_pfn_range() means map physical address pfn<<PAGE_SHIFT to
> user addr.
>
> For nommu arch it's implemented by vma->vm_start = pfn << PAGE_SHIFT which is
> wrong acroding the original meaning of this function.
>
> Some driver developer using remap_pfn_range() with correct parameter will get
> unexpected result because vm_start is changed.
>
> It should be implementd just like addr = pfn << PAGE_SHIFT which is meanless
> on nommu arch, so this patch just make it simply return 0.
I'd return -EINVAL if addr != pfn << PAGE_SHIFT.
And I can imagine architectures wanting to do something with the prot flags.
Daniel
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nommu: reimplement remap_pfn_range() to simply return 0
2011-06-20 6:59 ` Daniel Glöckner
@ 2011-06-20 7:51 ` Bob Liu
2011-06-20 12:04 ` [uclinux-dist-devel] " Mike Frysinger
1 sibling, 0 replies; 4+ messages in thread
From: Bob Liu @ 2011-06-20 7:51 UTC (permalink / raw)
To: Daniel Glöckner
Cc: akpm, linux-mm, gerg, dhowells, lethal, gerg, walken,
uclinux-dist-devel, geert
On Mon, Jun 20, 2011 at 2:59 PM, Daniel Glöckner <daniel-gl@gmx.net> wrote:
> On Mon, Jun 20, 2011 at 01:22:13PM +0800, Bob Liu wrote:
>> Function remap_pfn_range() means map physical address pfn<<PAGE_SHIFT to
>> user addr.
>>
>> For nommu arch it's implemented by vma->vm_start = pfn << PAGE_SHIFT which is
>> wrong acroding the original meaning of this function.
>>
>> Some driver developer using remap_pfn_range() with correct parameter will get
>> unexpected result because vm_start is changed.
>>
>> It should be implementd just like addr = pfn << PAGE_SHIFT which is meanless
>> on nommu arch, so this patch just make it simply return 0.
>
> I'd return -EINVAL if addr != pfn << PAGE_SHIFT.
okay.
> And I can imagine architectures wanting to do something with the prot flags.
>
Actually it's just a fake function on nommu arch, so in my opinion
we'd better keep it simple
as current.
--
Regards,
--Bob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [uclinux-dist-devel] [PATCH] nommu: reimplement remap_pfn_range() to simply return 0
2011-06-20 6:59 ` Daniel Glöckner
2011-06-20 7:51 ` Bob Liu
@ 2011-06-20 12:04 ` Mike Frysinger
1 sibling, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2011-06-20 12:04 UTC (permalink / raw)
To: Daniel Glöckner
Cc: Bob Liu, gerg, dhowells, linux-mm, lethal, geert, gerg,
uclinux-dist-devel, akpm, walken
On Mon, Jun 20, 2011 at 02:59, Daniel Glöckner wrote:
> And I can imagine architectures wanting to do something with the prot flags.
this func is implemented in common mmu code with no arch callbacks, so
there isnt anything different here. when bob said "nommu arch", he
wasnt referring to an actual architecture, but to nommu vs mmu memory
management cores.
-mike
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-20 12:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-20 5:22 [PATCH] nommu: reimplement remap_pfn_range() to simply return 0 Bob Liu
2011-06-20 6:59 ` Daniel Glöckner
2011-06-20 7:51 ` Bob Liu
2011-06-20 12:04 ` [uclinux-dist-devel] " Mike Frysinger
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).