ARM: 6672/1: LPAE: use phys_addr_t instead of unsigned long in mapping functions
authorWill Deacon <will.deacon@arm.com>
Tue, 15 Feb 2011 11:42:57 +0000 (12:42 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 15 Feb 2011 14:20:23 +0000 (14:20 +0000)
The unsigned long datatype is not sufficient for mapping physical addresses
>= 4GB.

This patch ensures that the phys_addr_t datatype is used to represent physical
addresses when converting from a PFN.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/include/asm/pgtable.h
arch/arm/mm/init.c
arch/arm/mm/mmu.c

index ebcb643..ca56791 100644 (file)
@@ -351,7 +351,7 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
 #define pte_unmap(pte)                 __pte_unmap(pte)
 
 #define pte_pfn(pte)           (pte_val(pte) >> PAGE_SHIFT)
-#define pfn_pte(pfn,prot)      __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
+#define pfn_pte(pfn,prot)      __pte(__pfn_to_phys(pfn) | pgprot_val(prot))
 
 #define pte_page(pte)          pfn_to_page(pte_pfn(pte))
 #define mk_pte(page,prot)      pfn_pte(page_to_pfn(page), prot)
index 5164069..14a00a1 100644 (file)
@@ -344,7 +344,7 @@ void __init bootmem_init(void)
         */
        arm_bootmem_free(min, max_low, max_high);
 
-       high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
+       high_memory = __va(((phys_addr_t)max_low << PAGE_SHIFT) - 1) + 1;
 
        /*
         * This doesn't seem to be used by the Linux memory manager any
@@ -392,8 +392,8 @@ free_memmap(unsigned long start_pfn, unsigned long end_pfn)
         * Convert to physical addresses, and
         * round start upwards and end downwards.
         */
-       pg = PAGE_ALIGN(__pa(start_pg));
-       pgend = __pa(end_pg) & PAGE_MASK;
+       pg = (unsigned long)PAGE_ALIGN(__pa(start_pg));
+       pgend = (unsigned long)__pa(end_pg) & PAGE_MASK;
 
        /*
         * If there are free pages between these,
index f512ad9..e09744e 100644 (file)
@@ -591,7 +591,7 @@ static void __init create_36bit_mapping(struct map_desc *md,
        pgd_t *pgd;
 
        addr = md->virtual;
-       phys = (unsigned long)__pfn_to_phys(md->pfn);
+       phys = __pfn_to_phys(md->pfn);
        length = PAGE_ALIGN(md->length);
 
        if (!(cpu_architecture() >= CPU_ARCH_ARMv6 || cpu_is_xsc3())) {
@@ -651,7 +651,8 @@ static void __init create_36bit_mapping(struct map_desc *md,
  */
 static void __init create_mapping(struct map_desc *md)
 {
-       unsigned long phys, addr, length, end;
+       unsigned long addr, length, end;
+       phys_addr_t phys;
        const struct mem_type *type;
        pgd_t *pgd;
 
@@ -680,7 +681,7 @@ static void __init create_mapping(struct map_desc *md)
        }
 
        addr = md->virtual & PAGE_MASK;
-       phys = (unsigned long)__pfn_to_phys(md->pfn);
+       phys = __pfn_to_phys(md->pfn);
        length = PAGE_ALIGN(md->length + (md->virtual & ~PAGE_MASK));
 
        if (type->prot_l1 == 0 && ((addr | phys | length) & ~SECTION_MASK)) {