From: downsj Date: Mon, 24 Feb 1997 01:16:06 +0000 (+0000) Subject: Add support for COMPAT_SUNOS and enable it. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0558a99b654e9c11fd43d71badd563f835cfc0f1;p=openbsd Add support for COMPAT_SUNOS and enable it. hp300 now runs sun3 SunOS executables! --- diff --git a/sys/arch/hp300/conf/DISKLESS b/sys/arch/hp300/conf/DISKLESS index 054e33d7c16..038ecd0d569 100644 --- a/sys/arch/hp300/conf/DISKLESS +++ b/sys/arch/hp300/conf/DISKLESS @@ -1,4 +1,4 @@ -# $OpenBSD: DISKLESS,v 1.13 1997/02/16 14:37:06 downsj Exp $ +# $OpenBSD: DISKLESS,v 1.14 1997/02/24 01:16:06 downsj Exp $ # $NetBSD: GENERIC,v 1.23 1997/01/31 06:12:57 thorpej Exp $ # # Generic kernel - one size fits all. @@ -41,6 +41,7 @@ option SE_KEYBOARD # include Swedish HIL keymap option COMPAT_HPUX # HP-UX binary compatibility option COMPAT_M68K4K # compat. with NetBSD/m68k4k binaries +option COMPAT_SUNOS # SunOS/sun3 binaries # Verbose descriptions of unconfigured DIO devices # (Warning: this compiles in a large string table) diff --git a/sys/arch/hp300/conf/GENERIC b/sys/arch/hp300/conf/GENERIC index 8a51d303420..59aeeecf069 100644 --- a/sys/arch/hp300/conf/GENERIC +++ b/sys/arch/hp300/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.17 1997/02/16 14:37:08 downsj Exp $ +# $OpenBSD: GENERIC,v 1.18 1997/02/24 01:16:07 downsj Exp $ # $NetBSD: GENERIC,v 1.23 1997/01/31 06:12:57 thorpej Exp $ # # Generic kernel - one size fits all. @@ -41,6 +41,7 @@ option SE_KEYBOARD # include Swedish HIL keymap option COMPAT_HPUX # HP-UX binary compatibility option COMPAT_M68K4K # compat. with NetBSD/m68k4k binaries +option COMPAT_SUNOS # SunOS/sun3 binaries # Verbose descriptions of unconfigured DIO devices # (Warning: this compiles in a large string table) diff --git a/sys/arch/hp300/conf/files.hp300 b/sys/arch/hp300/conf/files.hp300 index 8619240ecc3..6a3851f8b42 100644 --- a/sys/arch/hp300/conf/files.hp300 +++ b/sys/arch/hp300/conf/files.hp300 @@ -1,4 +1,4 @@ -# $OpenBSD: files.hp300,v 1.6 1997/02/16 10:42:18 downsj Exp $ +# $OpenBSD: files.hp300,v 1.7 1997/02/24 01:16:07 downsj Exp $ # $NetBSD: files.hp300,v 1.22 1997/01/30 22:11:19 scottr Exp $ # # hp300-specific configuration info @@ -194,3 +194,9 @@ major {vnd = 6} # include "compat/hpux/files.hpux" file arch/hp300/hp300/hpux_machdep.c compat_hpux + +# +# SunOS binary compatibility +# +include "compat/sunos/files.sunos" +file arch/m68k/m68k/sunos_machdep.c compat_sunos diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index caa1630b516..e14997b5d6f 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.19 1997/02/23 21:42:55 downsj Exp $ */ +/* $OpenBSD: machdep.c,v 1.20 1997/02/24 01:16:09 downsj Exp $ */ /* $NetBSD: machdep.c,v 1.80 1997/02/02 07:58:49 thorpej Exp $ */ /* @@ -152,6 +152,9 @@ extern short exframesize[]; #ifdef COMPAT_HPUX extern struct emul emul_hpux; #endif +#ifdef COMPAT_SUNOS +extern struct emul emul_sunos; +#endif /* prototypes for local functions */ caddr_t allocsys __P((caddr_t)); @@ -467,6 +470,17 @@ setregs(p, pack, stack, retval) p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0; m68881_restore(&p->p_addr->u_pcb.pcb_fpregs); #endif +#ifdef COMPAT_SUNOS + /* + * SunOS' ld.so does self-modifying code without knowing + * about the 040's cache purging needs. So we need to uncache + * writeable executable pages. + */ + if (p->p_emul == &emul_sunos) + p->p_md.md_flags |= MDP_UNCACHE_WX; + else + p->p_md.md_flags &= ~MDP_UNCACHE_WX; +#endif #ifdef COMPAT_HPUX p->p_md.md_flags &= ~MDP_HPUXMMAP; if (p->p_emul == &emul_hpux) { @@ -1697,11 +1711,15 @@ cpu_exec_aout_makecmds(p, epp) struct proc *p; struct exec_package *epp; { -#if defined(COMPAT_NOMID) || defined(COMPAT_44) +#if defined(COMPAT_NOMID) || defined(COMPAT_44) || defined(COMPAT_SUNOS) u_long midmag, magic; u_short mid; int error; struct exec *execp = epp->ep_hdr; +#ifdef COMPAT_SUNOS + extern sunos_exec_aout_makecmds + __P((struct proc *, struct exec_package *)); +#endif midmag = ntohl(execp->a_midmag); mid = (midmag >> 16) & 0xffff; @@ -1721,7 +1739,12 @@ cpu_exec_aout_makecmds(p, epp) break; #endif default: +#ifdef COMPAT_SUNOS + /* Hand it over to the SunOS emulation package. */ + error = sunos_exec_aout_makecmds(p, epp); +#else error = ENOEXEC; +#endif } return error; diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c index 2d604f4993c..dbf0777361e 100644 --- a/sys/arch/hp300/hp300/pmap.c +++ b/sys/arch/hp300/hp300/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.4 1997/02/10 11:13:32 downsj Exp $ */ +/* $OpenBSD: pmap.c,v 1.5 1997/02/24 01:16:09 downsj Exp $ */ /* $NetBSD: pmap.c,v 1.28 1997/02/02 08:01:32 thorpej Exp $ */ /* @@ -1376,6 +1376,15 @@ validate: npte = pa | pte_prot(pmap, prot) | (*pte & (PG_M|PG_U)) | PG_V; if (wired) npte |= PG_W; + +#if defined(M68040) + /* 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 + if (!checkpv && !cacheable) npte |= PG_CI; #if defined(M68040) diff --git a/sys/arch/hp300/include/proc.h b/sys/arch/hp300/include/proc.h index ce6790006e0..11c46e2f627 100644 --- a/sys/arch/hp300/include/proc.h +++ b/sys/arch/hp300/include/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.2 1997/01/12 15:13:40 downsj Exp $ */ +/* $OpenBSD: proc.h,v 1.3 1997/02/24 01:16:11 downsj Exp $ */ /* $NetBSD: proc.h,v 1.6 1994/10/26 07:26:35 cgd Exp $ */ /* @@ -45,7 +45,11 @@ struct mdproc { }; /* md_flags */ +#define MDP_STACKADJ 0x0002 /* frame SP adjusted; undo when syscall does ERE +START */ #define MDP_HPUXTRACE 0x0004 /* being traced by HP-UX process */ #define MDP_HPUXMMAP 0x0008 /* VA space is multiply mapped */ #define MDP_CCBDATA 0x0010 /* copyback caching of data (68040) */ #define MDP_CCBSTACK 0x0020 /* copyback caching of stack (68040) */ +#define MDP_UNCACHE_WX 0x0040 /* The process might modify code, so + don't cache writeable executable pages. */