From nobody Sat May 18 07:48:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1598309229; cv=pass; d=zohomail.com; s=zohoarc; b=kxqk/Y7NotBW9ORzuyGfJGkzjWvnT2/JWENX7brA6cSO/aW/cBMEdDFqIxFe9BrnXzkF3/FnJ25hV6lEnTgKju2jOtkivZiO4bhFPTKc78N3hcqmrs/zzi2wjfRNW/UIozngwVC8KHSzl69QUcpmBPUxZY+svcF8cS5vSlxRO8M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598309229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N6KIZ9ZswSBlb7850B30zD/evIRLg7FGhAxFrLSo7EE=; b=iW/LUTbHNceupZ4ommR0l8d3uRBwmmuLJdCAcLOiO3mFDEM2kzOBINoravS2AECMAQrdpDjMgnBu4QQc7zi0CCyTshXqFnftbhyrfH28WXO1HRtTwyCwX+vLoFCg8aARnqkVjbAa3g9H+DOKstBMdKpsTjvnx7pW3+d4xI2eiJo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159830922927031.118372896578194; Mon, 24 Aug 2020 15:47:09 -0700 (PDT) Received: from localhost ([::1]:56386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kALF5-00045X-2B for importer@patchew.org; Mon, 24 Aug 2020 18:47:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kALEG-0003eK-Ea for qemu-devel@nongnu.org; Mon, 24 Aug 2020 18:46:16 -0400 Received: from mail-eopbgr80129.outbound.protection.outlook.com ([40.107.8.129]:39006 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kALED-00059D-JT for qemu-devel@nongnu.org; Mon, 24 Aug 2020 18:46:16 -0400 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) by VI1PR03MB4575.eurprd03.prod.outlook.com (2603:10a6:803:59::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 22:31:07 +0000 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362]) by VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362%6]) with mapi id 15.20.3261.026; Mon, 24 Aug 2020 22:31:07 +0000 Received: from localhost.localdomain (147.91.217.235) by LO2P265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 22:31:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nUjZVXlZpN7kKtX4QfGuf3KiPiBXpp5FcwsZQLA9gZkuobe3X1w2n6epxjZx3tXFImNweb/yCpm5d5dSzA7NVs0PbFdiE/6c/OfyPYdx/Tf42ZscYfG3nWSivazAYQCjr/t4O5SXIYeJ1R8j82JtIFRcrQxLbpbjlr3H0BamthncuEnMfbwb5AbaSFww3OfJOCpiSVdnUgIY88+5xJGvjw9PRfGDSsxss9AJThjNZbUjR/8mhCFSU1wrU2+1NDksgjE8msLSyPQPEUme39I1ZFlUslZqZ4g8J0MnDasJMtf2LLbCN6iD/CU9OTcuUiMRFHNkAt7IgO6aGgnrpCsNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N6KIZ9ZswSBlb7850B30zD/evIRLg7FGhAxFrLSo7EE=; b=aNwk80pOKMXC7vybH2kO3F53znKMFjwuPUxn1P82/9a2Yp9UFjwmOYeJ6j9TB16vQUAAdEceEc5xaVQVkwgZF1wTtY+smLXcE+E1nLO9+fGIGXhqWT0nnZBoBKJnhrVWqviB/vKEK63jHavtnAlCQ4Dwr3hpuEOXcwRgZtKPugZAfZfFlz138ZtDze4M1iOzjARINaCHqAQtqcDzeAPwHujXw8w5SpVrwLsQjz3g861kjAws5ydsJmE7V3bZOxTbMCrtIm7YCoBYT3CHfwRrRQ31DyAM5J8WaWaHiEa4DJEX6qlrlxIYfTmvP4uW+2d8yEGtoypNJR1qsR2JhtLBNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N6KIZ9ZswSBlb7850B30zD/evIRLg7FGhAxFrLSo7EE=; b=P137ZK8UBN16tkH5hq4eilTh7C8lT9Zh48vE8xzKndrV7N768PV3HA6Rn/3w14IeaqXwF4NjVSP4UHZb0GVvabMxEuyANtUKpJkVBulr2T2sBi+i+qhst06fVJ4pfons5DDbdRBG3XCacb5WHjWKfP0zT0vj3Rypr1E6RV3SctM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] linux-user: Add support for ppoll_time64() and pselect6_time64() Date: Tue, 25 Aug 2020 00:30:49 +0200 Message-Id: <20200824223050.92032-2-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824223050.92032-1-Filip.Bozuta@syrmia.com> References: <20200824223050.92032-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::34) To VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [147.91.217.235] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8aab561a-66e9-49e1-ded9-08d8487d63da X-MS-TrafficTypeDiagnostic: VI1PR03MB4575: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m27K21jh7hE57PBO2/YaSStZbiG76O5S4dbNHq4GpRsK8bzHRhrJuEdIqFbaTYbUUhdev8ZdCp1ED74/d98VmkN/K+KLjCh0UA88O7NazRU4+QF7sgMUEp6ojuZIY9vZJh78Vw6Jy0ZGlmm8OCR2gZZwMHuFWf25M9CrEcxcgjd06T6WdVaYzyAJVu3X4wpAPJfB7883iV0zzNozgwuFuiVdIrDEnKQVm4Soww2rgbeiVbgL/NCDofXvDP6l223wLddieaDIrAO98UhQKErakoTFakwpasIaCNRYDz8gyu2vIxoqeBOZFTsu/a7YUI+ndA/J9aTrT5b8O/4CC8uCNrSdUaBJFu+itFeYjOmqyrHtycvAjFUetgO6PerYFeud7SftUP7O6NdK+KL9Jek1mmawm+e/j07lTGNrWbYBjlD4FZHleQi11nF+Zv55nC9BfCY/yhbZaVi2uQsQF7NWJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR03MB5246.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(136003)(346002)(366004)(396003)(39830400003)(6506007)(6486002)(6916009)(83380400001)(69590400007)(2906002)(956004)(8676002)(2616005)(8936002)(26005)(478600001)(36756003)(54906003)(316002)(966005)(66556008)(66946007)(186003)(16526019)(4326008)(66476007)(6666004)(30864003)(1076003)(52116002)(86362001)(107886003)(6512007)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ncCiCLWTX7hm7g/satjPnyep61k4jLlG9xVy+xX8b6+rdxC/AgtJspaa7uXSh3C8X5A6eJiGfV059hdVk2yLTPb9Ex0E5T/0tTXaxRd1HdXlRJKw3LMsAkKyp6AOf8U96aBDtsK4BAsZWz2WUocJ6UvKkkLX87PEBZJ1w/rKs+X08HBkNlr7G3vdQyfqmTDl3My0Ib7aq/ENsfnF7B9fs1dYFOhJ/9LQNot30tCP6cKx8mcaYDsPQ9jHbg+Bywvj4FwKukyykkLnj3sS0YmfYAV4Igkh2fo3xqFUOEgM/Uqm9vaKt5Y7xZ1pkC4X7zPNX1BY4w6HwBx7l/otDImXYSQJ20eOyR6KrZmZVXiIJoK/CXaE9IqCifdQekNb863QBzl9tFltN3E9pirKK0Ohm1X8Xmo0nGlScgOpqQiw3vPd+Y9WwfCGbYRQsC6nB2ZDrii4//zp4XH0Q0XdN7sBi5PfSzMZrEDw0yY0cUAPj4NfCd5xwOXPMnyJzL8yeZTbHPTOLSLzZlk8vSAL4zefswbFWzX8IyUdSHhSmWy4HXV/FzEFCsSUCanojfJbK0H8kREs9VJpRzeqWJ5nAa5eqfkAgQsn8L9AJAyzzS+0y4Cvt3U0adP+BanDBY3wWUQK/6WeC85+hiMtO5SzPzMp1A== X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8aab561a-66e9-49e1-ded9-08d8487d63da X-MS-Exchange-CrossTenant-AuthSource: VE1PR03MB5246.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 22:31:05.8973 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zMFsi/6IJRajUpPexEw+8nu0JvsJdHEuAgHAJepgfwEw02mYIOB1NxCmQDl8MFyuE1QKwFGTXqMFls8haDugeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB4575 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=40.107.8.129; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 18:46:10 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" This patch introduces functionality for following time64 syscalls: *ppoll_time64 This is a year 2038 safe variant of: int poll(struct pollfd *fds, nfds_t nfds, int timeout) -- wait for some event on a file descriptor -- man page: https://man7.org/linux/man-pages/man2/ppoll.2.html *pselect6_time64 This is a year 2038 safe variant of: int pselect6(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask); -- synchronous I/O multiplexing -- man page: https://man7.org/linux/man-pages/man2/pselect6.2.html Implementation notes: Year 2038 safe syscalls in this patch were implemented with the same code as their regular variants (ppoll() and pselect()). This code was moved to new functions ('do_ppoll()' and 'do_pselect6()') that take a 'bool time64' from which a right 'struct timespec' converti= ng function is called. (target_to_host/host_to_target_timespec() for regular and target_to_host/host_to_target_timespec64() for time64 variants) Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 462 +++++++++++++++++++++++-------------------- 1 file changed, 251 insertions(+), 211 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1211e759c2..fc6a6e32e4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -397,7 +397,7 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } =20 -#ifdef TARGET_NR_utimensat +#if defined(TARGET_NR_utimensat) #if defined(__NR_utimensat) #define __NR_sys_utimensat __NR_utimensat _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, @@ -763,11 +763,11 @@ safe_syscall5(int, waitid, idtype_t, idtype, id_t, id= , siginfo_t *, infop, \ int, options, struct rusage *, rusage) safe_syscall3(int, execve, const char *, filename, char **, argv, char **,= envp) #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) || \ - defined(TARGET_NR_pselect6) + defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64) safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, write= fds, \ fd_set *, exceptfds, struct timespec *, timeout, void *, sig) #endif -#if defined(TARGET_NR_ppoll) || defined(TARGET_NR_poll) +#if defined(TARGET_NR_ppoll) || defined(TARGET_NR_ppoll_time64) safe_syscall5(int, ppoll, struct pollfd *, ufds, unsigned int, nfds, struct timespec *, tsp, const sigset_t *, sigmask, size_t, sigsetsize) @@ -984,7 +984,7 @@ abi_long do_brk(abi_ulong new_brk) } =20 #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) || \ - defined(TARGET_NR_pselect6) + defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64) static inline abi_long copy_from_user_fdset(fd_set *fds, abi_ulong target_fds_addr, int n) @@ -1252,7 +1252,8 @@ static inline abi_long target_to_host_timespec(struct= timespec *host_ts, } #endif =20 -#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) +#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) = || \ + defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -1458,6 +1459,237 @@ static abi_long do_old_select(abi_ulong arg1) #endif #endif =20 +#if defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64) +static abi_long do_pselect6(abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6, + bool time64) +{ + abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; + fd_set rfds, wfds, efds; + fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; + struct timespec ts, *ts_ptr; + abi_long ret; + + /* + * The 6th arg is actually two args smashed together, + * so we cannot use the C library. + */ + sigset_t set; + struct { + sigset_t *set; + size_t size; + } sig, *sig_ptr; + + abi_ulong arg_sigset, arg_sigsize, *arg7; + target_sigset_t *target_sigset; + + n =3D arg1; + rfd_addr =3D arg2; + wfd_addr =3D arg3; + efd_addr =3D arg4; + ts_addr =3D arg5; + + ret =3D copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); + if (ret) { + return ret; + } + ret =3D copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); + if (ret) { + return ret; + } + ret =3D copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); + if (ret) { + return ret; + } + + /* + * This takes a timespec, and not a timeval, so we cannot + * use the do_select() helper ... + */ + if (ts_addr) { + if (time64) { + if (target_to_host_timespec64(&ts, ts_addr)) { + return -TARGET_EFAULT; + } + } else { + if (target_to_host_timespec(&ts, ts_addr)) { + return -TARGET_EFAULT; + } + } + ts_ptr =3D &ts; + } else { + ts_ptr =3D NULL; + } + + /* Extract the two packed args for the sigset */ + if (arg6) { + sig_ptr =3D &sig; + sig.size =3D SIGSET_T_SIZE; + + arg7 =3D lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); + if (!arg7) { + return -TARGET_EFAULT; + } + arg_sigset =3D tswapal(arg7[0]); + arg_sigsize =3D tswapal(arg7[1]); + unlock_user(arg7, arg6, 0); + + if (arg_sigset) { + sig.set =3D &set; + if (arg_sigsize !=3D sizeof(*target_sigset)) { + /* Like the kernel, we enforce correct size sigsets */ + return -TARGET_EINVAL; + } + target_sigset =3D lock_user(VERIFY_READ, arg_sigset, + sizeof(*target_sigset), 1); + if (!target_sigset) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, target_sigset); + unlock_user(target_sigset, arg_sigset, 0); + } else { + sig.set =3D NULL; + } + } else { + sig_ptr =3D NULL; + } + + ret =3D get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, + ts_ptr, sig_ptr)); + + if (!is_error(ret)) { + if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) { + return -TARGET_EFAULT; + } + if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) { + return -TARGET_EFAULT; + } + if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) { + return -TARGET_EFAULT; + } + if (time64) { + if (ts_addr && host_to_target_timespec(ts_addr, &ts)) { + return -TARGET_EFAULT; + } + } else { + if (ts_addr && host_to_target_timespec64(ts_addr, &ts)) { + return -TARGET_EFAULT; + } + } + } + return ret; +} +#endif + +#if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) || \ + defined(TARGET_NR_ppoll_time64) +static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, bool ppoll, bool ti= me64) +{ + struct target_pollfd *target_pfd; + unsigned int nfds =3D arg2; + struct pollfd *pfd; + unsigned int i; + abi_long ret; + + pfd =3D NULL; + target_pfd =3D NULL; + if (nfds) { + if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { + return -TARGET_EINVAL; + } + target_pfd =3D lock_user(VERIFY_WRITE, arg1, + sizeof(struct target_pollfd) * nfds, 1); + if (!target_pfd) { + return -TARGET_EFAULT; + } + + pfd =3D alloca(sizeof(struct pollfd) * nfds); + for (i =3D 0; i < nfds; i++) { + pfd[i].fd =3D tswap32(target_pfd[i].fd); + pfd[i].events =3D tswap16(target_pfd[i].events); + } + } + if (ppoll) { + struct timespec _timeout_ts, *timeout_ts =3D &_timeout_ts; + target_sigset_t *target_set; + sigset_t _set, *set =3D &_set; + + if (arg3) { + if (time64) { + if (target_to_host_timespec64(timeout_ts, arg3)) { + unlock_user(target_pfd, arg1, 0); + return -TARGET_EFAULT; + } + } else { + if (target_to_host_timespec(timeout_ts, arg3)) { + unlock_user(target_pfd, arg1, 0); + return -TARGET_EFAULT; + } + } + } else { + timeout_ts =3D NULL; + } + + if (arg4) { + if (arg5 !=3D sizeof(target_sigset_t)) { + unlock_user(target_pfd, arg1, 0); + return -TARGET_EINVAL; + } + + target_set =3D lock_user(VERIFY_READ, arg4, + sizeof(target_sigset_t), 1); + if (!target_set) { + unlock_user(target_pfd, arg1, 0); + return -TARGET_EFAULT; + } + target_to_host_sigset(set, target_set); + } else { + set =3D NULL; + } + + ret =3D get_errno(safe_ppoll(pfd, nfds, timeout_ts, + set, SIGSET_T_SIZE)); + + if (!is_error(ret) && arg3) { + if (time64) { + if (host_to_target_timespec64(arg3, timeout_ts)) { + return -TARGET_EFAULT; + } + } else { + if (host_to_target_timespec(arg3, timeout_ts)) { + return -TARGET_EFAULT; + } + } + } + if (arg4) { + unlock_user(target_set, arg4, 0); + } + } else { + struct timespec ts, *pts; + + if (arg3 >=3D 0) { + /* Convert ms to secs, ns */ + ts.tv_sec =3D arg3 / 1000; + ts.tv_nsec =3D (arg3 % 1000) * 1000000LL; + pts =3D &ts; + } else { + /* -ve poll() timeout means "infinite" */ + pts =3D NULL; + } + ret =3D get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0)); + } + + if (!is_error(ret)) { + for (i =3D 0; i < nfds; i++) { + target_pfd[i].revents =3D tswap16(pfd[i].revents); + } + } + unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); + return ret; +} +#endif + static abi_long do_pipe2(int host_pipe[], int flags) { #ifdef CONFIG_PIPE2 @@ -9045,106 +9277,11 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: - { - abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; - fd_set rfds, wfds, efds; - fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; - struct timespec ts, *ts_ptr; - - /* - * The 6th arg is actually two args smashed together, - * so we cannot use the C library. - */ - sigset_t set; - struct { - sigset_t *set; - size_t size; - } sig, *sig_ptr; - - abi_ulong arg_sigset, arg_sigsize, *arg7; - target_sigset_t *target_sigset; - - n =3D arg1; - rfd_addr =3D arg2; - wfd_addr =3D arg3; - efd_addr =3D arg4; - ts_addr =3D arg5; - - ret =3D copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n= ); - if (ret) { - return ret; - } - ret =3D copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n= ); - if (ret) { - return ret; - } - ret =3D copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n= ); - if (ret) { - return ret; - } - - /* - * This takes a timespec, and not a timeval, so we cannot - * use the do_select() helper ... - */ - if (ts_addr) { - if (target_to_host_timespec(&ts, ts_addr)) { - return -TARGET_EFAULT; - } - ts_ptr =3D &ts; - } else { - ts_ptr =3D NULL; - } - - /* Extract the two packed args for the sigset */ - if (arg6) { - sig_ptr =3D &sig; - sig.size =3D SIGSET_T_SIZE; - - arg7 =3D lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1= ); - if (!arg7) { - return -TARGET_EFAULT; - } - arg_sigset =3D tswapal(arg7[0]); - arg_sigsize =3D tswapal(arg7[1]); - unlock_user(arg7, arg6, 0); - - if (arg_sigset) { - sig.set =3D &set; - if (arg_sigsize !=3D sizeof(*target_sigset)) { - /* Like the kernel, we enforce correct size sigset= s */ - return -TARGET_EINVAL; - } - target_sigset =3D lock_user(VERIFY_READ, arg_sigset, - sizeof(*target_sigset), 1); - if (!target_sigset) { - return -TARGET_EFAULT; - } - target_to_host_sigset(&set, target_sigset); - unlock_user(target_sigset, arg_sigset, 0); - } else { - sig.set =3D NULL; - } - } else { - sig_ptr =3D NULL; - } - - ret =3D get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_pt= r, - ts_ptr, sig_ptr)); - - if (!is_error(ret)) { - if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) - return -TARGET_EFAULT; - if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) - return -TARGET_EFAULT; - if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) - return -TARGET_EFAULT; - - if (ts_addr && host_to_target_timespec(ts_addr, &ts)) - return -TARGET_EFAULT; - } - } - return ret; + return do_pselect6(arg1, arg2, arg3, arg4, arg5, arg6, false); +#endif +#ifdef TARGET_NR_pselect6_time64 + case TARGET_NR_pselect6_time64: + return do_pselect6(arg1, arg2, arg3, arg4, arg5, arg6, true); #endif #ifdef TARGET_NR_symlink case TARGET_NR_symlink: @@ -10076,114 +10213,17 @@ static abi_long do_syscall1(void *cpu_env, int n= um, abi_long arg1, case TARGET_NR__newselect: return do_select(arg1, arg2, arg3, arg4, arg5); #endif -#if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) -# ifdef TARGET_NR_poll +#ifdef TARGET_NR_poll case TARGET_NR_poll: -# endif -# ifdef TARGET_NR_ppoll + return do_ppoll(arg1, arg2, arg3, arg4, arg5, false, false); +#endif +#ifdef TARGET_NR_ppoll case TARGET_NR_ppoll: -# endif - { - struct target_pollfd *target_pfd; - unsigned int nfds =3D arg2; - struct pollfd *pfd; - unsigned int i; - - pfd =3D NULL; - target_pfd =3D NULL; - if (nfds) { - if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { - return -TARGET_EINVAL; - } - - target_pfd =3D lock_user(VERIFY_WRITE, arg1, - sizeof(struct target_pollfd) * nfds= , 1); - if (!target_pfd) { - return -TARGET_EFAULT; - } - - pfd =3D alloca(sizeof(struct pollfd) * nfds); - for (i =3D 0; i < nfds; i++) { - pfd[i].fd =3D tswap32(target_pfd[i].fd); - pfd[i].events =3D tswap16(target_pfd[i].events); - } - } - - switch (num) { -# ifdef TARGET_NR_ppoll - case TARGET_NR_ppoll: - { - struct timespec _timeout_ts, *timeout_ts =3D &_timeout_ts; - target_sigset_t *target_set; - sigset_t _set, *set =3D &_set; - - if (arg3) { - if (target_to_host_timespec(timeout_ts, arg3)) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EFAULT; - } - } else { - timeout_ts =3D NULL; - } - - if (arg4) { - if (arg5 !=3D sizeof(target_sigset_t)) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EINVAL; - } - - target_set =3D lock_user(VERIFY_READ, arg4, sizeof(tar= get_sigset_t), 1); - if (!target_set) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EFAULT; - } - target_to_host_sigset(set, target_set); - } else { - set =3D NULL; - } - - ret =3D get_errno(safe_ppoll(pfd, nfds, timeout_ts, - set, SIGSET_T_SIZE)); - - if (!is_error(ret) && arg3) { - host_to_target_timespec(arg3, timeout_ts); - } - if (arg4) { - unlock_user(target_set, arg4, 0); - } - break; - } -# endif -# ifdef TARGET_NR_poll - case TARGET_NR_poll: - { - struct timespec ts, *pts; - - if (arg3 >=3D 0) { - /* Convert ms to secs, ns */ - ts.tv_sec =3D arg3 / 1000; - ts.tv_nsec =3D (arg3 % 1000) * 1000000LL; - pts =3D &ts; - } else { - /* -ve poll() timeout means "infinite" */ - pts =3D NULL; - } - ret =3D get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0)); - break; - } -# endif - default: - g_assert_not_reached(); - } - - if (!is_error(ret)) { - for(i =3D 0; i < nfds; i++) { - target_pfd[i].revents =3D tswap16(pfd[i].revents); - } - } - unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * n= fds); - } - return ret; + return do_ppoll(arg1, arg2, arg3, arg4, arg5, true, false); +#endif +#ifdef TARGET_NR_ppoll_time64 + case TARGET_NR_ppoll_time64: + return do_ppoll(arg1, arg2, arg3, arg4, arg5, true, true); #endif case TARGET_NR_flock: /* NOTE: the flock constant seems to be the same for every --=20 2.25.1 From nobody Sat May 18 07:48:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1598308366; cv=pass; d=zohomail.com; s=zohoarc; b=WTQi0u8y4n1LjsKPt/vEPYKIBwQV9YFCWxWh7QzUgx6Qn8LgccnE1g1wq8WCWSA++sGVsg9Sj9qdAM+2R4ggf8CDgw80XkLAiKG1VTMws//pf309wKkePcqKt69eAWwm/cBoxwzAbOIUpQbz/4rXh0qzw3FHdvPpwyr4tThCYJE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598308366; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VpWUKwMHjkh1T/V+Ct2KD30TGl2imXue0l6/0vKi+pE=; b=anI5UYWLOPqCnFg8+Sz7yq5/sJs5wLgakBgF5rMPaQBUO/k+Bw7JblDRFHPL5pQtjcv1708560KOz5Bl84CeJZFlUQc38KgdrDiXl00Rr8QAzUR6zepCaNTbAR+kSQHUIt/+HMV8GGxcR3WlH47phNh1f0jMMjzlS5p2zSng+YE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598308365930980.9746802508508; Mon, 24 Aug 2020 15:32:45 -0700 (PDT) Received: from localhost ([::1]:44336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAL1A-0006UV-J5 for importer@patchew.org; Mon, 24 Aug 2020 18:32:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAL0E-0005Go-LK for qemu-devel@nongnu.org; Mon, 24 Aug 2020 18:31:46 -0400 Received: from mail-eopbgr10128.outbound.protection.outlook.com ([40.107.1.128]:39578 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAL0B-0003by-G0 for qemu-devel@nongnu.org; Mon, 24 Aug 2020 18:31:46 -0400 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) by VI1PR03MB4575.eurprd03.prod.outlook.com (2603:10a6:803:59::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 22:31:07 +0000 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362]) by VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362%6]) with mapi id 15.20.3261.026; Mon, 24 Aug 2020 22:31:07 +0000 Received: from localhost.localdomain (147.91.217.235) by LO2P265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 22:31:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EJUC1yWNUbkCHX+Zwd5q7gljrCFEUqwzPxOjQVAquUWxPmHjPjkzh6BH9tRuqVKZ83TapAtLDDhvTHXQLrLIMnysOS6RtmdvpbSCnwQfib0iw7xG8jVIbl5fX5cxd8Q/ucRJ4zNoVcOVrERbFiMy+9WqTi2xiLVA/+NRorVEkhkH6KVlZKMm8GGHKrALo9SqUKs3quluP0zxniDmJzY1ceUSzt2kBR8xBf05R0AJNRLOXuFXCdEconP7u5XThLbqbJbNDbLYzY7OqmkCQMcdrIZTNSUCsJqnoPX1x4xs55huNd1w6PUVJmxMAtq0af39tL0eQaEC4n4mYKPERR6mKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VpWUKwMHjkh1T/V+Ct2KD30TGl2imXue0l6/0vKi+pE=; b=U8Dd5nEVvXlw/KiFQ9Fq7ncTtxbP0lwe67QBx6u06xg+UxP47+ie48g9OFsJleD9MLQZ1jGPqDaUcXwFn5fmCxi4Hk+xUqqd3peCjH03dPrity8G9II4vwNr22u1kA8p6XmGp/LN23ivJUfMqS9ARZJsQCGiC7/wafSR95siUugy13frcxj0wnBCGMF6rZqFF8LGQIE6WdAstWb1F+nD8WD7siLg7vNqIyaEpaldB4zatC7ztVuQuKnZycENXyV6IhRb24opBeUAXK6xxQadtRxKAmPwPUtrT8ACctvzr9Ewfyv191BK5FDCOhcX3f9JFcJJrFt9GBwI3k4k/BsMZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VpWUKwMHjkh1T/V+Ct2KD30TGl2imXue0l6/0vKi+pE=; b=NeZ6XY3H8tevdCcAcr08u+CpgvDF+F3YpAphDFDas6g6xuAK2/xbx5BBgjozT5t2J5blFp0xFJbv3XBSkxAfzgJKnhLAFAOisf6Tbn/W9ZYf3FKAl+Y1hMw0wMFaZPOT8bwbVywcUMNpy4Wy2Ccu/YR+NVDPOLz7Z/FeXzSIFDE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] linux-user: Add support for utimensat_time64() and semtimedop_time64() Date: Tue, 25 Aug 2020 00:30:50 +0200 Message-Id: <20200824223050.92032-3-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824223050.92032-1-Filip.Bozuta@syrmia.com> References: <20200824223050.92032-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::34) To VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [147.91.217.235] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d8ce107-ebd7-4380-f3cc-08d8487d645c X-MS-TrafficTypeDiagnostic: VI1PR03MB4575: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +QT+H2LJxb20UUNOhgNula1/yfWzyQfjS21AgOanm5/CW6fISwraSwEWEiQFohA1FqI8ENjwk4Z7ws9YVlLOfe6RhJhkofDHQmjJJ9skJmlfJgEUY9qeL/WX1ySjX4SHqjBnmHkp6lPE4xqeEMZnF1Jam7Pjtn7YR9XWKTaE/w3rw8bqE1S7SW48aVxBgcxG92FuToQgBqiUnEYIe/OlvpChU7JMpgYQCtiiwubT4ekrWdWGRmWuWWHP3M9gxaRzS6R4FG81jqr/JLZjcUTJB0BvM/z8XQ2TpbY3e52jKuHE+3gE/p5nrdfpj8rQNRqYDvT7faobj55kW0AAQnSjsPON5NNZa2C/Jg9dI3x+3wYYLOj0NV46jC7mChGED5k1H/KXiiTvwUZXBeMWjQBVru8r70FZsnf4Vav5joPEUSSuzjwCSsPSfI1Ayh1HkUlrW8MnULM64dCyZjZKJP9Hng== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR03MB5246.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(136003)(346002)(366004)(396003)(39830400003)(6506007)(6486002)(6916009)(83380400001)(69590400007)(2906002)(956004)(8676002)(2616005)(8936002)(26005)(478600001)(36756003)(54906003)(316002)(966005)(66556008)(66946007)(186003)(16526019)(4326008)(66476007)(6666004)(1076003)(52116002)(86362001)(107886003)(6512007)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: qr7zUaRrpigeCv7aJQicGtssxw+sU60LfjLwGS4UCUdh2PjHKi1bS9GvGX/nwXQb7+DnwQYinszlH4s+9nUPBp9EuXk55cveJOLX1dO6VFQxBL1VFXCBWVxHp2iHLQI4l880dh+ZDk4TVvy0RRx3nvFnpKMRcH6XSOPBr9SpSQ9/27U07DfejLIEj0e3vIAHbIFJL1sW2KgZI05dq08HZty7WZvkki7lEGSHJ1cxDR6UWv/srEdg+IRF1tQ/7k8HF1DG7vkZReAd7Jkqy9q9QR1d1tZHKpreWIYPY5EXUAcPZELethlmEU0WUD8Z8rf+e2F7Hg3nfz0XoPurrk4Z/wJSENHgZ+cejx/tEhBZfVb1BAFxiPQGpOFIrTeMTVAZdI0O6VzLBiOSfQOVTJVr5uEA+IwOy3ez3y+o1fay59YWCYcQ7mShBgpHzc3MAy5p+9Nvzbo6ZP58Dz2rARduuhbSw1FOTDzlN4FUE84REo0+7wz01CkExBBgV/3/lGQJ6RnbeJGMpHoTX+RfG1qejZX8SzBGR0W/0foJMB0RN17OpRHYa9Haz+UgCY5cVNV33rNd0o4/fjuaO1pLjDyxy/fHohcLC9XmLkgx+zi8gHwrNJwXzVz6UCErpe8pCVEftic86UdfvZhWD0lDUaQ77A== X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d8ce107-ebd7-4380-f3cc-08d8487d645c X-MS-Exchange-CrossTenant-AuthSource: VE1PR03MB5246.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 22:31:06.6479 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ltIOt99Xf2kfOBK9jif/xsQdS0b3eS2NNpOrvNiU5ldzKEkLOpyqS7ML1m8mHwElqEXpsgtjCZDphAc5WELGKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB4575 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=40.107.1.128; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 18:31:41 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" This patch introduces functionality for following time64 syscalls: *utimensat_time64() int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags); -- change file timestamps with nanosecond precision -- man page: https://man7.org/linux/man-pages/man2/utimensat.2.html *semtimedop_time64() int semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout); -- System V semaphore operations -- man page: https://www.man7.org/linux/man-pages/man2/semtimedop.2.html Implementation notes: Syscall 'utimensat_time64()' is implemented in similar way as its regular variants only difference being that time64 converting function is used to convert values of 'struct timespec' between host and target ('target_to_host_timespec64()'). For syscall 'semtimedop_time64()' and additional argument is added in function 'do_semtimedop()' through which the aproppriate 'struct time= spec' converting function is called (false for regular target_to_host_timespec= () and true for target_to_host_timespec64()). For 'do_ipc()' a check was added as that additional argument: 'TARGET_ABI_BITS =3D=3D 64'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 60 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fc6a6e32e4..4d460af744 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1253,7 +1253,8 @@ static inline abi_long target_to_host_timespec(struct= timespec *host_ts, #endif =20 #if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) = || \ - defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64) + defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64) = || \ + defined(TARGET_NR_utimensat_time64) || defined(TARGET_NR_semtimedop_ti= me64) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -4117,7 +4118,7 @@ static inline abi_long target_to_host_sembuf(struct s= embuf *host_sembuf, } =20 #if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) || \ - defined(TARGET_NR_semtimedop) + defined(TARGET_NR_semtimedop) || defined(TARGET_NR_semtimedop_time64) =20 /* * This macro is required to handle the s390 variants, which passes the @@ -4134,7 +4135,7 @@ static inline abi_long target_to_host_sembuf(struct s= embuf *host_sembuf, static inline abi_long do_semtimedop(int semid, abi_long ptr, unsigned nsops, - abi_long timeout) + abi_long timeout, bool time64) { struct sembuf sops[nsops]; struct timespec ts, *pts =3D NULL; @@ -4142,8 +4143,14 @@ static inline abi_long do_semtimedop(int semid, =20 if (timeout) { pts =3D &ts; - if (target_to_host_timespec(pts, timeout)) { - return -TARGET_EFAULT; + if (time64) { + if (target_to_host_timespec64(pts, timeout)) { + return -TARGET_EFAULT; + } + } else { + if (target_to_host_timespec(pts, timeout)) { + return -TARGET_EFAULT; + } } } =20 @@ -4657,7 +4664,7 @@ static abi_long do_ipc(CPUArchState *cpu_env, =20 switch (call) { case IPCOP_semop: - ret =3D do_semtimedop(first, ptr, second, 0); + ret =3D do_semtimedop(first, ptr, second, 0, false); break; case IPCOP_semtimedop: /* @@ -4667,9 +4674,9 @@ static abi_long do_ipc(CPUArchState *cpu_env, * to a struct timespec where the generic variant uses fifth parameter. */ #if defined(TARGET_S390X) - ret =3D do_semtimedop(first, ptr, second, third); + ret =3D do_semtimedop(first, ptr, second, third, TARGET_ABI_BITS = =3D=3D 64); #else - ret =3D do_semtimedop(first, ptr, second, fifth); + ret =3D do_semtimedop(first, ptr, second, fifth, TARGET_ABI_BITS = =3D=3D 64); #endif break; =20 @@ -9887,11 +9894,15 @@ static abi_long do_syscall1(void *cpu_env, int num,= abi_long arg1, #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: - return do_semtimedop(arg1, arg2, arg3, 0); + return do_semtimedop(arg1, arg2, arg3, 0, false); #endif #ifdef TARGET_NR_semtimedop case TARGET_NR_semtimedop: - return do_semtimedop(arg1, arg2, arg3, arg4); + return do_semtimedop(arg1, arg2, arg3, arg4, false); +#endif +#ifdef TARGET_NR_semtimedop_time64 + case TARGET_NR_semtimedop_time64: + return do_semtimedop(arg1, arg2, arg3, arg4, true); #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: @@ -11938,6 +11949,35 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_utimensat_time64 + case TARGET_NR_utimensat_time64: + { + struct timespec *tsp, ts[2]; + if (!arg3) { + tsp =3D NULL; + } else { + if (target_to_host_timespec64(ts, arg3)) { + return -TARGET_EFAULT; + } + if (target_to_host_timespec64(ts + 1, arg3 + + sizeof(struct target__kernel_timespec= ))) { + return -TARGET_EFAULT; + } + tsp =3D ts; + } + if (!arg2) + ret =3D get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); + else { + p =3D lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret =3D get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); + unlock_user(p, arg2, 0); + } + } + return ret; +#endif #ifdef TARGET_NR_futex case TARGET_NR_futex: return do_futex(arg1, arg2, arg3, arg4, arg5, arg6); --=20 2.25.1