head/sys/amd64/linux32/linux32_sysvec.c
/*
 * Clear registers on exec
 * XXX copied from ia32_signal.c.
 */
Clear registers on exec
XXX copied from ia32_signal.c.
Clear registers on exec XXX copied from ia32_signal . c .
static void
exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack)
{
	struct trapframe *regs = td->td_frame;
	struct pcb *pcb = td->td_pcb;
	mtx_lock(&dt_lock);
	if (td->td_proc->p_md.md_ldt != NULL)
		user_ldt_free(td);
	else
		mtx_unlock(&dt_lock);
	critical_enter();
	wrmsr(MSR_FSBASE, 0);
	wrmsr(MSR_KGSBASE, 0);	
	pcb->pcb_fsbase = 0;
	pcb->pcb_gsbase = 0;
	critical_exit();
	pcb->pcb_initial_fpucw = __LINUX_NPXCW__;
	bzero((char *)regs, sizeof(struct trapframe));
	regs->tf_rip = imgp->entry_addr;
	regs->tf_rsp = stack;
	regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T);
	regs->tf_gs = _ugssel;
	regs->tf_fs = _ufssel;
	regs->tf_es = _udatasel;
	regs->tf_ds = _udatasel;
	regs->tf_ss = _udatasel;
	regs->tf_flags = TF_HASSEGS;
	regs->tf_cs = _ucode32sel;
	regs->tf_rbx = imgp->ps_strings;
	fpstate_drop(td);
	set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
	td->td_retval[1] = 0;
}
static void exec_linux_setregs ( struct thread * td , struct image_params * imgp , u_long stack ) { struct trapframe * regs = td -> td_frame ; struct pcb * pcb = td -> td_pcb ; mtx_lock ( & dt_lock ) ; if ( td -> td_proc -> p_md . md_ldt != NULL ) user_ldt_free ( td ) ; else mtx_unlock ( & dt_lock ) ; critical_enter ( ) ; wrmsr ( MSR_FSBASE , 0 ) ; wrmsr ( MSR_KGSBASE , 0 ) ; pcb -> pcb_fsbase = 0 ; pcb -> pcb_gsbase = 0 ; critical_exit ( ) ; pcb -> pcb_initial_fpucw = __LINUX_NPXCW__ ; bzero ( ( char * ) regs , sizeof ( struct trapframe ) ) ; regs -> tf_rip = imgp -> entry_addr ; regs -> tf_rsp = stack ; regs -> tf_rflags = PSL_USER | ( regs -> tf_rflags & PSL_T ) ; regs -> tf_gs = _ugssel ; regs -> tf_fs = _ufssel ; regs -> tf_es = _udatasel ; regs -> tf_ds = _udatasel ; regs -> tf_ss = _udatasel ; regs -> tf_flags = TF_HASSEGS ; regs -> tf_cs = _ucode32sel ; regs -> tf_rbx = imgp -> ps_strings ; fpstate_drop ( td ) ; set_pcb_flags ( pcb , PCB_32BIT | PCB_FULL_IRET ) ; td -> td_retval [ 1 ] = 0 ; }
Clear registers on exec
 XXX copied from ia32_signal.c.
Clear registers on exec XXX copied from ia32_signal . c .
/* User value while we're in the kernel */ /* Do full restore on return so that we can change to a different %cs */