Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <gang.chen.5i5j@gmail.com>
Acked-by: Xuetao Guan <gxt@mprc.pku.edu.cn>
Signed-off-by: Xuetao Guan <gxt@mprc.pku.edu.cn>

authored by

Chen Gang and committed by
Guan Xuetao
8a016596 aaad6183

+23
+23
arch/unicore32/include/asm/io.h
··· 48 48 #define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) 49 49 #define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1) 50 50 51 + #ifdef CONFIG_STRICT_DEVMEM 52 + 53 + #include <linux/ioport.h> 54 + #include <linux/mm.h> 55 + 56 + /* 57 + * devmem_is_allowed() checks to see if /dev/mem access to a certain 58 + * address is valid. The argument is a physical page number. 59 + * We mimic x86 here by disallowing access to system RAM as well as 60 + * device-exclusive MMIO regions. This effectively disable read()/write() 61 + * on /dev/mem. 62 + */ 63 + static inline int devmem_is_allowed(unsigned long pfn) 64 + { 65 + if (iomem_is_exclusive(pfn << PAGE_SHIFT)) 66 + return 0; 67 + if (!page_is_ram(pfn)) 68 + return 1; 69 + return 0; 70 + } 71 + 72 + #endif /* CONFIG_STRICT_DEVMEM */ 73 + 51 74 #endif /* __KERNEL__ */ 52 75 #endif /* __UNICORE_IO_H__ */