Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148496572
D29687.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D29687.id.diff
View Options
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -581,6 +581,34 @@
}
#endif
+/*
+ * Reset the hardware debug registers if they were in use.
+ * They won't have any meaning for the newly exec'd process.
+ */
+void
+x86_clear_dbregs(struct pcb *pcb)
+{
+ if ((pcb->pcb_flags & PCB_DBREGS) == 0)
+ return;
+
+ pcb->pcb_dr0 = 0;
+ pcb->pcb_dr1 = 0;
+ pcb->pcb_dr2 = 0;
+ pcb->pcb_dr3 = 0;
+ pcb->pcb_dr6 = 0;
+ pcb->pcb_dr7 = 0;
+
+ if (pcb == curpcb) {
+ /*
+ * Clear the debug registers on the running CPU,
+ * otherwise they will end up affecting the next
+ * process we switch to.
+ */
+ reset_dbregs();
+ }
+ clear_pcb_flags(pcb, PCB_DBREGS);
+}
+
/*
* Reset registers to default values on exec.
*/
@@ -617,27 +645,7 @@
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
- /*
- * Reset the hardware debug registers if they were in use.
- * They won't have any meaning for the newly exec'd process.
- */
- if (pcb->pcb_flags & PCB_DBREGS) {
- pcb->pcb_dr0 = 0;
- pcb->pcb_dr1 = 0;
- pcb->pcb_dr2 = 0;
- pcb->pcb_dr3 = 0;
- pcb->pcb_dr6 = 0;
- pcb->pcb_dr7 = 0;
- if (pcb == curpcb) {
- /*
- * Clear the debug registers on the running
- * CPU, otherwise they will end up affecting
- * the next process we switch to.
- */
- reset_dbregs();
- }
- clear_pcb_flags(pcb, PCB_DBREGS);
- }
+ x86_clear_dbregs(pcb);
/*
* Drop the FP state if we hold it, so that the process gets a
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1121,6 +1121,34 @@
}
#endif
+/*
+ * Reset the hardware debug registers if they were in use.
+ * They won't have any meaning for the newly exec'd process.
+ */
+void
+x86_clear_dbregs(struct pcb *pcb)
+{
+ if ((pcb->pcb_flags & PCB_DBREGS) == 0)
+ return;
+
+ pcb->pcb_dr0 = 0;
+ pcb->pcb_dr1 = 0;
+ pcb->pcb_dr2 = 0;
+ pcb->pcb_dr3 = 0;
+ pcb->pcb_dr6 = 0;
+ pcb->pcb_dr7 = 0;
+
+ if (pcb == curpcb) {
+ /*
+ * Clear the debug registers on the running CPU,
+ * otherwise they will end up affecting the next
+ * process we switch to.
+ */
+ reset_dbregs();
+ }
+ pcb->pcb_flags &= ~PCB_DBREGS;
+}
+
/*
* Reset registers to default values on exec.
*/
@@ -1174,27 +1202,7 @@
/* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
regs->tf_ebx = (register_t)imgp->ps_strings;
- /*
- * Reset the hardware debug registers if they were in use.
- * They won't have any meaning for the newly exec'd process.
- */
- if (pcb->pcb_flags & PCB_DBREGS) {
- pcb->pcb_dr0 = 0;
- pcb->pcb_dr1 = 0;
- pcb->pcb_dr2 = 0;
- pcb->pcb_dr3 = 0;
- pcb->pcb_dr6 = 0;
- pcb->pcb_dr7 = 0;
- if (pcb == curpcb) {
- /*
- * Clear the debug registers on the running
- * CPU, otherwise they will end up affecting
- * the next process we switch to.
- */
- reset_dbregs();
- }
- pcb->pcb_flags &= ~PCB_DBREGS;
- }
+ x86_clear_dbregs(pcb);
pcb->pcb_initial_npxcw = __INITIAL_NPXCW__;
diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h
--- a/sys/x86/include/x86_var.h
+++ b/sys/x86/include/x86_var.h
@@ -123,6 +123,7 @@
int dbreg_set_watchpoint(vm_offset_t addr, vm_size_t size, int access);
int dbreg_clr_watchpoint(vm_offset_t addr, vm_size_t size);
void dbreg_list_watchpoints(void);
+void x86_clear_dbregs(struct pcb *pcb);
bool disable_wp(void);
void restore_wp(bool old_wp);
void finishidentcpu(void);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 19, 6:31 AM (2 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29951956
Default Alt Text
D29687.id.diff (3 KB)
Attached To
Mode
D29687: x86: add x86_clear_dbregs() and ensure all ABI exec set_regs method clear debug registers file
Attached
Detach File
Event Timeline
Log In to Comment