From: Jialin Wang <wjl.linux@gmail.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org, Jialin Wang <wjl.linux@gmail.com>
Subject: [PATCH] x86/reboot: Disable CET in machine_real_restart()
Date: Sun, 11 Oct 2026 23:18:03 +0800 [thread overview]
Message-ID: <20261011151807.263575-1-wjl.linux@gmail.com> (raw)
When a kernel panic occurs in an environment without ACPI reboot or
8042 keyboard reset support (such as QEMU microvm),
native_machine_emergency_restart() falls back through BOOT_ACPI,
BOOT_KBD, BOOT_EFI, and eventually invokes machine_real_restart(MRR_BIOS)
to switch back to real mode for a BIOS reboot.
When kernel IBT is enabled, the indirect far jump (ljmpl) in
machine_real_restart() jumps to the 32-bit compatibility mode entry point
(pa_machine_real_restart_asm). Because machine_real_restart_asm does not
begin with an ENDBR32 instruction, an indirect branch tracking #CP fault
is triggered. Since ibt_fatal is true, do_kernel_cp_fault() triggers:
Missing ENDBR: 0x9a230
kernel BUG at arch/x86/kernel/cet.c:133!
This issue can be reproduced with virtme-ng:
vng -v -r -- 'echo c >/proc/sysrq-trigger'
which launches QEMU with the microvm architecture:
qemu-system-x86_64 -M microvm,accel=kvm,pcie=on,rtc=on \
-cpu host,topoext=on -smp 16 -no-reboot \
-kernel <vmlinuz> -append '... panic=-1 ...'
Invoke cet_disable() in machine_real_restart() before loading the
trampoline page table and executing the far jump, ensuring IBT is disabled
and avoiding the #CP fault.
Assisted-by: LLM
Signed-off-by: Jialin Wang <wjl.linux@gmail.com>
---
arch/x86/kernel/reboot.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 0fed6d0d7e32..eb23b8977de5 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -114,6 +114,13 @@ void __noreturn machine_real_restart(unsigned int type)
CMOS_WRITE(0x00, 0x8f);
spin_unlock(&rtc_lock);
+ /*
+ * Disable CET before loading the trampoline page table and jumping
+ * to the real-mode trampoline. This avoids missing-ENDBR #CP faults
+ * during the far jump.
+ */
+ cet_disable();
+
/*
* Switch to the trampoline page table.
*/
--
2.56.0
next reply other threads:[~2026-10-11 15:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 15:18 Jialin Wang [this message]
2026-10-11 15:56 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261011151807.263575-1-wjl.linux@gmail.com \
--to=wjl.linux@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®