From patchwork Tue Mar 31 15:46:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38689 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by sourceware.org (Postfix) with ESMTPS id 31A51385DC01 for ; Tue, 31 Mar 2020 15:54:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 31A51385DC01 IronPort-SDR: ExUvKzH2FXXn2JPCwHGaDIURUePaXRemVDzcBFB8jXS6tZlxyUlOWptWcl1FgQpj+f2CmxT75v wjwvSuNgKciS9Ji3/ytzsVqwW/Meh4vpSq7EE5cdlfvpmpI6GO0hIuw/Nxgl3PJj5cD/YQxO64 Tc5Bd+LGXlggiTXbFt3UDrZwNC5nql3xf2eDRrRmTLI5bm7/71ID8Im6YaGa3c+4MNQQgFtgRm PLKZ0RkeEA6p0IU9qsZ+ZLzw4E7Zjmmv0sgH+K1mxJmtQn04Sj0I7KvSJrp25SEt13FrTOl3SI bvc= X-IronPort-AV: E=Sophos;i="5.72,328,1580745600"; d="scan'208";a="134068947" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 Mar 2020 23:54:40 +0800 IronPort-SDR: Xpfb+rut9aRs/lsg8FskkHJ7nhtzYmR2gfov+DZpi9rIpkBh7aRCsj+uwnt8dx9b3CYL/79Acg JqKmD6tSe7eRQ77EyfwZTH8TfZKV3iK340qMXbhujm8Pv7PngOkaloxrgUe/h48+LSyQo1uttd pg9oHwnhN6OYj0E6MztihP3lzofGOmqcffDOWXF7uSZTWCLJGtzfmAORw0FGTyS9oU3NFkPLfi dqi4mqM9lzLQdb1Php31dwsTg+XJb1ZK9g7CqO/b2bqDQcULOqjl8IhwN3nDVFfPfocNTRFlcE J4vDJjD60HMzJTA5Cgs4I3fl Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 08:45:34 -0700 IronPort-SDR: bdzPoL4ZrolDOQrtQQuU5PwYtnMUvEONZh+Ur6UqfD4RmXgaoCETp33s4P97uRaR+LA9nm0gtk YmRdI0jrhw+/Oa3h/xAavyd10MKpmZaG9fLamog2MsmRCMTqzSYITU+o/5JxEi8Q/zW2g6zCom rQZXz3T3txFG4thqxH078vO8m9C2sjVCcptT/AJezs91FDqmnPjwLOqg4zhxEugDkBtdzX39yr 7R0qW+vzfQhtL8PoCf3yeQUPvTakcOEme+Vh52zoOOCY3idTR0Ew+THf2Ex6Xgu+aWzFZ82K7v c4I= WDCIronportException: Internal Received: from usa001473.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.55.8]) by uls-op-cesaip01.wdc.com with ESMTP; 31 Mar 2020 08:54:40 -0700 From: Alistair Francis To: libc-alpha@sourceware.org Cc: Vineet.Gupta1@synopsys.com, alistair23@gmail.com, Alistair Francis , Lukasz Majewski Subject: [PATCH v7 1/5] sysv: Define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 Date: Tue, 31 Mar 2020 08:46:52 -0700 Message-Id: <20200331154656.687841-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331154656.687841-1-alistair.francis@wdc.com> References: <20200331154656.687841-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-26.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 15:54:43 -0000 On y2038 safe 32-bit systems the Linux kernel expects itimerval and rusage to use a 32-bit time_t, even though the other time_t's are 64-bit. There are currently no plans to make 64-bit time_t versions of these structs. There are also other occurrences where the time passed to the kernel via timeval doesn't match the wordsize. To handle these cases let's define a new macro __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64. This macro specifies if the kernel's old_timeval matches the new timeval64. This should be true for 64-bit architectures except for Alpha's old osf syscalls and x32. Reviewed-by: Lukasz Majewski Reviewed-by: Adhemerval Zanella --- bits/typesizes.h | 6 ++++++ sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 3 +++ sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 6 ++++++ sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 6 ++++++ sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 6 ++++++ sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 5 +++++ 6 files changed, 32 insertions(+) diff --git a/bits/typesizes.h b/bits/typesizes.h index 599408973e..8f16903a21 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -76,10 +76,16 @@ /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ # define __STATFS_MATCHES_STATFS64 1 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 # define __STATFS_MATCHES_STATFS64 0 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h index 28ee3e5920..1d1fd242dc 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h @@ -73,6 +73,9 @@ /* Not for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ # define __STATFS_MATCHES_STATFS64 0 +/* And for getitimer, setitimer and rusage */ +#define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 + /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 1024 diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h index 7c963e523e..4fb246ac74 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h @@ -77,11 +77,17 @@ /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ # define __STATFS_MATCHES_STATFS64 1 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 # define __STATFS_MATCHES_STATFS64 0 + +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0 #endif + /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 1024 diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h index e775e460bb..2bc87c1079 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h @@ -82,10 +82,16 @@ /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ # define __STATFS_MATCHES_STATFS64 1 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 # define __STATFS_MATCHES_STATFS64 0 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h index ac48c23e37..288a902b5f 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h @@ -76,10 +76,16 @@ /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ # define __STATFS_MATCHES_STATFS64 1 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 # define __STATFS_MATCHES_STATFS64 0 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h index 87c50a4f32..1bb4a1620c 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h @@ -88,10 +88,15 @@ /* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ # define __STATFS_MATCHES_STATFS64 1 + +/* And for getitimer, setitimer and rusage */ +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1 #else # define __RLIM_T_MATCHES_RLIM64_T 0 # define __STATFS_MATCHES_STATFS64 0 + +# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0 #endif /* Number of descriptors that can fit in an `fd_set'. */ From patchwork Tue Mar 31 15:46:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38691 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by sourceware.org (Postfix) with ESMTPS id 2A64F385DC00 for ; Tue, 31 Mar 2020 15:54:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2A64F385DC00 IronPort-SDR: b096baGaKYk1Ik/SNGf6MIgOoLr8YM/qHNnK7jPnS/PZKig5oup2M1LAnKJvqvoS1bY1RPTOUo 4exav82PlfIHGlc3l85fj+zXUlf/YWIMTQtkaVViH/o7E9EfhifSf4om06v+KSr5RSPqZsC2nO UDA7Fto8o48lLnvKT0cwjiJNPz3tnZv9qKQy+I0//R4hDn1G57EL8BGbMgDriWgyYORSMgfHkS 5bGUaoeoi8w7BaQup7VewQaDKYsCcwR/2yYHgiyyW1KfUoghKhSW2zRHuw4D8O/CnVMlZ0d72N fPA= X-IronPort-AV: E=Sophos;i="5.72,328,1580745600"; d="scan'208";a="134068948" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 Mar 2020 23:54:40 +0800 IronPort-SDR: i89WSNCnGJZvbF+t/6c7MiX9kxcel6hQ7FnkGQJpDyA++BJq7ICxNIVgU7qwXc+7Ev5+QeWxzZ gUGb7plCij9RZm6A4J95nBUeuqsVB7qOCvSdCQe2Wq3tskyz14KVWXyvg6mLI68z2aEGIhaZcN E8/APxzpUWynP4XGjOipJCAKJly3e7TsjMGuo1bopoDYrI9npjm8ROvVmvhf2FcfQtS3j7ixFt XzgBPeeQ5IuMVQ35erTJrtIWaLTNvMBUJr5EyeAONVPF08BZu4LvGaz6tSmK4VOx1EhThEm79Y 4rfHT40k6y+2NzWB1vYG7ajA Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 08:45:34 -0700 IronPort-SDR: ujWHRu54feF65lmD89pR7gYYjKpcHQ13UmWOL+zdClaxErIMtPzyk8hFpSZdCeFMssih9DuYds q9TDbkkKWgJxbcviuNQR+TGxugX3QfaCcrUbUdC0iUe0JZ0v+4tXQ+V2pAeVrCsejinUcBubCO 4Ad/Mu7HYls7Bt2kWLzdWjeU5dO0vprnpJrt/1jaiBtlGgr60f47P9zG8FTtm1HMJ3HMwKgr+U LO4+vEotonZSIjHY553sudS3mvCAc0gxtGG3drBj0l9tgeIYMgGFikX3LXdV2h5dvD6Id4xLeh rGE= WDCIronportException: Internal Received: from usa001473.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.55.8]) by uls-op-cesaip01.wdc.com with ESMTP; 31 Mar 2020 08:54:40 -0700 From: Alistair Francis To: libc-alpha@sourceware.org Cc: Vineet.Gupta1@synopsys.com, alistair23@gmail.com, Alistair Francis , Lukasz Majewski , Adhemerval Zanella Subject: [PATCH v7 2/5] linux: Use long time_t __getitimer/__setitimer Date: Tue, 31 Mar 2020 08:46:53 -0700 Message-Id: <20200331154656.687841-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331154656.687841-1-alistair.francis@wdc.com> References: <20200331154656.687841-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-26.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 15:54:45 -0000 The Linux kernel expects itimerval to use a 32-bit time_t, even on archs with a 64-bit time_t (like RV32). To address this let's convert itimerval to/from 32-bit and 64-bit to ensure the kernel always gets a 32-bit time_t. While we are converting these functions let's also convert them to be the y2038 safe versions. This means there is a *64 function that is called by a backwards compatible wrapper. Tested-by: Lukasz Majewski Reviewed-by: Adhemerval Zanella --- include/time.h | 15 +++++ sysdeps/unix/syscalls.list | 2 - sysdeps/unix/sysv/linux/getitimer.c | 61 +++++++++++++++++ sysdeps/unix/sysv/linux/setitimer.c | 94 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/tv32-compat.h | 31 +++++++++ 5 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/getitimer.c create mode 100644 sysdeps/unix/sysv/linux/setitimer.c create mode 100644 sysdeps/unix/sysv/linux/tv32-compat.h diff --git a/include/time.h b/include/time.h index 2523e0ff0d..4522fe9c4f 100644 --- a/include/time.h +++ b/include/time.h @@ -6,6 +6,7 @@ # include # include # include