From patchwork Thu Jul 7 23:17:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9219923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E019660467 for ; Thu, 7 Jul 2016 23:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9EC625EF7 for ; Thu, 7 Jul 2016 23:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEA9D26538; Thu, 7 Jul 2016 23:18:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C29525EF7 for ; Thu, 7 Jul 2016 23:18:19 +0000 (UTC) Received: from localhost ([::1]:42708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLIYk-00010u-5t for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Jul 2016 19:18:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLIYS-00010g-RV for qemu-devel@nongnu.org; Thu, 07 Jul 2016 19:18:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLIYO-0001G8-Ru for qemu-devel@nongnu.org; Thu, 07 Jul 2016 19:18:00 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:59646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLIYO-0001Ef-IK for qemu-devel@nongnu.org; Thu, 07 Jul 2016 19:17:56 -0400 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MSak0-1athYd2vps-00Ra9i; Fri, 08 Jul 2016 01:17:40 +0200 From: Laurent Vivier To: Riku Voipio Date: Fri, 8 Jul 2016 01:17:27 +0200 Message-Id: <1467933447-5696-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.5 X-Provags-ID: V03:K0:fHmjT1Dd5LNF3kQ/vQrqkq+G6Rxw5ivCi83oCnKagNkL9k5ZJ/v ULmA38QtclONDEdamKg0/Ux/ZIlAgDvHMV8cfMoyjONcg6eeSL19nFPnNNHv6/4xH/mnstJ tU99ZyW+7RsdMrDNuoomSD+UKOFKqz79i9KtPm/tDGnt1el2sokS/5b07jaddwMfBvhIg0H /TqCeRZTYIlgdFBe3FpdQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:T5IoaDyltzw=:QtIjQ0FcFHgq3TBuKK+M7A ALaRzqxrlgM/qTk3PvuABnEhy/peFTxtwTcshSrSI7Tzr8skEsGwmBE/nhDyhe3Y3bkh59nPQ KKCW7RZppE7iVnfPHV0UgYAlHMgg+FW2LUl9HVKDm4/PCip1Y4gRoK4P3FEkuibAFxm6ivTC7 9izZ/hu8w1uzyyMJ/wh+cRm3H08FIWZjFgYk3rNB2NyxlbQtbJbR/TYOpfjeNupzttEc40PUM tbewjt2JEJ7qKQpHnijvWC3hqlZP9f0fks/9Ivsg9KIzU/2afPDufCNuwxiAFBVrbb8SaArRU hbEH884MpJ34Ylgwogq8592iw3yPK64r1oRBXdWH9wMjJ+rYi1dj31i3jxpnAdQO8imr6G4Sm eBdOEMABuhkwXRd2MAJ36is2UEG6wW1N8tsnsH3uuBrRB7PADQXDJwQYEPzbObmQ36DZjmDTH 9QeiYI91DlC+sfCnHRDFRxs8NDYwGJCtw4GES9rGMyvgFc+ea3inkdpOMvN/x+lUz7P96tDEB UVx//Lh4AgsCOP1NCOMJ0yCPpw0e11QJ83+NklOP5+Ng6gopWolBLsBVQv4wuA3UIDnqSKNza oQp/zN8qtH182Ttf20jM2HIwlPafvgHMEu/MLcALvPZ+qoj64GfeAQjlMJ/y7sJVb+JLMN1Y5 9aLw5CE5YzZNE/G4bG7pZkbEGTeFb0aAc76WYsdhbjIOX+RYE134iozniMX674wDc+Pk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.74 Subject: [Qemu-devel] [PATCH] linux-user: fix TARGET_NR_select X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Timothy Pearson , Allan Wirth , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP TARGET_NR_select can have three different implementations: 1- to always return -ENOSYS microblaze, ppc, ppc64 -> TARGET_WANT_NI_OLD_SELECT 2- to take parameters from a structure pointed by arg1 (kernel sys_old_select) i386, arm, m68k -> TARGET_WANT_OLD_SYS_SELECT 3- to take parameters from arg[1-5] (kernel sys_select) x86_64, alpha, s390x, cris, sparc, sparc64 Some (new) architectures don't define NR_select, 4- but only NR__newselect with sys_select: mips, mips64, sh 5- don't define NR__newselect, and use pselect6 syscall: aarch64, openrisc, tilegx, unicore32 Reported-by: Timothy Pearson Reported-by: Allan Wirth Suggested-by: Peter Maydell Signed-off-by: Laurent Vivier Reviewed-by: Peter Maydell --- linux-user/arm/target_syscall.h | 2 ++ linux-user/i386/target_syscall.h | 2 ++ linux-user/m68k/target_syscall.h | 2 ++ linux-user/microblaze/target_syscall.h | 2 ++ linux-user/openrisc/syscall_nr.h | 2 -- linux-user/ppc/target_syscall.h | 2 ++ linux-user/sh4/syscall_nr.h | 2 +- linux-user/syscall.c | 48 ++++++++++++++++++++++------------ linux-user/tilegx/syscall_nr.h | 1 - 9 files changed, 42 insertions(+), 21 deletions(-) diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h index 11077b7..b1073bf 100644 --- a/linux-user/arm/target_syscall.h +++ b/linux-user/arm/target_syscall.h @@ -33,4 +33,6 @@ struct target_pt_regs { #define TARGET_MLOCKALL_MCL_CURRENT 1 #define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_WANT_OLD_SYS_SELECT + #endif /* TARGET_SYSCALL_H */ diff --git a/linux-user/i386/target_syscall.h b/linux-user/i386/target_syscall.h index 0ac84dc..6678763 100644 --- a/linux-user/i386/target_syscall.h +++ b/linux-user/i386/target_syscall.h @@ -154,4 +154,6 @@ struct target_vm86plus_struct { #define TARGET_MLOCKALL_MCL_CURRENT 1 #define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_WANT_OLD_SYS_SELECT + #endif /* TARGET_SYSCALL_H */ diff --git a/linux-user/m68k/target_syscall.h b/linux-user/m68k/target_syscall.h index 97a4cc0..5e2ccf1 100644 --- a/linux-user/m68k/target_syscall.h +++ b/linux-user/m68k/target_syscall.h @@ -24,6 +24,8 @@ struct target_pt_regs { #define TARGET_MLOCKALL_MCL_CURRENT 1 #define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_WANT_OLD_SYS_SELECT + void do_m68k_simcall(CPUM68KState *, int); #endif /* TARGET_SYSCALL_H */ diff --git a/linux-user/microblaze/target_syscall.h b/linux-user/microblaze/target_syscall.h index 3c1ed27..65b07c2 100644 --- a/linux-user/microblaze/target_syscall.h +++ b/linux-user/microblaze/target_syscall.h @@ -53,4 +53,6 @@ struct target_pt_regs { #define TARGET_MLOCKALL_MCL_CURRENT 1 #define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_WANT_NI_OLD_SELECT + #endif diff --git a/linux-user/openrisc/syscall_nr.h b/linux-user/openrisc/syscall_nr.h index 6b1c7d2..04059d0 100644 --- a/linux-user/openrisc/syscall_nr.h +++ b/linux-user/openrisc/syscall_nr.h @@ -459,8 +459,6 @@ #define TARGET_NR_getdents 1065 #define __ARCH_WANT_SYS_GETDENTS #define TARGET_NR_futimesat 1066 -#define TARGET_NR_select 1067 -#define __ARCH_WANT_SYS_SELECT #define TARGET_NR_poll 1068 #define TARGET_NR_epoll_wait 1069 #define TARGET_NR_ustat 1070 diff --git a/linux-user/ppc/target_syscall.h b/linux-user/ppc/target_syscall.h index 7ca83c2..6616678 100644 --- a/linux-user/ppc/target_syscall.h +++ b/linux-user/ppc/target_syscall.h @@ -75,4 +75,6 @@ struct target_revectored_struct { #define TARGET_MLOCKALL_MCL_CURRENT 0x2000 #define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_WANT_NI_OLD_SELECT + #endif /* TARGET_SYSCALL_H */ diff --git a/linux-user/sh4/syscall_nr.h b/linux-user/sh4/syscall_nr.h index 5009984..e99f735 100644 --- a/linux-user/sh4/syscall_nr.h +++ b/linux-user/sh4/syscall_nr.h @@ -84,7 +84,7 @@ #define TARGET_NR_settimeofday 79 #define TARGET_NR_getgroups 80 #define TARGET_NR_setgroups 81 -#define TARGET_NR_select 82 + /* 82 was sys_oldselect */ #define TARGET_NR_symlink 83 #define TARGET_NR_oldlstat 84 #define TARGET_NR_readlink 85 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 37f0660..e7ec2d3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1255,6 +1255,29 @@ static abi_long do_select(int n, return ret; } + +#if defined(TARGET_WANT_OLD_SYS_SELECT) +static abi_long do_old_select(abi_ulong arg1) +{ + struct target_sel_arg_struct *sel; + abi_ulong inp, outp, exp, tvp; + long nsel; + + if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) { + return -TARGET_EFAULT; + } + + nsel = tswapal(sel->n); + inp = tswapal(sel->inp); + outp = tswapal(sel->outp); + exp = tswapal(sel->exp); + tvp = tswapal(sel->tvp); + + unlock_user_struct(sel, arg1, 0); + + return do_select(nsel, inp, outp, exp, tvp); +} +#endif #endif static abi_long do_pipe2(int host_pipe[], int flags) @@ -8372,24 +8395,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #if defined(TARGET_NR_select) case TARGET_NR_select: -#if defined(TARGET_S390X) || defined(TARGET_ALPHA) - ret = do_select(arg1, arg2, arg3, arg4, arg5); +#if defined(TARGET_WANT_NI_OLD_SELECT) + /* some architectures used to have old_select here + * but now ENOSYS it. + */ + ret = -TARGET_ENOSYS; +#elif defined(TARGET_WANT_OLD_SYS_SELECT) + ret = do_old_select(arg1); #else - { - struct target_sel_arg_struct *sel; - abi_ulong inp, outp, exp, tvp; - long nsel; - - if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) - goto efault; - nsel = tswapal(sel->n); - inp = tswapal(sel->inp); - outp = tswapal(sel->outp); - exp = tswapal(sel->exp); - tvp = tswapal(sel->tvp); - unlock_user_struct(sel, arg1, 0); - ret = do_select(nsel, inp, outp, exp, tvp); - } + ret = do_select(arg1, arg2, arg3, arg4, arg5); #endif break; #endif diff --git a/linux-user/tilegx/syscall_nr.h b/linux-user/tilegx/syscall_nr.h index 87fb72c..b86f0fc 100644 --- a/linux-user/tilegx/syscall_nr.h +++ b/linux-user/tilegx/syscall_nr.h @@ -311,7 +311,6 @@ #define TARGET_NR_creat 1064 #define TARGET_NR_getdents 1065 #define TARGET_NR_futimesat 1066 -#define TARGET_NR_select 1067 #define TARGET_NR_poll 1068 #define TARGET_NR_epoll_wait 1069 #define TARGET_NR_ustat 1070