From patchwork Sat Mar 28 15:22:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38647 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by sourceware.org (Postfix) with ESMTPS id 50B40385E009 for ; Sat, 28 Mar 2020 15:30:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 50B40385E009 IronPort-SDR: zSLMfHjmrzUjUC0iJAot8J3Hk+dcsW0r6MpQfgSbStVosXMO6bM93UMglUU6UTnGL6lzlHqpj4 UzGolwc04j7I0BuOtTZ/HRuYIMJdn4koPGCJHwwEhB1PEKllggrcieI2igKfIOPy/UVq9F60IV avxcpaR9ALBPxC8oqJEY7FhZeoikdBGrhagFEJLS8ZFX5OQusM6h9qLbBMjZPxol/Hx+reuB4+ B8334p9rU6plaVMvIN0DULuP413FtDnF81UDgEYAY6Tdui8mlgu5Ryz+5AfHGlfhIg3cfAasXd +6E= X-IronPort-AV: E=Sophos;i="5.72,316,1580745600"; d="scan'208";a="138142287" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Mar 2020 23:30:29 +0800 IronPort-SDR: aNXNdIBrs+FHOWYCCLSckRSmB5i9Y6X/rbpzc37y2av5vVM3lLE0VJYm4avwVTwXjFy00hQ3ol xvIhkSm6nxXFA0yNXl4X/tG2/acIE9senCLr9L+7/DMfxjJUhcSIwtll7HanjvMYc4cYHouXTA BEdNHvvjHPbKl4eWwpTgPn0HSjxOnVZEf4MrBFbpMGsq9n6YLEmzkFJEzR9zdv5H+JQOAMGc4s s/m6UzmjQmPM+D/meN949OAcRdMuGX0YC99ESrZ3siO0Sbwn8rI/G1uZAWKmLu1M2Z3PypRlrv FsJyqKBLr9zkeu3e5IKlajq3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2020 08:21:28 -0700 IronPort-SDR: xYv43KoPNZYpkhLP350MXHGTRQtAQ8qDt0Ke2mLQwECntXFci5KjDGQLC3G/3Hl7fUQ1HLkBpX JIc7+iMdq9uu6quhJmI3HiTly2EEf4m39slScF3ae7lbSlu9gi7i5ru/gQvjKYIIX5BaNIUxmN axLtpciZ+srRjN6O5PZaixr1df8s87pWA3Yo1uCswfVfqtc3cTIscJ8v/JnX5wz37Rm/0raxTL WcJk7yse7GRfmnKw4TpQ8QEMyjuP3o9jkabVFJhbHC5gtymoaBhc+fmQ0SBPWMzs7Quj8sjchG Dkw= WDCIronportException: Internal Received: from wdapacbjl0003.my.asia.wdc.com (HELO risc6-mainframe.hgst.com) ([10.86.55.5]) by uls-op-cesaip02.wdc.com with ESMTP; 28 Mar 2020 08:30:28 -0700 From: Alistair Francis To: libc-alpha@sourceware.org Cc: Vineet.Gupta1@synopsys.com, alistair23@gmail.com, Alistair Francis , Lukasz Majewski Subject: [PATCH v6 1/5] sysv: Define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 Date: Sat, 28 Mar 2020 08:22:45 -0700 Message-Id: <20200328152249.972428-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200328152249.972428-1-alistair.francis@wdc.com> References: <20200328152249.972428-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-25.2 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: Sat, 28 Mar 2020 15:30:34 -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 --- 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 Sat Mar 28 15:22:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38648 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by sourceware.org (Postfix) with ESMTPS id D4381385E00B for ; Sat, 28 Mar 2020 15:30:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D4381385E00B IronPort-SDR: 8FOdCp01CI+5TH+SivAzZmVDLu0Ex/RNZREcc/KOuydnk7ViTe7rmjiQZ2q4RCA2CQYPosSsFt E1v6rZ5c3gHyIrSb+opH6VzmWSCVHt8WxIQAS/9iYQh6tEFKR8ue+pd8HqxQscLNYq6r5OcJFF eJLFos9+OKrFf+Rd5N9o+efvE0Ww+jIxf1hoLqUSzGuG7YklYBviH1MI8ryQvjvm1MDj/qug2m EGKsI9qaXmutKt86Bm1i/4aszMNIGbKIL09WeF1qMyTxntkgnddDnReylUibMmVYKj6VIg/BUO wJA= X-IronPort-AV: E=Sophos;i="5.72,316,1580745600"; d="scan'208";a="138142288" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Mar 2020 23:30:29 +0800 IronPort-SDR: 0/5JYUs/aC02uzj4UJ8v3F/+GWeeQxkgddj1sxdLMjHYjo2ckbVjvtypFRlUA+DZAFHxrqZr7V GnBs1wQHV2ZgAO6kCY7XwnV3qKz4dkZmaK0pendrqPwSauKNiEFnl+BidEY+Fm4X93X5R7Qsct ZSemD2dNeqvd0lAcJQJjvV7S4+YFqZx3W8Mqg/R0YnTKaQMmBNCVXA4Q3S9VIShXFWHXxioO92 bH5EU0Ee1vGzagpMCQfoxUc/GTFWrDVNZLoWaReAONuzKJ7TN8KCUumUOGAt+9IoP66CUJTlzG UMcOxJz3CTB4fU8d5N4v7896 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2020 08:21:28 -0700 IronPort-SDR: B7OYpQtOcKI6d5B5gwSEEX+JHSv18VasEEitULi+Wt5b7nHZ8Gm3J791z3F0HGHsl/pPjg4zjI A7vPbtOToTlGhqAG13IxCVWTO+y75gY2yOaBGLVYHCVg8w6HyZ9m4XeA677Fhzx4F223Nhh3L7 9xzWeuTB8Qv0FVpp4/jZq9dLdxouf1PmJgCnUXprAbXrnR52hntIEjP3XQ/GFMlk5s5vyHiw3z tWdqVxjhhMzy3O+Ac9CaIv62JziZ2MZvINNMhs98Mgwkwy6r3t1k8/yv2sdk96AqMpbp0N+aU2 eTI= WDCIronportException: Internal Received: from wdapacbjl0003.my.asia.wdc.com (HELO risc6-mainframe.hgst.com) ([10.86.55.5]) by uls-op-cesaip02.wdc.com with ESMTP; 28 Mar 2020 08:30:28 -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 v6 2/5] linux: Use long time_t __getitimer/__setitimer Date: Sat, 28 Mar 2020 08:22:46 -0700 Message-Id: <20200328152249.972428-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200328152249.972428-1-alistair.francis@wdc.com> References: <20200328152249.972428-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-25.7 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: Sat, 28 Mar 2020 15:30:34 -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 | 59 +++++++++++++++++ sysdeps/unix/sysv/linux/setitimer.c | 94 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/tv32-compat.h | 31 +++++++++ 5 files changed, 199 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