Module Name: src
Committed By: maxv
Date: Thu Sep 27 13:04:22 UTC 2018
Modified Files:
src/sys/arch/x86/include: dbregs.h
src/sys/arch/x86/x86: dbregs.c
Log Message:
Export x86_dbregs_{save/restore}, will be used outside. Reproduce some
internal dbregs logic in them.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/dbregs.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/x86/dbregs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/include/dbregs.h
diff -u src/sys/arch/x86/include/dbregs.h:1.6 src/sys/arch/x86/include/dbregs.h:1.7
--- src/sys/arch/x86/include/dbregs.h:1.6 Thu Jul 26 09:29:08 2018
+++ src/sys/arch/x86/include/dbregs.h Thu Sep 27 13:04:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dbregs.h,v 1.6 2018/07/26 09:29:08 maxv Exp $ */
+/* $NetBSD: dbregs.h,v 1.7 2018/09/27 13:04:22 maxv Exp $ */
/*
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -110,6 +110,10 @@ void x86_dbregs_init(void);
void x86_dbregs_clear(struct lwp *);
void x86_dbregs_abandon(struct lwp *);
void x86_dbregs_read(struct lwp *, struct dbreg *);
+
+void x86_dbregs_save(struct lwp *);
+void x86_dbregs_restore(struct lwp *);
+
void x86_dbregs_store_dr6(struct lwp *);
int x86_dbregs_user_trap(void);
int x86_dbregs_validate(const struct dbreg *);
Index: src/sys/arch/x86/x86/dbregs.c
diff -u src/sys/arch/x86/x86/dbregs.c:1.11 src/sys/arch/x86/x86/dbregs.c:1.12
--- src/sys/arch/x86/x86/dbregs.c:1.11 Thu Jul 26 09:29:08 2018
+++ src/sys/arch/x86/x86/dbregs.c Thu Sep 27 13:04:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dbregs.c,v 1.11 2018/07/26 09:29:08 maxv Exp $ */
+/* $NetBSD: dbregs.c,v 1.12 2018/09/27 13:04:21 maxv Exp $ */
/*
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -144,11 +144,15 @@ x86_dbregs_read(struct lwp *l, struct db
memcpy(regs, pcb->pcb_dbregs, sizeof(*regs));
}
-static void
+void
x86_dbregs_save(struct lwp *l)
{
struct pcb *pcb = lwp_getpcb(l);
+ if (!(pcb->pcb_flags & PCB_DBREGS)) {
+ return;
+ }
+
KASSERT(pcb->pcb_dbregs != NULL);
pcb->pcb_dbregs->dr[0] = rdr0();
@@ -160,11 +164,15 @@ x86_dbregs_save(struct lwp *l)
pcb->pcb_dbregs->dr[7] = rdr7();
}
-static void
+void
x86_dbregs_restore(struct lwp *l)
{
struct pcb *pcb = lwp_getpcb(l);
+ if (!(pcb->pcb_flags & PCB_DBREGS)) {
+ return;
+ }
+
KASSERT(pcb->pcb_dbregs != NULL);
ldr0(pcb->pcb_dbregs->dr[0]);