Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * sys_ppc32.c: 32-bit system calls with complex calling conventions.
  4 *
  5 * Copyright (C) 2001 IBM
  6 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  8 *
  9 * 32-bit system calls with 64-bit arguments pass those in register pairs.
 10 * This must be specially dealt with on 64-bit kernels. The compat_arg_u64_dual
 11 * in generic compat syscalls is not always usable because the register
 12 * pairing is constrained depending on preceding arguments.
 13 *
 14 * An analogous problem exists on 32-bit kernels with ARCH_HAS_SYSCALL_WRAPPER,
 15 * the defined system call functions take the pt_regs as an argument, and there
 16 * is a mapping macro which maps registers to arguments
 17 * (SC_POWERPC_REGS_TO_ARGS) which also does not deal with these 64-bit
 18 * arguments.
 19 *
 20 * This file contains these system calls.
 21 */
 22
 23#include <linux/kernel.h>
 24#include <linux/sched.h>
 25#include <linux/fs.h> 
 26#include <linux/mm.h> 
 27#include <linux/file.h> 
 28#include <linux/signal.h>
 29#include <linux/resource.h>
 30#include <linux/times.h>
 31#include <linux/smp.h>
 32#include <linux/sem.h>
 33#include <linux/msg.h>
 34#include <linux/shm.h>
 35#include <linux/poll.h>
 36#include <linux/personality.h>
 37#include <linux/stat.h>
 
 38#include <linux/in.h>
 39#include <linux/syscalls.h>
 40#include <linux/unistd.h>
 41#include <linux/sysctl.h>
 42#include <linux/binfmts.h>
 43#include <linux/security.h>
 44#include <linux/compat.h>
 45#include <linux/ptrace.h>
 46#include <linux/elf.h>
 47#include <linux/ipc.h>
 48#include <linux/slab.h>
 49
 50#include <asm/ptrace.h>
 51#include <asm/types.h>
 52#include <linux/uaccess.h>
 53#include <asm/unistd.h>
 54#include <asm/time.h>
 55#include <asm/mmu_context.h>
 56#include <asm/ppc-pci.h>
 57#include <asm/syscalls.h>
 58#include <asm/switch_to.h>
 59
 60#ifdef CONFIG_PPC32
 61#define PPC32_SYSCALL_DEFINE4	SYSCALL_DEFINE4
 62#define PPC32_SYSCALL_DEFINE5	SYSCALL_DEFINE5
 63#define PPC32_SYSCALL_DEFINE6	SYSCALL_DEFINE6
 
 
 
 
 
 
 
 
 
 
 
 
 64#else
 65#define PPC32_SYSCALL_DEFINE4	COMPAT_SYSCALL_DEFINE4
 66#define PPC32_SYSCALL_DEFINE5	COMPAT_SYSCALL_DEFINE5
 67#define PPC32_SYSCALL_DEFINE6	COMPAT_SYSCALL_DEFINE6
 68#endif
 69
 70PPC32_SYSCALL_DEFINE6(ppc_pread64,
 71		       unsigned int, fd,
 72		       char __user *, ubuf, compat_size_t, count,
 73		       u32, reg6, u32, pos1, u32, pos2)
 74{
 75	return ksys_pread64(fd, ubuf, count, merge_64(pos1, pos2));
 76}
 77
 78PPC32_SYSCALL_DEFINE6(ppc_pwrite64,
 79		       unsigned int, fd,
 80		       const char __user *, ubuf, compat_size_t, count,
 81		       u32, reg6, u32, pos1, u32, pos2)
 82{
 83	return ksys_pwrite64(fd, ubuf, count, merge_64(pos1, pos2));
 84}
 85
 86PPC32_SYSCALL_DEFINE5(ppc_readahead,
 87		       int, fd, u32, r4,
 88		       u32, offset1, u32, offset2, u32, count)
 89{
 90	return ksys_readahead(fd, merge_64(offset1, offset2), count);
 91}
 92
 93PPC32_SYSCALL_DEFINE4(ppc_truncate64,
 94		       const char __user *, path, u32, reg4,
 95		       unsigned long, len1, unsigned long, len2)
 96{
 97	return ksys_truncate(path, merge_64(len1, len2));
 98}
 99
