From: "H. Peter Anvin" <hpa@zytor.com>
To: Jialin Wang <wjl.linux@gmail.com>,
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
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/reboot: Disable CET in machine_real_restart()
Date: Sun, 11 Oct 2026 08:56:10 -0700 [thread overview]
Message-ID: <4928ACDC-A246-4DD4-8814-AE680ADB7CD9@zytor.com> (raw)
In-Reply-To: <20261011151807.263575-1-wjl.linux@gmail.com>
On October 11, 2026 8:18:03 AM PDT, Jialin Wang <wjl.linux@gmail.com> wrote:
>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.
> */
Indeed, this is very correct.
Reviewed-by: H. Peter Anvin (Rosaic) <hpa@zytor.com>
prev parent reply other threads:[~2026-10-11 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 15:18 Jialin Wang
2026-10-11 15:56 ` H. Peter Anvin [this message]
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=4928ACDC-A246-4DD4-8814-AE680ADB7CD9@zytor.com \
--to=hpa@zytor.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=wjl.linux@gmail.com \
--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®