reload_ds:
RELOAD_SEG_REG(%ds)
ret
+
+/*===========================================================================*/
+/* switch_address_space */
+/*===========================================================================*/
+/* PUBLIC void switch_address_space(struct proc *p)
+ *
+ * sets the %cr3 register to the supplied value if it is not already set to the
+ * same value in which case it would only result in an extra TLB flush which is
+ * not desirable
+ */
+ .balign 16
+.globl switch_address_space
+switch_address_space:
+
+ /* read the process pointer */
+ mov 4(%esp), %edx
+ /* enable process' segment descriptors */
+ lldt P_LDT_SEL(%edx)
+ /* get the new cr3 value */
+ movl P_CR3(%edx), %eax
+ /* test if the new cr3 != NULL */
+ cmpl $0, %eax
+ je 0f
+
+ /*
+ * test if the cr3 is loaded with the current value to avoid unnecessary
+ * TLB flushes
+ */
+ mov %cr3, %ecx
+ cmp %ecx, %eax
+ je 0f
+ mov %eax, %cr3
+ mov %edx, ptproc
+ movl $0, dirtypde
+0:
+ ret
/* %eax is set by schedcheck() to the process to run */
mov %eax, %ebp /* will assume P_STACKBASE == 0 */
- cmpl $0, P_CR3(%ebp)
- jz 0f
-
- /*
- * test if the cr3 is loaded with the current value to avoid unnecessary
- * TLB flushes
- */
- mov P_CR3(%ebp), %eax
- mov %cr3, %ecx
- cmp %ecx, %eax
- jz 0f
- mov %eax, %cr3
- mov %ebp, ptproc
- movl $0, dirtypde
-0:
-
/* reconstruct the stack for iret */
movl SSREG(%ebp), %eax
push %eax
RESTORE_GP_REGS(%ebp)
- lldt P_LDT_SEL(%ebp) /* enable process' segment descriptors */
RESTORE_SEGS(%ebp)
movl %ss:BPREG(%ebp), %ebp
m_ptr = (message *) proc->p_reg.bx;
bit_map = proc->p_reg.dx;
- /* do_ipc() expects the given process's memory to be accessible. */
- vm_set_cr3(proc);
-
/* Make the system call, for real this time. */
proc->p_reg.retreg = do_ipc(call_nr, src_dst_e, m_ptr, bit_map);
}
idle();
}
+ switch_address_space(proc_ptr);
+
check_misc_flags:
vmassert(proc_ptr);
_PROTOTYPE( int arch_phys_map_reply, (int index, vir_bytes addr));
_PROTOTYPE( int arch_enable_paging, (void));
+_PROTOTYPE(void switch_address_space, (struct proc * p));
#endif /* PROTO_H */