From nobody Tue Dec 16 03:23:59 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.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; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1583519612; cv=none; d=zohomail.com; s=zohoarc; b=e5EHdkCZIapZhB2zKJ7T8vhAYHdVbn8BbNWuVMsFmjcKTggDrLqeCoG6pLAYeYKY2JyjdzhMkTJARKAJiCkRmXM2TEzEnWyQHfDQ7/yaAAcdNG4BI+BuqHxe5QebYakeg2tno8vTczkB2ZjBeV5VTDs423XtFHoySp2JDneKotM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583519612; h=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=RrwWVC0k41MmpbFlLWoH3f/PNwg0LU5LISY0KjGv7Ss=; b=GT1NviaKCMKQFxXpXAQigDQigVEdyEMLjg0HBMpzuTi2JRxtN7G6zdeCQJmKxUrSkTGrsa6UG6uvkej3tyUYNIy6lRdo5ajDTDSfhot1bRZB+si0vr5CQ/0SO6iTIoFUjs0Zjn7jbu5Ed3vrEmY0WuBQBWnaCgYn65OpR16W84M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583519612172169.52685598270193; Fri, 6 Mar 2020 10:33:32 -0800 (PST) Received: from localhost ([::1]:40804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAHmt-0000k5-5f for importer@patchew.org; Fri, 06 Mar 2020 13:33:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAHlX-0008EM-22 for qemu-devel@nongnu.org; Fri, 06 Mar 2020 13:32:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAHlV-0003Tu-Nj for qemu-devel@nongnu.org; Fri, 06 Mar 2020 13:32:06 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:47162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAHlV-0003Q8-Eq; Fri, 06 Mar 2020 13:32:05 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Mar 2020 02:31:46 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 10:23:53 -0800 Received: from risc6-mainframe.sdcorp.global.sandisk.com (HELO risc6-mainframe.int.fusionio.com) ([10.196.158.235]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Mar 2020 10:31:43 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1583519532; x=1615055532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4Bhx9QdhIgpC1T3sfDyOZNyN2dm4mKGOjTxObaOqx5U=; b=Vn2hh65d5QOuf2C6onEEgk6bDkbrLw0mWgmWTnQV3sVGAB3nlTTSprqQ uyWoOt26lZBeV8hAwi3PQBvq2hunlYT2qCax+aBddg8NUE0wKDX8vWDFP QhgTn5qgfqEkSSvQlUrw++Ea/AYwEnSp3K3GVzcjKkVH09TLLkKvt63Lf MuC3BQ69xzrB2pW7XeB5PY0abMXoM6vhr6xi7OzPj2qdBfmTync9r9ZIV wTw/Ymi11YiWFKmiii2LnwlYUtsaFi9bDdzkStPMPxl9k346wPgoLLG2B p0PxehJd6v8MpJytnExuUQoPZadycOArNygzGlNbL2wKVunDb+GqZg2IN g==; IronPort-SDR: 1zF5nKzLnSjkJPBi5MHy8VZNJi7c5yJ3H6NRfvRxvrIzRGiH+yNeG+tx12Olq5z++FkFZvTDgw qk+WYxnbCD5y8FU1go5JoqAkqCnHZBk1zCXTRC9CtMke4I5/KC+Ui5beyVc6wvpH//dyh4jPzZ sVs9MhOloHAhbOMpwwHTPajwJMXvFaT2JiuN6MSpLabzmodXI+GXioYRV8wjbnpI4kVlBMEJvO onF/edjPxE9dYt3hoGYF7jC7+eIZuilCyAEZnY2QgCOWOu2ocMX7j+aBg1dcYv3YaavMnTzskh PzY= X-IronPort-AV: E=Sophos;i="5.70,523,1574092800"; d="scan'208";a="233755496" IronPort-SDR: WtUEOaHRqP8RsT5MFW/FtD68KETkPZ8NGeGIlkUtjVlaSXKv50Ck7WmjwYn8CBmT2TPg9mRvSq YBxFqWtbVaKx70SdGXyIqlE8uGyZgiC59Db3rSlb+IZY9x8mwFTHkJfqQx/BCkKv5Ff7BqUwRe XE1FC2SJoFju32q7SsJdyzCIY3ODICakhJlXXtwRlwVxEc2M8zilOVHL4zniiqWo1lJJJ6iThK oB4091kl7VA53zSPU3RImPo9MlfLiHn1YDSFJ/bZge0PhaYM/ap+mndThowKUV/5eQ9yL4dpmM aWyh3oZbMWBbWcny0J/x3FZE IronPort-SDR: +kA2M0/fxCDWIjD5hwKnf+SQ/ANpCpwoveJ03vUyo5wjtTAUN7tVWnoRqZnJEKMEtsLsg0vzwx H6zWE0dHPQqzc9swUgdND7OCRTRKntx9h0jjtkChC72CsP4p6Iv6ssYXXlfBCep1ESbveI/CLj /SIvAIbMJ5yg2kWLzBFUgVd/Q+SDuKrevy/0DAjGxJwkma8Pxd7bo2P3+/IG3UtWZKrtO79m+F H67EVA7K+k65qSnMii/DOS62v7upnnIv3vFx+RdVmhRrff0YOQKPBMPjLOHiq3GiiOSQpLQxRD ctc= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, aleksandar.m.mail@gmail.com, laurent@vivier.eu Subject: [PATCH v6 2/4] linux-user/syscall: Add support for clock_gettime64/clock_settime64 Date: Fri, 6 Mar 2020 10:24:25 -0800 Message-Id: <5fa31f8938fb16e6d07d3ec10e6ddb7a4e274f79.1583518447.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 68.232.143.124 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: alistair.francis@wdc.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add support for the clock_gettime64/clock_settime64 syscalls. If your host is 64-bit or is 32-bit with the *_time64 syscall then the timespec will correctly be a 64-bit time_t. Otherwise the host will return a 32-bit time_t which will be rounded to 64-bits. This will be incorrect after y2038. Signed-off-by: Alistair Francis Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1a7df23440..0f219b26c1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1231,6 +1231,22 @@ static inline abi_long target_to_host_timespec(struc= t timespec *host_ts, } #endif =20 +#if defined(TARGET_NR_clock_settime64) +static inline abi_long target_to_host_timespec64(struct timespec *host_ts, + abi_ulong target_addr) +{ + struct target__kernel_timespec *target_ts; + + if (!lock_user_struct(VERIFY_READ, target_ts, target_addr, 1)) { + return -TARGET_EFAULT; + } + __get_user(host_ts->tv_sec, &target_ts->tv_sec); + __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); + unlock_user_struct(target_ts, target_addr, 0); + return 0; +} +#endif + static inline abi_long host_to_target_timespec(abi_ulong target_addr, struct timespec *host_ts) { @@ -11460,6 +11476,18 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return ret; } #endif +#ifdef TARGET_NR_clock_settime64 + case TARGET_NR_clock_settime64: + { + struct timespec ts; + + ret =3D target_to_host_timespec64(&ts, arg2); + if (!is_error(ret)) { + ret =3D get_errno(clock_settime(arg1, &ts)); + } + return ret; + } +#endif #ifdef TARGET_NR_clock_gettime case TARGET_NR_clock_gettime: { @@ -11471,6 +11499,17 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return ret; } #endif +#ifdef TARGET_NR_clock_gettime64 + case TARGET_NR_clock_gettime64: + { + struct timespec ts; + ret =3D get_errno(clock_gettime(arg1, &ts)); + if (!is_error(ret)) { + ret =3D host_to_target_timespec64(arg2, &ts); + } + return ret; + } +#endif #ifdef TARGET_NR_clock_getres case TARGET_NR_clock_getres: { --=20 2.25.1