Module Name: src
Committed By: mlelstv
Date: Sat Nov 12 16:06:04 UTC 2016
Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.c netbsd32_ioctl.h
Log Message:
Fix netbsd32 emulation for clockctl_ntp_adjtime.
The ioctl args reference a timex structure that needs to be
transformed to 64bit layout and back.
The 32bit ioctl definition was wrong for mips, as register_t is 64bit
for N32 abi.
To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/compat/netbsd32/netbsd32_ioctl.c
cvs rdiff -u -r1.54 -r1.55 src/sys/compat/netbsd32/netbsd32_ioctl.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.84 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.85
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.84 Wed Jul 13 11:11:53 2016
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c Sat Nov 12 16:06:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill Exp $ */
+/* $NetBSD: netbsd32_ioctl.c,v 1.85 2016/11/12 16:06:04 mlelstv Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.84 2016/07/13 11:11:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.85 2016/11/12 16:06:04 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioc
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_ioctl.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
+#include <compat/netbsd32/netbsd32_conv.h>
#include <dev/vndvar.h>
@@ -921,6 +922,29 @@ netbsd32_from_devrescanargs(
NETBSD32PTR32(s32p->locators, p->locators);
}
+static int
+netbsd32_do_clockctl_ntp_adjtime(struct clockctl_ntp_adjtime *args)
+{
+
+ struct netbsd32_timex ntv32;
+ struct timex ntv;
+ int error;
+
+ error = copyin(args->tp, &ntv32, sizeof(ntv32));
+ if (error)
+ return (error);
+
+ netbsd32_to_timex(&ntv32, &ntv);
+ ntp_adjtime1(&ntv);
+ netbsd32_from_timex(&ntv, &ntv32);
+
+ error = copyout(&ntv32, args->tp, sizeof(ntv));
+ if (error == 0)
+ args->retval = ntp_timestatus();
+
+ return error;
+}
+
/*
* main ioctl syscall.
*
@@ -1291,8 +1315,26 @@ netbsd32_ioctl(struct lwp *l, const stru
IOCTL_STRUCT_CONV_TO(CLOCKCTL_CLOCK_SETTIME,
clockctl_clock_settime);
case CLOCKCTL_NTP_ADJTIME32:
- IOCTL_STRUCT_CONV_TO(CLOCKCTL_NTP_ADJTIME,
- clockctl_ntp_adjtime);
+ {
+ size = IOCPARM_LEN(CLOCKCTL_NTP_ADJTIME);
+ if (size > sizeof(stkbuf))
+ data = memp = kmem_alloc(size, KM_SLEEP);
+ else
+ data = (void *)stkbuf;
+
+ netbsd32_to_clockctl_ntp_adjtime(
+ (const struct netbsd32_clockctl_ntp_adjtime *)data32,
+ (struct clockctl_ntp_adjtime *)data,
+ CLOCKCTL_NTP_ADJTIME);
+ error = netbsd32_do_clockctl_ntp_adjtime(
+ (struct clockctl_ntp_adjtime *)data);
+ netbsd32_from_clockctl_ntp_adjtime(
+ (const struct clockctl_ntp_adjtime *)data,
+ (struct netbsd32_clockctl_ntp_adjtime *)data32,
+ CLOCKCTL_NTP_ADJTIME);
+
+ break;
+ }
case KIOCGSYMBOL32:
IOCTL_STRUCT_CONV_TO(KIOCGSYMBOL, ksyms_gsymbol);
Index: src/sys/compat/netbsd32/netbsd32_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.54 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.55
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.54 Wed Jul 13 11:11:53 2016
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h Sat Nov 12 16:06:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_ioctl.h,v 1.54 2016/07/13 11:11:53 jmcneill Exp $ */
+/* $NetBSD: netbsd32_ioctl.h,v 1.55 2016/11/12 16:06:04 mlelstv Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -552,7 +552,7 @@ struct netbsd32_clockctl_clock_settime {
struct netbsd32_clockctl_ntp_adjtime {
netbsd32_timexp_t tp;
- /* register_t */ int32_t retval;
+ register32_t retval;
};
#define CLOCKCTL_NTP_ADJTIME32 _IOWR('C', 0x8, \