Skip to contentSkip to conversation

ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

PATCH Superseded R Sricharan 3 participants 8 messages Aug 6, 2012 – Mar 15, 2013 Arm (32-bit)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

 arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +18 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
 				  unsigned long end, unsigned long pfn,
 				  const struct mem_type *type)
 {
-	pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+	unsigned long next;
+	pte_t *pte;
+	phys_addr_t phys;
+
 	do {
-		set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-		pfn++;
-	} while (pte++, addr += PAGE_SIZE, addr != end);
+		if ((end-addr) & PMD_MASK)
+			next = (addr + PMD_SIZE) & PMD_MASK;
+		else
+			next = end;
+
+		pte = early_pte_alloc(pmd, addr, type->prot_l1);
+		do {
+			set_pte_ext(pte, pfn_pte(pfn,
+					__pgprot(type->prot_pte)), 0);
+			pfn++;
+		} while (pte++, addr += PAGE_SIZE, addr != next);
+
+		phys += next - addr;
+	} while (pmd++, addr = next, addr != end);
 }
 
 static void __init alloc_init_section(pud_t *pud, unsigned long addr,
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

Hi,

Quoted 53 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

 arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +10 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                  unsigned long end, unsigned long pfn,
                                  const struct mem_type *type)
 {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
        do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 10 lines
arch/arm/mm/mmu.c +8 -0
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
 }
 

ping..

Thanks,
Sricharan

#2 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

Hi,

Quoted 58 lines · Sricharan

Hi,

Quoted 56 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

 arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +13 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                  unsigned long end, unsigned long pfn,
                                  const struct mem_type *type)
 {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
        do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 7 lines
arch/arm/mm/mmu.c +5 -0
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
 }
 

ping..

Ping again.
The issue is reproducible in mainline with CMA + LPAE enabled. CMA tries to reserve/map 16 MB with 2 level table entries and
crashes in alloc_init_pte.

This patch fixes that. Just posted a V3 of the same patch.

         https://patchwork.kernel.org/patch/1472031/

Thanks,
Sricharan

#3 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

(sorry for if you got this message twice, gmail's new reply method decided to send html)

Quoted 69 lines · Sricharan

Hi,

Quoted 58 lines · Sricharan

Hi,

Quoted 56 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

 arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +13 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                  unsigned long end, unsigned long pfn,
                                  const struct mem_type *type)
 {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
        do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 7 lines
arch/arm/mm/mmu.c +5 -0
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
 }
 

ping..

Quoted 8 lines

Ping again.
The issue is reproducible in mainline with CMA + LPAE enabled. CMA tries to reserve/map 16 MB with 2 level table entries and
crashes in alloc_init_pte.

This patch fixes that. Just posted a V3 of the same patch.

         https://patchwork.kernel.org/patch/1472031/

I thought there was another patch where the looping was in an alloc_init_pmd() function, or there are just two different threads. I acked the other but not this one as I don't think looping over pmd inside the alloc_init_pte() function is the right thing.

Signature · 1 line
Catalin
#4 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

Quoted 78 lines · Catalin Marinas

(sorry for if you got this message twice, gmail's new reply method decided to send html)

Quoted 74 lines · Sricharan

Hi,

Quoted 58 lines · Sricharan

Hi,

Quoted 56 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

  arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +13 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                   unsigned long end, unsigned long pfn,
                                   const struct mem_type *type)
  {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
         do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 7 lines
arch/arm/mm/mmu.c +5 -0
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
  }
 

ping..

Ping again.
The issue is reproducible in mainline with CMA + LPAE enabled. CMA tries to reserve/map 16 MB with 2 level table entries and
crashes in alloc_init_pte.

Quoted 9 lines
Quoted 3 lines

This patch fixes that. Just posted a V3 of the same patch.

          https://patchwork.kernel.org/patch/1472031/

I thought there was another patch where the looping was in an alloc_init_pmd() function, or there are just two different threads. I acked the other but not this one as I don't think looping over pmd inside the alloc_init_pte() function is the right thing.

