Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-compat]: src/sys Use a hook callback to allow sparc fpu code to...



details:   https://anonhg.NetBSD.org/src/rev/80940a45724e
branches:  pgoyette-compat
changeset: 830850:80940a45724e
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Oct 02 01:43:53 2018 +0000

description:
Use a hook callback to allow sparc fpu code to determine if a process
is running under sunos emulation (in which case, fpu cleanup uses a
different set of fpu_codes[]).

diffstat:

 sys/arch/aarch64/aarch64/netbsd32_machdep.c |   4 ++--
 sys/arch/aarch64/conf/files.aarch64         |   6 +++---
 sys/arch/sparc/fpu/fpu.c                    |  27 +++++++++++++++++----------
 sys/compat/sunos/sunos_mod.c                |  18 ++++++++++++++++--
 sys/compat/sunos32/sunos32_mod.c            |  22 ++++++++++++++++++----
 sys/kern/compat_stub.c                      |   8 +++++++-
 sys/sys/compat_stub.h                       |   9 ++++++++-
 7 files changed, 71 insertions(+), 23 deletions(-)

diffs (256 lines):

diff -r 7a9a49828280 -r 80940a45724e sys/arch/aarch64/aarch64/netbsd32_machdep.c
--- a/sys/arch/aarch64/aarch64/netbsd32_machdep.c       Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/arch/aarch64/aarch64/netbsd32_machdep.c       Tue Oct 02 01:43:53 2018 +0000
@@ -29,9 +29,9 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep.c,v 1.1.2.3 2018/10/01 21:19:16 pgoyette Exp $");
+__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep.c,v 1.1.2.4 2018/10/02 01:43:53 pgoyette Exp $");
 
-#if defined(_KERNEL_OPT
+#if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
diff -r 7a9a49828280 -r 80940a45724e sys/arch/aarch64/conf/files.aarch64
--- a/sys/arch/aarch64/conf/files.aarch64       Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/arch/aarch64/conf/files.aarch64       Tue Oct 02 01:43:53 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.aarch64,v 1.2.2.2 2018/09/30 01:45:35 pgoyette Exp $
+#      $NetBSD: files.aarch64,v 1.2.2.3 2018/10/02 01:43:53 pgoyette Exp $
 
 defflag opt_cpuoptions.h       AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h       AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -118,8 +118,8 @@
 file   arch/aarch64/aarch64/netbsd32_machdep.c         compat_netbsd32
 #file  arch/aarch64/aarch32/aarch32_oabi_machdep.c     compat_aarch32_oabi
 #file  arch/aarch64/aarch32/aarch32_eabi_machdep.c     compat_aarch32_eabi
-#file  arch/aarch64/aarch32/compat_13_machdep.c        compat_13 & compat_netbsd32
-#file  arch/aarch64/aarch32/compat_16_machdep.c        compat_16 & compat_netbsd32
+file   arch/aarch64/aarch32/netbsd32_machdep_13.c      compat_13 & compat_netbsd32
+file   arch/aarch64/aarch32/netbsd32_machdep_16.c      compat_16 & compat_netbsd32
 
 # Linux binary compatibility (COMPAT_LINUX)
 #include "compat/ossaudio/files.ossaudio"
