2d72cbec41
. add cpufeature detection of both . use it for both ipc and kernelcall traps, using a register for call number . SYSENTER/SYSCALL does not save any context, therefore userland has to save it . to accomodate multiple kernel entry/exit types, the entry type is recorded in the process struct. hitherto all types were interrupt (soft int, exception, hard int); now SYSENTER/SYSCALL is new, with the difference that context is not fully restored from proc struct when running the process again. this can't be done as some information is missing. . complication: cases in which the kernel has to fully change process context (i.e. sigreturn). in that case the exit type is changed from SYSENTER/SYSEXIT to soft-int (i.e. iret) and context is fully restored from the proc struct. this does mean the PC and SP must change, as the sysenter/sysexit userland code will otherwise try to restore its own context. this is true in the sigreturn case. . override all usage by setting libc_ipc=1
66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
/* The kernel call that is implemented in this file:
|
|
* m_type: SYS_SIGRETURN
|
|
*
|
|
* The parameters for this kernel call are:
|
|
* m2_i1: SIG_ENDPT # process returning from handler
|
|
* m2_p1: SIG_CTXT_PTR # pointer to sigcontext structure
|
|
*
|
|
*/
|
|
|
|
#include "kernel/system.h"
|
|
#include <string.h>
|
|
#include <machine/cpu.h>
|
|
|
|
#if USE_SIGRETURN
|
|
|
|
/*===========================================================================*
|
|
* do_sigreturn *
|
|
*===========================================================================*/
|
|
int do_sigreturn(struct proc * caller, message * m_ptr)
|
|
{
|
|
/* POSIX style signals require sys_sigreturn to put things in order before
|
|
* the signalled process can resume execution
|
|
*/
|
|
struct sigcontext sc;
|
|
register struct proc *rp;
|
|
int proc_nr, r;
|
|
|
|
if (! isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL);
|
|
if (iskerneln(proc_nr)) return(EPERM);
|
|
rp = proc_addr(proc_nr);
|
|
|
|
/* Copy in the sigcontext structure. */
|
|
if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR,
|
|
KERNEL, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK)
|
|
return r;
|
|
|
|
/* Restore user bits of psw from sc, maintain system bits from proc. */
|
|
sc.sc_psw = (sc.sc_psw & X86_FLAGS_USER) |
|
|
(rp->p_reg.psw & ~X86_FLAGS_USER);
|
|
|
|
#if defined(__i386__)
|
|
/* Don't panic kernel if user gave bad selectors. */
|
|
sc.sc_cs = rp->p_reg.cs;
|
|
sc.sc_ds = rp->p_reg.ds;
|
|
sc.sc_es = rp->p_reg.es;
|
|
sc.sc_ss = rp->p_reg.ss;
|
|
sc.sc_fs = rp->p_reg.fs;
|
|
sc.sc_gs = rp->p_reg.gs;
|
|
#endif
|
|
|
|
/* Restore the registers. */
|
|
arch_proc_setcontext(rp, &sc.sc_regs, 1);
|
|
#if defined(__i386__)
|
|
if(sc.sc_flags & MF_FPU_INITIALIZED)
|
|
{
|
|
memcpy(rp->p_seg.fpu_state, &sc.sc_fpu_state, FPU_XFP_SIZE);
|
|
rp->p_misc_flags |= MF_FPU_INITIALIZED; /* Restore math usage flag. */
|
|
/* force reloading FPU */
|
|
release_fpu(rp);
|
|
}
|
|
#endif
|
|
|
|
return(OK);
|
|
}
|
|
#endif /* USE_SIGRETURN */
|
|
|