Skip to content

Commit

Permalink
Merge branch 'misc.sparc' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/viro/vfs

Pull sparc syscall cleanups from Al Viro:
 "sparc syscall stuff - killing pointless wrappers, conversions to
  {COMPAT_,}SYSCALL_DEFINE"

* 'misc.sparc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  sparc: get rid of asm wrapper for nis_syscall()
  sparc: switch compat {f,}truncate64() to COMPAT_SYSCALL_DEFINE
  sparc: switch compat pread64 and pwrite64 to COMPAT_SYSCALL_DEFINE
  convert compat sync_file_range() to COMPAT_SYSCALL_DEFINE
  switch sparc_remap_file_pages() to SYSCALL_DEFINE
  sparc: get rid of memory_ordering(2) wrapper
  sparc: trivial conversions to {COMPAT_,}SYSCALL_DEFINE()
  sparc: bury a zombie extern that had been that way for twenty years
  sparc: get rid of remaining SIGN... wrappers
  sparc: kill useless SIGN... wrappers
  sparc: get rid of sys_sparc_pipe() wrappers
  • Loading branch information
Linus Torvalds committed Apr 7, 2018
2 parents 90fda63 + 47db697 commit 8844a50
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 181 deletions.
15 changes: 0 additions & 15 deletions arch/sparc/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -801,26 +801,11 @@ SUN_PI_(lda [%l4] ASI_M_MMUREGS, %l5) ! read sfsr last
RESTORE_ALL

.align 4
.globl sys_nis_syscall
sys_nis_syscall:
mov %o7, %l5
add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
call c_sys_nis_syscall
mov %l5, %o7

sunos_execv:
.globl sunos_execv
b sys_execve
clr %i2

.align 4
.globl sys_sparc_pipe
sys_sparc_pipe:
mov %o7, %l5
add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
call sparc_pipe
mov %l5, %o7

.align 4
.globl sys_sigstack
sys_sigstack:
Expand Down
38 changes: 0 additions & 38 deletions arch/sparc/kernel/sys32.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,6 @@

.text

#define SIGN1(STUB,SYSCALL,REG1) \
.align 32; \
.globl STUB; \
STUB: sethi %hi(SYSCALL), %g1; \
jmpl %g1 + %lo(SYSCALL), %g0; \
sra REG1, 0, REG1

#define SIGN2(STUB,SYSCALL,REG1,REG2) \
.align 32; \
.globl STUB; \
STUB: sethi %hi(SYSCALL), %g1; \
sra REG1, 0, REG1; \
jmpl %g1 + %lo(SYSCALL), %g0; \
sra REG2, 0, REG2

#define SIGN3(STUB,SYSCALL,REG1,REG2,REG3) \
.align 32; \
.globl STUB; \
STUB: sra REG1, 0, REG1; \
sethi %hi(SYSCALL), %g1; \
sra REG2, 0, REG2; \
jmpl %g1 + %lo(SYSCALL), %g0; \
sra REG3, 0, REG3

SIGN1(sys32_readahead, compat_sys_readahead, %o0)
SIGN2(sys32_fadvise64, compat_sys_fadvise64, %o0, %o4)
SIGN2(sys32_fadvise64_64, compat_sys_fadvise64_64, %o0, %o5)
SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1)
SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1)
SIGN1(sys32_io_submit, compat_sys_io_submit, %o1)
SIGN1(sys32_mq_open, compat_sys_mq_open, %o1)
SIGN1(sys32_select, compat_sys_select, %o0)
SIGN1(sys32_futex, compat_sys_futex, %o1)
SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0)
SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0)
SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
SIGN2(sys32_renameat2, sys_renameat2, %o0, %o2)

.globl sys32_mmap2
sys32_mmap2:
sethi %hi(sys_mmap), %g1
Expand Down
89 changes: 36 additions & 53 deletions arch/sparc/kernel/sys_sparc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,14 @@

#include "systbls.h"

asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low)
COMPAT_SYSCALL_DEFINE3(truncate64, const char __user *, path, u32, high, u32, low)
{
if ((int)high < 0)
return -EINVAL;
else
return ksys_truncate(path, (high << 32) | low);
return ksys_truncate(path, ((u64)high << 32) | low);
}

asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)
COMPAT_SYSCALL_DEFINE3(ftruncate64, unsigned int, fd, u32, high, u32, low)
{
if ((int)high < 0)
return -EINVAL;
else
return ksys_ftruncate(fd, (high << 32) | low);
return ksys_ftruncate(fd, ((u64)high << 32) | low);
}

