Re: [PATCH RFC v3 2/4] x86/bus_lock: Handle warn and fatal in #DB for bus lock

From: Xiaoyao Li
Date: Tue Nov 03 2020 - 07:15:36 EST


On 10/31/2020 8:27 AM, Fenghua Yu wrote:

...

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 3c70fb34028b..1c3442000972 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -953,6 +953,13 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
goto out_irq;
}
+ /*
+ * Handle bus lock. #DB for bus lock can only be triggered from
+ * userspace.
+ */
+ if (!(dr6 & DR_BUS_LOCK))

it should be

if (dr6 & DR_BUS_LOCK)

since you keep DR6.[bit 11] reserved in this version. bit 11 of debug_read_clear_dr6() being set to 1 means bus lock detected.


+ handle_bus_lock(regs);
+
/* Add the virtual_dr6 bits for signals. */
dr6 |= current->thread.virtual_dr6;
if (dr6 & (DR_STEP | DR_TRAP_BITS) || icebp)