[RFC PATCH 11/12] PAT 64b: devmem do not read pages not mapped in identity map

From: venkatesh . pallipadi
Date: Thu Dec 13 2007 - 18:59:21 EST


Enable valid_phys_addr_range for x86_64 and check whether the identity
mapping exists before reading /dev/mem. For reserved regions there is no
identity mappings any more and then cannot be read from /dev/mem.

Side effect is that dd of entire memory will not work any more, once there are
reserved holes in memory space.

TBD: Read reserved regions as 0xffff or something, and continue reading
across holes, till we reach the high_memory (end of memory).

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
Signed-off-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
---

Index: linux-2.6.24-rc/arch/x86/kernel/e820_64.c
===================================================================
--- linux-2.6.24-rc.orig/arch/x86/kernel/e820_64.c
+++ linux-2.6.24-rc/arch/x86/kernel/e820_64.c
@@ -220,6 +220,11 @@ int is_memory_all_valid(unsigned long st
}
EXPORT_SYMBOL_GPL(is_memory_all_valid);

+int valid_phys_addr_range(unsigned long addr, size_t count)
+{
+ return is_memory_all_valid(addr, addr + count);
+}
+
/*
* Find a free area in a specific range.
*/
Index: linux-2.6.24-rc/include/asm-x86/io_64.h
===================================================================
--- linux-2.6.24-rc.orig/include/asm-x86/io_64.h
+++ linux-2.6.24-rc/include/asm-x86/io_64.h
@@ -265,6 +265,15 @@ extern int iommu_bio_merge;
*/
#define xlate_dev_kmem_ptr(p) p

+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
+extern int valid_phys_addr_range (unsigned long addr, size_t count);
+
+static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
+{
+ return 1;
+}
+
+
#endif /* __KERNEL__ */

#endif

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/