> From: Masami Hiramatsu (Google) <[email protected]> > > In exc_machine_check_user(), local_db_save() and local_db_restore() are > invoked in the outer entry stubs (DEFINE_IDTENTRY_MCE_USER, > DEFINE_FREDENTRY_MCE, and DEFINE_IDTENTRY_RAW), surrounding > exc_machine_check_user(). > > However, exc_machine_check_user() calls irqentry_exit_to_user_mode(), > which handles pending thread work and may schedule() if TIF_NEED_RESCHED > is set. If the task migrates to another CPU during schedule(), > local_db_restore() runs on the new CPU with the dr7 state saved from the > old CPU. This corrupts the new CPU's DR7 hardware debug register and > leaves the old CPU's DR7 disabled. > In short, local_db_save() and local_db_restore() pair must be run > on the same CPU. > > To fix this, move local_db_save() and local_db_restore() inside > exc_machine_check_user() and exc_machine_check_kernel(). In > exc_machine_check_user(), DR7 is saved and restored strictly around > do_machine_check() to avoid schedule() during migration. In > exc_machine_check_kernel(), local_db_save() is called at the entry point > to prevent early memory accesses from triggering nested #DB exceptions, > and restored on all exits. > > Fixes: cd840e424f27 ("x86/entry, mce: Disallow #DB during #MC") > Assisted-by: Antigravity:gemini-3.8-flash > Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/178875277830.93794.14247844688761142429.stgit@devnote2?part=1
