From 4845fd8c368dc72284b19e45d9bf735840d200a5 Mon Sep 17 00:00:00 2001 From: niklas Date: Tue, 28 Nov 1995 20:43:08 +0000 Subject: [PATCH] Fix SunOS emulation on 040 --- sys/arch/amiga/amiga/pmap.c | 10 ++++++++-- sys/arch/amiga/include/proc.h | 2 ++ sys/arch/m68k/m68k/sunos_machdep.c | 16 ++++++++++++++++ sys/compat/sunos/sunos_exec.c | 8 ++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/sys/arch/amiga/amiga/pmap.c b/sys/arch/amiga/amiga/pmap.c index 60697284291..145fc82e943 100644 --- a/sys/arch/amiga/amiga/pmap.c +++ b/sys/arch/amiga/amiga/pmap.c @@ -1390,9 +1390,15 @@ validate: * AMIGA pages in a MACH page. */ #ifdef M68040 - if (mmutype == MMU_68040 && pmap == pmap_kernel() && va >= AMIGA_UPTBASE && - va < (AMIGA_UPTBASE + AMIGA_UPTMAXSIZE)) + if (mmutype == MMU_68040 && pmap == pmap_kernel() && + va >= AMIGA_UPTBASE && va < (AMIGA_UPTBASE + AMIGA_UPTMAXSIZE)) cacheable = FALSE; /* don't cache user page tables */ + + /* Don't cache if process can't take it, like SunOS ones. */ + if (mmutype == MMU_68040 && pmap != pmap_kernel() && + (curproc->p_md.md_flags & MDP_UNCACHE_WX) && + (prot & VM_PROT_EXECUTE) && (prot & VM_PROT_WRITE)) + checkpv = cacheable = FALSE; #endif npte = (pa & PG_FRAME) | pte_prot(pmap, prot) | PG_V; npte |= (*(int *)pte & (PG_M|PG_U)); diff --git a/sys/arch/amiga/include/proc.h b/sys/arch/amiga/include/proc.h index 6ee0eefbb90..03e0110ba2e 100644 --- a/sys/arch/amiga/include/proc.h +++ b/sys/arch/amiga/include/proc.h @@ -50,4 +50,6 @@ struct mdproc { #define MDP_STACKADJ 0x0002 /* frame SP adjusted, might have to undo when system call returns ERESTART. */ +#define MDP_UNCACHE_WX 0x0004 /* The process might modify code, so + don't cache writeable executable pages. */ #endif /* !_MACHINE_PROC_H_ */ diff --git a/sys/arch/m68k/m68k/sunos_machdep.c b/sys/arch/m68k/m68k/sunos_machdep.c index a7c4df1f6e9..25e3ed7694f 100644 --- a/sys/arch/m68k/m68k/sunos_machdep.c +++ b/sys/arch/m68k/m68k/sunos_machdep.c @@ -86,6 +86,22 @@ struct sunos_sigframe { struct sunos_sigcontext sf_sc; /* I don't know if that's what comes here */ }; + +/* + * SunOS' ld.so does self-modifying code without knowing about the 040's + * cache purging needs. So we need to uncache writeable executable pages. + */ +void +sunos_setregs(p, pack, stack, retval) + register struct proc *p; + struct exec_package *pack; + u_long stack; + register_t *retval; +{ + setregs(p, pack, stack, retval); + p->p_md.md_flags |= MDP_UNCACHE_WX; +} + /* * much simpler sendsig() for SunOS processes, as SunOS does the whole * context-saving in usermode. For now, no hardware information (ie. diff --git a/sys/compat/sunos/sunos_exec.c b/sys/compat/sunos/sunos_exec.c index 3ed414feb97..e2ada6fff0b 100644 --- a/sys/compat/sunos/sunos_exec.c +++ b/sys/compat/sunos/sunos_exec.c @@ -68,6 +68,10 @@ extern struct sysent sunos_sysent[]; extern char *sunos_syscallnames[]; #endif extern void sunos_sendsig __P((sig_t, int, int, u_long)); +#ifdef m68k +extern void sunos_setregs __P((struct proc *, struct exec_package *, u_long, + register_t *)); +#endif extern char sigcode[], esigcode[]; const char sunos_emul_path[] = "/emul/sunos"; @@ -89,7 +93,11 @@ struct emul emul_sunos = { #endif 0, copyargs, +#ifdef m68k + sunos_setregs, +#else setregs, +#endif sigcode, esigcode, }; -- 2.20.1