# HG changeset patch # User quintela@elfo.mitica # Node ID b5b4c76164972243479a9cb2a428a93a5aef7263 # Parent ad6b852bd54573cf46e8f34ffaeeae3877ec5603 devmem xen bits diff -r ad6b852bd545 -r b5b4c7616497 arch/i386/mm/init-xen.c --- a/arch/i386/mm/init-xen.c Thu Jul 27 02:02:42 2006 +0200 +++ b/arch/i386/mm/init-xen.c Thu Jul 27 02:21:44 2006 +0200 @@ -276,6 +276,25 @@ int page_is_ram(unsigned long pagenr) return 0; } +/* + * devmem_is_allowed() checks to see if /dev/mem access to a certain address is + * valid. The argument is a physical page number. + * + * + * On x86, access has to be given to the first megabyte of ram because that area + * contains bios code and data regions used by X and dosemu and similar apps. + * Access has to be given to non-kernel-ram areas as well, these contain the PCI + * mmio resources as well as potential bios/acpi data regions. + */ +int devmem_is_allowed(unsigned long pagenr) +{ + if (pagenr <= 256) + return 1; + if (!page_is_ram(pagenr)) + return 1; + return 0; +} + #ifdef CONFIG_HIGHMEM pte_t *kmap_pte; pgprot_t kmap_prot; diff -r ad6b852bd545 -r b5b4c7616497 arch/x86_64/mm/init-xen.c --- a/arch/x86_64/mm/init-xen.c Thu Jul 27 02:02:42 2006 +0200 +++ b/arch/x86_64/mm/init-xen.c Thu Jul 27 02:21:44 2006 +0200 @@ -960,6 +960,31 @@ int __add_pages(struct zone *z, unsigned } #endif /* CONFIG_MEMORY_HOTPLUG */ +static inline int page_is_ram (unsigned long pagenr) +{ + return 1; +} + +/* + * devmem_is_allowed() checks to see if /dev/mem access to a certain address is + * valid. The argument is a physical page number. + * + * + * On x86-64, access has to be given to the first megabyte of ram because that area + * contains bios code and data regions used by X and dosemu and similar apps. + * Access has to be given to non-kernel-ram areas as well, these contain the PCI + * mmio resources as well as potential bios/acpi data regions. + */ +int devmem_is_allowed(unsigned long pagenr) +{ + if (pagenr <= 256) + return 1; + if (!page_is_ram(pagenr)) + return 1; + return 0; +} + + static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules, kcore_vsyscall; diff -r ad6b852bd545 -r b5b4c7616497 include/asm-i386/mach-xen/asm/page.h --- a/include/asm-i386/mach-xen/asm/page.h Thu Jul 27 02:02:42 2006 +0200 +++ b/include/asm-i386/mach-xen/asm/page.h Thu Jul 27 02:21:44 2006 +0200 @@ -287,6 +287,8 @@ extern unsigned int __VMALLOC_RESERVE; extern int sysctl_legacy_va_layout; +extern int devmem_is_allowed(unsigned long pagenr); + extern int page_is_ram(unsigned long pagenr); #endif /* __ASSEMBLY__ */ diff -r ad6b852bd545 -r b5b4c7616497 include/asm-x86_64/mach-xen/asm/page.h --- a/include/asm-x86_64/mach-xen/asm/page.h Thu Jul 27 02:02:42 2006 +0200 +++ b/include/asm-x86_64/mach-xen/asm/page.h Thu Jul 27 02:21:44 2006 +0200 @@ -322,6 +322,10 @@ static inline pgd_t __pgd(unsigned long #include <asm-generic/memory_model.h> #include <asm-generic/page.h> +#ifndef __ASSEMBLY__ +extern int devmem_is_allowed(unsigned long pagenr); +#endif + #endif /* __KERNEL__ */ #endif /* _X86_64_PAGE_H */