From nobody Sun May 19 03:38:18 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=1598296982; cv=pass; d=zohomail.com; s=zohoarc; b=kg86ffaX1JYRfYJTD0qc4aBT43n0X8nOHSZ9pODNzzi54J0MaG2S5kP82Ups+SmsRQO0GLCVKYEzOuTB+ZKi5S9iy2HUNhA9Mds4y5t4TtaibAOYMsMJ+GfZmRRKYVQ3426YCTNDBQJNrnNxacKS4D6bQ97RrBVlZhfue63MfUc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598296982; 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=C7nBWuTR5c7BYDKK426It8dwWF6GornGuzvQ3D/NuvI=; b=QrQqGi95iKGavBIticfLMTlZL0s2KKwD373+LzCD6UvWjBk/BOv6sPVEg+tLf33E2MBtFGnjd3SKxndziWaa2cNRNBtelGnFXkIaqLnue05YLz9o/u47KBl8VJUf/Fa6ZcfFtXwOq/egWKnee35gukb/X05jyfKyL8Hmi7t7OEU= 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 1598296982451852.011208855326; Mon, 24 Aug 2020 12:23:02 -0700 (PDT) Received: from localhost ([::1]:37478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAI3Z-0007Dp-5K for importer@patchew.org; Mon, 24 Aug 2020 15:23:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAI2Q-0005w7-Th for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:21:50 -0400 Received: from mail-eopbgr70128.outbound.protection.outlook.com ([40.107.7.128]:6919 helo=EUR04-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 1kAI2O-0006qi-Nc for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:21:50 -0400 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) by VI1PR0301MB2254.eurprd03.prod.outlook.com (2603:10a6:800:29::24) 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 19:21:32 +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 19:21:31 +0000 Received: from localhost.localdomain (147.91.217.238) by ZR0P278CA0017.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24 via Frontend Transport; Mon, 24 Aug 2020 19:21:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F0JEmzJfb0xMi/vRStssN4UJ59i6csxhZ1FruBqGIobOJwh4HTEH0DVeMkC0oK2b9hEpSlR5WgffdXy2taBHpT/XhWj2aWHW3gS93sNe3zOEJcX4x7QspLEWt6lpKuRfMHrDOwEsc4I7XBFyKh7CEeMDlfF99obWqbblYTxBVgfyKyEYDI1Fq9+IilJNHUKlEL25Se79eLfqWV9Ig+dlNH7of0bIDwSrTllN5S/sBUyAek6xFimMbyja+JgI5aN5QgPrx2Q1x/jZMG7Ez4krlTl1SyTMpKe1UjbZYxO3Uw36M8KPJC05BvUx33h4jdWxuibFWFcPaEaTZLKhyimdjQ== 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=C7nBWuTR5c7BYDKK426It8dwWF6GornGuzvQ3D/NuvI=; b=heQ5Sjfr8j/yCFnhPPderawDVMLk7LQwuKas+sL/4nxmB2c1c2IJ3NZNuvJh7EuXW95ElwUpJAXEe/tfVz21hgazH/8p1a510216yQ9SuUvol1SqIu+NFh9RizCivCkW0bkcpc0OWfcPMx/rc9YGSTuL4ChmuNegg++d+NH8WGaUFuBqkYqRboyiR19s3avJjV1dpgK5dk59WhsZoH7ZIGT3C8Uwr/gbycC4Jhgh6g7ItZec/dTRQKkGYVgDz52DcljJIUkljR0xz/AdChDOh2S6AkWNwXCiNu7anbrgtlSpHM83rdOWEyuUjolnoKn9H+wtoAJDKTYJ4oXoJTbG+g== 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=C7nBWuTR5c7BYDKK426It8dwWF6GornGuzvQ3D/NuvI=; b=AdZUvyJ2VXyRdI2cdifCl+MPAVvgwwKs4zikkCe23s9sHRgFdMtTA3ty/pGA+3QoAzXWDPdCQ1TLjEnk2SUMvJlyDuI78uB3c+TujT42Nhkut3zy1tPGdcdHf3lYSUFKA+rvJ6J8f8ceR5XAiH5D1aR8omQY/hp5+47etC3rYRk= 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 v3 1/2] linux-user: Add support for 'clock_nanosleep_time64()' and 'clock_adjtime64()' Date: Mon, 24 Aug 2020 21:21:15 +0200 Message-Id: <20200824192116.65562-2-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824192116.65562-1-Filip.Bozuta@syrmia.com> References: <20200824192116.65562-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: ZR0P278CA0017.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::27) 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.238] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1527809d-c0b6-4da9-26ca-08d84862e7e6 X-MS-TrafficTypeDiagnostic: VI1PR0301MB2254: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QpkIB+9KDnXp3d4xKUmj2+Qhg/56OzyRUnWVKdWqDEGQVzHp0Nb2vUoXVefwuG1xbFKGjQL994K7buXhJ9VC4R0ehNuGSBoKOLlB1ugNCvixlmr8XBGN97wVR/1eWalxZvZKtE6p9m4dAIktZQiZrrKPphXmLuVN+MSioVodlcXclb6jhWBJEoxLvUYf7pbeHn5w9kMHux2j7zr/+r3RCp0RJ3dTD/W50kLPhy62M73TomiA9OxT4SSyv1pXMldagAug02q1oYUiUdSMHiUiriVN0yxq03ip8Kw1Kk1qo5mJCNAHMdieMEFniPnRtQCM/Y/YhvXwgFyMzCYy4Mo8BN3BPB4vVF5EFFHLtatYTBfCnMqYaOyQLB+vPA7eOveVlRdHuJC0Koj/idwUB5lyy4EQ0a7nAnvd7WhjFZppb2455iDZGsUgSbKlwDQpmroTFhVtb75KolXbw0sKTvYDhg== 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:(346002)(376002)(39830400003)(136003)(396003)(366004)(6666004)(956004)(2616005)(5660300002)(66556008)(66476007)(66946007)(2906002)(1076003)(478600001)(4326008)(107886003)(83380400001)(6916009)(6512007)(8936002)(6486002)(966005)(186003)(6506007)(69590400007)(16526019)(86362001)(316002)(52116002)(8676002)(36756003)(54906003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jeiflx+IHrl0DgX2UJuf5NOEEahjxh8AWbKBtMksfCMNhH1NAeQBHb63/lvDmK3T0AcpFSBe4B6/ZO+jXELc5lxYzLrsfAoCVhzzy5/UE9998qaIy//KrozV+O1+ixNasZ9jyrNOmadbA5OLQZ8hFQmjrZxsctFPN8j4NjhTM1njkCBaNSS5EMHFk+RfpNDxJKADlkUTmNxkUuSu19lslr7VMEErpLXEwZrxrQ3+wLEs+wPxTM/l0KqQe1vOAEcImMgGUTklc9lhVEwzCpvDZ2DoN8vZF+1n4QAeDRYQl3rQJ31w3K17oP2Auxk90spHlo71o4pc1zodjQvBSX4I+0n+QYjBM3bNUFvcZaniI5wOmnqdB4ewxJc5vlACv77wUX7mw6RbnhOx3zIcOC/9aThUk3k2ZqS9dbWvtkFWw7Ld3jdeT0Ys1JLx4B3hw2U9lTOu9IMLv6CnmaIoIkSduXxXBhn3/+kzc0C9xZDU+R6goz0RP9ZCq40Ry59LwDJ3vx/lGQ1P0k9h8hxehLA5wpp0VAsZO2rMhOu5qv6aCDLeIXSMAS0NzMahA+T8b6f2JBSHO+0wR87chHDWFX41nSn9S5UUMN/gEIknR8ZfpNRleXtPOc5jGbE1TBuDQAYFUDBg5ONWc0uqAioQiSsSyA== X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1527809d-c0b6-4da9-26ca-08d84862e7e6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR03MB5246.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 19:21:31.0368 (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: B0YgEuTHwci24sP9pM2ePADGawVud1VvYl4SlANfkbgse7idCe0vDv8Hk5MuMv+yxbIHGtzn6V0DQfXK95PxZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2254 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.7.128; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 15:21:42 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 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_NONE=-0.0001, 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: Riku Voipio , 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 implements functionality for following time64 syscall: *clock_nanosleep_time64() This is a year 2038 safe vairant of syscall: int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *request, struct timespec *remain) --high-resolution sleep with specifiable clock-- man page: https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html *clock_adjtime64() This is a year 2038 safe variant of syscall: int clock_adjtime(clockid_t clk_id, struct timex *buf) --tune kernel clock-- man page: https://man7.org/linux/man-pages/man2/clock_adjtime.2.html Implementation notes: Syscall 'clock_nanosleep_time64()' was implemented similarly to syscall 'clock_nanosleep()' except that 'host_to_target_timespec64()' and 'target_to_host_timespec64()' were used instead of the regular 'host_to_target_timespec()' and 'target_to_host_timespec()'. For 'clock_adjtime64()' a 64-bit target kernel version of 'struct timex' was defined in 'syscall_defs.h': 'struct target__kernel_timex'. This type was used to convert the values of 64-bit timex type between host and target. For this purpose a 64-bit timex converting functions 'target_to_host_timex64()' and 'host_to_target_timex64()'. An existing function 'copy_to_user_timeval64()' was used to convert the field 'time' which if of type 'struct timeval' from host to target. Function 'copy_from_user_timveal64()' was added in this patch and used to convert the 'time' field from target to host. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 137 +++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 31 +++++++++ 2 files changed, 166 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05f03919ff..a359bd8620 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -809,7 +809,8 @@ safe_syscall4(int, accept4, int, fd, struct sockaddr *,= addr, socklen_t *, len, safe_syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) #endif -#ifdef TARGET_NR_clock_nanosleep +#if defined(TARGET_NR_clock_nanosleep) || \ + defined(TARGET_NR_clock_nanosleep_time64) safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags, const struct timespec *, req, struct timespec *, rem) #endif @@ -1205,8 +1206,25 @@ static inline abi_long copy_to_user_timeval(abi_ulon= g target_tv_addr, return 0; } =20 +static inline abi_long copy_from_user_timeval64(struct timeval *tv, + abi_ulong target_tv_addr) +{ + struct target__kernel_sock_timeval *target_tv; + + if (!lock_user_struct(VERIFY_READ, target_tv, target_tv_addr, 1)) { + return -TARGET_EFAULT; + } + + __get_user(tv->tv_sec, &target_tv->tv_sec); + __get_user(tv->tv_usec, &target_tv->tv_usec); + + unlock_user_struct(target_tv, target_tv_addr, 0); + + return 0; +} + static inline abi_long copy_to_user_timeval64(abi_ulong target_tv_addr, - const struct timeval *tv) + const struct timeval *tv) { struct target__kernel_sock_timeval *target_tv; =20 @@ -6771,6 +6789,87 @@ static inline abi_long host_to_target_timex(abi_long= target_addr, } #endif =20 + +#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME) +static inline abi_long target_to_host_timex64(struct timex *host_tx, + abi_long target_addr) +{ + struct target__kernel_timex *target_tx; + + if (copy_from_user_timeval64(&host_tx->time, target_addr + + offsetof(struct target__kernel_timex, + time))) { + return -TARGET_EFAULT; + } + + if (!lock_user_struct(VERIFY_READ, target_tx, target_addr, 1)) { + return -TARGET_EFAULT; + } + + __get_user(host_tx->modes, &target_tx->modes); + __get_user(host_tx->offset, &target_tx->offset); + __get_user(host_tx->freq, &target_tx->freq); + __get_user(host_tx->maxerror, &target_tx->maxerror); + __get_user(host_tx->esterror, &target_tx->esterror); + __get_user(host_tx->status, &target_tx->status); + __get_user(host_tx->constant, &target_tx->constant); + __get_user(host_tx->precision, &target_tx->precision); + __get_user(host_tx->tolerance, &target_tx->tolerance); + __get_user(host_tx->tick, &target_tx->tick); + __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); + __get_user(host_tx->jitter, &target_tx->jitter); + __get_user(host_tx->shift, &target_tx->shift); + __get_user(host_tx->stabil, &target_tx->stabil); + __get_user(host_tx->jitcnt, &target_tx->jitcnt); + __get_user(host_tx->calcnt, &target_tx->calcnt); + __get_user(host_tx->errcnt, &target_tx->errcnt); + __get_user(host_tx->stbcnt, &target_tx->stbcnt); + __get_user(host_tx->tai, &target_tx->tai); + + unlock_user_struct(target_tx, target_addr, 0); + return 0; +} + +static inline abi_long host_to_target_timex64(abi_long target_addr, + struct timex *host_tx) +{ + struct target__kernel_timex *target_tx; + + if (copy_to_user_timeval64(target_addr + + offsetof(struct target__kernel_timex, time), + &host_tx->time)) { + return -TARGET_EFAULT; + } + + if (!lock_user_struct(VERIFY_WRITE, target_tx, target_addr, 0)) { + return -TARGET_EFAULT; + } + + __put_user(host_tx->modes, &target_tx->modes); + __put_user(host_tx->offset, &target_tx->offset); + __put_user(host_tx->freq, &target_tx->freq); + __put_user(host_tx->maxerror, &target_tx->maxerror); + __put_user(host_tx->esterror, &target_tx->esterror); + __put_user(host_tx->status, &target_tx->status); + __put_user(host_tx->constant, &target_tx->constant); + __put_user(host_tx->precision, &target_tx->precision); + __put_user(host_tx->tolerance, &target_tx->tolerance); + __put_user(host_tx->tick, &target_tx->tick); + __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); + __put_user(host_tx->jitter, &target_tx->jitter); + __put_user(host_tx->shift, &target_tx->shift); + __put_user(host_tx->stabil, &target_tx->stabil); + __put_user(host_tx->jitcnt, &target_tx->jitcnt); + __put_user(host_tx->calcnt, &target_tx->calcnt); + __put_user(host_tx->errcnt, &target_tx->errcnt); + __put_user(host_tx->stbcnt, &target_tx->stbcnt); + __put_user(host_tx->tai, &target_tx->tai); + + unlock_user_struct(target_tx, target_addr, 1); + return 0; +} +#endif + static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp, abi_ulong target_addr) { @@ -9726,6 +9825,21 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, } } return ret; +#endif +#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME) + case TARGET_NR_clock_adjtime64: + { + struct timex htx; + + if (target_to_host_timex64(&htx, arg2) !=3D 0) { + return -TARGET_EFAULT; + } + ret =3D get_errno(clock_adjtime(arg1, &htx)); + if (!is_error(ret) && host_to_target_timex64(arg2, &htx)) { + return -TARGET_EFAULT; + } + } + return ret; #endif case TARGET_NR_getpgid: return get_errno(getpgid(arg1)); @@ -11684,6 +11798,25 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return ret; } #endif +#ifdef TARGET_NR_clock_nanosleep_time64 + case TARGET_NR_clock_nanosleep_time64: + { + struct timespec ts; + + if (target_to_host_timespec64(&ts, arg3)) { + return -TARGET_EFAULT; + } + + ret =3D get_errno(safe_clock_nanosleep(arg1, arg2, + &ts, arg4 ? &ts : NULL)); + + if (ret =3D=3D -TARGET_EINTR && arg4 && arg2 !=3D TIMER_ABSTIME && + host_to_target_timespec64(arg4, &ts)) { + return -TARGET_EFAULT; + } + return ret; + } +#endif =20 #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 152ec637cb..3783c5a07e 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -287,6 +287,37 @@ struct target_timex { abi_int:32; abi_int:32; abi_int:32; }; =20 +struct target__kernel_timex { + abi_uint modes; /* Mode selector */ + abi_int: 32; /* pad */ + abi_llong offset; /* Time offset */ + abi_llong freq; /* Frequency offset */ + abi_llong maxerror; /* Maximum error (microseconds) */ + abi_llong esterror; /* Estimated error (microseconds) */ + abi_int status; /* Clock command/status */ + abi_int: 32; /* pad */ + abi_llong constant; /* PLL (phase-locked loop) time constant= */ + abi_llong precision; /* Clock precision (microseconds, ro) */ + abi_llong tolerance; /* Clock freq. tolerance (ppm, ro) */ + struct target__kernel_sock_timeval time; /* Current time */ + abi_llong tick; /* Microseconds between clock ticks */ + abi_llong ppsfreq; /* PPS (pulse per second) frequency */ + abi_llong jitter; /* PPS jitter (ro); nanoseconds */ + abi_int shift; /* PPS interval duration (seconds) */ + abi_int: 32; /* pad */ + abi_llong stabil; /* PPS stability */ + abi_llong jitcnt; /* PPS jitter limit exceeded (ro) */ + abi_llong calcnt; /* PPS calibration intervals */ + abi_llong errcnt; /* PPS calibration errors */ + abi_llong stbcnt; /* PPS stability limit exceeded */ + abi_int tai; /* TAI offset */ + + /* Further padding bytes to allow for future expansion */ + abi_int:32; abi_int:32; abi_int:32; abi_int:32; + abi_int:32; abi_int:32; abi_int:32; abi_int:32; + abi_int:32; abi_int:32; abi_int:32; +}; + typedef abi_long target_clock_t; =20 #define TARGET_HZ 100 --=20 2.25.1 From nobody Sun May 19 03:38:18 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=1598296977; cv=pass; d=zohomail.com; s=zohoarc; b=Jel8Y/ThKQLgPMcDGLWbITMxqSx11gvedLDRSrxcVWjzml28S530bK1HvJVotV/JsJVnSFBHEgdUPJSh+XisfMvP0ylrSItbjUBkFwDqhsLjYLoBicJZBf/KvS38CyZLmt2tsZkXkSsU8W3mVuyO/K9w99Vgi7iUQJ3Flr7vHm4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598296977; 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=ggqDEXsd5E6qQLIjbuwhSkczyc9cXyy9GfvRMFHH/b4=; b=DJwCv6HnADdbbbHhp+EFnfJxfPaOMc7IHbCm2fLdS1vxGjKqGKjH1APIVnX2YAZYELpl7tbT7RhcIxf+834/+cfnyVOFex0uWhlD1XQ+B2VIEzSUyVG99g2O6zR93MEy7p+RT/yefMf+gtw1NXh1CchrkugSxO5vJqIfdJfDies= 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 1598296977334783.342948144267; Mon, 24 Aug 2020 12:22:57 -0700 (PDT) Received: from localhost ([::1]:37270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAI3T-00078i-JB for importer@patchew.org; Mon, 24 Aug 2020 15:22:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAI2O-0005su-Ar for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:21:48 -0400 Received: from mail-eopbgr70128.outbound.protection.outlook.com ([40.107.7.128]:6919 helo=EUR04-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 1kAI2M-0006qi-IN for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:21:48 -0400 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) by VI1PR0301MB2254.eurprd03.prod.outlook.com (2603:10a6:800:29::24) 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 19:21:32 +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 19:21:32 +0000 Received: from localhost.localdomain (147.91.217.238) by ZR0P278CA0017.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24 via Frontend Transport; Mon, 24 Aug 2020 19:21:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jSbjeO/huMAzJpyGyHOf66xFtHBc6UHih3gfFGgAIS54dY+v1F6JbefF0BoHqAoV1ZTGFAwx++azMKhbYDY3onLheFB2tzdNu+Cl6/+VAxs1ffg/cHWsHeWiUby+zHxk98AgIIo9upo5gqXoRHQHqC/8MP/Dne6+SODXjuw+6kLWZvtlXgSwW5AUG50p1LdiROMzb1KSorsCTaVdR30rSpR1AviT5OTxGPXiVghXih7GzPNi3j1pz5CXfrYT/iKbQsOTZgUUyUuFfb+Oie0MYj2mr609ZBKZFhgdJZoqEluNozS6S6IRNBcfUbUoTdy16XkE2q74lfgn/eVrNwtdmg== 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=ggqDEXsd5E6qQLIjbuwhSkczyc9cXyy9GfvRMFHH/b4=; b=VpaA2F85KK1EpIm0vR4NUxyx0z9dlZZupr7e7VRyWQNwokVf3ItOPO7q5UD8Fbf5cakocHji1lXJDUutGQp9YrcVmFp/2/wtBhlDVnLubAnnDsiuGt6ehdbX3PI/xeZbyTv9F39yvrj79WJe+b95mLuPIlZGg+8/O6c6g1L4GX1AI8/sSo36un2ttCM1zyYZjRD2sKneAnf+8vvkzit52JeB+Ly5Wbam75Kv8Qd7POW9mMMypo449sG0SxfaPcxkjbHe+9KTSjwIATNkkVb4HSxs+I6PL1Fv4HWB4wzx5EPz3YJrZ+asQb7LDnYgWg6+TEew1OO8x1/F6jwGu3gluQ== 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=ggqDEXsd5E6qQLIjbuwhSkczyc9cXyy9GfvRMFHH/b4=; b=GAgXKGFr8aXW0MY5jSuuE+sCwt4MdP7oF7atOgvZD9Pqd/FZadIlPPJCIoCueXKU5KuFrUpX9f+zbZBC0oPoxu8NsDFDKmf1sNqv1yUqokZ89Iae8bwo2DyCYqJiRSMVhew+T7e85BljVzME9ndh1cIAfxjL435HD/hDbeICQDU= 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 v3 2/2] linux-user: Add support for 'rt_sigtimedwait_time64()' and 'sched_rr_get_interval_time64()' Date: Mon, 24 Aug 2020 21:21:16 +0200 Message-Id: <20200824192116.65562-3-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824192116.65562-1-Filip.Bozuta@syrmia.com> References: <20200824192116.65562-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: ZR0P278CA0017.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::27) 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.238] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69226eb6-51ec-4581-c6ad-08d84862e867 X-MS-TrafficTypeDiagnostic: VI1PR0301MB2254: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t3epBBC2926yJWX8mKqbDr9SATCSs+5Pe+McysobhzDIKCf4gUfN8BY1JL0IpHhSmtPVNrRuBZACG6Up3ykDZq/lUlfLgW+DJx1g9e+kMcnM4KungWGGxuV5Oub5o9braM0M/5UDn9uRDlztIPIbHjHlMf1/Gmr5jR4hqQ9/5stm9ei3dz24m053+kDr5+Heo+k4EeuTd3BKIB7q7V8wn7G6oB9iCESLcIpZphrNFsUifvnCc4qGtEASafJFsDKt6e+XjQh0h9Qn5ZnapMYThwvOQtrH1BZMVCY+iVKcZtmzxmVF9aZYxNN24AHrcfaUHlmrDb2gY/W2wAEYpsdEANWiDOjWJg89Bb5EZcGiNN36JCAxnXMUJugZHREEmG6bn65ZxFs/+jKM0rlqEasB2CELULg2VkUZUKWKp1DhZIx6bZBw/hWxkqBJH1xdXQExvAYn4CKsT1IRa/QYRWwogA== 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:(346002)(376002)(39830400003)(136003)(396003)(366004)(6666004)(956004)(2616005)(5660300002)(66556008)(66476007)(66946007)(2906002)(1076003)(478600001)(4326008)(107886003)(83380400001)(6916009)(6512007)(8936002)(6486002)(966005)(186003)(6506007)(69590400007)(16526019)(86362001)(316002)(52116002)(8676002)(36756003)(54906003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cMqE0IJJ+E7v52BVuNLNPRUDmSMVZrs6tpQVcrD+xzZnhmt1qv5tuIZ7RzQknEDLpJuNbgGIY5+W9JE4V92/3gDewVCR6MM/aw3B6WDEt6kPtIJXd/jeUu4Qo8y/HclitzepnGPW1MTtKDjxfwrX1jFDul21zjfaVsanJZ4kG+bdZy5olNOfatNxzTiWOW342eqwiO0i1Xgp0Q4jsK4xHdZ9y/k5rOx+9Y5zTKW/m+rOpP4SD8fiOOqrhu3DEB+P5l1TcKnOcI3VsffAFCRERdvk+Hfp6T8IRcLwostiaCNpgLMo4v7F0Bc3Bv31F8Z+4Onp7NjEQLPpqUhbUn/L/4gnAJh9FUfadz7dAHDPuOY9ufwaUq2plU0u6Ly2rjoqkzKIaZ3v3fpmF4C1+N/AvCNq3MRl2QIBRUVvEtoJxkOiVpkGiKab0wDDiKFBD7djUpR5Mb94B4D6tehLV1UVowpZXNSTraTQOTreFKJnRrEBES9CShbKl7iynqRdsZNAKHqGANi3nKsLFcg6L1oGDTHv/raJM4JkIYTieqNGDEhr/zbiuxgGSx4b1latnz681l0PeQQz9erPP8YSGJRV2F5loN9JvHls/oM7NhTip8e25XyHBRESDVlzEghp4HGmDij8Ao/CV/OpJJF6X1vo/w== X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69226eb6-51ec-4581-c6ad-08d84862e867 X-MS-Exchange-CrossTenant-AuthSource: VE1PR03MB5246.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 19:21:31.8453 (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: vXKLYZDLUjBIfDW/tvNM8yb4keuUmOEkj79tdqkBNKxU1JHshuBuEvt9swr1kipciRcNRER3HHFEWV+6rDTBRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0301MB2254 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.7.128; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 15:21:42 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 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_NONE=-0.0001, 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: Riku Voipio , 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 implements functionality for following time64 syscalls: *rt_sigtimedwait_time64() This is a year 2038 safe variant of syscall: int rt_sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout, size_t sigsetsize) --synchronously wait for queued signals-- man page: https://man7.org/linux/man-pages/man2/rt_sigtimedwait.2.html *sched_rr_get_interval_time64() This is a year 2038 safe variant of syscall: int sched_rr_get_interval(pid_t pid, struct timespec *tp) --get the SCHED_RR interval for the named process-- man page: https://man7.org/linux/man-pages/man2/sched_rr_get_interval.2= .html Implementation notes: These syscalls were implemented in similar ways like 'rt_sigtimedwait()' and 'sched_rr_get_interval()' except that functions 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used to convert values of 'struct timespec' between host and target. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a359bd8620..0533a5a5bb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8831,6 +8831,48 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, } } return ret; +#endif +#ifdef TARGET_NR_rt_sigtimedwait_time64 + case TARGET_NR_rt_sigtimedwait_time64: + { + sigset_t set; + struct timespec uts, *puts; + siginfo_t uinfo; + + if (arg4 !=3D sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + + p =3D lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, p); + unlock_user(p, arg1, 0); + if (arg3) { + puts =3D &uts; + if (target_to_host_timespec64(puts, arg3)) { + return -TARGET_EFAULT; + } + } else { + puts =3D NULL; + } + ret =3D get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts, + SIGSET_T_SIZE)); + if (!is_error(ret)) { + if (arg2) { + p =3D lock_user(VERIFY_WRITE, arg2, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &uinfo); + unlock_user(p, arg2, sizeof(target_siginfo_t)); + } + ret =3D host_to_target_signal(ret); + } + } + return ret; #endif case TARGET_NR_rt_sigqueueinfo: { @@ -10351,6 +10393,17 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_sched_rr_get_interval_time64 + case TARGET_NR_sched_rr_get_interval_time64: + { + struct timespec ts; + ret =3D get_errno(sched_rr_get_interval(arg1, &ts)); + if (!is_error(ret)) { + ret =3D host_to_target_timespec64(arg2, &ts); + } + } + return ret; +#endif #if defined(TARGET_NR_nanosleep) case TARGET_NR_nanosleep: { --=20 2.25.1