From 85f1c223b39c92c49e8b7c6c7ad39d3e42a27574 Mon Sep 17 00:00:00 2001 From: bsd Date: Sun, 20 Feb 2000 20:51:23 +0000 Subject: Don't forget to reset the hardware debug registers when a process that was using them exits. Don't allow a user process to cause the kernel to take a TRCTRAP on a user space address. Reviewed by: jlemon, sef Approved by: jkh --- sys/amd64/amd64/trap.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'sys/amd64/amd64/trap.c') diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 4199346..a8b73cf 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -519,8 +519,26 @@ kernel_trap: frame.tf_eflags &= ~PSL_T; return; } + /* + * Ignore debug register trace traps due to + * accesses in the user's address space, which + * can happen under several conditions such as + * if a user sets a watchpoint on a buffer and + * then passes that buffer to a system call. + * We still want to get TRCTRAPS for addresses + * in kernel space because that is useful when + * debugging the kernel. + */ + if (user_dbreg_trap()) { + /* + * Reset breakpoint bits because the + * processor doesn't + */ + load_dr6(rdr6() & 0xfffffff0); + return; + } /* - * Fall through. + * Fall through (TRCTRAP kernel mode, kernel address) */ case T_BPTFLT: /* -- cgit v1.1