100PPC32_SYSCALL_DEFINE4(ppc_ftruncate64,
101		       unsigned int, fd, u32, reg4,
102		       unsigned long, len1, unsigned long, len2)
 
 
 
 
 
 
103{
104	return ksys_ftruncate(fd, merge_64(len1, len2));
105}
106
107PPC32_SYSCALL_DEFINE6(ppc32_fadvise64,
108		       int, fd, u32, unused, u32, offset1, u32, offset2,
109		       size_t, len, int, advice)
110{
111	return ksys_fadvise64_64(fd, merge_64(offset1, offset2), len,
112				 advice);
113}
114
115PPC32_SYSCALL_DEFINE6(ppc_sync_file_range2,
116		       int, fd, unsigned int, flags,
117		       unsigned int, offset1, unsigned int, offset2,
118		       unsigned int, nbytes1, unsigned int, nbytes2)
119{
120	loff_t offset = merge_64(offset1, offset2);
121	loff_t nbytes = merge_64(nbytes1, nbytes2);
122
123	return ksys_sync_file_range(fd, offset, nbytes, flags);
124}
125
126#ifdef CONFIG_PPC32
127SYSCALL_DEFINE6(ppc_fallocate,
128		int, fd, int, mode,
129		u32, offset1, u32, offset2, u32, len1, u32, len2)
130{
131	return ksys_fallocate(fd, mode,
132			      merge_64(offset1, offset2),
133			      merge_64(len1, len2));
134}
135#endif
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls.
  4 *
  5 * Copyright (C) 2001 IBM
  6 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  8 *
  9 * These routines maintain argument size conversion between 32bit and 64bit
 10 * environment.
 
 
 
 
 
 
 
 
 
 
 11 */
 12
 13#include <linux/kernel.h>
 14#include <linux/sched.h>
 15#include <linux/fs.h> 
 16#include <linux/mm.h> 
 17#include <linux/file.h> 
 18#include <linux/signal.h>
 19#include <linux/resource.h>
 20#include <linux/times.h>
 21#include <linux/smp.h>
 22#include <linux/sem.h>
 23#include <linux/msg.h>
 24#include <linux/shm.h>
 25#include <linux/poll.h>
 26#include <linux/personality.h>
 27#include <linux/stat.h>
 28#include <linux/mman.h>
 29#include <linux/in.h>
 30#include <linux/syscalls.h>
 31#include <linux/unistd.h>
 32#include <linux/sysctl.h>
 33#include <linux/binfmts.h>
 34#include <linux/security.h>
 35#include <linux/compat.h>
 36#include <linux/ptrace.h>
 37#include <linux/elf.h>
 38#include <linux/ipc.h>
 39#include <linux/slab.h>
 40
 41#include <asm/ptrace.h>
 42#include <asm/types.h>
 43#include <linux/uaccess.h>
 44#include <asm/unistd.h>
 45#include <asm/time.h>
 46#include <asm/mmu_context.h>
 47#include <asm/ppc-pci.h>
 48#include <asm/syscalls.h>
 49#include <asm/switch_to.h>
 50
 51unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
 52			  unsigned long prot, unsigned long flags,
 53			  unsigned long fd, unsigned long pgoff)
 54{
 55	/* This should remain 12 even if PAGE_SIZE changes */
 56	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
 57}
 58
 59/* 
 60 * long long munging:
 61 * The 32 bit ABI passes long longs in an odd even register pair.
 62 * High and low parts are swapped depending on endian mode,
 63 * so define a macro (similar to mips linux32) to handle that.
 64 */
 65#ifdef __LITTLE_ENDIAN__
 66#define merge_64(low, high) ((u64)high << 32) | low
 67#else
 68#define merge_64(high, low) ((u64)high << 32) | low
 
 
 69#endif
 70
 71compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
 72			     u32 reg6, u32 pos1, u32 pos2)
 
 
 73{
 74	return ksys_pread64(fd, ubuf, count, merge_64(pos1, pos2));
 75}
 76
 77compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count,
 78			      u32 reg6, u32 pos1, u32 pos2)
 
 
 79{
 80	return ksys_pwrite64(fd, ubuf, count, merge_64(pos1, pos2));
 81}
 82
 83compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offset1, u32 offset2, u32 count)
 
 
 84{
 85	return ksys_readahead(fd, merge_64(offset1, offset2), count);
 86}
 87
 88asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
 89				unsigned long len1, unsigned long len2)
 
 90{
 91	return ksys_truncate(path, merge_64(len1, len2));
 92}
 93
 94asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offset1, u32 offset2,
 95				     u32 len1, u32 len2)
 96{
 97	return ksys_fallocate(fd, mode, ((loff_t)offset1 << 32) | offset2,
 98			     merge_64(len1, len2));
 99}
100
101asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long len1,
102				 unsigned long len2)
103{
104	return ksys_ftruncate(fd, merge_64(len1, len2));
105}
106
107long ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
108		     size_t len, int advice)
 
109{
110	return ksys_fadvise64_64(fd, merge_64(offset1, offset2), len,
111				 advice);
112}
113
114asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,
115				   unsigned offset1, unsigned offset2,
116				   unsigned nbytes1, unsigned nbytes2)
 
117{
118	loff_t offset = merge_64(offset1, offset2);
119	loff_t nbytes = merge_64(nbytes1, nbytes2);
120
121	return ksys_sync_file_range(fd, offset, nbytes, flags);
122}