I submitted a patch last week for what I think is the same issue ("arm:
mm: Populate initial page tables across sections") but I don't think I ever saw any feedback on the patch. Do we have three patches floating around fixing the same issue?

Laura

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#5 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

Hi,

Quoted 89 lines · Laura Abbott
Quoted 78 lines · Catalin Marinas

(sorry for if you got this message twice, gmail's new reply method decided to send html)

Quoted 74 lines · Sricharan

Hi,

Quoted 58 lines · Sricharan

Hi,

Quoted 56 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

  arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +13 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                   unsigned long end, unsigned long pfn,
                                   const struct mem_type *type)
  {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
         do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 7 lines
arch/arm/mm/mmu.c +5 -0
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
  }
 

ping..

Ping again.
The issue is reproducible in mainline with CMA + LPAE enabled. CMA tries to reserve/map 16 MB with 2 level table entries and
crashes in alloc_init_pte.

Quoted 9 lines
Quoted 3 lines

This patch fixes that. Just posted a V3 of the same patch.

          https://patchwork.kernel.org/patch/1472031/

I thought there was another patch where the looping was in an alloc_init_pmd() function, or there are just two different threads. I acked the other but not this one as I don't think looping over pmd inside the alloc_init_pte() function is the right thing.

Quoted 4 lines

I submitted a patch last week for what I think is the same issue ("arm: mm: Populate initial page tables across sections") but I don't think I ever saw any feedback on the patch. Do we have three patches floating around fixing the same issue?

Laura

your patch is looking like the intial version that i posted. So after some reviews, finally ended up with the below patch [1]. Can you please check if your issue gets fixed with this.

[1] http://permalink.gmane.org/gmane.linux.ports.arm.kernel/216880

Regards,
Sricharan

#6 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

Quoted 93 lines · Sricharan R

Hi,

Quoted 91 lines · Laura Abbott
Quoted 78 lines · Catalin Marinas

(sorry for if you got this message twice, gmail's new reply method decided to send html)

Quoted 74 lines · Sricharan

Hi,

Quoted 58 lines · Sricharan

Hi,

Quoted 56 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

   arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
   1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +13 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                    unsigned long end, unsigned long pfn,
                                    const struct mem_type *type)
   {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
          do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 7 lines
arch/arm/mm/mmu.c +5 -0
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
   }
 
    ping..

Ping again.
The issue is reproducible in mainline with CMA + LPAE enabled. CMA tries to reserve/map 16 MB with 2 level table entries and
crashes in alloc_init_pte.

Quoted 9 lines
Quoted 3 lines

This patch fixes that. Just posted a V3 of the same patch.

https://patchwork.kernel.org/patch/1472031/

I thought there was another patch where the looping was in an alloc_init_pmd() function, or there are just two different threads. I acked the other but not this one as I don't think looping over pmd inside the alloc_init_pte() function is the right thing.

I submitted a patch last week for what I think is the same issue ("arm: mm: Populate initial page tables across sections") but I don't think I ever saw any feedback on the patch. Do we have three patches floating around fixing the same issue?

Quoted 8 lines
Quoted 2 lines

Laura

your patch is looking like the intial version that i posted. So after some reviews, finally ended up with the below patch [1]. Can you please check if your issue gets fixed with this.

[1] http://permalink.gmane.org/gmane.linux.ports.arm.kernel/216880

The patch does fix the problem for me as well. You are welcome to add

Tested-by Laura Abbott <[email protected]>

Laura

Quoted 9 lines

Regards,
Sricharan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#7 lore raw

PATCH v2 1/1 ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.

Quoted 100 lines · Laura Abbott
Quoted 99 lines · Sricharan R

Hi,

Quoted 89 lines · Laura Abbott
Quoted 78 lines · Catalin Marinas

(sorry for if you got this message twice, gmail's new reply method decided to send html)

Quoted 74 lines · Sricharan

Hi,

Quoted 58 lines · Sricharan

Hi,

Quoted 56 lines

With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped.

The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range.

Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped.

---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE.

   arch/arm/mm/mmu.c |   22 ++++++++++++++++++----
   1 file changed, 18 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +13 -4
index cf4528d..0ed8808 100644
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
                                    unsigned long end, unsigned long pfn,
                                    const struct mem_type *type)
   {
-       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+       unsigned long next;
+       pte_t *pte;
+       phys_addr_t phys;
+
          do {
-               set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
-               pfn++;
-       } while (pte++, addr += PAGE_SIZE, addr != end);
+               if ((end-addr) & PMD_MASK)
+                       next = (addr + PMD_SIZE) & PMD_MASK;
+               else
+                       next = end;
+
+               pte = early_pte_alloc(pmd, addr, type->prot_l1);
+               do {
+                       set_pte_ext(pte, pfn_pte(pfn,
+                                       __pgprot(type->prot_pte)), 0);
Quoted 8 lines

arch/arm/mm/mmu.c static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, · line 608

Quoted 7 lines
arch/arm/mm/mmu.c +5 -0
+                       pfn++;
+               } while (pte++, addr += PAGE_SIZE, addr != next);
+
+               phys += next - addr;
+       } while (pmd++, addr = next, addr != end);
   }
 
    ping..

Ping again.
The issue is reproducible in mainline with CMA + LPAE enabled. CMA tries to reserve/map 16 MB with 2 level table entries and
crashes in alloc_init_pte.

Quoted 9 lines
Quoted 3 lines

This patch fixes that. Just posted a V3 of the same patch.

https://patchwork.kernel.org/patch/1472031/

I thought there was another patch where the looping was in an alloc_init_pmd() function, or there are just two different threads. I acked the other but not this one as I don't think looping over pmd inside the alloc_init_pte() function is the right thing.

Quoted 4 lines

I submitted a patch last week for what I think is the same issue ("arm: mm: Populate initial page tables across sections") but I don't think I ever saw any feedback on the patch. Do we have three patches floating around fixing the same issue?

Laura

your patch is looking like the intial version that i posted. So after some reviews, finally ended up with the below patch [1]. Can you please check if your issue gets fixed with this.

Quoted 7 lines
Quoted 2 lines

[1] http://permalink.gmane.org/gmane.linux.ports.arm.kernel/216880

The patch does fix the problem for me as well. You are welcome to add

Tested-by Laura Abbott <[email protected]>

Thanks for testing and will add .

Regards,
Sricharan