From patchwork Fri Jan 31 17:04:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 37630 Received: (qmail 39484 invoked by alias); 31 Jan 2020 17:11:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 39476 invoked by uid 89); 31 Jan 2020 17:11:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: esa4.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1580490695; x=1612026695; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=XykPUSwfsCAyAlIRgH1qyNmA4vZO8egu44v6E4i+wLs=; b=RCcgcDVNK751VK6AW8T2QTiQv9GId/DMpGb4yduth9bcfzNOTmcc3ZWT 3ujoUnWp8oMJtKwdRphXd/BXUisrnxscqKay0toVPR0cyssrh28yrmp7n ehlenLVZy6S4KXWKDF9P/RRtLMRMPg0HpjuBM4NLv67CgcP0Su0WyUjn0 0MfujyPZ28FIezmt/qnQa/zgF6UjuaqWYE85vrv0Ohzax/esmIZpFlDW4 +QfvckPDfJ9hcoXNq9ajKq/X8CO/e0yVPJcgxAEeCfpjU436FHZkCl0De bs4j8XLQv/7O+SsIGIo0uLy4uu0oi5ej+xno07d/9fFcd8zjSVrhJKZV3 A==; IronPort-SDR: I1x1Tgd1N6PoKcgOV9+hHyvZ/fzw9q1kbxCcLPXwUguQNTG49IGY57Tl0BjwDwrwFrTQoD6Zl4 HV1mP8lkA+ib38gKRLTer572BUKNPBs618t9G3x0ylpYlLunR66DjVEMshhNOvQnIVBGszNk6O EMjgY5Tt9nlQ4q2ynBcpbaFOZZTg1sgkiF1oh+5rEVz3wsDFNUuKvWsF6DxmREpU/lHas4Unpa p5ZGkj3j57vXGfNOBSUyxKtG1IYUYwvs3cqBD+ihZBzW6mwrCtR4p3dQkIsQ3xKdzxn8O36eEX XEw= IronPort-SDR: oC4h5v1I4zvttn7Ho+bMgpWHXhSjJtblTo6X3HFKDN/x+i1M06j71wxst2c+6uJ1wD76S8Z/so +XV7GXyXhnw5t0JKikm3s8PguaDF+fLCqNhkph9oB879ySEOGVB7qXISQCTk+KIReZabNJwtdc +3JJ0NC/F3otmW4H+6cabyQg3nTsuHzCJa+zMSzlJX0VR9T0HCjLpRxgF+KYeyT8GiIoSj08KV Xw41Y9sNUVLdpyRFEP0hYH4xYkdYC43TIC66qr45IgvpNZCHCfX954DM7+5oualb4ABzK2hlzd AMF6NXYiB3T/237OoxOJhtYh IronPort-SDR: AfH12U3bIHNTfQ4wnk36Wgfr0GKKjzULHkuC66MvhNezq1AfS1XtxHFQXqKANybs+ChIbJTw9q QxdOxTw3c3AfYpRl/w5wklOd+Ju1jwbnxEQXW9KlK9CosxOMS4pvYio9GZKaais8P662ph+3Mb c4NXWYPKJ6+4q4dMxih72TEhw5P0zHPihWe/qEwVT1u+tfeD8xn64eFOGtvrsdMTlcn1hwttMp pP74Wk1V56Lym9fjEhI2bRP/efxqoguqIn1/vBzDPhsdwVEdt0ufw6tKaf3H98h5KRV8AYyF5F X2A= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH] sysv: linux: Pass 64-bit version of semctl syscall Date: Fri, 31 Jan 2020 09:04:57 -0800 Message-Id: <20200131170457.25952-1-alistair.francis@wdc.com> MIME-Version: 1.0 Adjust the semctl syscall to match what the kernel expects. That is pass a version with a *_high version of sem_otime and sem_ctime in the order that the kernel expects. --- include/sys/sem.h | 35 +++++++++++++++++++ sysdeps/unix/sysv/linux/bits/sem-pad.h | 1 + sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h | 1 + sysdeps/unix/sysv/linux/mips/bits/sem-pad.h | 2 ++ .../unix/sysv/linux/powerpc/bits/sem-pad.h | 2 ++ sysdeps/unix/sysv/linux/semctl.c | 30 +++++++++++++--- sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h | 2 ++ sysdeps/unix/sysv/linux/x86/bits/sem-pad.h | 1 + 8 files changed, 70 insertions(+), 4 deletions(-) diff --git a/include/sys/sem.h b/include/sys/sem.h index 69fdf1f752..70b83127cb 100644 --- a/include/sys/sem.h +++ b/include/sys/sem.h @@ -5,5 +5,40 @@ __typeof__ (semtimedop) __semtimedop attribute_hidden; +# endif + +# ifdef __SEMID_DS_HIGH +# if defined (__SEMID_DS_HIGH_END) +struct __semid_ds32 { + struct ipc_perm sem_perm; /* permissions .. see ipc.h */ + __syscall_ulong_t sem_otime; /* last semop time */ + __syscall_ulong_t sem_ctime; /* last change time */ + __syscall_ulong_t sem_nsems; /* no. of semaphores in array */ + __syscall_ulong_t sem_otime_high; + __syscall_ulong_t sem_ctime_high; +}; +# elif defined (__SEMID_DS_HIGH_SWAP) +struct __semid_ds32 { + struct ipc_perm sem_perm; /* operation permission struct */ + __syscall_ulong_t sem_otime_high; /* last semop() time high */ + __syscall_ulong_t sem_otime; /* last semop() time */ + __syscall_ulong_t sem_ctime_high; /* last time changed by semctl() high */ + __syscall_ulong_t sem_ctime; /* last time changed by semctl() */ + __syscall_ulong_t sem_nsems; /* number of semaphores in set */ + __syscall_ulong_t __glibc_reserved3; + __syscall_ulong_t __glibc_reserved4; +}; +# else +struct __semid_ds32 { + struct ipc_perm sem_perm; /* operation permission struct */ + __syscall_ulong_t sem_otime; /* last semop() time */ + __syscall_ulong_t sem_otime_high; /* last semop() time high */ + __syscall_ulong_t sem_ctime; /* last time changed by semctl() */ + __syscall_ulong_t sem_ctime_high; /* last time changed by semctl() high */ + __syscall_ulong_t sem_nsems; /* number of semaphores in set */ + __syscall_ulong_t __glibc_reserved3; + __syscall_ulong_t __glibc_reserved4; +}; +# endif # endif #endif diff --git a/sysdeps/unix/sysv/linux/bits/sem-pad.h b/sysdeps/unix/sysv/linux/bits/sem-pad.h index 566ce039cc..18235e56df 100644 --- a/sysdeps/unix/sysv/linux/bits/sem-pad.h +++ b/sysdeps/unix/sysv/linux/bits/sem-pad.h @@ -31,3 +31,4 @@ #define __SEM_PAD_AFTER_TIME (__TIMESIZE == 32) #define __SEM_PAD_BEFORE_TIME 0 +#define __SEMID_DS_HIGH (__WORDSIZE == 32) diff --git a/sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h b/sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h index ee0332325b..7e112018a6 100644 --- a/sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h +++ b/sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h @@ -24,3 +24,4 @@ #define __SEM_PAD_AFTER_TIME 0 #define __SEM_PAD_BEFORE_TIME (__TIMESIZE == 32) +#define __SEMID_DS_HIGH (__WORDSIZE == 32) diff --git a/sysdeps/unix/sysv/linux/mips/bits/sem-pad.h b/sysdeps/unix/sysv/linux/mips/bits/sem-pad.h index 4c581f7694..12f2bd9c62 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/sem-pad.h +++ b/sysdeps/unix/sysv/linux/mips/bits/sem-pad.h @@ -22,3 +22,5 @@ #define __SEM_PAD_AFTER_TIME 0 #define __SEM_PAD_BEFORE_TIME 0 +#define __SEMID_DS_HIGH (__WORDSIZE == 32) +#define __SEMID_DS_HIGH_END (__WORDSIZE == 32) diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h b/sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h index 42d8827906..a13ca5f6bd 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h @@ -24,3 +24,5 @@ #define __SEM_PAD_AFTER_TIME 0 #define __SEM_PAD_BEFORE_TIME (__TIMESIZE == 32) +#define __SEMID_DS_HIGH (__WORDSIZE == 32) +#define __SEMID_DS_HIGH_SWAP (__WORDSIZE == 32) diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c index 0c3eb0932f..34d3125fc3 100644 --- a/sysdeps/unix/sysv/linux/semctl.c +++ b/sysdeps/unix/sysv/linux/semctl.c @@ -28,6 +28,7 @@ union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ + struct __semid_ds32 *buf32; unsigned short int *array; /* array for GETALL & SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ }; @@ -43,12 +44,33 @@ union semun static int semctl_syscall (int semid, int semnum, int cmd, union semun arg) { -#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS - return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64, - arg.array); +#ifdef __SEMID_DS_HIGH + int ret; +# ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS + ret = INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64, + arg.array); +# else + ret = INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64, + SEMCTL_ARG_ADDRESS (arg)); +# endif +/* If we aren't going to overflow the time_t sem_ctime/sem_otime set it */ +# if __TIMESIZE == 64 && __WORDSIZE == 32 + if (ret == 0) + { + arg.buf->sem_ctime = arg.buf32->sem_ctime | ((time_t) arg.buf32->sem_ctime_high << 32); + arg.buf->sem_otime = arg.buf32->sem_otime | ((time_t) arg.buf32->sem_otime_high << 32); + } +# endif + return ret; #else +# ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS + return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64, + arg.array); +# else return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64, - SEMCTL_ARG_ADDRESS (arg)); + SEMCTL_ARG_ADDRESS (arg)); +# endif + #endif } diff --git a/sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h b/sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h index 5f4e214d12..79655b8149 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h @@ -24,3 +24,5 @@ #define __SEM_PAD_AFTER_TIME 0 #define __SEM_PAD_BEFORE_TIME (__TIMESIZE == 32) +#define __SEMID_DS_HIGH (__WORDSIZE == 32) +#define __SEMID_DS_HIGH_SWAP (__WORDSIZE == 32) diff --git a/sysdeps/unix/sysv/linux/x86/bits/sem-pad.h b/sysdeps/unix/sysv/linux/x86/bits/sem-pad.h index 102e226997..db397857e7 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/sem-pad.h +++ b/sysdeps/unix/sysv/linux/x86/bits/sem-pad.h @@ -22,3 +22,4 @@ #define __SEM_PAD_AFTER_TIME 1 #define __SEM_PAD_BEFORE_TIME 0 +#define __SEMID_DS_HIGH 1