[PATCH 2/4] x86: ioremap: fix physical address check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the physical address is too high to be handled by ioremap() in
x86_32 PAE (e.g. more than 36-bit physical address), ioremap() must
return error (NULL). However, current x86 ioremap try to map this too
high physical address, and it causes unexpected behavior.

The ioremap() seems to check the specified physical address using
phys_addr_valid(). But current phys_addr_valid() returns true even if
more than 36-bit address range is specified because
boot_cpu_data.x86_phys_bits can have more than 36 even in X86_32 PAE
mode (boot_cpu_data.x86_phys_bits seems to hold maximum capability of
the processor).

To fix the problem, this patch changes phys_addr_valid() function to
return false when more than 36-bit address range is specified in PAE.
The phys_addr_valid() function is used only by ioremap() in X86_32 PAE
mode. So this change only affects ioremap() in X86_32 PAE mode.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@xxxxxxxxxxxxxx>

---
 arch/x86/mm/physaddr.h |    4 ++++
 1 file changed, 4 insertions(+)

Index: linux-2.6.34/arch/x86/mm/physaddr.h
===================================================================
--- linux-2.6.34.orig/arch/x86/mm/physaddr.h	2010-06-10 07:28:28.177229689 +0900
+++ linux-2.6.34/arch/x86/mm/physaddr.h	2010-06-10 07:28:32.587190857 +0900
@@ -3,8 +3,12 @@
 static inline int phys_addr_valid(resource_size_t addr)
 {
 #ifdef CONFIG_PHYS_ADDR_T_64BIT
+#ifdef CONFIG_X86_64
 	return !(addr >> boot_cpu_data.x86_phys_bits);
 #else
+	return !(addr >> 36);
+#endif
+#else
 	return 1;
 #endif
 }


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


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux