2019-05-27 08:55:01 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
2005-04-16 15:20:36 -07:00
/*
2022-10-12 13:53:34 +10:00
* sys_ppc32 . c : 32 - bit system calls with complex calling conventions .
2005-04-16 15:20:36 -07:00
*
* Copyright ( C ) 2001 IBM
* Copyright ( C ) 1997 , 1998 Jakub Jelinek ( jj @ sunsite . mff . cuni . cz )
* Copyright ( C ) 1997 David S . Miller ( davem @ caip . rutgers . edu )
*
2022-10-12 13:53:34 +10:00
* 32 - bit system calls with 64 - bit arguments pass those in register pairs .
* This must be specially dealt with on 64 - bit kernels . The compat_arg_u64_dual
* in generic compat syscalls is not always usable because the register
* pairing is constrained depending on preceding arguments .
*
* An analogous problem exists on 32 - bit kernels with ARCH_HAS_SYSCALL_WRAPPER ,
* the defined system call functions take the pt_regs as an argument , and there
* is a mapping macro which maps registers to arguments
* ( SC_POWERPC_REGS_TO_ARGS ) which also does not deal with these 64 - bit
* arguments .
*
* This file contains these system calls .
2005-04-16 15:20:36 -07:00
*/
# include <linux/kernel.h>
# include <linux/sched.h>
# include <linux/fs.h>
# include <linux/mm.h>
# include <linux/file.h>
# include <linux/signal.h>
# include <linux/resource.h>
# include <linux/times.h>
# include <linux/smp.h>
# include <linux/sem.h>
# include <linux/msg.h>
# include <linux/shm.h>
# include <linux/poll.h>
# include <linux/personality.h>
# include <linux/stat.h>
# include <linux/in.h>
# include <linux/syscalls.h>
# include <linux/unistd.h>
# include <linux/sysctl.h>
# include <linux/binfmts.h>
# include <linux/security.h>
# include <linux/compat.h>
# include <linux/ptrace.h>
# include <linux/elf.h>
2007-10-16 23:29:24 -07:00
# include <linux/ipc.h>
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 17:04:11 +09:00
# include <linux/slab.h>
2005-04-16 15:20:36 -07:00
# include <asm/ptrace.h>
# include <asm/types.h>
2016-12-24 11:46:01 -08:00
# include <linux/uaccess.h>
2005-04-16 15:20:36 -07:00
# include <asm/unistd.h>
# include <asm/time.h>
# include <asm/mmu_context.h>
2005-09-28 02:50:25 +10:00
# include <asm/ppc-pci.h>
2006-11-27 19:18:59 +01:00
# include <asm/syscalls.h>
2012-03-28 18:30:02 +01:00
# include <asm/switch_to.h>
2005-04-16 15:20:36 -07:00
2022-10-12 13:53:34 +10:00
# ifdef CONFIG_PPC32
# define PPC32_SYSCALL_DEFINE4 SYSCALL_DEFINE4
# define PPC32_SYSCALL_DEFINE5 SYSCALL_DEFINE5
# define PPC32_SYSCALL_DEFINE6 SYSCALL_DEFINE6
# else
# define PPC32_SYSCALL_DEFINE4 COMPAT_SYSCALL_DEFINE4
# define PPC32_SYSCALL_DEFINE5 COMPAT_SYSCALL_DEFINE5
# define PPC32_SYSCALL_DEFINE6 COMPAT_SYSCALL_DEFINE6
# endif
PPC32_SYSCALL_DEFINE6 ( ppc_pread64 ,
2022-09-21 16:55:55 +10:00
unsigned int , fd ,
char __user * , ubuf , compat_size_t , count ,
u32 , reg6 , u32 , pos1 , u32 , pos2 )
2005-04-16 15:20:36 -07:00
{
2021-01-03 01:35:30 +00:00
return ksys_pread64 ( fd , ubuf , count , merge_64 ( pos1 , pos2 ) ) ;
2005-04-16 15:20:36 -07:00
}
2022-10-12 13:53:34 +10:00
PPC32_SYSCALL_DEFINE6 ( ppc_pwrite64 ,
2022-09-21 16:55:55 +10:00
unsigned int , fd ,
const char __user * , ubuf , compat_size_t , count ,
u32 , reg6 , u32 , pos1 , u32 , pos2 )
2005-04-16 15:20:36 -07:00
{
2021-01-03 01:35:30 +00:00
return ksys_pwrite64 ( fd , ubuf , count , merge_64 ( pos1 , pos2 ) ) ;
2005-04-16 15:20:36 -07:00
}
2022-10-12 13:53:34 +10:00
PPC32_SYSCALL_DEFINE5 ( ppc_readahead ,
2022-09-21 16:55:55 +10:00
int , fd , u32 , r4 ,
u32 , offset1 , u32 , offset2 , u32 , count )
2005-04-16 15:20:36 -07:00
{
2021-01-03 01:35:30 +00:00
return ksys_readahead ( fd , merge_64 ( offset1 , offset2 ) , count ) ;
2005-04-16 15:20:36 -07:00
}
2022-10-12 13:53:34 +10:00
PPC32_SYSCALL_DEFINE4 ( ppc_truncate64 ,
2022-09-21 16:55:55 +10:00
const char __user * , path , u32 , reg4 ,
unsigned long , len1 , unsigned long , len2 )
2005-04-16 15:20:36 -07:00
{
2021-01-03 01:35:30 +00:00
return ksys_truncate ( path , merge_64 ( len1 , len2 ) ) ;
2005-04-16 15:20:36 -07:00
}
2022-10-12 13:53:34 +10:00
PPC32_SYSCALL_DEFINE4 ( ppc_ftruncate64 ,
2022-09-21 16:55:55 +10:00
unsigned int , fd , u32 , reg4 ,
unsigned long , len1 , unsigned long , len2 )
2005-04-16 15:20:36 -07:00
{
2021-01-03 01:35:30 +00:00
return ksys_ftruncate ( fd , merge_64 ( len1 , len2 ) ) ;
2005-04-16 15:20:36 -07:00
}
2022-10-12 13:53:34 +10:00
PPC32_SYSCALL_DEFINE6 ( ppc32_fadvise64 ,
2022-09-21 16:55:55 +10:00
int , fd , u32 , unused , u32 , offset1 , u32 , offset2 ,
size_t , len , int , advice )
2005-04-16 15:20:36 -07:00
{
2021-01-03 01:35:30 +00:00
return ksys_fadvise64_64 ( fd , merge_64 ( offset1 , offset2 ) , len ,
2018-03-11 11:34:45 +01:00
advice ) ;
2005-04-16 15:20:36 -07:00
}
2022-10-31 15:47:35 +01:00
PPC32_SYSCALL_DEFINE6 ( ppc_sync_file_range2 ,
2022-09-21 16:55:55 +10:00
int , fd , unsigned int , flags ,
unsigned int , offset1 , unsigned int , offset2 ,
unsigned int , nbytes1 , unsigned int , nbytes2 )
Introduce fixed sys_sync_file_range2() syscall, implement on PowerPC and ARM
Not all the world is an i386. Many architectures need 64-bit arguments to be
aligned in suitable pairs of registers, and the original
sys_sync_file_range(int, loff_t, loff_t, int) was therefore wasting an
argument register for padding after the first integer. Since we don't
normally have more than 6 arguments for system calls, that left no room for
the final argument on some architectures.
Fix this by introducing sys_sync_file_range2(int, int, loff_t, loff_t) which
all fits nicely. In fact, ARM already had that, but called it
sys_arm_sync_file_range. Move it to fs/sync.c and rename it, then implement
the needed compatibility routine. And stop the missing syscall check from
bitching about the absence of sys_sync_file_range() if we've implemented
sys_sync_file_range2() instead.
Tested on PPC32 and with 32-bit and 64-bit userspace on PPC64.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-06-27 14:10:09 -07:00
{
2021-01-03 01:35:30 +00:00
loff_t offset = merge_64 ( offset1 , offset2 ) ;
loff_t nbytes = merge_64 ( nbytes1 , nbytes2 ) ;
Introduce fixed sys_sync_file_range2() syscall, implement on PowerPC and ARM
Not all the world is an i386. Many architectures need 64-bit arguments to be
aligned in suitable pairs of registers, and the original
sys_sync_file_range(int, loff_t, loff_t, int) was therefore wasting an
argument register for padding after the first integer. Since we don't
normally have more than 6 arguments for system calls, that left no room for
the final argument on some architectures.
Fix this by introducing sys_sync_file_range2(int, int, loff_t, loff_t) which
all fits nicely. In fact, ARM already had that, but called it
sys_arm_sync_file_range. Move it to fs/sync.c and rename it, then implement
the needed compatibility routine. And stop the missing syscall check from
bitching about the absence of sys_sync_file_range() if we've implemented
sys_sync_file_range2() instead.
Tested on PPC32 and with 32-bit and 64-bit userspace on PPC64.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-06-27 14:10:09 -07:00
2018-03-11 11:34:47 +01:00
return ksys_sync_file_range ( fd , offset , nbytes , flags ) ;
Introduce fixed sys_sync_file_range2() syscall, implement on PowerPC and ARM
Not all the world is an i386. Many architectures need 64-bit arguments to be
aligned in suitable pairs of registers, and the original
sys_sync_file_range(int, loff_t, loff_t, int) was therefore wasting an
argument register for padding after the first integer. Since we don't
normally have more than 6 arguments for system calls, that left no room for
the final argument on some architectures.
Fix this by introducing sys_sync_file_range2(int, int, loff_t, loff_t) which
all fits nicely. In fact, ARM already had that, but called it
sys_arm_sync_file_range. Move it to fs/sync.c and rename it, then implement
the needed compatibility routine. And stop the missing syscall check from
bitching about the absence of sys_sync_file_range() if we've implemented
sys_sync_file_range2() instead.
Tested on PPC32 and with 32-bit and 64-bit userspace on PPC64.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-06-27 14:10:09 -07:00
}
2022-10-31 15:47:35 +01:00
# ifdef CONFIG_PPC32
SYSCALL_DEFINE6 ( ppc_fallocate ,
int , fd , int , mode ,
u32 , offset1 , u32 , offset2 , u32 , len1 , u32 , len2 )
{
return ksys_fallocate ( fd , mode ,
merge_64 ( offset1 , offset2 ) ,
merge_64 ( len1 , len2 ) ) ;
}
# endif