From patchwork Sat Jun 21 22:53:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 362495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CBCF114008F for ; Sun, 22 Jun 2014 09:01:41 +1000 (EST) Received: from localhost ([::1]:46732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WyUI0-0001RJ-3u for incoming@patchwork.ozlabs.org; Sat, 21 Jun 2014 19:01:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WyUAc-0005BD-1c for qemu-devel@nongnu.org; Sat, 21 Jun 2014 18:54:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WyUAW-0005dl-C5 for qemu-devel@nongnu.org; Sat, 21 Jun 2014 18:54:01 -0400 Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]:50793) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WyUAW-0005dP-5t for qemu-devel@nongnu.org; Sat, 21 Jun 2014 18:53:56 -0400 Received: by mail-we0-f181.google.com with SMTP id q59so5200313wes.40 for ; Sat, 21 Jun 2014 15:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=IyqHFFnqeLvPFpG0wSrhIdlv0V0Pgz651QUE85VTW8s=; b=dRyWOU4ryCdrYVdFjRDE5WMv153KzttJIikvlk4f9qAy4ByGcI5B2ntVZjULqnvWkK emqvPxv0LNjycUEI+GmSzrBUpe2J78k9NM/xXuNUkmvYIPNl5pVMhH9ZUbBrmxa/QovI x4wuNjzsXOYq7EvgbLekO+i/lnhw00l5D4D0nuCJlgVXwOh2lfaYfcjy7jbhcRSFbq/n xj0ULkaEZyRIxF+GCz4YfkFZFWs2BXDM7rdzfwus0KfB+cm5fdLZ3Q6JUnbZpshSrGHg CliRSeDqMKR4fl/u7rASniufWVtpwwvHPFnrl+tkRMv/I7AR1U8DyAHUDW4D4CUpzB1Q UsEw== X-Received: by 10.180.13.208 with SMTP id j16mr14359645wic.15.1403391234646; Sat, 21 Jun 2014 15:53:54 -0700 (PDT) Received: from pburton-laptop.home (host81-156-187-173.range81-156.btcentralplus.com. [81.156.187.173]) by mx.google.com with ESMTPSA id ub8sm17971892wib.0.2014.06.21.15.53.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 21 Jun 2014 15:53:54 -0700 (PDT) From: Paul Burton To: qemu-devel@nongnu.org Date: Sat, 21 Jun 2014 23:53:05 +0100 Message-Id: <1403391191-18603-11-git-send-email-paul@archlinuxmips.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1403391191-18603-1-git-send-email-paul@archlinuxmips.org> References: <1403391191-18603-1-git-send-email-paul@archlinuxmips.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::235 Cc: Riku Voipio , Paul Burton Subject: [Qemu-devel] [PATCH v2 10/16] linux-user: support timerfd_{create, gettime, settime} syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adds support for the timerfd_create, timerfd_gettime & timerfd_settime syscalls, allowing use of timerfds by target programs. Signed-off-by: Paul Burton --- Changes in v2: - None. --- linux-user/strace.list | 9 +++++++++ linux-user/syscall.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/linux-user/strace.list b/linux-user/strace.list index fcb258d..8de972a 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1404,6 +1404,15 @@ #ifdef TARGET_NR_timer_settime { TARGET_NR_timer_settime, "timer_settime" , NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_timerfd_create +{ TARGET_NR_timerfd_create, "timerfd_create" , NULL, NULL, NULL }, +#endif +#ifdef TARGET_NR_timerfd_gettime +{ TARGET_NR_timerfd_gettime, "timerfd_gettime" , NULL, NULL, NULL }, +#endif +#ifdef TARGET_NR_timerfd_settime +{ TARGET_NR_timerfd_settime, "timerfd_settime" , NULL, NULL, NULL }, +#endif #ifdef TARGET_NR_times { TARGET_NR_times, "times" , NULL, NULL, NULL }, #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cd0221b..1c300be 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -58,6 +58,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include #include +#include #include #include //#include @@ -9430,6 +9431,49 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } #endif +#ifdef TARGET_NR_timerfd_create + case TARGET_NR_timerfd_create: + ret = get_errno(timerfd_create(arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl))); + break; +#endif + +#ifdef TARGET_NR_timerfd_gettime + case TARGET_NR_timerfd_gettime: + { + struct itimerspec its_curr; + + ret = get_errno(timerfd_gettime(arg1, &its_curr)); + + if (arg2 && host_to_target_itimerspec(arg2, &its_curr)) { + goto efault; + } + } + break; +#endif + +#ifdef TARGET_NR_timerfd_settime + case TARGET_NR_timerfd_settime: + { + struct itimerspec its_new, its_old, *p_new; + + if (arg3) { + if (target_to_host_itimerspec(&its_new, arg3)) + goto efault; + p_new = &its_new; + } else { + p_new = NULL; + } + + ret = get_errno(timerfd_settime(arg1, arg2, p_new, &its_old)); + + if (arg4 && host_to_target_itimerspec(arg4, &its_old)) { + goto efault; + } + } + break; +#endif + default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num);