Skip to content

Commit b497ef5

Browse files
committed
y2038: xtensa: Extend sysvipc data structures
xtensa, uses a nonstandard variation of the generic sysvipc data structures, intended to have the padding moved around so it can deal with big-endian 32-bit user space that has 64-bit time_t. xtensa tries hard to define the structures so they work in both big-endian and little-endian systems with padding on the right side. However, they only succeeded for for two of the three structures, and their struct shmid64_ds ended up being defined in two identical copies, and the big-endian one is wrong. This takes just take the same approach here that we have for the asm-generic headers and adds separate 32-bit fields for the upper halves of the timestamps, to let libc deal with the mess in user space. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent d0b67de commit b497ef5

3 files changed

Lines changed: 28 additions & 51 deletions

File tree

‎arch/xtensa/include/uapi/asm/msgbuf.h‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* between kernel and user space.
88
*
99
* Pad space is left for:
10-
* - 64-bit time_t to solve y2038 problem
1110
* - 2 miscellaneous 32-bit values
1211
*
1312
* This file is subject to the terms and conditions of the GNU General
@@ -21,19 +20,19 @@
2120
struct msqid64_ds {
2221
struct ipc64_perm msg_perm;
2322
#ifdef __XTENSA_EB__
24-
unsigned int __unused1;
25-
__kernel_time_t msg_stime; /* last msgsnd time */
26-
unsigned int __unused2;
27-
__kernel_time_t msg_rtime; /* last msgrcv time */
28-
unsigned int __unused3;
29-
__kernel_time_t msg_ctime; /* last change time */
23+
unsigned long msg_stime_high;
24+
unsigned long msg_stime; /* last msgsnd time */
25+
unsigned long msg_rtime_high;
26+
unsigned long msg_rtime; /* last msgrcv time */
27+
unsigned long msg_ctime_high;
28+
unsigned long msg_ctime; /* last change time */
3029
#elif defined(__XTENSA_EL__)
31-
__kernel_time_t msg_stime; /* last msgsnd time */
32-
unsigned int __unused1;
33-
__kernel_time_t msg_rtime; /* last msgrcv time */
34-
unsigned int __unused2;
35-
__kernel_time_t msg_ctime; /* last change time */
36-
unsigned int __unused3;
30+
unsigned long msg_stime; /* last msgsnd time */
31+
unsigned long msg_stime_high;
32+
unsigned long msg_rtime; /* last msgrcv time */
33+
unsigned long msg_rtime_high;
34+
unsigned long msg_ctime; /* last change time */
35+
unsigned long msg_ctime_high;
3736
#else
3837
# error processor byte order undefined!
3938
#endif

‎arch/xtensa/include/uapi/asm/sembuf.h‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* between kernel and user space.
1515
*
1616
* Pad space is left for:
17-
* - 64-bit time_t to solve y2038 problem
1817
* - 2 miscellaneous 32-bit values
1918
*
2019
*/
@@ -27,15 +26,15 @@
2726
struct semid64_ds {
2827
struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
2928
#ifdef __XTENSA_EL__
30-
__kernel_time_t sem_otime; /* last semop time */
31-
unsigned long __unused1;
32-
__kernel_time_t sem_ctime; /* last change time */
33-
unsigned long __unused2;
29+
unsigned long sem_otime; /* last semop time */
30+
unsigned long sem_otime_high;
31+
unsigned long sem_ctime; /* last change time */
32+
unsigned long sem_ctime_high;
3433
#else
35-
unsigned long __unused1;
36-
__kernel_time_t sem_otime; /* last semop time */
37-
unsigned long __unused2;
38-
__kernel_time_t sem_ctime; /* last change time */
34+
unsigned long sem_otime_high;
35+
unsigned long sem_otime; /* last semop time */
36+
unsigned long sem_ctime_high;
37+
unsigned long sem_ctime; /* last change time */
3938
#endif
4039
unsigned long sem_nsems; /* no. of semaphores in array */
4140
unsigned long __unused3;

‎arch/xtensa/include/uapi/asm/shmbuf.h‎

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*
55
* The shmid64_ds structure for Xtensa architecture.
66
* Note extra padding because this structure is passed back and forth
7-
* between kernel and user space.
7+
* between kernel and user space, but the padding is on the wrong
8+
* side for big-endian xtensa, for historic reasons.
89
*
910
* Pad space is left for:
10-
* - 64-bit time_t to solve y2038 problem
1111
* - 2 miscellaneous 32-bit values
1212
*
1313
* This file is subject to the terms and conditions of the GNU General Public
@@ -20,42 +20,21 @@
2020
#ifndef _XTENSA_SHMBUF_H
2121
#define _XTENSA_SHMBUF_H
2222

23-
#if defined (__XTENSA_EL__)
2423
struct shmid64_ds {
2524
struct ipc64_perm shm_perm; /* operation perms */
2625
size_t shm_segsz; /* size of segment (bytes) */
27-
__kernel_time_t shm_atime; /* last attach time */
28-
unsigned long __unused1;
29-
__kernel_time_t shm_dtime; /* last detach time */
30-
unsigned long __unused2;
31-
__kernel_time_t shm_ctime; /* last change time */
32-
unsigned long __unused3;
26+
unsigned long shm_atime; /* last attach time */
27+
unsigned long shm_atime_high;
28+
unsigned long shm_dtime; /* last detach time */
29+
unsigned long shm_dtime_high;
30+
unsigned long shm_ctime; /* last change time */
31+
unsigned long shm_ctime_high;
3332
__kernel_pid_t shm_cpid; /* pid of creator */
3433
__kernel_pid_t shm_lpid; /* pid of last operator */
3534
unsigned long shm_nattch; /* no. of current attaches */
3635
unsigned long __unused4;
3736
unsigned long __unused5;
3837
};
39-
#elif defined (__XTENSA_EB__)
40-
struct shmid64_ds {
41-
struct ipc64_perm shm_perm; /* operation perms */
42-
size_t shm_segsz; /* size of segment (bytes) */
43-
__kernel_time_t shm_atime; /* last attach time */
44-
unsigned long __unused1;
45-
__kernel_time_t shm_dtime; /* last detach time */
46-
unsigned long __unused2;
47-
__kernel_time_t shm_ctime; /* last change time */
48-
unsigned long __unused3;
49-
__kernel_pid_t shm_cpid; /* pid of creator */
50-
__kernel_pid_t shm_lpid; /* pid of last operator */
51-
unsigned long shm_nattch; /* no. of current attaches */
52-
unsigned long __unused4;
53-
unsigned long __unused5;
54-
};
55-
#else
56-
# error endian order not defined
57-
#endif
58-
5938

6039
struct shminfo64 {
6140
unsigned long shmmax;

0 commit comments

Comments
 (0)