summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-30 18:40:27 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-30 18:40:27 +0000
commitda563911f75aa7905fc1ea4103641b1b20c67cf0 (patch)
tree542ad1afeec92bcabcfbe5dab25751ba32bbcfb3 /sys
parent9522e056233b2d58cfd2b4ce269b40b17ef856f0 (diff)
integrate 040 MDP_UNCACHE_WX cache changes by niklas & deraadt
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mac68k/include/proc.h2
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c17
-rw-r--r--sys/arch/mac68k/mac68k/pmap.c7
3 files changed, 26 insertions, 0 deletions
diff --git a/sys/arch/mac68k/include/proc.h b/sys/arch/mac68k/include/proc.h
index c343f3a496c..7707df4d577 100644
--- a/sys/arch/mac68k/include/proc.h
+++ b/sys/arch/mac68k/include/proc.h
@@ -48,3 +48,5 @@ 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. */
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index 20f1b8ec68c..d410a95d648 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -123,6 +123,11 @@
#include <dev/cons.h>
+#ifdef COMPAT_SUNOS
+#include <compat/sunos/sunos_syscall.h>
+extern struct emul emul_sunos;
+#endif
+
#include "via.h"
#include "macrom.h"
#include "ether.h"
@@ -478,6 +483,18 @@ setregs(p, pack, sp, retval)
if (fpu_type) {
m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
}
+
+#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
}
#define SS_RTEFRAME 1
diff --git a/sys/arch/mac68k/mac68k/pmap.c b/sys/arch/mac68k/mac68k/pmap.c
index 8d504e68e82..d9f3b1cc551 100644
--- a/sys/arch/mac68k/mac68k/pmap.c
+++ b/sys/arch/mac68k/mac68k/pmap.c
@@ -1381,6 +1381,13 @@ validate:
npte = pa | pte_prot(pmap, prot) | (*pte & (PG_M|PG_U)) | PG_V;
if (wired)
npte |= PG_W;
+
+ /* 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;
+
if (!checkpv && !cacheable)
npte |= PG_CI;
#if defined(M68040)