git: dbb32ca9394a - stable/12 - x86: clear %db registers in new process

Konstantin Belousov kib at FreeBSD.org
Sat May 1 00:39:11 UTC 2021


The branch stable/12 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=dbb32ca9394a0b5732551705055bc0efbf88b5e2

commit dbb32ca9394a0b5732551705055bc0efbf88b5e2
Author:     Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-03-30 15:40:02 +0000
Commit:     Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-05-01 00:38:29 +0000

    x86: clear %db registers in new process
    
    (cherry picked from commit 8223717ce62c1ad0becc34ce69fe2d1771f3ba05)
---
 sys/amd64/amd64/vm_machdep.c | 8 ++++++++
 sys/i386/i386/vm_machdep.c   | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index eae5c36d2533..5b3845e5c68e 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -181,6 +181,14 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
 	bcopy(get_pcb_user_save_td(td1), get_pcb_user_save_pcb(pcb2),
 	    cpu_max_ext_state_size);
 
+	/* Reset debug registers in the new process */
+	pcb2->pcb_dr0 = 0;
+	pcb2->pcb_dr1 = 0;
+	pcb2->pcb_dr2 = 0;
+	pcb2->pcb_dr3 = 0;
+	pcb2->pcb_dr6 = 0;
+	pcb2->pcb_dr7 = 0;
+
 	/* Point mdproc and then copy over td1's contents */
 	mdp2 = &p2->p_md;
 	bcopy(&p1->p_md, mdp2, sizeof(*mdp2));
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
index 06112ebb34d0..c76074f5446d 100644
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -192,6 +192,14 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
 	bcopy(get_pcb_user_save_td(td1), get_pcb_user_save_pcb(pcb2),
 	    cpu_max_ext_state_size);
 
+	/* Reset debug registers in the new process */
+	pcb2->pcb_dr0 = 0;
+	pcb2->pcb_dr1 = 0;
+	pcb2->pcb_dr2 = 0;
+	pcb2->pcb_dr3 = 0;
+	pcb2->pcb_dr6 = 0;
+	pcb2->pcb_dr7 = 0;
+
 	/* Point mdproc and then copy over td1's contents */
 	mdp2 = &p2->p_md;
 	bcopy(&p1->p_md, mdp2, sizeof(*mdp2));


More information about the dev-commits-src-all mailing list