Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Initial pass at setting up the compat_60 module.



details:   https://anonhg.NetBSD.org/src/rev/cf7a497f7250
branches:  pgoyette-compat
changeset: 321043:cf7a497f7250
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Mar 16 01:16:29 2018 +0000

description:
Initial pass at setting up the compat_60 module.

XXX needs some work to properly handle cpu_ucode stuff.

While here, move details of compat_70 init/fini routines into the
module itself.

diffstat:

 sys/compat/common/compat_60_mod.c |  32 ++++++++++++++++++++++++++++++--
 sys/compat/common/compat_70_mod.c |  24 ++++++++++++++++++------
 sys/compat/common/compat_mod.c    |  19 ++++++++++---------
 sys/compat/common/compat_mod.h    |   8 +++++++-
 sys/compat/common/kern_sa_60.c    |  22 +++++++++++++++++++++-
 sys/kern/kern_cpu.c               |  27 +++++++++++++++++++--------
 sys/kern/systrace_args.c          |   2 +-
 7 files changed, 106 insertions(+), 28 deletions(-)

diffs (truncated from 312 to 300 lines):

diff -r 1afc28ce254d -r cf7a497f7250 sys/compat/common/compat_60_mod.c
--- a/sys/compat/common/compat_60_mod.c Fri Mar 16 00:38:17 2018 +0000
+++ b/sys/compat/common/compat_60_mod.c Fri Mar 16 01:16:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_60_mod.c,v 1.1.2.1 2018/03/15 23:23:36 pgoyette Exp $   */
+/*     $NetBSD: compat_60_mod.c,v 1.1.2.2 2018/03/16 01:16:29 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_60_mod.c,v 1.1.2.1 2018/03/15 23:23:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_60_mod.c,v 1.1.2.2 2018/03/16 01:16:29 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -51,21 +51,49 @@
 #include <compat/common/compat_util.h>
 #include <compat/common/compat_mod.h>
 
+static const struct syscall_package compat_60_syscalls[] = {
+       { SYS_compat_60_lwp_park, 0, (sy_call_t *)compat_60_sys__lwp_park },
+       { NULL, 0, NULL }
+};
+
 #define REQUIRED_60 "compat_70"                /* XXX No compat_80 yet */
 MODULE(MODULE_CLASS_EXEC, compat_60, REQUIRED_60);
 
+#ifdef CPU_UCODE
+int (*orig_compat_6_cpu_ucode)(struct compat6_cpu_ucode *);
+int (*orig_compat6_cpu_ucode_apply)(const struct compat6_cpu_ucode *);
+#endif
+
 static int
 compat_60_modcmd(modcmd_t cmd, void *arg)
 {
+       int error;
 
        switch (cmd) {
        case MODULE_CMD_INIT:
+               error = syscall_establish(NULL, compat_60_syscalls);
+               if (error != 0)
+                       return error;
+#ifdef CPU_UCODE
+               orig_get_version = vec_compat6_cpu_ucode_get_version;
+               *vec_compat6_cpu_ucode_get_version =
+                   compat6_cpu_ucode_get_version;
+               orig_apply = vec_compat6_cpu_ucode_apply;
+               *vec_compat6_cpu_ucode_apply = compat6_cpu_ucode_apply;
+#endif
                return 0;
 
        case MODULE_CMD_FINI:
+               *vec_compat6_cpu_ucode_get_version = orig_get_version;
+               *vec_compat6_cpu_ucode_apply = orig_apply;
+               error = syscall_disestablish(NULL, compat_60_syscalls);
+               if (error != 0)
+                       return error;
                return 0;
 
        default:
                return ENOTTY;
        }
 }