static int cp_compat_stat64(struct kstat *stat,
Expand Down Expand Up @@ -98,8 +92,8 @@ static int cp_compat_stat64(struct kstat *stat,
return err;
}

asmlinkage long compat_sys_stat64(const char __user * filename,
struct compat_stat64 __user *statbuf)
COMPAT_SYSCALL_DEFINE2(stat64, const char __user *, filename,
struct compat_stat64 __user *, statbuf)
{
struct kstat stat;
int error = vfs_stat(filename, &stat);
Expand All @@ -109,8 +103,8 @@ asmlinkage long compat_sys_stat64(const char __user * filename,
return error;
}

asmlinkage long compat_sys_lstat64(const char __user * filename,
struct compat_stat64 __user *statbuf)
COMPAT_SYSCALL_DEFINE2(lstat64, const char __user *, filename,
struct compat_stat64 __user *, statbuf)
{
struct kstat stat;
int error = vfs_lstat(filename, &stat);
Expand All @@ -120,8 +114,8 @@ asmlinkage long compat_sys_lstat64(const char __user * filename,
return error;
}

asmlinkage long compat_sys_fstat64(unsigned int fd,
struct compat_stat64 __user * statbuf)
COMPAT_SYSCALL_DEFINE2(fstat64, unsigned int, fd,
struct compat_stat64 __user *, statbuf)
{
struct kstat stat;
int error = vfs_fstat(fd, &stat);
Expand All @@ -131,9 +125,9 @@ asmlinkage long compat_sys_fstat64(unsigned int fd,
return error;
}

asmlinkage long compat_sys_fstatat64(unsigned int dfd,
const char __user *filename,
struct compat_stat64 __user * statbuf, int flag)
COMPAT_SYSCALL_DEFINE4(fstatat64, unsigned int, dfd,
const char __user *, filename,
struct compat_stat64 __user *, statbuf, int, flag)
{
struct kstat stat;
int error;
Expand Down Expand Up @@ -194,61 +188,50 @@ COMPAT_SYSCALL_DEFINE5(rt_sigaction, int, sig,
return ret;
}

asmlinkage compat_ssize_t sys32_pread64(unsigned int fd,
char __user *ubuf,
compat_size_t count,
unsigned long poshi,
unsigned long poslo)
COMPAT_SYSCALL_DEFINE5(pread64, unsigned int, fd, char __user *, ubuf,
compat_size_t, count, u32, poshi, u32, poslo)
{
return ksys_pread64(fd, ubuf, count, (poshi << 32) | poslo);
return ksys_pread64(fd, ubuf, count, ((u64)poshi << 32) | poslo);
}

asmlinkage compat_ssize_t sys32_pwrite64(unsigned int fd,
char __user *ubuf,
compat_size_t count,
unsigned long poshi,
unsigned long poslo)
COMPAT_SYSCALL_DEFINE5(pwrite64, unsigned int, fd, char __user *, ubuf,
compat_size_t, count, u32, poshi, u32, poslo)
{
return ksys_pwrite64(fd, ubuf, count, (poshi << 32) | poslo);
return ksys_pwrite64(fd, ubuf, count, ((u64)poshi << 32) | poslo);
}

asmlinkage long compat_sys_readahead(int fd,
unsigned long offhi,
unsigned long offlo,
compat_size_t count)
COMPAT_SYSCALL_DEFINE4(readahead, int, fd, u32, offhi, u32, offlo,
compat_size_t, count)
{
return ksys_readahead(fd, (offhi << 32) | offlo, count);
return ksys_readahead(fd, ((u64)offhi << 32) | offlo, count);
}

long compat_sys_fadvise64(int fd,
unsigned long offhi,
unsigned long offlo,
compat_size_t len, int advice)
COMPAT_SYSCALL_DEFINE5(fadvise64, int, fd, u32, offhi, u32, offlo,
compat_size_t, len, int, advice)
{
return ksys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
return ksys_fadvise64_64(fd, ((u64)offhi << 32) | offlo, len, advice);
}

long compat_sys_fadvise64_64(int fd,
unsigned long offhi, unsigned long offlo,
unsigned long lenhi, unsigned long lenlo,
int advice)
COMPAT_SYSCALL_DEFINE6(fadvise64_64, int, fd, u32, offhi, u32, offlo,
u32, lenhi, u32, lenlo, int, advice)
{
return ksys_fadvise64_64(fd,
(offhi << 32) | offlo,
(lenhi << 32) | lenlo,
((u64)offhi << 32) | offlo,
((u64)lenhi << 32) | lenlo,
advice);
}

long sys32_sync_file_range(unsigned int fd, unsigned long off_high, unsigned long off_low, unsigned long nb_high, unsigned long nb_low, unsigned int flags)
COMPAT_SYSCALL_DEFINE6(sync_file_range, unsigned int, fd, u32, off_high, u32, off_low,
u32, nb_high, u32, nb_low, unsigned int, flags)
{
return ksys_sync_file_range(fd,
(off_high << 32) | off_low,
(nb_high << 32) | nb_low,
flags);
((u64)off_high << 32) | off_low,
((u64)nb_high << 32) | nb_low,
flags);
}

asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
u32 lenhi, u32 lenlo)
COMPAT_SYSCALL_DEFINE6(fallocate, int, fd, int, mode, u32, offhi, u32, offlo,
u32, lenhi, u32, lenlo)
{
return ksys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
((loff_t)lenhi << 32) | lenlo);
Expand Down
31 changes: 15 additions & 16 deletions arch/sparc/kernel/sys_sparc_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/* XXX Make this per-binary type, this way we can detect the type of
* XXX a binary. Every Sparc executable calls this very early on.
*/
asmlinkage unsigned long sys_getpagesize(void)
SYSCALL_DEFINE0(getpagesize)
{
return PAGE_SIZE; /* Possibly older binaries want 8192 on sun4's? */
}
Expand Down Expand Up @@ -73,15 +73,15 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
* sys_pipe() is the normal C calling standard for creating
* a pipe. It's not the way unix traditionally does this, though.
*/
asmlinkage long sparc_pipe(struct pt_regs *regs)
SYSCALL_DEFINE0(sparc_pipe)
{
int fd[2];
int error;

error = do_pipe_flags(fd, 0);
if (error)
goto out;
regs->u_regs[UREG_I1] = fd[1];
current_pt_regs()->u_regs[UREG_I1] = fd[1];
error = fd[0];
out:
return error;
Expand All @@ -98,27 +98,27 @@ int sparc_mmap_check(unsigned long addr, unsigned long len)

/* Linux version of mmap */

asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags, unsigned long fd,
unsigned long pgoff)
SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
unsigned long, prot, unsigned long, flags, unsigned long, fd,
unsigned long, pgoff)
{
/* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
we have. */
return ksys_mmap_pgoff(addr, len, prot, flags, fd,
pgoff >> (PAGE_SHIFT - 12));
}

asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags, unsigned long fd,
unsigned long off)
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
unsigned long, prot, unsigned long, flags, unsigned long, fd,
unsigned long, off)
{
/* no alignment check? */
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
}