diff -r 7a9a49828280 -r 80940a45724e sys/arch/sparc/fpu/fpu.c
--- a/sys/arch/sparc/fpu/fpu.c  Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/arch/sparc/fpu/fpu.c  Tue Oct 02 01:43:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.27 2012/02/12 16:34:10 matt Exp $ */
+/*     $NetBSD: fpu.c,v 1.27.46.1 2018/10/02 01:43:53 pgoyette Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.27 2012/02/12 16:34:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.27.46.1 2018/10/02 01:43:53 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -49,6 +49,7 @@
 #include <sys/systm.h>
 #include <sys/syslog.h>
 #include <sys/signalvar.h>
+#include <sys/compat_stub.h>
 
 #include <machine/instr.h>
 #include <machine/reg.h>
@@ -108,7 +109,6 @@
        X8(FPE_FLTOVF),
        X16(FPE_FLTINV)
 };
-#if defined(COMPAT_SUNOS)
 static u_char fpu_codes_sunos[] = {
        X1(FPE_FLTINEX_TRAP),
        X2(FPE_FLTDIV_TRAP),
@@ -116,11 +116,17 @@
        X8(FPE_FLTOVF_TRAP),
        X16(FPE_FLTOPERR_TRAP)
 };
-extern struct emul emul_sunos;
-#endif /* SUNOS_COMPAT */
+
 /* Note: SVR4(Solaris) FPE_* codes happen to be compatible with ours */
 
 /*
+ * HOOK for checking if the lwp's emul matches sunos
+ */
+MODULE_CALL_HOOK_DECL(get_emul_sunos_hook, f, (const struct emul **emul));
+MODULE_CALL_HOOK(get_emul_sunos_hook, f, (const struct emul ** emul), (emul),
+    enosys());
+
+/*
  * The FPU gave us an exception.  Clean up the mess.  Note that the
  * fp queue can only have FPops in it, never load/store FP registers
  * nor FBfcc instructions.  Experiments with `crashme' prove that
@@ -142,12 +148,13 @@
        struct fpemu fe;
        u_char *fpu_codes;
        int code = 0;
+       const struct emul *sunos_emul;
 
-       fpu_codes =
-#ifdef COMPAT_SUNOS
-               (p->p_emul == &emul_sunos) ? fpu_codes_sunos :
-#endif
-               fpu_codes_native;
+       if (get_emul_sunos_hook_f_call(&sunos_emul) == 0 &&
+           p->p_emul == sunos_emul)
+               fpu_codes = fpu_codes_sunos;
+       else
+               fpu_codes = fpu_codes_native;
 
        switch ((fsr >> FSR_FTT_SHIFT) & FSR_FTT_MASK) {
 
diff -r 7a9a49828280 -r 80940a45724e sys/compat/sunos/sunos_mod.c
--- a/sys/compat/sunos/sunos_mod.c      Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/compat/sunos/sunos_mod.c      Tue Oct 02 01:43:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunos_mod.c,v 1.3 2014/03/07 01:33:44 christos Exp $   */
+/*     $NetBSD: sunos_mod.c,v 1.3.28.1 2018/10/02 01:43:53 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_mod.c,v 1.3 2014/03/07 01:33:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_mod.c,v 1.3.28.1 2018/10/02 01:43:53 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/module.h>
 #include <sys/exec.h>
 #include <sys/exec_aout.h>
 #include <sys/signalvar.h>
+#include <sys/compat_stub.h>
 
 #include <machine/sunos_machdep.h>
 
@@ -60,14 +61,27 @@
 };
 
 static int
+get_sunos_emul(const struct emul **e)
+{
+
+       *e = &emul_sunos;
+       return 0;
+}
+
+MODULE_SET_HOOK(get_emul_sunos_hook, "sun_emul", get_sunos_emul);
+MODULE_UNSET_HOOK(get_emul_sunos_hook);
+
+static int
 compat_sunos_modcmd(modcmd_t cmd, void *arg)
 {
 
        switch (cmd) {
        case MODULE_CMD_INIT:
+               get_emul_sunos_hook_set();
                return exec_add(&sunos_execsw, 1);
 
        case MODULE_CMD_FINI:
+               get_emul_sunos_hook_unset();
                return exec_remove(&sunos_execsw, 1);
 
        default:
diff -r 7a9a49828280 -r 80940a45724e sys/compat/sunos32/sunos32_mod.c
--- a/sys/compat/sunos32/sunos32_mod.c  Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/compat/sunos32/sunos32_mod.c  Tue Oct 02 01:43:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunos32_mod.c,v 1.3 2014/03/07 01:33:44 christos Exp $ */
+/*     $NetBSD: sunos32_mod.c,v 1.3.28.1 2018/10/02 01:43:53 pgoyette Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos32_mod.c,v 1.3 2014/03/07 01:33:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos32_mod.c,v 1.3.28.1 2018/10/02 01:43:53 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/module.h>
 #include <sys/exec.h>
 #include <sys/exec_aout.h>
 #include <sys/signalvar.h>
+#include <sys/compat_stub.h>
 
 #include <machine/sunos_machdep.h>
 
@@ -62,14 +63,27 @@
 };
 
 static int
+get_sunos_emul(const struct emul **e)
+{
+ 
+       *e = &emul_sunos;
+       return 0;
+}
+ 
+MODULE_SET_HOOK(get_emul_sunos_hook, "sun_emul", get_sunos_emul);
+MODULE_UNSET_HOOK(get_emul_sunos_hook);
+  
+static int
 compat_sunos_modcmd(modcmd_t cmd, void *arg)
 {
-
+ 
        switch (cmd) {
        case MODULE_CMD_INIT:
+               get_emul_sunos_hook_set();
                return exec_add(&sunos_execsw, 1);
-
+ 
        case MODULE_CMD_FINI:
+               get_emul_sunos_hook_unset();
                return exec_remove(&sunos_execsw, 1);
 
        default:
diff -r 7a9a49828280 -r 80940a45724e sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/kern/compat_stub.c    Tue Oct 02 01:43:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.25 2018/09/25 21:41:30 pgoyette Exp $        */
+/* $NetBSD: compat_stub.c,v 1.1.2.26 2018/10/02 01:43:53 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -170,3 +170,9 @@
  * hook for kern_proc_32
  */
 struct kern_proc_32_hook_t kern_proc_32_hook;
+
+/*
+ * Hook for sparc fpu code to check if a process is running 
+ * under sunos emulation
+ */
+struct get_emul_sunos_hook_t get_emul_sunos_hook;
diff -r 7a9a49828280 -r 80940a45724e sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h     Tue Oct 02 00:00:09 2018 +0000
+++ b/sys/sys/compat_stub.h     Tue Oct 02 01:43:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.37 2018/09/25 21:41:30 pgoyette Exp $        */
+/* $NetBSD: compat_stub.h,v 1.1.2.38 2018/10/02 01:43:53 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -218,4 +218,11 @@
 MODULE_HOOK2(kern_proc_32_hook, (struct proc *, struct ps_strings *),
     (char **, size_t, vaddr_t *));
 
+/*
+ * Hook to allow sparc fpu code to see if a process is using sunos
+ * emulation, and select proper fup codes
+ */
+struct emul;
+MODULE_HOOK(get_emul_sunos_hook, (const struct emul **));
+
 #endif /* _SYS_COMPAT_STUB_H */



Home | Main Index | Thread Index | Old Index