Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/i386/vm_machdep.c
Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
cpu_copy_thread(struct thread *td, struct thread *td0) | cpu_copy_thread(struct thread *td, struct thread *td0) | ||||
{ | { | ||||
struct pcb *pcb2; | struct pcb *pcb2; | ||||
/* Point the pcb to the top of the stack. */ | /* Point the pcb to the top of the stack. */ | ||||
pcb2 = td->td_pcb; | pcb2 = td->td_pcb; | ||||
/* Ensure that td0's pcb is up to date. */ | |||||
if (td0 == curthread) | |||||
td0->td_pcb->pcb_gs = rgs(); | |||||
critical_enter(); | |||||
kib: Why not call npxexit() there, same as for amd64? | |||||
Done Inline Actions
This matches cpu_fork() for i386 which does not use npxexit(). If we'd rather fix i386 to use npxexit() can I throw that into this series. jhb: > Why not call npxexit() there, same as for amd64?
This matches cpu_fork() for i386 which does… | |||||
if (PCPU_GET(fpcurthread) == td0) | |||||
npxsave(td0->td_pcb->pcb_save); | |||||
critical_exit(); | |||||
/* | /* | ||||
* Copy the upcall pcb. This loads kernel regs. | * Copy the upcall pcb. This loads kernel regs. | ||||
* Those not loaded individually below get their default | * Those not loaded individually below get their default | ||||
* values here. | * values here. | ||||
*/ | */ | ||||
bcopy(td0->td_pcb, pcb2, sizeof(*pcb2)); | bcopy(td0->td_pcb, pcb2, sizeof(*pcb2)); | ||||
pcb2->pcb_flags &= ~(PCB_NPXINITDONE | PCB_NPXUSERINITDONE | | pcb2->pcb_flags &= ~PCB_KERNNPX; | ||||
PCB_KERNNPX); | |||||
pcb2->pcb_save = get_pcb_user_save_pcb(pcb2); | pcb2->pcb_save = get_pcb_user_save_pcb(pcb2); | ||||
bcopy(get_pcb_user_save_td(td0), pcb2->pcb_save, | bcopy(get_pcb_user_save_td(td0), pcb2->pcb_save, | ||||
cpu_max_ext_state_size); | cpu_max_ext_state_size); | ||||
/* | /* | ||||
* Create a new fresh stack for the new thread. | * Create a new fresh stack for the new thread. | ||||
*/ | */ | ||||
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); | bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); | ||||
Show All 11 Lines | cpu_copy_thread(struct thread *td, struct thread *td0) | ||||
* return address on stack. These are the kernel mode register values. | * return address on stack. These are the kernel mode register values. | ||||
*/ | */ | ||||
pcb2->pcb_edi = 0; | pcb2->pcb_edi = 0; | ||||
pcb2->pcb_esi = (int)fork_return; /* trampoline arg */ | pcb2->pcb_esi = (int)fork_return; /* trampoline arg */ | ||||
pcb2->pcb_ebp = 0; | pcb2->pcb_ebp = 0; | ||||
pcb2->pcb_esp = (int)td->td_frame - sizeof(void *); /* trampoline arg */ | pcb2->pcb_esp = (int)td->td_frame - sizeof(void *); /* trampoline arg */ | ||||
pcb2->pcb_ebx = (int)td; /* trampoline arg */ | pcb2->pcb_ebx = (int)td; /* trampoline arg */ | ||||
pcb2->pcb_eip = (int)fork_trampoline + setidt_disp; | pcb2->pcb_eip = (int)fork_trampoline + setidt_disp; | ||||
pcb2->pcb_gs = rgs(); | |||||
Not Done Inline ActionsThis should be fine but unrelated? kib: This should be fine but unrelated? | |||||
Done Inline Actions
It's just part of the 'update pcb before copy logic' which now matches cpu_fork(). Since I had to add the FPU save, I figured this should mirror cpu_fork() at the same time. jhb: > This should be fine but unrelated?
It's just part of the 'update pcb before copy logic'… | |||||
/* | /* | ||||
* If we didn't copy the pcb, we'd need to do the following registers: | * If we didn't copy the pcb, we'd need to do the following registers: | ||||
* pcb2->pcb_cr3: cloned above. | * pcb2->pcb_cr3: cloned above. | ||||
* pcb2->pcb_dr*: cloned above. | * pcb2->pcb_dr*: cloned above. | ||||
* pcb2->pcb_savefpu: cloned above. | * pcb2->pcb_savefpu: cloned above. | ||||
* pcb2->pcb_flags: cloned above. | * pcb2->pcb_flags: cloned above. | ||||
* pcb2->pcb_onfault: cloned above (always NULL here?). | * pcb2->pcb_onfault: cloned above (always NULL here?). | ||||
* pcb2->pcb_gs: cloned above. | * pcb2->pcb_gs: cloned above. | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |
Why not call npxexit() there, same as for amd64?