[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1834032058.38902.1397625329658.JavaMail.root@bj-mail03.pku.edu.cn>
Date: Wed, 16 Apr 2014 13:15:29 +0800 (CST)
From: 管雪涛 <gxt@....edu.cn>
To: Chen Gang <gang.chen.5i5j@...il.com>
Cc: Guan Xuetao <gxt@...c.pku.edu.cn>, akpm@...ux-foundation.org,
liuj97@...il.com, rientjes@...gle.com, dhowells@...hat.com,
mhocko@...e.cz, mgorman@...e.de, linux-kernel@...r.kernel.org
Subject: 回复: [PATCH v3] arch:unicore32:mm: add devmem_is_allowed() to support STRICT_DEVMEM
Acked-by: Xuetao Guan <gxt@...c.pku.edu.cn>
----- Chen Gang <gang.chen.5i5j@...il.com> 写道:
> 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@...il.com>
> ---
> arch/unicore32/include/asm/io.h | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/arch/unicore32/include/asm/io.h b/arch/unicore32/include/asm/io.h
> index 39decb6..ae327e4 100644
> --- a/arch/unicore32/include/asm/io.h
> +++ b/arch/unicore32/include/asm/io.h
> @@ -44,5 +44,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 <linux/ioport.h>
> +#include <linux/mm.h>
> +
> +/*
> + * 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__ */
> --
> 1.7.9.5
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists