diff options
author | sukadev@linux.vnet.ibm.com <sukadev@linux.vnet.ibm.com> | 2011-12-02 07:26:23 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-12-07 22:22:52 -0500 |
commit | 8a3e3d31d13ece3003e8f750178a7db02c5cd123 (patch) | |
tree | 975f02f4077cf9631de20011211fddb5367f937a | |
parent | 11eab297f57bd6168425ae968e56c314e71b024e (diff) |
powerpc: Punch a hole in /dev/mem for librtas
With CONFIG_STRICT_DEVMEM=y, user space cannot read any part of /dev/mem.
Since this breaks librtas, punch a hole in /dev/mem to allow access to the
rmo_buffer that librtas needs.
Anton Blanchard reported the problem and helped with the fix.
A quick test for this patch:
# cat /proc/rtas/rmo_buffer
000000000f190000 10000
# python -c "print 0x000000000f190000 / 0x10000"
3865
# dd if=/dev/mem of=/tmp/foo count=1 bs=64k skip=3865
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000205235 s, 319 MB/s
# dd if=/dev/mem of=/tmp/foo
dd: reading `/dev/mem': Operation not permitted
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.00022519 s, 0.0 kB/s
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/include/asm/rtas.h | 12 | ||||
-rw-r--r-- | arch/powerpc/mm/mem.c | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index 1646b76bd3d2..01c143bb77ae 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h | |||
@@ -313,5 +313,17 @@ static inline u32 rtas_config_addr(int busno, int devfn, int reg) | |||
313 | extern void __cpuinit rtas_give_timebase(void); | 313 | extern void __cpuinit rtas_give_timebase(void); |
314 | extern void __cpuinit rtas_take_timebase(void); | 314 | extern void __cpuinit rtas_take_timebase(void); |
315 | 315 | ||
316 | #ifdef CONFIG_PPC_RTAS | ||
317 | static inline int page_is_rtas_user_buf(unsigned long pfn) | ||
318 | { | ||
319 | unsigned long paddr = (pfn << PAGE_SHIFT); | ||
320 | if (paddr >= rtas_rmo_buf && paddr < (rtas_rmo_buf + RTAS_RMOBUF_MAX)) | ||
321 | return 1; | ||
322 | return 0; | ||
323 | } | ||
324 | #else | ||
325 | static inline int page_is_rtas_user_buf(unsigned long pfn) { return 0;} | ||
326 | #endif | ||
327 | |||
316 | #endif /* __KERNEL__ */ | 328 | #endif /* __KERNEL__ */ |
317 | #endif /* _POWERPC_RTAS_H */ | 329 | #endif /* _POWERPC_RTAS_H */ |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 83d819f30864..395f42d5f785 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <asm/vdso.h> | 51 | #include <asm/vdso.h> |
52 | #include <asm/fixmap.h> | 52 | #include <asm/fixmap.h> |
53 | #include <asm/swiotlb.h> | 53 | #include <asm/swiotlb.h> |
54 | #include <asm/rtas.h> | ||
54 | 55 | ||
55 | #include "mmu_decl.h" | 56 | #include "mmu_decl.h" |
56 | 57 | ||
@@ -600,6 +601,8 @@ int devmem_is_allowed(unsigned long pfn) | |||
600 | return 0; | 601 | return 0; |
601 | if (!page_is_ram(pfn)) | 602 | if (!page_is_ram(pfn)) |
602 | return 1; | 603 | return 1; |
604 | if (page_is_rtas_user_buf(pfn)) | ||
605 | return 1; | ||
603 | return 0; | 606 | return 0; |
604 | } | 607 | } |
605 | #endif /* CONFIG_STRICT_DEVMEM */ | 608 | #endif /* CONFIG_STRICT_DEVMEM */ |