From nobody Mon Feb 9 19:55:41 2026 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=1584144399; cv=none; d=zohomail.com; s=zohoarc; b=mC/fLi2Nx+qQNHrRvdV3fekNG6qOJBE0gIFz2ZGq3VhdYyeeUD+9WwQxZDAmN/MMgTV95nZ/UTlGnZpnzf9vkgkDVGr20DzPpVidxYZqQsFQg0+M6cpN4g0+q+jMLqQb9KKhcpmDf7Vjr0CQDpdle2G1N5PLco0ca67Pd2hvLRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584144399; 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=vXZLVJLywsOT1sb4Ma7uQdD89PFSguXsKB2Vv+WlPao=; b=d2UB3X22zGgqfwYG45hhjsSo/ijvAg2WzGG5n7NqQSLCXzrzSI1XEaBMaeR977XIO6V/+UYBWrUrJ8xQgwQGutPjddjt+VnseLt59IMGZnef1KT5TBDJ+XGq9wCjqrf1RNJFIa6xtonZcbIYEn241oSjKhxq/OyO9FFQXBbwSZU= 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 1584144399738592.1368644528851; Fri, 13 Mar 2020 17:06:39 -0700 (PDT) Received: from localhost ([::1]:39212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCuK6-0004n0-N5 for importer@patchew.org; Fri, 13 Mar 2020 20:06:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49532) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCuHs-0002Mq-NC for qemu-devel@nongnu.org; Fri, 13 Mar 2020 20:04:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCuHr-0002lb-LK for qemu-devel@nongnu.org; Fri, 13 Mar 2020 20:04:20 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:59693) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCuHr-0002Yq-Bw; Fri, 13 Mar 2020 20:04:19 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Mar 2020 08:04:34 +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; 13 Mar 2020 16:56:15 -0700 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; 13 Mar 2020 17:04:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1584144276; x=1615680276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5LAi0O+mTaWDQDimiBocyA7wHcDy5fDRMj7L3Yuk5mg=; b=ElOZYTtYcsFZ/DmMpXeJgGLfi4Y+ztLTse/kycwT1F0fFuePuX8jQc+2 +0QI51rGRkxr/pdY66pSB/E1SwQLFZTyqpCxxjI2uGEnxKX7eLKJH+jhj sP6vL1gQj7B0rqbfNI5EnSk0El5VRhuiLKcCcHK95JWIcIMAwI1E5rGM/ ch+Aj/cRo3qogLZXdFb4iQTlNbWnzSkurtZOmzcPDFsxh3kukZIW/2Dsm Ur6c68zJghrQRAHawoKJ60rJdsOqvjJ4NlwB/dNDFpoO+LdD02nsxSCSe Brnc5t2qzR1cN8nXyARz/OrZXMEijqny0bdLETICmx6HSG7ecNl3sx3zM Q==; IronPort-SDR: 0nL148wVL0zZPX73+ib/t/n7QANKk49ILLECVm52iq4FXXMo5iau2bd5Dw1B/9F4DOtGxQeUIf jRW6fOHDM7NTCo5+frrqmTun2Z7tz4SdoUyVJWoCRC0MSX1Sy2JtuBkXcVK1N/771DddUUnkuc 1iyzc1mBdFHoAlQwz00G3jrpNiSz5U+lyR9V2EjZ2kHdEH7nGo7QeexYfBLoPYK6fvS0J4Hkfr D8crGoX5lOkCSzBnoVWMw7u8RkIxjGCNfloSozAxD6shjM7735aU9vVaTkYPXsbpec+V5qQzVO Wzo= X-IronPort-AV: E=Sophos;i="5.70,550,1574092800"; d="scan'208";a="234512347" IronPort-SDR: e0JnlDK1nR/KaIZceeM0D+GLtnQ3ZoUBuH0MQm4qx2bND8n3j0pNgMvnUq9W2EHW0Kc1DuDSDT nwgu6RtFaALdCTgMCZyakJyEketo3pq434y9G3QYTBcZOXl5oEUkEMsz5ca8HTb3yCe1NOppqf p/BCvZpBo2nF4Iq5DzrDLMSlhNex6vNvMZpYoDoxdLDKgvOQG8Z54F+6tk+happG92lWuKPArP nFCL11/0TvNwrD8gHnv6tSNLN4galTrvo49Bld7h6he8+3H2vHLM19cMydgxDdDQBW5hbSr/Ly 9BZ3RizttSjk98+KRyOJdg2V IronPort-SDR: 69rhew06GaGn6/i3783P27LMwsehdUKDmth15d4SuoOR9TiTBtogBuz7bSk47iz8UOXUXEhIXZ wnS+mYVxuHuqlnWFp4NF4crkF4Asgue0jymQIAU6daRFxJAl/9hMTGdC+Ii8SomB6c3ga9g6Ht wQ8UYtYKKwyB7WgXgyVOvYTsXZe6HyAKXWyYDotUBOop67liWdo3LJl+dVG38Vn+ofbou1B9u8 qKgcRzzPmIGbO1YWJ4wg2W6qlbjS9zbK+A/i/o5UTcJ1Y+N0P5DlN/6BmMn0CnG3gWGZ43vfRX eQY= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, laurent@vivier.eu Subject: [PATCH v8 2/4] linux-user/syscall: Add support for clock_gettime64/clock_settime64 Date: Fri, 13 Mar 2020 16:56:51 -0700 Message-Id: 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 909bec94a5..60fd775d9c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1229,6 +1229,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) { @@ -11458,6 +11474,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: { @@ -11469,6 +11497,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