+
+
diff -r 1afc28ce254d -r cf7a497f7250 sys/compat/common/compat_70_mod.c
--- a/sys/compat/common/compat_70_mod.c Fri Mar 16 00:38:17 2018 +0000
+++ b/sys/compat/common/compat_70_mod.c Fri Mar 16 01:16:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_70_mod.c,v 1.1.2.2 2018/03/15 23:14:21 pgoyette Exp $   */
+/*     $NetBSD: compat_70_mod.c,v 1.1.2.3 2018/03/16 01:16:29 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.2 2018/03/15 23:14:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.3 2018/03/16 01:16:29 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -56,19 +56,31 @@
 
 MODULE(MODULE_CLASS_EXEC, compat_70, NULL);    /* XXX No compat_80 yet */
 
+void compat_70_init(void)
+{
+
+       vec_ocreds_valid = true;
+       rtsock_70_init();
+}
+
+void compat_70_fini(void)
+{
+
+       rtsock_70_fini();
+       vec_ocreds_valid = false;
+}
+
 static int
 compat_70_modcmd(modcmd_t cmd, void *arg)
 {
 
        switch (cmd) {
        case MODULE_CMD_INIT:
-               vec_ocreds_valid = true;
-               rtsock_70_init();
+               compat_70_init();
                return 0;
 
        case MODULE_CMD_FINI:
-               rtsock_70_fini();
-               vec_ocreds_valid = false;
+               compat_70_fini();
                return 0;
 
        default:
diff -r 1afc28ce254d -r cf7a497f7250 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c    Fri Mar 16 00:38:17 2018 +0000
+++ b/sys/compat/common/compat_mod.c    Fri Mar 16 01:16:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.c,v 1.24.14.11 2018/03/15 23:34:53 pgoyette Exp $   */
+/*     $NetBSD: compat_mod.c,v 1.24.14.12 2018/03/16 01:16:29 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.11 2018/03/15 23:34:53 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.12 2018/03/16 01:16:29 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -236,9 +236,6 @@
        { SYS_compat_50_aio_suspend, 0, (sy_call_t *)compat_50_sys_aio_suspend },
        { SYS_compat_50_quotactl, 0, (sy_call_t *)compat_50_sys_quotactl },
 #endif
-#if defined(COMPAT_60)
-       { SYS_compat_60__lwp_park, 0, (sy_call_t *)compat_60_sys__lwp_park },
-#endif
        { 0, 0, NULL },
 };
 
@@ -287,16 +284,20 @@
                uvm_50_init();
                if_50_init();
 #endif
+#ifdef COMPAT_60
+               compat_60_init();
+#endif
 #ifdef COMPAT_70
-               vec_ocreds_valid = true;
-               rtsock_70_init();
+               compat_70_init();
 #endif
                return 0;
 
        case MODULE_CMD_FINI:
 #ifdef COMPAT_70
-               rtsock_70_fini();
-               vec_ocreds_valid = false;
+               compat_70_fini();
+#endif
+#ifdef COMPAT_60
+               compat_60_fini();
 #endif
 #ifdef COMPAT_10
                vfs_syscalls_10_fini();
diff -r 1afc28ce254d -r cf7a497f7250 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Fri Mar 16 00:38:17 2018 +0000
+++ b/sys/compat/common/compat_mod.h    Fri Mar 16 01:16:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.h,v 1.1 2013/02/21 01:39:54 pgoyette Exp $  */
+/*     $NetBSD: compat_mod.h,v 1.1.42.1 2018/03/16 01:16:29 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,4 +38,10 @@
 void compat_sysctl_time(struct sysctllog **);
 void compat_sysctl_vfs(struct sysctllog **);
 
+void compat_70_init(void);
+void compat_70_fini(void);
+
+void compat_60_init(void);
+void compat_60_fini(void);
+
 #endif /* !_COMPAT_MOD_H_ */
diff -r 1afc28ce254d -r cf7a497f7250 sys/compat/common/kern_sa_60.c
--- a/sys/compat/common/kern_sa_60.c    Fri Mar 16 00:38:17 2018 +0000
+++ b/sys/compat/common/kern_sa_60.c    Fri Mar 16 01:16:29 2018 +0000
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: kern_sa_60.c,v 1.1 2012/02/19 17:40:46 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: kern_sa_60.c,v 1.1.42.1 2018/03/16 01:16:29 pgoyette Exp $");
 
 #include <sys/systm.h>
 #include <sys/syscall.h>
@@ -82,3 +82,23 @@
 {
        return sys_nosys(l, uap, retval);
 }
+
+static const struct syscall_package compat__60_syscalls[] = {
+       { SYS_compat_60_sa_register, 0,
+           (sy_call_t *)compat_60_sys_sa_register },
+       { SYS_compat_60_sa_stacks, 0, (sy_call_t *)compat_60_sys_sa_stacks },
+       { SYS_compat_60_sa_enable, 0, (sy_call_t *)compat_60_sys_sa_enable },
+       { SYS_compat_60_sa_setconcurrency, 0,
+           (sy_call_t *)compat_60_sys_sa_setconcurrency },
+       { SYS_compat_60_sa_yield, 0, (sy_call_t *)compat_60_sys_sa_yield },
+       { SYS_compat_60_sa_preempt, 0, (sy_call_t *)compat_60_sys_sa_preempt },
+       { SYS_compat_60_lwp_park, 0, (sy_call_t *)
+
+
+62      COMPAT_43 MODULAR compat        \
+                { int|sys||fstat(int fd, struct stat43 *sb); } fstat43
+
+       { SYS_compat_43_fstat43, 0, (sy_call_t *)compat_43_sys_fstat },
+
+
+
diff -r 1afc28ce254d -r cf7a497f7250 sys/kern/kern_cpu.c
--- a/sys/kern/kern_cpu.c       Fri Mar 16 00:38:17 2018 +0000
+++ b/sys/kern/kern_cpu.c       Fri Mar 16 01:16:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_cpu.c,v 1.71 2015/08/29 12:24:00 maxv Exp $       */
+/*     $NetBSD: kern_cpu.c,v 1.71.16.1 2018/03/16 01:16:29 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.71 2015/08/29 12:24:00 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.71.16.1 2018/03/16 01:16:29 pgoyette Exp $");
 
 #include "opt_cpu_ucode.h"
 #include "opt_compat_netbsd.h"
@@ -132,6 +132,19 @@
 static char cpu_model[128];
 
 /*
+ * routine vectors for compat code
+ */
+static int stub_compat_6_cpu_ucode(const struct compat6_cpu_ucode *ucode)
+{
+
+       return ENOTTY;
+}
+int (*vec_compat6_cpu_ucode_get_version)(struct compat6_cpu_ucode *) =
+    stub_compat_6_cpu_ucode;
+int (*vec_compat6_cpu_ucode_apply(const struct compat6_cpu_ucode *) =
+    stub_compat_6_cpu_ucode;
+
+/*
  * mi_cpu_init: early initialisation of MI CPU related structures.
  *
  * Note: may not block and memory allocator is not yet available.
@@ -285,11 +298,10 @@
                error = cpu_ucode_get_version((struct cpu_ucode_version *)data);
                break;
 
-#ifdef COMPAT_60
        case OIOC_CPU_UCODE_GET_VERSION:
-               error = compat6_cpu_ucode_get_version((struct compat6_cpu_ucode *)data);
+               error = (*vec_compat6_cpu_ucode_get_version)(
+                   (struct compat6_cpu_ucode *)data);
                break;
-#endif
 
        case IOC_CPU_UCODE_APPLY:
                error = kauth_authorize_machdep(l->l_cred,
@@ -300,17 +312,16 @@
                error = cpu_ucode_apply((const struct cpu_ucode *)data);
                break;
 
-#ifdef COMPAT_60
        case OIOC_CPU_UCODE_APPLY:
                error = kauth_authorize_machdep(l->l_cred,
                    KAUTH_MACHDEP_CPU_UCODE_APPLY,
                    NULL, NULL, NULL, NULL);
                if (error != 0)
                        break;
-               error = compat6_cpu_ucode_apply((const struct compat6_cpu_ucode *)data);
+               error = (*vec_compat6_cpu_ucode_apply(
+                   (const struct compat6_cpu_ucode *)data);
                break;
 #endif
-#endif



Home | Main Index | Thread Index | Old Index