The Android patch titled "ARM: allow the kernel text section to be made read-only" modifies alloc_init_pte() and adds a BUG_ON to detect the case where a section mapping is being overwritten. However the test doesn't allow for the legitimate case where the PMD is empty, as can happen for kernels built with CONFIG_ARM_LPAE. So extend the test to allow this.
Signed-off-by: Jon Medhurst tixy@linaro.org --- arch/arm/mm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 9eb7a4e..c35bbda 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -587,7 +587,7 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, pte_t *pte = start_pte + pte_index(addr);
/* If replacing a section mapping, the whole section must be replaced */ - BUG_ON(pmd_bad(*pmd) && ((addr | end) & ~PMD_MASK)); + BUG_ON(!pmd_none(*pmd) && pmd_bad(*pmd) && ((addr | end) & ~PMD_MASK));
do { set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);