Index: sys/amd64/linux/linux_sysvec.c =================================================================== --- sys/amd64/linux/linux_sysvec.c +++ sys/amd64/linux/linux_sysvec.c @@ -425,60 +425,15 @@ { struct trapframe *regs; struct pcb *pcb; - register_t saved_rflags; regs = td->td_frame; pcb = td->td_pcb; - if (td->td_proc->p_md.md_ldt != NULL) - user_ldt_free(td); + exec_setregs(td, imgp, stack); - pcb->pcb_fsbase = 0; - pcb->pcb_gsbase = 0; - clear_pcb_flags(pcb, PCB_32BIT); pcb->pcb_initial_fpucw = __LINUX_NPXCW__; - set_pcb_flags(pcb, PCB_FULL_IRET); - - saved_rflags = regs->tf_rflags & PSL_T; - bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_rip = imgp->entry_addr; regs->tf_rsp = stack; - regs->tf_rflags = PSL_USER | saved_rflags; - regs->tf_ss = _udatasel; - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _ufssel; - 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); - } - - /* - * Drop the FP state if we hold it, so that the process gets a - * clean FP state if it uses the FPU again. - */ - fpstate_drop(td); + regs->tf_rdi = 0; } /*