From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Subject: kernel: Fix absolute memory access for /dev/mem
Patch-mainline: not yet
Git-commit: -
References: bnc#820982, LTC#93650

Description: kernel: Fix absolute memory access for /dev/mem
Symptom: Prefix page and absolute zero pages are not correctly
              returned when reading /dev/mem.
Problem: The s390 asm/io.h file includes the asm-generic/io.h file
              which then defines the xlate_dev_mem_ptr() function
              and therefore overwrites the s390 specific version that
              does the correct swap operation of prefix and absolut zero
              pages. The problem is a regression that was introduced with
              line item KRN0911 (s390: PCI stub functions).
Solution: Add "#ifndef xlate_dev_mem_ptr" in asm-generic/io.h and
              "#define xlate_dev_mem_ptr" in asm/io.h. This ensures
              that the s390 version is used.
Reproduction: With this fix "zgetdump -i /dev/mem" should display UTS
              information:
              $ zgetdump -i /dev/mem  2>&1 | grep UTS
                UTS node name......: p23lp54
                UTS kernel release.: 3.0.74-0.9-default+
                UTS kernel version.: #10 SMP Tue May 21 11:24:40 CEST 2013
              Without the fix no UTS information is shown.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Acked-by: Torsten Duwe <duwe@suse.de>

---
 arch/s390/include/asm/io.h |    1 +
 include/asm-generic/io.h   |    2 ++
 2 files changed, 3 insertions(+)

--- a/arch/s390/include/asm/io.h
+++ b/arch/s390/include/asm/io.h
@@ -40,6 +40,7 @@ static inline void * phys_to_virt(unsign
 }
 
 void *xlate_dev_mem_ptr(phys_addr_t phys);
+#define xlate_dev_mem_ptr xlate_dev_mem_ptr
 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
 
 /*
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -356,7 +356,9 @@ extern void ioport_unmap(void __iomem *p
 #endif /* CONFIG_GENERIC_IOMAP */
 
 #define xlate_dev_kmem_ptr(p)	p
+#ifndef xlate_dev_mem_ptr
 #define xlate_dev_mem_ptr(p)	__va(p)
+#endif
 
 #ifndef virt_to_bus
 static inline unsigned long virt_to_bus(volatile void *address)
