mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-03 11:13:56 +08:00
x86/debug: Only clear/set ->virtual_dr6 for userspace #DB
The ->virtual_dr6 is the value used by ptrace_{get,set}_debugreg(6). A kernel #DB clearing it could mean spurious malfunction of ptrace() expectations. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Kyle Huey <me@kylehuey.com> Link: https://lore.kernel.org/r/20201027093608.028952500@infradead.org
This commit is contained in:
parent
2a9baf5ad4
commit
a195f3d452
@ -793,12 +793,6 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
|
|||||||
set_debugreg(DR6_RESERVED, 6);
|
set_debugreg(DR6_RESERVED, 6);
|
||||||
dr6 ^= DR6_RESERVED; /* Flip to positive polarity */
|
dr6 ^= DR6_RESERVED; /* Flip to positive polarity */
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear the virtual DR6 value, ptrace routines will set bits here for
|
|
||||||
* things we want signals for.
|
|
||||||
*/
|
|
||||||
current->thread.virtual_dr6 = 0;
|
|
||||||
|
|
||||||
return dr6;
|
return dr6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -942,6 +936,12 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
|
|||||||
irqentry_enter_from_user_mode(regs);
|
irqentry_enter_from_user_mode(regs);
|
||||||
instrumentation_begin();
|
instrumentation_begin();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear the virtual DR6 value, ptrace() routines will set bits here
|
||||||
|
* for things it wants signals for.
|
||||||
|
*/
|
||||||
|
current->thread.virtual_dr6 = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The SDM says "The processor clears the BTF flag when it
|
* The SDM says "The processor clears the BTF flag when it
|
||||||
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
|
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
|
||||||
|
Loading…
Reference in New Issue
Block a user