Port-evbmips archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Lemote Yeeloong observations
In article <jojfua$7u1$1%dough.gmane.org@localhost>,
Christos Zoulas <christos%astron.com@localhost> wrote:
>In article <20120511071141.GC28474%mail.duskware.de@localhost>,
>Martin Husemann <martin%duskware.de@localhost> wrote:
>>On Fri, May 11, 2012 at 12:52:49AM -0500, John D. Baker wrote:
>>> Searching for EINVAL revealed calls to netbsd32_ioctl() with commands
>>> "CLOCKCTL_CLOCK_SETTIME", "CLOCKCTL_SETTIMEOFDAY", and "_IOWR" as
>>> failing in this way. A few lines earlier, ioctl() calls with command
>>> "CLOCKCTL_NTP_ADJTIME" fails with EFAULT. Alignment issues?
>>
>>This seems strange, the address should be that of a global variable in ntpd,
>>and thus should be properly aligned.
>>
>>Could you instrument the code in src/sys/compat/netbsd32/netbsd32_time.c
>>and see if the EFAULT comes from the return (error); in line 155 and print
>>the pointer value?
>>
>>Something like:
>>
>> if ((error = copyin(SCARG_P32(uap, tp), &ntv32, sizeof(ntv32)))) {
>> printf("error %d pointer %p\n", error, (void*)SCARG_P32(uap,
>> tp));
>> return error;
>> }
>
>The issue is that the ioctls are not being translated.
>
Does this patch fix the problem for you?
christos
Index: netbsd32_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_ioctl.c,v
retrieving revision 1.64
diff -u -p -u -r1.64 netbsd32_ioctl.c
--- netbsd32_ioctl.c 6 Oct 2011 03:19:32 -0000 1.64
+++ netbsd32_ioctl.c 11 May 2012 17:01:26 -0000
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioc
#include <sys/kmem.h>
#include <sys/envsys.h>
#include <sys/wdog.h>
+#include <sys/clockctl.h>
#ifdef __sparc__
#include <dev/sun/fbio.h>
@@ -76,63 +77,6 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioc
#include <dev/vndvar.h>
-/* prototypes for the converters */
-static inline void netbsd32_to_partinfo(struct netbsd32_partinfo *,
- struct partinfo *, u_long);
-#if 0
-static inline void netbsd32_to_format_op(struct netbsd32_format_op *,
- struct format_op *, u_long);
-#endif
-static inline void netbsd32_to_oifreq(struct netbsd32_oifreq *, struct oifreq
*,
- u_long cmd);
-static inline void netbsd32_to_ifreq(struct netbsd32_ifreq *, struct ifreq *,
- u_long cmd);
-static inline void netbsd32_to_if_addrprefreq(
- const struct netbsd32_if_addrprefreq *, struct if_addrprefreq *, u_long);
-static inline void netbsd32_to_ifconf(struct netbsd32_ifconf *,
- struct ifconf *, u_long);
-static inline void netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *,
- struct ifmediareq *, u_long);
-static inline void netbsd32_to_ifdrv(struct netbsd32_ifdrv *, struct ifdrv *,
- u_long);
-static inline void netbsd32_to_sioc_vif_req(struct netbsd32_sioc_vif_req *,
- struct sioc_vif_req *, u_long);
-static inline void netbsd32_to_sioc_sg_req(struct netbsd32_sioc_sg_req *,
- struct sioc_sg_req *, u_long);
-static inline void netbsd32_from_partinfo(struct partinfo *,
- struct netbsd32_partinfo *, u_long);
-#if 0
-static inline void netbsd32_from_format_op(struct format_op *,
- struct netbsd32_format_op *,
- u_long);
-#endif
-static inline void netbsd32_from_if_addrprefreq(const struct if_addrprefreq *,
- struct netbsd32_if_addrprefreq *,
- u_long);
-static inline void netbsd32_from_ifreq(struct ifreq *,
- struct netbsd32_ifreq *, u_long);
-static inline void netbsd32_from_oifreq(struct oifreq *,
- struct netbsd32_oifreq *, u_long);
-static inline void netbsd32_from_ifconf(struct ifconf *,
- struct netbsd32_ifconf *, u_long);
-static inline void netbsd32_from_ifmediareq(struct ifmediareq *,
- struct netbsd32_ifmediareq *,
- u_long);
-static inline void netbsd32_from_ifdrv(struct ifdrv *,
- struct netbsd32_ifdrv *, u_long);
-static inline void netbsd32_from_sioc_vif_req(struct sioc_vif_req *,
- struct netbsd32_sioc_vif_req *,
- u_long);
-static inline void netbsd32_from_sioc_sg_req(struct sioc_sg_req *,
- struct netbsd32_sioc_sg_req *,
- u_long);
-
-/* wsdisplay stuff */
-static inline void netbsd32_to_wsdisplay_addscreendata(
- struct netbsd32_wsdisplay_addscreendata *,
- struct wsdisplay_addscreendata *,
- u_long);
-
/* convert to/from different structures */
static inline void
@@ -361,6 +305,50 @@ netbsd32_to_wsdisplay_cursor(struct netb
c->mask = NETBSD32PTR64(c32->mask);
}
+static inline void
+netbsd32_to_clockctl_settimeofday(
+ const struct netbsd32_clockctl_settimeofday *s32p,
+ struct clockctl_settimeofday *p,
+ u_long cmd)
+{
+
+ p->tv = NETBSD32PTR64(s32p->tv);
+ p->tzp = NETBSD32PTR64(s32p->tzp);
+}
+
+static inline void
+netbsd32_to_clockctl_adjtime(
+ const struct netbsd32_clockctl_adjtime *s32p,
+ struct clockctl_adjtime *p,
+ u_long cmd)
+{
+
+ p->delta = NETBSD32PTR64(s32p->delta);
+ p->olddelta = NETBSD32PTR64(s32p->olddelta);
+}
+
+static inline void
+netbsd32_to_clockctl_clock_settime(
+ const struct netbsd32_clockctl_clock_settime *s32p,
+ struct clockctl_clock_settime *p,
+ u_long cmd)
+{
+
+ p->clock_id = s32p->clock_id;
+ p->tp = NETBSD32PTR64(s32p->tp);
+}
+
+static inline void
+netbsd32_to_clockctl_ntp_adjtime(
+ const struct netbsd32_clockctl_ntp_adjtime *s32p,
+ struct clockctl_ntp_adjtime *p,
+ u_long cmd)
+{
+
+ p->tp = NETBSD32PTR64(s32p->tp);
+ p->retval = s32p->retval;
+}
+
/*
* handle ioctl conversions from 64-bit kernel -> netbsd32
*/
@@ -598,6 +586,50 @@ netbsd32_from_u_long(u_long *p, netbsd32
*s32p = (netbsd32_u_long)*p;
}
+static inline void
+netbsd32_from_clockctl_settimeofday(
+ const struct clockctl_settimeofday *p,
+ struct netbsd32_clockctl_settimeofday *s32p,
+ u_long cmd)
+{
+
+ NETBSD32PTR32(s32p->tv, p->tv);
+ NETBSD32PTR32(s32p->tzp, p->tzp);
+}
+
+static inline void
+netbsd32_from_clockctl_adjtime(
+ const struct clockctl_adjtime *p,
+ struct netbsd32_clockctl_adjtime *s32p,
+ u_long cmd)
+{
+
+ NETBSD32PTR32(s32p->delta, p->delta);
+ NETBSD32PTR32(s32p->olddelta, p->olddelta);
+}
+
+static inline void
+netbsd32_from_clockctl_clock_settime(
+ const struct clockctl_clock_settime *p,
+ struct netbsd32_clockctl_clock_settime *s32p,
+ u_long cmd)
+{
+
+ s32p->clock_id = p->clock_id;
+ NETBSD32PTR32(s32p->tp, p->tp);
+}
+
+static inline void
+netbsd32_from_clockctl_ntp_adjtime(
+ const struct clockctl_ntp_adjtime *p,
+ struct netbsd32_clockctl_ntp_adjtime *s32p,
+ u_long cmd)
+{
+
+ NETBSD32PTR32(s32p->tp, p->tp);
+ s32p->retval = p->retval;
+}
+
/*
* main ioctl syscall.
*
@@ -927,6 +959,18 @@ netbsd32_ioctl(struct lwp *l, const stru
case POWER_EVENT_RECVDICT32:
IOCTL_STRUCT_CONV_TO(POWER_EVENT_RECVDICT, plistref);
+ case CLOCKCTL_SETTIMEOFDAY32:
+ IOCTL_STRUCT_CONV_TO(CLOCKCTL_SETTIMEOFDAY,
+ clockctl_settimeofday);
+ case CLOCKCTL_ADJTIME32:
+ IOCTL_STRUCT_CONV_TO(CLOCKCTL_ADJTIME, clockctl_adjtime);
+ case CLOCKCTL_CLOCK_SETTIME32:
+ IOCTL_STRUCT_CONV_TO(CLOCKCTL_CLOCK_SETTIME,
+ clockctl_clock_settime);
+ case CLOCKCTL_NTP_ADJTIME32:
+ IOCTL_STRUCT_CONV_TO(CLOCKCTL_NTP_ADJTIME,
+ clockctl_ntp_adjtime);
+
default:
#ifdef NETBSD32_MD_IOCTL
error = netbsd32_md_ioctl(fp, com, data32, l);
Index: netbsd32_ioctl.h
===================================================================
RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_ioctl.h,v
retrieving revision 1.41
diff -u -p -u -r1.41 netbsd32_ioctl.h
--- netbsd32_ioctl.h 28 Sep 2011 01:46:39 -0000 1.41
+++ netbsd32_ioctl.h 11 May 2012 17:01:26 -0000
@@ -463,3 +463,36 @@ struct netbsd32_wdog_conf {
int wc_count;
};
#define WDOGIOC_GWDOGS32 _IOWR('w', 5, struct netbsd32_wdog_conf)
+
+
+struct netbsd32_clockctl_settimeofday {
+ netbsd32_timevalp_t tv;
+ netbsd32_voidp tzp;
+};
+
+#define CLOCKCTL_SETTIMEOFDAY32 _IOW('C', 0x5, \
+ struct netbsd32_clockctl_settimeofday)
+
+struct netbsd32_clockctl_adjtime {
+ netbsd32_timevalp_t delta;
+ netbsd32_timevalp_t olddelta;
+};
+
+#define CLOCKCTL_ADJTIME32 _IOWR('C', 0x6, struct netbsd32_clockctl_adjtime)
+
+struct netbsd32_clockctl_clock_settime {
+ netbsd32_clockid_t clock_id;
+ netbsd32_timespecp_t tp;
+};
+
+#define CLOCKCTL_CLOCK_SETTIME32 _IOW('C', 0x7, \
+ struct netbsd32_clockctl_clock_settime)
+
+struct netbsd32_clockctl_ntp_adjtime {
+ netbsd32_timexp_t tp;
+ /* register_t */ int32_t retval;
+};
+
+#define CLOCKCTL_NTP_ADJTIME32 _IOWR('C', 0x8, \
+ struct netbsd32_clockctl_ntp_adjtime)
+
Home |
Main Index |
Thread Index |
Old Index