From nobody Sat Apr 27 12:35:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16432312493961000.6539832444904; Wed, 26 Jan 2022 13:07:29 -0800 (PST) Received: from localhost ([::1]:47764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCpVo-0001Dq-JE for importer@patchew.org; Wed, 26 Jan 2022 16:07:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCosS-0008Lq-6f for qemu-devel@nongnu.org; Wed, 26 Jan 2022 15:26:48 -0500 Received: from nowt.default.pbrook.uk0.bigv.io ([213.138.114.50]:38843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCosP-0007Zx-Sf for qemu-devel@nongnu.org; Wed, 26 Jan 2022 15:26:47 -0500 Received: from cpc91554-seac25-2-0-cust857.7-2.cable.virginm.net ([82.27.199.90] helo=wren.ecobee.com) by nowt.default.pbrook.uk0.bigv.io with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1nCosJ-0006Pv-6z; Wed, 26 Jan 2022 20:26:39 +0000 From: Paul Brook To: qemu-devel@nongnu.org Subject: [PATCH] linux-user: Fix inotify on aarch64 Date: Wed, 26 Jan 2022 20:26:36 +0000 Message-Id: <20220126202636.655289-1-paul@nowt.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=213.138.114.50; envelope-from=paul@nowt.org; helo=nowt.default.pbrook.uk0.bigv.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 26 Jan 2022 16:01:55 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Paul Brook Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1643231252197100001 Content-Type: text/plain; charset="utf-8" The inotify implementation originally called the raw host syscalls. Commit 3b3f24add0 changed this to use the glibc wrappers. However ifdefs in syscall.c still test for presence of the raw syscalls. This causes a problem on e.g. aarch64 hosts which never had the inotify_init syscall - it had been obsoleted by inotify_init1 before aarch64 was invented! However it does have a perfectly good glibc implementation of inotify_wait. Fix this by removing all the raw __NR_inotify_* tests, and instead check CONFIG_INOTIFY, which already tests for the glibc functionality we use. Also remove the now-pointless sys_inotify* wrappers. Tested using x86-64 inotifywatch on aarch64 host, and vice-versa Signed-off-by: Paul Brook Reviewed-by: Laurent Vivier --- linux-user/fd-trans.c | 5 ++--- linux-user/syscall.c | 50 +++++++++---------------------------------- 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 6941089959..30e7b49112 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -1460,9 +1460,8 @@ TargetFdTrans target_eventfd_trans =3D { .target_to_host_data =3D swap_data_eventfd, }; =20 -#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \ - (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \ - defined(__NR_inotify_init1)) +#if defined(CONFIG_INOTIFY) && (defined(TARGET_NR_inotify_init) || \ + defined(TARGET_NR_inotify_init1)) static abi_long host_to_target_data_inotify(void *buf, size_t len) { struct inotify_event *ev; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 56a3e17183..17cc38fe34 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -272,9 +272,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type= 4 arg4,type5 arg5, \ #if defined(__NR_futex_time64) # define __NR_sys_futex_time64 __NR_futex_time64 #endif -#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_statx __NR_statx =20 #if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) @@ -447,33 +444,6 @@ static int sys_renameat2(int oldfd, const char *old, =20 #ifdef CONFIG_INOTIFY #include - -#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) -static int sys_inotify_init(void) -{ - return (inotify_init()); -} -#endif -#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) -static int sys_inotify_add_watch(int fd,const char *pathname, int32_t mask) -{ - return (inotify_add_watch(fd, pathname, mask)); -} -#endif -#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) -static int sys_inotify_rm_watch(int fd, int32_t wd) -{ - return (inotify_rm_watch(fd, wd)); -} -#endif -#ifdef CONFIG_INOTIFY1 -#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) -static int sys_inotify_init1(int flags) -{ - return (inotify_init1(flags)); -} -#endif -#endif #else /* Userspace can usually survive runtime without inotify */ #undef TARGET_NR_inotify_init @@ -12263,35 +12233,35 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, case TARGET_NR_futex_time64: return do_futex_time64(cpu, arg1, arg2, arg3, arg4, arg5, arg6); #endif -#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) +#ifdef CONFIG_INOTIFY +#if defined(TARGET_NR_inotify_init) case TARGET_NR_inotify_init: - ret =3D get_errno(sys_inotify_init()); + ret =3D get_errno(inotify_init()); if (ret >=3D 0) { fd_trans_register(ret, &target_inotify_trans); } return ret; #endif -#ifdef CONFIG_INOTIFY1 -#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) +#if defined(TARGET_NR_inotify_init1) && defined(CONFIG_INOTIFY1) case TARGET_NR_inotify_init1: - ret =3D get_errno(sys_inotify_init1(target_to_host_bitmask(arg1, + ret =3D get_errno(inotify_init1(target_to_host_bitmask(arg1, fcntl_flags_tbl))); if (ret >=3D 0) { fd_trans_register(ret, &target_inotify_trans); } return ret; #endif -#endif -#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) +#if defined(TARGET_NR_inotify_add_watch) case TARGET_NR_inotify_add_watch: p =3D lock_user_string(arg2); - ret =3D get_errno(sys_inotify_add_watch(arg1, path(p), arg3)); + ret =3D get_errno(inotify_add_watch(arg1, path(p), arg3)); unlock_user(p, arg2, 0); return ret; #endif -#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) +#if defined(TARGET_NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: - return get_errno(sys_inotify_rm_watch(arg1, arg2)); + return get_errno(inotify_rm_watch(arg1, arg2)); +#endif #endif =20 #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) --=20 2.34.1