long sparc_remap_file_pages(unsigned long start, unsigned long size,
unsigned long prot, unsigned long pgoff,
unsigned long flags)
SYSCALL_DEFINE5(sparc_remap_file_pages, unsigned long, start, unsigned long, size,
unsigned long, prot, unsigned long, pgoff,
unsigned long, flags)
{
/* This works on an existing mmap so we don't need to validate
* the range as that was done at the original mmap call.
Expand All @@ -127,11 +127,10 @@ long sparc_remap_file_pages(unsigned long start, unsigned long size,
(pgoff >> (PAGE_SHIFT - 12)), flags);
}

/* we come to here via sys_nis_syscall so it can setup the regs argument */
asmlinkage unsigned long
c_sys_nis_syscall (struct pt_regs *regs)
SYSCALL_DEFINE0(nis_syscall)
{
static int count = 0;
struct pt_regs *regs = current_pt_regs();

if (count++ > 5)
return -ENOSYS;
Expand Down Expand Up @@ -202,7 +201,7 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig,
return ret;
}

asmlinkage long sys_getdomainname(char __user *name, int len)
SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len)
{
int nlen, err;

Expand Down
18 changes: 8 additions & 10 deletions arch/sparc/kernel/sys_sparc_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

/* #define DEBUG_UNIMP_SYSCALL */

asmlinkage unsigned long sys_getpagesize(void)
SYSCALL_DEFINE0(getpagesize)
{
return PAGE_SIZE;
}
Expand Down Expand Up @@ -310,15 +310,15 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
* sys_pipe() is the normal C calling standard for creating
* a pipe. It's not the way unix traditionally does this, though.
*/
SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)
SYSCALL_DEFINE0(sparc_pipe)
{
int fd[2];
int error;

error = do_pipe_flags(fd, 0);
if (error)
goto out;
regs->u_regs[UREG_I1] = fd[1];
current_pt_regs()->u_regs[UREG_I1] = fd[1];
error = fd[0];
out:
return error;
Expand Down Expand Up @@ -480,10 +480,10 @@ SYSCALL_DEFINE5(64_mremap, unsigned long, addr, unsigned long, old_len,
return sys_mremap(addr, old_len, new_len, flags, new_addr);
}

/* we come to here via sys_nis_syscall so it can setup the regs argument */
asmlinkage unsigned long c_sys_nis_syscall(struct pt_regs *regs)
SYSCALL_DEFINE0(nis_syscall)
{
static int count;
struct pt_regs *regs = current_pt_regs();

/* Don't make the system unusable, if someone goes stuck */
if (count++ > 5)
Expand Down Expand Up @@ -523,8 +523,6 @@ asmlinkage void sparc_breakpoint(struct pt_regs *regs)
exception_exit(prev_state);
}

extern void check_pending(int signum);

SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len)
{
int nlen, err;
Expand Down Expand Up @@ -608,9 +606,9 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
return 0;
}

asmlinkage long sparc_memory_ordering(unsigned long model,
struct pt_regs *regs)
SYSCALL_DEFINE1(memory_ordering, unsigned long, model)
{
struct pt_regs *regs = current_pt_regs();
if (model >= 3)
return -EINVAL;
regs->tstate = (regs->tstate & ~TSTATE_MM) | (model << 14);
Expand Down Expand Up @@ -644,7 +642,7 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
return ret;
}

asmlinkage long sys_kern_features(void)
SYSCALL_DEFINE0(kern_features)
{
return KERN_FEATURE_MIXED_MODE_STACK;
}
Loading

0 comments on commit 8844a50

Please sign in to comment.