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 MP-safe hook for the rnd_ioctl compat_50...
details: https://anonhg.NetBSD.org/src/rev/32ab17c91b1a
branches: pgoyette-compat
changeset: 830865:32ab17c91b1a
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Fri Oct 12 22:30:54 2018 +0000
description:
Use a MP-safe hook for the rnd_ioctl compat_50 calls.
diffstat:
sys/compat/common/compat_50_mod.c | 7 +++++--
sys/compat/common/compat_mod.h | 4 +++-
sys/compat/common/rndpseudo_50.c | 25 +++++++++++++++++++++++--
sys/compat/netbsd32/netbsd32_compat_50.c | 18 ++++++++++--------
sys/kern/compat_stub.c | 8 +++++++-
sys/kern/kern_rndq.c | 23 ++++++++++++++---------
sys/sys/compat_stub.h | 8 +++++++-
7 files changed, 69 insertions(+), 24 deletions(-)
diffs (277 lines):
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/compat/common/compat_50_mod.c
--- a/sys/compat/common/compat_50_mod.c Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/compat/common/compat_50_mod.c Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_50_mod.c,v 1.1.2.16 2018/09/23 04:31:17 pgoyette Exp $ */
+/* $NetBSD: compat_50_mod.c,v 1.1.2.17 2018/10/12 22:30:54 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.16 2018/09/23 04:31:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.17 2018/10/12 22:30:54 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -85,6 +85,7 @@
puffs_50_init();
wsevent_50_init();
vnd_50_init();
+ rndpseudo_50_init();
return error;
@@ -105,6 +106,7 @@
{
int error = 0;
+ rndpseudo_50_fini();
vnd_50_fini();
wsevent_50_fini();
puffs_50_fini();
@@ -146,6 +148,7 @@
puffs_50_init();
wsevent_50_init();
vnd_50_init();
+ rndpseudo_50_init();
return error;
}
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/compat/common/compat_mod.h Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.h,v 1.1.42.22 2018/09/19 04:12:43 pgoyette Exp $ */
+/* $NetBSD: compat_mod.h,v 1.1.42.23 2018/10/12 22:30:54 pgoyette Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -72,6 +72,8 @@
void uipc_syscalls_50_fini(void);
void vnd_50_init(void);
void vnd_50_fini(void);
+void rndpseudo_50_init(void);
+void rndpseudo_50_fini(void);
#endif
#ifdef COMPAT_40
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/compat/common/rndpseudo_50.c
--- a/sys/compat/common/rndpseudo_50.c Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/compat/common/rndpseudo_50.c Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $ */
+/* $nETbsD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rndpseudo_50.c,v 1.2.38.2 2018/10/12 22:30:54 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -40,7 +40,11 @@
#include <sys/file.h>
#include <sys/rnd.h>
+#include <sys/module_hook.h>
+#include <sys/compat_stub.h>
+
#include <compat/sys/rnd.h>
+#include <compat/common/compat_mod.h>
/*
* Convert from rndsource_t to rndsource50_t, for the results from
@@ -116,3 +120,20 @@
return ret;
}
+
+MODULE_SET_HOOK(rnd_ioctl_50_hook, "rnd_50", compat_50_rnd_ioctl);
+MODULE_UNSET_HOOK(rnd_ioctl_50_hook);
+
+void
+rndpseudo_50_init(void)
+{
+
+ rnd_ioctl_50_hook_set();
+}
+
+void
+rndpseudo_50_fini(void)
+{
+
+ rnd_ioctl_50_hook_unset();
+}
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/compat/netbsd32/netbsd32_compat_50.c
--- a/sys/compat/netbsd32/netbsd32_compat_50.c Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_50.c Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_50.c,v 1.32.16.12 2018/10/03 11:59:21 pgoyette Exp $ */
+/* $NetBSD: netbsd32_compat_50.c,v 1.32.16.13 2018/10/12 22:30:54 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.32.16.12 2018/10/03 11:59:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.32.16.13 2018/10/12 22:30:54 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -69,6 +69,7 @@
#include <sys/vfs_syscalls.h>
#include <sys/rnd.h>
#include <sys/compat_stub.h>
+#include <sys/module_hook.h>
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_syscall.h>
@@ -1030,6 +1031,9 @@
{ 0, 0, NULL }
};
+MODULE_SET_HOOK(rnd_ioctl_50_32_hook, "rnd32_50", compat32_50_rnd_ioctl);
+MODULE_UNSET_HOOK(rnd_ioctl_50_32_hook);
+
MODULE(MODULE_CLASS_EXEC, compat_netbsd32_50, "compat_netbsd32_60,compat_50");
static int
@@ -1039,19 +1043,17 @@
switch (cmd) {
case MODULE_CMD_INIT:
- vec_compat32_50_rnd_ioctl = compat32_50_rnd_ioctl;
ret = syscall_establish(&emul_netbsd32,
compat_netbsd32_50_syscalls);
- if (ret)
- vec_compat32_50_rnd_ioctl = (void *)enosys;
+ if (ret == 0)
+ rnd_ioctl_50_32_hook_set();
return ret;
case MODULE_CMD_FINI:
- vec_compat32_50_rnd_ioctl = (void *)enosys;
ret = syscall_disestablish(&emul_netbsd32,
compat_netbsd32_50_syscalls);
- if (ret)
- vec_compat32_50_rnd_ioctl = compat32_50_rnd_ioctl;
+ if (ret == 0)
+ rnd_ioctl_50_32_hook_unset();
return ret;
default:
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/kern/compat_stub.c Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.26 2018/10/02 01:43:53 pgoyette Exp $ */
+/* $NetBSD: compat_stub.c,v 1.1.2.27 2018/10/12 22:30:54 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -176,3 +176,9 @@
* under sunos emulation
*/
struct get_emul_sunos_hook_t get_emul_sunos_hook;
+
+/*
+ * Hook for rnd_ioctl_50 callbacks
+ */
+struct rnd_ioctl_50_hook_t rnd_ioctl_50_hook;
+struct rnd_ioctl_50_32_hook_t rnd_ioctl_50_32_hook;
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/kern/kern_rndq.c Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rndq.c,v 1.89.16.3 2018/09/23 07:44:13 pgoyette Exp $ */
+/* $NetBSD: kern_rndq.c,v 1.89.16.4 2018/10/12 22:30:54 pgoyette Exp $ */
/*-
* Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.89.16.3 2018/09/23 07:44:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.89.16.4 2018/10/12 22:30:54 pgoyette Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -53,6 +53,8 @@
#include <sys/rngtest.h>
#include <sys/file.h>
#include <sys/systm.h>
+#include <sys/module_hook.h>
+#include <sys/compat_stub.h>
#include <dev/rnd_private.h>
@@ -173,11 +175,6 @@
static rndsave_t *boot_rsp;
-int (*vec_compat_50_rnd_ioctl)(struct file *, u_long, void *) =
- (void *)enosys;
-int (*vec_compat32_50_rnd_ioctl)(struct file *, u_long, void *) =
- (void *)enosys;
-
static inline void
rnd_printf(const char *fmt, ...)
{
@@ -1449,6 +1446,14 @@
}
}
+MODULE_CALL_HOOK_DECL(rnd_ioctl_50_hook, f, (struct file *, u_long, void *));
+MODULE_CALL_HOOK_DECL(rnd_ioctl_50_32_hook, f, (struct file *, u_long, void *));
+
+MODULE_CALL_HOOK(rnd_ioctl_50_hook, f,
+ (struct file *fp, u_long cmd, void *addr), (fp, cmd, addr), enosys());
+MODULE_CALL_HOOK(rnd_ioctl_50_32_hook, f,
+ (struct file *fp, u_long cmd, void *addr), (fp, cmd, addr), enosys());
+
int
rnd_system_ioctl(struct file *fp, u_long cmd, void *addr)
{
@@ -1495,10 +1500,10 @@
break;
default:
- ret = (*vec_compat_50_rnd_ioctl)(fp, cmd, addr);
+ ret = rnd_ioctl_50_hook_f_call(fp, cmd, addr);
#if defined(_LP64)
if (ret == ENOSYS)
- ret = (*vec_compat32_50_rnd_ioctl)(fp, cmd, addr);
+ ret = rnd_ioctl_50_32_hook_f_call(fp, cmd, addr);
#endif
if (ret == ENOSYS)
ret = ENOTTY;
diff -r 3ca49b6175ba -r 32ab17c91b1a sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h Fri Oct 12 10:28:29 2018 +0000
+++ b/sys/sys/compat_stub.h Fri Oct 12 22:30:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.38 2018/10/02 01:43:53 pgoyette Exp $ */
+/* $NetBSD: compat_stub.h,v 1.1.2.39 2018/10/12 22:30:54 pgoyette Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -225,4 +225,10 @@
struct emul;
MODULE_HOOK(get_emul_sunos_hook, (const struct emul **));
+/*
+ * Hooks for rnd_ioctl_50
+ */
+MODULE_HOOK(rnd_ioctl_50_hook, (struct file *, u_long, void *));
+MODULE_HOOK(rnd_ioctl_50_32_hook, (struct file *, u_long, void *));
+
#endif /* _SYS_COMPAT_STUB_H */
Home |
Main Index |
Thread Index |
Old Index