mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
9afc5eee65
Christoph Hellwig suggested a slightly different path for handling backwards compatibility with the 32-bit time_t based system calls: Rather than simply reusing the compat_sys_* entry points on 32-bit architectures unchanged, we get rid of those entry points and the compat_time types by renaming them to something that makes more sense on 32-bit architectures (which don't have a compat mode otherwise), and then share the entry points under the new name with the 64-bit architectures that use them for implementing the compatibility. The following types and interfaces are renamed here, and moved from linux/compat_time.h to linux/time32.h: old new --- --- compat_time_t old_time32_t struct compat_timeval struct old_timeval32 struct compat_timespec struct old_timespec32 struct compat_itimerspec struct old_itimerspec32 ns_to_compat_timeval() ns_to_old_timeval32() get_compat_itimerspec64() get_old_itimerspec32() put_compat_itimerspec64() put_old_itimerspec32() compat_get_timespec64() get_old_timespec32() compat_put_timespec64() put_old_timespec32() As we already have aliases in place, this patch addresses only the instances that are relevant to the system call interface in particular, not those that occur in device drivers and other modules. Those will get handled separately, while providing the 64-bit version of the respective interfaces. I'm not renaming the timex, rusage and itimerval structures, as we are still debating what the new interface will look like, and whether we will need a replacement at all. This also doesn't change the names of the syscall entry points, which can be done more easily when we actually switch over the 32-bit architectures to use them, at that point we need to change COMPAT_SYSCALL_DEFINEx to SYSCALL_DEFINEx with a new name, e.g. with a _time32 suffix. Suggested-by: Christoph Hellwig <hch@infradead.org> Link: https://lore.kernel.org/lkml/20180705222110.GA5698@infradead.org/ Signed-off-by: Arnd Bergmann <arnd@arndb.de>
107 lines
2.9 KiB
C
107 lines
2.9 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Support for n32 Linux/MIPS ELF binaries.
|
|
* Author: Ralf Baechle (ralf@linux-mips.org)
|
|
*
|
|
* Copyright (C) 1999, 2001 Ralf Baechle
|
|
* Copyright (C) 1999, 2001 Silicon Graphics, Inc.
|
|
*
|
|
* Heavily inspired by the 32-bit Sparc compat code which is
|
|
* Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
|
|
* Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
|
|
*/
|
|
|
|
#define ELF_ARCH EM_MIPS
|
|
#define ELF_CLASS ELFCLASS32
|
|
#ifdef __MIPSEB__
|
|
#define ELF_DATA ELFDATA2MSB;
|
|
#else /* __MIPSEL__ */
|
|
#define ELF_DATA ELFDATA2LSB;
|
|
#endif
|
|
|
|
/* ELF register definitions */
|
|
#define ELF_NGREG 45
|
|
#define ELF_NFPREG 33
|
|
|
|
typedef unsigned long elf_greg_t;
|
|
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
|
|
|
|
typedef double elf_fpreg_t;
|
|
typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
|
|
|
|
/*
|
|
* This is used to ensure we don't load something for the wrong architecture.
|
|
*/
|
|
#define elf_check_arch elfn32_check_arch
|
|
|
|
#define TASK32_SIZE 0x7fff8000UL
|
|
#undef ELF_ET_DYN_BASE
|
|
#define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
|
|
|
|
#include <asm/processor.h>
|
|
#include <linux/elfcore.h>
|
|
#include <linux/compat.h>
|
|
#include <linux/math64.h>
|
|
|
|
#define elf_prstatus elf_prstatus32
|
|
struct elf_prstatus32
|
|
{
|
|
struct elf_siginfo pr_info; /* Info associated with signal */
|
|
short pr_cursig; /* Current signal */
|
|
unsigned int pr_sigpend; /* Set of pending signals */
|
|
unsigned int pr_sighold; /* Set of held signals */
|
|
pid_t pr_pid;
|
|
pid_t pr_ppid;
|
|
pid_t pr_pgrp;
|
|
pid_t pr_sid;
|
|
struct old_timeval32 pr_utime; /* User time */
|
|
struct old_timeval32 pr_stime; /* System time */
|
|
struct old_timeval32 pr_cutime;/* Cumulative user time */
|
|
struct old_timeval32 pr_cstime;/* Cumulative system time */
|
|
elf_gregset_t pr_reg; /* GP registers */
|
|
int pr_fpvalid; /* True if math co-processor being used. */
|
|
};
|
|
|
|
#define elf_prpsinfo elf_prpsinfo32
|
|
struct elf_prpsinfo32
|
|
{
|
|
char pr_state; /* numeric process state */
|
|
char pr_sname; /* char for pr_state */
|
|
char pr_zomb; /* zombie */
|
|
char pr_nice; /* nice val */
|
|
unsigned int pr_flag; /* flags */
|
|
__kernel_uid_t pr_uid;
|
|
__kernel_gid_t pr_gid;
|
|
pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
|
|
/* Lots missing */
|
|
char pr_fname[16]; /* filename of executable */
|
|
char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
|
|
};
|
|
|
|
#define elf_caddr_t u32
|
|
#define init_elf_binfmt init_elfn32_binfmt
|
|
|
|
#define jiffies_to_timeval jiffies_to_old_timeval32
|
|
static __inline__ void
|
|
jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
|
|
{
|
|
/*
|
|
* Convert jiffies to nanoseconds and separate with
|
|
* one divide.
|
|
*/
|
|
u64 nsec = (u64)jiffies * TICK_NSEC;
|
|
u32 rem;
|
|
value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
|
|
value->tv_usec = rem / NSEC_PER_USEC;
|
|
}
|
|
|
|
#define ELF_CORE_EFLAGS EF_MIPS_ABI2
|
|
|
|
#undef TASK_SIZE
|
|
#define TASK_SIZE TASK_SIZE32
|
|
|
|
#undef ns_to_timeval
|
|
#define ns_to_timeval ns_to_old_timeval32
|
|
|
|
#include "../../../fs/binfmt_elf.c"
|