]> www.infradead.org Git - linux.git/commitdiff
x86: Convert unreachable() to BUG()
authorPeter Zijlstra <peterz@infradead.org>
Thu, 28 Nov 2024 09:39:02 +0000 (10:39 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 2 Dec 2024 11:01:43 +0000 (12:01 +0100)
Avoid unreachable() as it can (and will in the absence of UBSAN)
generate fallthrough code. Use BUG() so we get a UD2 trap (with
unreachable annotation).

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.028316261@infradead.org
arch/x86/kernel/process.c
arch/x86/kernel/reboot.c
arch/x86/kvm/svm/sev.c

index f63f8fd00a91f3d1171f307b92179556ba2d716d..15507e739c255bc697be5276ee3fabe8d2084d41 100644 (file)
@@ -838,7 +838,7 @@ void __noreturn stop_this_cpu(void *dummy)
 #ifdef CONFIG_SMP
        if (smp_ops.stop_this_cpu) {
                smp_ops.stop_this_cpu();
-               unreachable();
+               BUG();
        }
 #endif
 
index 615922838c510bdd634f50cfba5f385b18b0c587..dc1dd3f3e67fcdab9893e50dcad755f199c18b18 100644 (file)
@@ -883,7 +883,7 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
 
        if (smp_ops.stop_this_cpu) {
                smp_ops.stop_this_cpu();
-               unreachable();
+               BUG();
        }
 
        /* Assume hlt works */
index 943bd074a5d37212a1fdf1f01e42f1c8f0e416c6..fe6cc763fd518949fa107e531a8988c0af30b68c 100644 (file)
@@ -3820,7 +3820,7 @@ next_range:
                goto next_range;
        }
 
-       unreachable();
+       BUG();
 }
 
 static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)