Skip to contentSkip to conversation

arm64/mm: Replace BUG_ON() with VM_WARN_ON_ONCE()

PATCH Applied Anshuman Khandual 2 participants 2 messages Apr 30 – May 19 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/mm: Replace BUG_ON() with VM_WARN_ON_ONCE()

Avoid BUG_ON() while checking for inconsistent page table state conditions and instead replace them with VM_WARN_ON_ONCE().

---
This patch applies on v7.1-rc1

Took the liberty in including David's tag from an internal discussion.

Earlier context during D128 RFC review.

https://lore.kernel.org/all/[email protected]/

 arch/arm64/include/asm/pgtable.h |  4 ++--
 arch/arm64/mm/mmu.c              | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)
arch/arm64/include/asm/pgtable.h +2 -2
index 4dfa42b7d053..c9e4e00a9af2 100644
@@ -1007,7 +1007,7 @@ static inline pud_t *p4d_pgtable(p4d_t p4d)
 
 static inline phys_addr_t pud_offset_phys(p4d_t *p4dp, unsigned long addr)
 {
-	BUG_ON(!pgtable_l4_enabled());
+	VM_WARN_ON_ONCE(!pgtable_l4_enabled());
 
 	return p4d_page_paddr(READ_ONCE(*p4dp)) + pud_index(addr) * sizeof(pud_t);
 }
@@ -1130,7 +1130,7 @@ static inline p4d_t *pgd_to_folded_p4d(pgd_t *pgdp, unsigned long addr)
 
 static inline phys_addr_t p4d_offset_phys(pgd_t *pgdp, unsigned long addr)
 {
-	BUG_ON(!pgtable_l5_enabled());
+	VM_WARN_ON_ONCE(!pgtable_l5_enabled());
 
 	return pgd_page_paddr(READ_ONCE(*pgdp)) + p4d_index(addr) * sizeof(p4d_t);
 }
arch/arm64/mm/mmu.c +6 -6
index dd85e093ffdb..4c8959153ac4 100644
@@ -273,8 +273,8 @@ static int init_pmd(pmd_t *pmdp, unsigned long addr, unsigned long end,
 			if (ret)
 				return ret;
 
-			BUG_ON(pmd_val(old_pmd) != 0 &&
-			       pmd_val(old_pmd) != READ_ONCE(pmd_val(*pmdp)));
+			VM_WARN_ON_ONCE(pmd_val(old_pmd) != 0 &&
+					pmd_val(old_pmd) != READ_ONCE(pmd_val(*pmdp)));
 		}
 		phys += next - addr;
 	} while (pmdp++, addr = next, addr != end);
@@ -394,8 +394,8 @@ static int alloc_init_pud(p4d_t *p4dp, unsigned long addr, unsigned long end,
 			if (ret)
 				goto out;
 
-			BUG_ON(pud_val(old_pud) != 0 &&
-			       pud_val(old_pud) != READ_ONCE(pud_val(*pudp)));
+			VM_WARN_ON_ONCE(pud_val(old_pud) != 0 &&
+					pud_val(old_pud) != READ_ONCE(pud_val(*pudp)));
 		}
 		phys += next - addr;
 	} while (pudp++, addr = next, addr != end);
@@ -445,8 +445,8 @@ static int alloc_init_p4d(pgd_t *pgdp, unsigned long addr, unsigned long end,
 		if (ret)
 			goto out;
 
-		BUG_ON(p4d_val(old_p4d) != 0 &&
-		       p4d_val(old_p4d) != READ_ONCE(p4d_val(*p4dp)));
+		VM_WARN_ON_ONCE(p4d_val(old_p4d) != 0 &&
+				p4d_val(old_p4d) != READ_ONCE(p4d_val(*p4dp)));
 
 		phys += next - addr;
 	} while (p4dp++, addr = next, addr != end);
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 4 lines · Anshuman Khandual

Avoid BUG_ON() while checking for inconsistent page table state conditions and instead replace them with VM_WARN_ON_ONCE().

Applied to arm64 (for-next/mm), thanks!

[1/1] arm64/mm: Replace BUG_ON() with VM_WARN_ON_ONCE()

      https://git.kernel.org/arm64/c/13d0fdc09016

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev