diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c --- a/sys/arm64/arm64/elf32_machdep.c +++ b/sys/arm64/arm64/elf32_machdep.c @@ -239,6 +239,7 @@ uintptr_t stack) { struct trapframe *tf = td->td_frame; + struct pcb *pcb = td->td_pcb; memset(tf, 0, sizeof(struct trapframe)); @@ -256,8 +257,13 @@ tf->tf_spsr = PSR_M_32; #ifdef VFP - vfp_reset_state(td, td->td_pcb); + vfp_reset_state(td, pcb); #endif + + /* + * Clear debug register state. It is not applicable to the new process. + */ + bzero(&pcb->pcb_dbg_regs, sizeof(pcb->pcb_dbg_regs)); } void diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -569,7 +569,10 @@ vfp_reset_state(td, pcb); #endif - /* TODO: Shouldn't we also reset pcb_dbg_regs? */ + /* + * Clear debug register state. It is not applicable to the new process. + */ + bzero(&pcb->pcb_dbg_regs, sizeof(pcb->pcb_dbg_regs)); } /* Sanity check these are the same size, they will be memcpy'd to and fro */ diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -351,6 +351,7 @@ uintptr_t stack) { struct trapframe *regs = td->td_frame; + struct pcb *pcb = td->td_pcb; /* LINUXTODO: validate */ LIN_SDT_PROBE0(sysvec, linux_exec_setregs, todo); @@ -365,14 +366,19 @@ #endif regs->tf_elr = imgp->entry_addr; - td->td_pcb->pcb_tpidr_el0 = 0; - td->td_pcb->pcb_tpidrro_el0 = 0; + pcb->pcb_tpidr_el0 = 0; + pcb->pcb_tpidrro_el0 = 0; WRITE_SPECIALREG(tpidrro_el0, 0); WRITE_SPECIALREG(tpidr_el0, 0); #ifdef VFP - vfp_reset_state(td, td->td_pcb); + vfp_reset_state(td, pcb); #endif + + /* + * Clear debug register state. It is not applicable to the new process. + */ + bzero(&pcb->pcb_dbg_regs, sizeof(pcb->pcb_dbg_regs)); } int