From 312c6df40354e81d052d96c9d0c68cca82a65053 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Sat, 3 May 2014 09:06:28 +0800 Subject: arch/unicore32/include/asm/io.h: add readl_relaxed() generic definition Need generic definition for readl_relaxed(), like other architectures have done. Or can not pass compiling with allmodconfig, the related error: CC [M] drivers/message/fusion/mptbase.o drivers/message/fusion/mptbase.c: In function 'mpt_send_handshake_request': drivers/message/fusion/mptbase.c:1224: error: implicit declaration of function 'readl_relaxed' Signed-off-by: Chen Gang Acked-by: Xuetao Guan Signed-off-by: Xuetao Guan --- arch/unicore32/include/asm/io.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch/unicore32/include/asm/io.h') diff --git a/arch/unicore32/include/asm/io.h b/arch/unicore32/include/asm/io.h index 39decb6e6f57..d6920301465a 100644 --- a/arch/unicore32/include/asm/io.h +++ b/arch/unicore32/include/asm/io.h @@ -39,6 +39,10 @@ extern void __uc32_iounmap(volatile void __iomem *addr); #define ioremap_nocache(cookie, size) __uc32_ioremap(cookie, size) #define iounmap(cookie) __uc32_iounmap(cookie) +#define readb_relaxed readb +#define readw_relaxed readw +#define readl_relaxed readl + #define HAVE_ARCH_PIO_SIZE #define PIO_OFFSET (unsigned int)(PCI_IOBASE) #define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) -- cgit v1.2.3-55-g7522 From 8a016596a56282f1414cf90e575040cffdabe68e Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Tue, 15 Apr 2014 09:21:30 +0800 Subject: arch:unicore32:mm: add devmem_is_allowed() to support STRICT_DEVMEM unicore32 supports STRICT_DEVMEM, so it needs devmem_is_allowed(), like some of other architectures have done (e.g. arm, powerpc, x86 ...). The related error with allmodconfig: CC drivers/char/mem.o drivers/char/mem.c: In function ‘range_is_allowed’: drivers/char/mem.c:69: error: implicit declaration of function ‘devmem_is_allowed’ make[2]: *** [drivers/char/mem.o] Error 1 make[1]: *** [drivers/char] Error 2 make: *** [drivers] Error 2 Signed-off-by: Chen Gang Acked-by: Xuetao Guan Signed-off-by: Xuetao Guan --- arch/unicore32/include/asm/io.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'arch/unicore32/include/asm/io.h') diff --git a/arch/unicore32/include/asm/io.h b/arch/unicore32/include/asm/io.h index d6920301465a..cb1d8fd2b16b 100644 --- a/arch/unicore32/include/asm/io.h +++ b/arch/unicore32/include/asm/io.h @@ -48,5 +48,28 @@ extern void __uc32_iounmap(volatile void __iomem *addr); #define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) #define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1) +#ifdef CONFIG_STRICT_DEVMEM + +#include +#include + +/* + * devmem_is_allowed() checks to see if /dev/mem access to a certain + * address is valid. The argument is a physical page number. + * We mimic x86 here by disallowing access to system RAM as well as + * device-exclusive MMIO regions. This effectively disable read()/write() + * on /dev/mem. + */ +static inline int devmem_is_allowed(unsigned long pfn) +{ + if (iomem_is_exclusive(pfn << PAGE_SHIFT)) + return 0; + if (!page_is_ram(pfn)) + return 1; + return 0; +} + +#endif /* CONFIG_STRICT_DEVMEM */ + #endif /* __KERNEL__ */ #endif /* __UNICORE_IO_H__ */ -- cgit v1.2.3-55-g7522