Message ID | 20200602204105.43866-1-alistair.francis@wdc.com |
---|---|
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C7A9383F846; Tue, 2 Jun 2020 20:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C7A9383F846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591131014; bh=64qU84MpsrY9LhM8jroh59/Rd4imm/khBe7Kasj+4pk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qpL+bRLoC0vi1OpfEO8G9D15rRyelfGMc01mUWWmbj7gw9YqCjjySZXRvbcJ88jFl HNw77bzVE41JJHwtlbUjgPhkVcTK5tqAXm95RWLtB0lY077IHGGl8fDtDPi9wMniU6 HhB1t0rrRUwNNmQ0CL9gxhRbIo11KTb5JR7i+h48= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by sourceware.org (Postfix) with ESMTPS id 2A2CC385DC00 for <libc-alpha@sourceware.org>; Tue, 2 Jun 2020 20:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2A2CC385DC00 IronPort-SDR: Y67zWVaH2WpYPMxU/bKqLZ748FcXp5sWdwSXnHn68j/wylu7wRPrMFEZG3kk1xQ+sdsV1avRMb 9h/Yb5YKqoBH5Z6FtRX0Z7/jJa+RDgj21fABuViAgRQPEr/TZJ6Mk6nd+bHAkr/mCitZ9ntWUM wm6rcUzbXF2aXtMto1mJcMzHrLOKBMHcDXcpvHzmPtLAwBBNC4JwzNAhViFSbySpFrAy0jYizE 1lBX7MHu4QnsdVQ9cN3cLBrj236uBULS5l7GOIFuVrpzucWFiEluT4vCu+5QoL9ttsFTlmN8zJ GGQ= X-IronPort-AV: E=Sophos;i="5.73,465,1583164800"; d="scan'208";a="140480632" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Jun 2020 04:49:51 +0800 IronPort-SDR: XbKXbeVS6rJrXCaPtFEW8B/hErVrKuf4VRQINAGVUnS+DPbhwm5vMORPBFtrI7QCPnZOzCThkQ 8xV5kU0sGhQmzyy9qxz/Eckhs8N3STtzM= 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; 02 Jun 2020 13:38:57 -0700 IronPort-SDR: 7bmmMoO7jXsBF92s1CrCA0uqnVWSRCce2uIjW9eA+Ue3XURBNP7oghAGkkZ4pvgZCXFUnDwZLF hgupCWWvWIcQ== WDCIronportException: Internal Received: from cne220230.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.57.144]) by uls-op-cesaip01.wdc.com with ESMTP; 02 Jun 2020 13:49:50 -0700 To: libc-alpha@sourceware.org Subject: [PATCH v9 0/2] Support semctl_syscall() for __TIMESIZE==64 Date: Tue, 2 Jun 2020 13:41:03 -0700 Message-Id: <20200602204105.43866-1-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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 <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Alistair Francis via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Alistair Francis <alistair.francis@wdc.com> Cc: stepan@golosunov.pp.ru, Alistair Francis <alistair.francis@wdc.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
Support semctl_syscall() for __TIMESIZE==64
|
|
Message
Alistair Francis
June 2, 2020, 8:41 p.m. UTC
This series supports the semctl calls on a system with __TIMESIZE==64 and __WORDSIZE==32 while not breaking current architectures. This is a step towards full y2038 support, but does not get us there yet. See: https://sourceware.org/pipermail/libc-alpha/2020-May/113774.html for more details on what is still required. This series adds a new __semid_ds32 that is passed to the kernel (as part of a union) when running on 32-bit systems. If we are doing an IPC_STAT/SEM_STAT command then the 32-bit sem_{c,o}time{_high} values are combined to create a 64-bit value. The semctl_syscall() function passes a union semun to the kernel. The union includes struct semid_ds as a member. On 32-bit architectures the Linux kernel provides a *_high version of the 32-bit sem_otime and sem_ctime values. These can be combined to get a 64-bit version of the time. This patch adjusts the struct semid_ds to support the *_high versions of sem_otime and sem_ctime. For 32-bit systems with a 64-bit time_t this can be used to get a 64-bit time from the two 32-bit values. This series was tested by running: ./scripts/build-many-glibcs.py ... compilers ./scripts/build-many-glibcs.py ... glibcs on my x86_64 machine. I also ran make check on RV32 and I only see a total of 9 test failures. v9: - Don't use defined inside a #define v8: - Revert back to v6-ish and only support __TIMESIZE==64 v7: - Re-write based on code from Adhemerval. v6: - Update the 3rd patch to pass a temp buffer to the kernel v5: - Address v4 review comments - Set the semid_ds struct from a temp struct v4: - Remove the __IPC_TIME64 macro - It was only used once and doesn't work if __IPC_64 is 0 (which is usually is) - Address failures pointed out by Vineet Gupta Alistair Francis (2): sysv: linux: Define the __semid_ds32 struct sysv: linux: Pass 64-bit version of semctl syscall .../unix/sysv/linux/hppa/struct__semid_ds32.h | 30 +++++++++++ sysdeps/unix/sysv/linux/ipc_priv.h | 7 +++ .../unix/sysv/linux/mips/struct__semid_ds32.h | 28 +++++++++++ .../sysv/linux/powerpc/struct__semid_ds32.h | 30 +++++++++++ sysdeps/unix/sysv/linux/semctl.c | 50 +++++++++++++++++-- .../sysv/linux/sparc/struct__semid_ds32.h | 30 +++++++++++ sysdeps/unix/sysv/linux/struct__semid_ds32.h | 30 +++++++++++ .../unix/sysv/linux/x86/struct__semid_ds32.h | 30 +++++++++++ 8 files changed, 231 insertions(+), 4 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/hppa/struct__semid_ds32.h create mode 100644 sysdeps/unix/sysv/linux/mips/struct__semid_ds32.h create mode 100644 sysdeps/unix/sysv/linux/powerpc/struct__semid_ds32.h create mode 100644 sysdeps/unix/sysv/linux/sparc/struct__semid_ds32.h create mode 100644 sysdeps/unix/sysv/linux/struct__semid_ds32.h create mode 100644 sysdeps/unix/sysv/linux/x86/struct__semid_ds32.h
Comments
On 02/06/2020 17:41, Alistair Francis wrote: > This series supports the semctl calls on a system with __TIMESIZE==64 > and __WORDSIZE==32 while not breaking current architectures. This is a > step towards full y2038 support, but does not get us there yet. > > See: https://sourceware.org/pipermail/libc-alpha/2020-May/113774.html > for more details on what is still required. > > This series adds a new __semid_ds32 that is passed to the kernel > (as part of a union) when running on 32-bit systems. If we are doing an > IPC_STAT/SEM_STAT command then the 32-bit sem_{c,o}time{_high} values > are combined to create a 64-bit value. I think this patch still does not go in to the direction it was discussed in last iteration. This patch just handles the case of 32-bit architectures with only 64-bit time_t support, where to fully cover all possible scenarios we will need to handle the 32-bit architectures where it would be possible to select the time_t ABI (i386 for instance). To move this support forward I implemented the idea we discussed in a personal branch [1]. Instead of adding the the '__semid_ds32' I added two new structures: 1. kernel_semid64_ds: used internally only on 32-bit architectures to issue the syscall. As for __semid_ds32, a handful architectures (hppa, i386, mips, powerpc32, sparc32) requires specific implementation due its specific kernel ABI. 2. semid_ds64: this is only for __TIMESIZE != 64 to used along with the 64-bit semctl. It is different than the kernel one because the exported 64-bit time_t might require different alignment depending of the architecture ABI. So the resulting implementation does: 1. For 64-bit architectures it assumes semid_ds already contains 64-bit time_t fields it will result in just the __semctl symbol using the __semctl64 code: static int semctl_syscall (int semid, int semnum, int cmd, union semun arg) { [...] } int semctl ([...]) { union semun arg64 = { 0 }; [...] switch (cmd) { [...] arg64 = va_arg (ap, union semun); [...] } union semun arg = arg64; int ret = semctl_syscall (semid, semnum, cmd, arg); [...] } Basically the semid_ds argument is passed as-is to the kernel interface. 2. For 32-bit architectures with default 64-bit time_t (newer ABIs such riscv32 or arc), it will also result in only one symbol but with the required high/low handling: static int semctl_syscall (int semid, int semnum, int cmd, union ksemun64 arg) { [...] } int semctl ([...]) { union semun arg64 = { 0 }; [...] switch (cmd) { [...] arg64 = va_arg (ap, union semun64); [...] } struct kernel_semid64_ds ksemid; union ksemun64 ksemun = semun64_to_ksemun64 (cmd, arg64, &ksemid); union ksemun64 arg = ksemun; int ret = semctl_syscall (semid, semnum, cmd, arg); [...] switch (cmd) { case IPC_STAT: case SEM_STAT: case SEM_STAT_ANY: [...] ksemid64_to_semid64 (arg.buf, arg64.buf); } [...] } It might be possible to optimize it further to avoid the kernel_semid64_ds to semun transformation if the exported glibc ABI for the architectures matches the expected kernel ABI, but the implementation is already complex enough and don't think this should be a hotspot in any case. 3. Finally for 32-bit architecture with both 32-bit and 64-bit time_t support we follow the already set way to provide one symbol with 64-bit time_t support and implement the 32-bit time_t support on basis of the 64-bit one: static int semctl_syscall (int semid, int semnum, int cmd, union ksemun64 arg) { [...] } int __semctl64 ([...]) { union semun64 arg64 = { 0 }; [...] switch (cmd) { [...] arg64 = va_arg (ap, union semun64); [...] } struct kernel_semid64_ds ksemid; union ksemun64 ksemun = semun64_to_ksemun64 (cmd, arg64, &ksemid); union ksemun64 arg = ksemun; int ret = semctl_syscall (semid, semnum, cmd, arg); [...] switch (cmd) { case IPC_STAT: case SEM_STAT: case SEM_STAT_ANY: [...] ksemid64_to_semid64 (arg.buf, arg64.buf); } [...] } int __semctl (int semid, int semnum, int cmd, ...) { union semun arg = { 0 }; [...] switch (cmd) { [...] arg = va_arg (ap, union semun); [...] } struct __semid64_ds semid64; union semun64 arg64 = semun_to_semun64 (cmd, arg, &semid64); int ret = __semctl64 (semid, semnum, cmd, arg64); switch (cmd) { case IPC_STAT: case SEM_STAT: case SEM_STAT_ANY: semid64_ds_to_semid_ds (arg.buf, arg64.buf); } } The default 32-bit symbol will allocate and copy the semid_ds over multiple buffers, but this should be deprecated in favor of the __semctl64 anyway. I did some sniff tests on i686, arm, mips, and powerpc where this code should change the way the function is implemented. Could you also check on riscv32 since currently there is no 32-bit architecture with default 64-bit time_t? If it ok for riscv32 I can send it upstream. [1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/semctl-y2038