Skip to contentSkip to conversation

x86/mm: avoid false-positive objtool warning in page_fault_oops()

PATCH In review Arnd Bergmann 2 participants 2 messages Dec 17, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: avoid false-positive objtool warning in page_fault_oops()

From: Arnd Bergmann <[email protected]>

When printing the oops for a VMAP_STACK overflow, the final call frompage_fault_oops() does not return to the original stack, which confuses gcc, and the unreachable() annotation leads to the end of the function just continuing on in the next one:

arch/x86/mm/fault.o: warning: objtool: page_fault_oops() falls through to next function kernelmode_fixup_or_oops.constprop.0()

To work around the warning, add an explicit endless loop here that objtool can detect.

Fixes 6271cfdfc0e4 ("x86/mm: Improve stack-overflow #PF handling")

---
I'm not sure about this one, maybe there is a way for objtool to detect this and not warn?

---
 arch/x86/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/fault.c +1 -1
index e6c469b323cc..0ef6e3cc54d2 100644
@@ -678,7 +678,7 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code,
 			      ASM_CALL_ARG3,
 			      , [arg1] "r" (regs), [arg2] "r" (address), [arg3] "r" (&info));
 
-		unreachable();
+		do { } while (1); /* unreachable */
 	}
 #endif
 
Signature · 1 line
2.39.5
maintainer
#1 lore raw
Quoted 26 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When printing the oops for a VMAP_STACK overflow, the final call frompage_fault_oops() does not return to the original stack, which confuses gcc, and the unreachable() annotation leads to the end of the function just continuing on in the next one:

arch/x86/mm/fault.o: warning: objtool: page_fault_oops() falls through to next function kernelmode_fixup_or_oops.constprop.0()

To work around the warning, add an explicit endless loop here that objtool can detect.

Fixes 6271cfdfc0e4 ("x86/mm: Improve stack-overflow #PF handling")

---
I'm not sure about this one, maybe there is a way for objtool to detect this and not warn?

---
 arch/x86/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/fault.c +0 -0
index e6c469b323cc..0ef6e3cc54d2 100644

arch/x86/mm/fault.c page_fault_oops(struct pt_regs *regs, unsigned long error_code, · line 681

Quoted 5 lines
arch/x86/mm/fault.c +1 -1
@@ -678,7 +678,7 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code,
 			      ASM_CALL_ARG3,
 			      , [arg1] "r" (regs), [arg2] "r" (address), [arg3] "r" (&info));
 
-		unreachable();
+		do { } while (1); /* unreachable */

Ah, I have one that puts a BUG() there, like 2190966fbc14 ("x86: Convert unreachable() to BUG()").

For some reason this hunk went missing from that patch.