From owner-freebsd-emulation@FreeBSD.ORG Thu Oct 14 18:46:26 2010 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id 656E31065673; Thu, 14 Oct 2010 18:46:26 +0000 (UTC) Date: Thu, 14 Oct 2010 18:46:26 +0000 From: Alexander Best To: freebsd-emulation@freebsd.org Message-ID: <20101014184626.GA1961@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline Subject: reduce 'unknown op 265' message storm X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2010 18:46:26 -0000 --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline hi there, i see a lot of these warnings: 'linux_sys_futex: unknown op 265' although there is no support in the linuxulator for opcode 256 (FUTEX_CLOCK_REALTIME) it is possible to handle some of these cases earlier. FUTEX_CLOCK_REALTIME can be used to tell linux to use CLOCK_REALTIME instead of CLOCK_MONOTONIC. FUTEX_CLOCK_REALTIME however must only be set, if either FUTEX_WAIT_BITSET or FUTEX_WAIT_REQUEUE_PI are set too. if that's not the case we can die with -ENOSYS right at the beginning. cheers. alex -- a13x --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="linux_futex.diff" diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index 01af020..00c657c 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -416,7 +416,7 @@ futex_atomic_op(struct thread *td, int encoded_op, uint32_t *uaddr) int linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args) { - int op_ret, val, ret, nrwake; + int clockrt, nrwake, op_ret, ret, val; struct linux_emuldata *em; struct waiting_proc *wp; struct futex *f, *f2 = NULL; @@ -429,7 +429,18 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args) * in most cases (ie. when futexes are not shared on file descriptor * or between different processes.). */ - args->op = (args->op & ~LINUX_FUTEX_PRIVATE_FLAG); + args->op = args->op & ~LINUX_FUTEX_PRIVATE_FLAG; + + /* + * Currently support for switching between CLOCK_MONOTONIC and + * CLOCK_REALTIME is not present. However Linux forbids the use of + * FUTEX_CLOCK_REALTIME with any op except FUTEX_WAIT_BITSET and + * FUTEX_WAIT_REQUEUE_PI. + */ + clockrt = args->op & LINUX_FUTEX_CLOCK_REALTIME; + args->op = args->op & ~LINUX_FUTEX_CLOCK_REALTIME; + if (clockrt && args->op != LINUX_FUTEX_WAIT_BITSET && args->op != LINUX_FUTEX_WAIT_REQUEUE_PI) + return (-ENOSYS); switch (args->op) { case LINUX_FUTEX_WAIT: @@ -639,6 +650,14 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args) } return (EINVAL); + case LINUX_FUTEX_WAIT_BITSET: + /* not yet implemented */ + return (ENOSYS); + + case LINUX_FUTEX_WAIT_REQUEUE_PI: + /* not yet implemented */ + return (ENOSYS); + default: printf("linux_sys_futex: unknown op %d\n", args->op); return (ENOSYS); diff --git a/sys/compat/linux/linux_futex.h b/sys/compat/linux/linux_futex.h index 1d462a7..3a10918 100644 --- a/sys/compat/linux/linux_futex.h +++ b/sys/compat/linux/linux_futex.h @@ -48,8 +48,12 @@ extern struct mtx futex_mtx; #define LINUX_FUTEX_LOCK_PI 6 #define LINUX_FUTEX_UNLOCK_PI 7 #define LINUX_FUTEX_TRYLOCK_PI 8 +#define LINUX_FUTEX_WAIT_BITSET 9 +#define \ +LINUX_FUTEX_WAIT_REQUEUE_PI 11 #define LINUX_FUTEX_PRIVATE_FLAG 128 +#define LINUX_FUTEX_CLOCK_REALTIME 256 #define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */ #define FUTEX_OP_ADD 1 /* *(int *)UADDR2 += OPARG; */ --ZPt4rx8FFjLCG7dd--