From patchwork Thu Jan 26 18:32:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Barcelo X-Patchwork-Id: 138106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 08C1AB6F9D for ; Fri, 27 Jan 2012 12:54:41 +1100 (EST) Received: from localhost ([::1]:59109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqaHP-0008Cz-Hv for incoming@patchwork.ozlabs.org; Thu, 26 Jan 2012 20:07:03 -0500 Received: from [140.186.70.92] (port=60919 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqU7i-0000Wx-5K for qemu-devel@nongnu.org; Thu, 26 Jan 2012 13:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqU7b-0001oC-6w for qemu-devel@nongnu.org; Thu, 26 Jan 2012 13:32:37 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:33847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqU7b-0001nw-0L for qemu-devel@nongnu.org; Thu, 26 Jan 2012 13:32:31 -0500 Received: by pbdd2 with SMTP id d2so1131926pbd.4 for ; Thu, 26 Jan 2012 10:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=eimmdT3iATz1sC+ouBzD0sHCsQIothd3yNUx4S9UOKU=; b=DKSgODB0rGa5LYBXQZJ8JYh4VtSEn8tORg3Ac8JD1SMEFfnO+P26APhd6pQfBHIcZn 6r2gM03C5/fJTzvm6w00qXpEIxQMtP4z98WC3iFbqgPbdMB9mrUMbWyy/NiMHaBf0QSe XWNdGAIv2fsxX8a6hyxUk1Wn/E7ImQaUjx544= Received: by 10.68.74.102 with SMTP id s6mr7092165pbv.81.1327602748131; Thu, 26 Jan 2012 10:32:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.208.6 with HTTP; Thu, 26 Jan 2012 10:32:08 -0800 (PST) From: Alex Barcelo Date: Thu, 26 Jan 2012 19:32:08 +0100 X-Google-Sender-Auth: BMbtmEDPlW230uh5lprz3R2MLWw Message-ID: To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 X-Mailman-Approved-At: Thu, 26 Jan 2012 20:06:33 -0500 Subject: [Qemu-devel] Trying to add usermode support for signalfd (but failing) 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 I was trying to add signalfd support on qemu-ppc (specifically, I'm doing a configure with "--enable-debug-tcg --enable-debug --disable-strip --disable-kvm --disable-bsd-user --disable-darwin-user --enable-profiler --target-list=ppc-linux-user --disable-curl --enable-nptl"). At first I thought that it should be straightforward, so I simply added the syscall to the "do_syscall" code. See the patch at the end. The test program used is the example that can be found on the signalfd(2) manpage. It fails with a "qemu: Unsupported syscall: 313"... but the syscall 313 IS supported (it's the splice syscall, which the configure detects and enables the CONFIG_SPLICE and it seems correct). I checked with a splice-specific test --it worked as it should. I debugged a bit and it seems that the switch ignores this syscall, but only when this 313 syscall is called from inside the signalfd syscall (it seems that internally signalfd calls a splice). I am completely lost, I was hoping that somebody could point me some directions. #else @@ -8141,6 +8144,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; } #endif + case TARGET_NR_signalfd: + { + sigset_t set, *set_ptr; + + if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) + goto efault; + target_to_host_old_sigset(&set, p); + set_ptr = &set; + ret = get_errno(sys_signalfd(arg1,set_ptr,arg3) ); + break; + } default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2bf9e7e..bcf527f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -57,6 +57,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include //#include +#include #include #include #include @@ -198,12 +199,14 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_inotify_init __NR_inotify_init #define __NR_sys_inotify_add_watch __NR_inotify_add_watch #define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch +#define __NR_sys_signalfd __NR_signalfd #if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) || \ defined(__s390x__) #define __NR__llseek __NR_lseek #endif +_syscall3(int, sys_signalfd, int, fd, const sigset_t * , mask , int, flags); #ifdef __NR_gettid _syscall0(int, gettid)