On Tue, Sep 22, 2026 at 01:24:55PM +0900, Masami Hiramatsu (Google) wrote:
> 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

verify_tags: WARNING: Zapping LLM ads tag: ['Antigravity:gemini-3.8-flash'].

Needs to be:

Assisted-by: LLM

Please fix all your patches.

> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
> ---
> Changes in v15:
>  - Move local_db_save() to the entry of exc_machine_check_kernel() and
>    restore it on early return from mce_check_crashing_cpu() to prevent
>    nested #DB on watched variables.
> Changes in v14:
>  - Newly added.
> ---
>  arch/x86/kernel/cpu/mce/core.c |   27 ++++++++++-----------------
>  1 file changed, 10 insertions(+), 17 deletions(-)

Yah, makes sense.

I'm thinking this needs to be CC:stable and I should take it in now.

Peter?

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Reply via email to