162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci/*
462306a36Sopenharmony_ci *    PARISC specific syscalls
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci *    Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org>
762306a36Sopenharmony_ci *    Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
862306a36Sopenharmony_ci *    Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
962306a36Sopenharmony_ci *    Copyright (C) 1999-2020 Helge Deller <deller@gmx.de>
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/uaccess.h>
1362306a36Sopenharmony_ci#include <asm/elf.h>
1462306a36Sopenharmony_ci#include <linux/file.h>
1562306a36Sopenharmony_ci#include <linux/fs.h>
1662306a36Sopenharmony_ci#include <linux/linkage.h>
1762306a36Sopenharmony_ci#include <linux/mm.h>
1862306a36Sopenharmony_ci#include <linux/mman.h>
1962306a36Sopenharmony_ci#include <linux/sched/signal.h>
2062306a36Sopenharmony_ci#include <linux/sched/mm.h>
2162306a36Sopenharmony_ci#include <linux/shm.h>
2262306a36Sopenharmony_ci#include <linux/syscalls.h>
2362306a36Sopenharmony_ci#include <linux/utsname.h>
2462306a36Sopenharmony_ci#include <linux/personality.h>
2562306a36Sopenharmony_ci#include <linux/random.h>
2662306a36Sopenharmony_ci#include <linux/compat.h>
2762306a36Sopenharmony_ci#include <linux/elf-randomize.h>
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/*
3062306a36Sopenharmony_ci * Construct an artificial page offset for the mapping based on the physical
3162306a36Sopenharmony_ci * address of the kernel file mapping variable.
3262306a36Sopenharmony_ci */
3362306a36Sopenharmony_ci#define GET_FILP_PGOFF(filp)		\
3462306a36Sopenharmony_ci	(filp ? (((unsigned long) filp->f_mapping) >> 8)	\
3562306a36Sopenharmony_ci		 & ((SHM_COLOUR-1) >> PAGE_SHIFT) : 0UL)
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_cistatic unsigned long shared_align_offset(unsigned long filp_pgoff,
3862306a36Sopenharmony_ci					 unsigned long pgoff)
3962306a36Sopenharmony_ci{
4062306a36Sopenharmony_ci	return (filp_pgoff + pgoff) << PAGE_SHIFT;
4162306a36Sopenharmony_ci}
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_cistatic inline unsigned long COLOR_ALIGN(unsigned long addr,
4462306a36Sopenharmony_ci			 unsigned long filp_pgoff, unsigned long pgoff)
4562306a36Sopenharmony_ci{
4662306a36Sopenharmony_ci	unsigned long base = (addr+SHM_COLOUR-1) & ~(SHM_COLOUR-1);
4762306a36Sopenharmony_ci	unsigned long off  = (SHM_COLOUR-1) &
4862306a36Sopenharmony_ci		shared_align_offset(filp_pgoff, pgoff);
4962306a36Sopenharmony_ci	return base + off;
5062306a36Sopenharmony_ci}
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define STACK_SIZE_DEFAULT (USER_WIDE_MODE			\
5462306a36Sopenharmony_ci			? (1 << 30)	/* 1 GB */		\
5562306a36Sopenharmony_ci			: (CONFIG_STACK_MAX_DEFAULT_SIZE_MB*1024*1024))
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciunsigned long calc_max_stack_size(unsigned long stack_max)
5862306a36Sopenharmony_ci{
5962306a36Sopenharmony_ci#ifdef CONFIG_COMPAT
6062306a36Sopenharmony_ci	if (!USER_WIDE_MODE && (stack_max == COMPAT_RLIM_INFINITY))
6162306a36Sopenharmony_ci		stack_max = STACK_SIZE_DEFAULT;
6262306a36Sopenharmony_ci	else
6362306a36Sopenharmony_ci#endif
6462306a36Sopenharmony_ci	if (stack_max == RLIM_INFINITY)
6562306a36Sopenharmony_ci		stack_max = STACK_SIZE_DEFAULT;
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	return stack_max;
6862306a36Sopenharmony_ci}
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/*
7262306a36Sopenharmony_ci * Top of mmap area (just below the process stack).
7362306a36Sopenharmony_ci */
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/*
7662306a36Sopenharmony_ci * When called from arch_get_unmapped_area(), rlim_stack will be NULL,
7762306a36Sopenharmony_ci * indicating that "current" should be used instead of a passed-in
7862306a36Sopenharmony_ci * value from the exec bprm as done with arch_pick_mmap_layout().
7962306a36Sopenharmony_ci */
8062306a36Sopenharmony_ciunsigned long mmap_upper_limit(struct rlimit *rlim_stack)
8162306a36Sopenharmony_ci{
8262306a36Sopenharmony_ci	unsigned long stack_base;
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci	/* Limit stack size - see setup_arg_pages() in fs/exec.c */
8562306a36Sopenharmony_ci	stack_base = rlim_stack ? rlim_stack->rlim_max
8662306a36Sopenharmony_ci				: rlimit_max(RLIMIT_STACK);
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci	stack_base = calc_max_stack_size(stack_base);
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci	/* Add space for stack randomization. */
9162306a36Sopenharmony_ci	if (current->flags & PF_RANDOMIZE)
9262306a36Sopenharmony_ci		stack_base += (STACK_RND_MASK << PAGE_SHIFT);
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	return PAGE_ALIGN(STACK_TOP - stack_base);
9562306a36Sopenharmony_ci}
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_cienum mmap_allocation_direction {UP, DOWN};
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_cistatic unsigned long arch_get_unmapped_area_common(struct file *filp,
10062306a36Sopenharmony_ci	unsigned long addr, unsigned long len, unsigned long pgoff,
10162306a36Sopenharmony_ci	unsigned long flags, enum mmap_allocation_direction dir)
10262306a36Sopenharmony_ci{
10362306a36Sopenharmony_ci	struct mm_struct *mm = current->mm;
10462306a36Sopenharmony_ci	struct vm_area_struct *vma, *prev;
10562306a36Sopenharmony_ci	unsigned long filp_pgoff;
10662306a36Sopenharmony_ci	int do_color_align;
10762306a36Sopenharmony_ci	struct vm_unmapped_area_info info;
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci	if (unlikely(len > TASK_SIZE))
11062306a36Sopenharmony_ci		return -ENOMEM;
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	do_color_align = 0;
11362306a36Sopenharmony_ci	if (filp || (flags & MAP_SHARED))
11462306a36Sopenharmony_ci		do_color_align = 1;
11562306a36Sopenharmony_ci	filp_pgoff = GET_FILP_PGOFF(filp);
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci	if (flags & MAP_FIXED) {
11862306a36Sopenharmony_ci		/* Even MAP_FIXED mappings must reside within TASK_SIZE */
11962306a36Sopenharmony_ci		if (TASK_SIZE - len < addr)
12062306a36Sopenharmony_ci			return -EINVAL;
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci		if ((flags & MAP_SHARED) && filp &&
12362306a36Sopenharmony_ci		    (addr - shared_align_offset(filp_pgoff, pgoff))
12462306a36Sopenharmony_ci				& (SHM_COLOUR - 1))
12562306a36Sopenharmony_ci			return -EINVAL;
12662306a36Sopenharmony_ci		return addr;
12762306a36Sopenharmony_ci	}
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci	if (addr) {
13062306a36Sopenharmony_ci		if (do_color_align)
13162306a36Sopenharmony_ci			addr = COLOR_ALIGN(addr, filp_pgoff, pgoff);
13262306a36Sopenharmony_ci		else
13362306a36Sopenharmony_ci			addr = PAGE_ALIGN(addr);
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci		vma = find_vma_prev(mm, addr, &prev);
13662306a36Sopenharmony_ci		if (TASK_SIZE - len >= addr &&
13762306a36Sopenharmony_ci		    (!vma || addr + len <= vm_start_gap(vma)) &&
13862306a36Sopenharmony_ci		    (!prev || addr >= vm_end_gap(prev)))
13962306a36Sopenharmony_ci			return addr;
14062306a36Sopenharmony_ci	}
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci	info.length = len;
14362306a36Sopenharmony_ci	info.align_mask = do_color_align ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
14462306a36Sopenharmony_ci	info.align_offset = shared_align_offset(filp_pgoff, pgoff);
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	if (dir == DOWN) {
14762306a36Sopenharmony_ci		info.flags = VM_UNMAPPED_AREA_TOPDOWN;
14862306a36Sopenharmony_ci		info.low_limit = PAGE_SIZE;
14962306a36Sopenharmony_ci		info.high_limit = mm->mmap_base;
15062306a36Sopenharmony_ci		addr = vm_unmapped_area(&info);
15162306a36Sopenharmony_ci		if (!(addr & ~PAGE_MASK))
15262306a36Sopenharmony_ci			return addr;
15362306a36Sopenharmony_ci		VM_BUG_ON(addr != -ENOMEM);
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci		/*
15662306a36Sopenharmony_ci		 * A failed mmap() very likely causes application failure,
15762306a36Sopenharmony_ci		 * so fall back to the bottom-up function here. This scenario
15862306a36Sopenharmony_ci		 * can happen with large stack limits and large mmap()
15962306a36Sopenharmony_ci		 * allocations.
16062306a36Sopenharmony_ci		 */
16162306a36Sopenharmony_ci	}
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci	info.flags = 0;
16462306a36Sopenharmony_ci	info.low_limit = mm->mmap_base;
16562306a36Sopenharmony_ci	info.high_limit = mmap_upper_limit(NULL);
16662306a36Sopenharmony_ci	return vm_unmapped_area(&info);
16762306a36Sopenharmony_ci}
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ciunsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
17062306a36Sopenharmony_ci	unsigned long len, unsigned long pgoff, unsigned long flags)
17162306a36Sopenharmony_ci{
17262306a36Sopenharmony_ci	return arch_get_unmapped_area_common(filp,
17362306a36Sopenharmony_ci			addr, len, pgoff, flags, UP);
17462306a36Sopenharmony_ci}
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ciunsigned long arch_get_unmapped_area_topdown(struct file *filp,
17762306a36Sopenharmony_ci	unsigned long addr, unsigned long len, unsigned long pgoff,
17862306a36Sopenharmony_ci	unsigned long flags)
17962306a36Sopenharmony_ci{
18062306a36Sopenharmony_ci	return arch_get_unmapped_area_common(filp,
18162306a36Sopenharmony_ci			addr, len, pgoff, flags, DOWN);
18262306a36Sopenharmony_ci}
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ciasmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
18562306a36Sopenharmony_ci	unsigned long prot, unsigned long flags, unsigned long fd,
18662306a36Sopenharmony_ci	unsigned long pgoff)
18762306a36Sopenharmony_ci{
18862306a36Sopenharmony_ci	/* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
18962306a36Sopenharmony_ci	   we have. */
19062306a36Sopenharmony_ci	return ksys_mmap_pgoff(addr, len, prot, flags, fd,
19162306a36Sopenharmony_ci			       pgoff >> (PAGE_SHIFT - 12));
19262306a36Sopenharmony_ci}
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ciasmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
19562306a36Sopenharmony_ci		unsigned long prot, unsigned long flags, unsigned long fd,
19662306a36Sopenharmony_ci		unsigned long offset)
19762306a36Sopenharmony_ci{
19862306a36Sopenharmony_ci	if (!(offset & ~PAGE_MASK)) {
19962306a36Sopenharmony_ci		return ksys_mmap_pgoff(addr, len, prot, flags, fd,
20062306a36Sopenharmony_ci					offset >> PAGE_SHIFT);
20162306a36Sopenharmony_ci	} else {
20262306a36Sopenharmony_ci		return -EINVAL;
20362306a36Sopenharmony_ci	}
20462306a36Sopenharmony_ci}
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci/* Fucking broken ABI */
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci#ifdef CONFIG_64BIT
20962306a36Sopenharmony_ciasmlinkage long parisc_truncate64(const char __user * path,
21062306a36Sopenharmony_ci					unsigned int high, unsigned int low)
21162306a36Sopenharmony_ci{
21262306a36Sopenharmony_ci	return ksys_truncate(path, (long)high << 32 | low);
21362306a36Sopenharmony_ci}
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ciasmlinkage long parisc_ftruncate64(unsigned int fd,
21662306a36Sopenharmony_ci					unsigned int high, unsigned int low)
21762306a36Sopenharmony_ci{
21862306a36Sopenharmony_ci	return ksys_ftruncate(fd, (long)high << 32 | low);
21962306a36Sopenharmony_ci}
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci/* stubs for the benefit of the syscall_table since truncate64 and truncate
22262306a36Sopenharmony_ci * are identical on LP64 */
22362306a36Sopenharmony_ciasmlinkage long sys_truncate64(const char __user * path, unsigned long length)
22462306a36Sopenharmony_ci{
22562306a36Sopenharmony_ci	return ksys_truncate(path, length);
22662306a36Sopenharmony_ci}
22762306a36Sopenharmony_ciasmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length)
22862306a36Sopenharmony_ci{
22962306a36Sopenharmony_ci	return ksys_ftruncate(fd, length);
23062306a36Sopenharmony_ci}
23162306a36Sopenharmony_ciasmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
23262306a36Sopenharmony_ci{
23362306a36Sopenharmony_ci	return sys_fcntl(fd, cmd, arg);
23462306a36Sopenharmony_ci}
23562306a36Sopenharmony_ci#else
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ciasmlinkage long parisc_truncate64(const char __user * path,
23862306a36Sopenharmony_ci					unsigned int high, unsigned int low)
23962306a36Sopenharmony_ci{
24062306a36Sopenharmony_ci	return ksys_truncate(path, (loff_t)high << 32 | low);
24162306a36Sopenharmony_ci}
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ciasmlinkage long parisc_ftruncate64(unsigned int fd,
24462306a36Sopenharmony_ci					unsigned int high, unsigned int low)
24562306a36Sopenharmony_ci{
24662306a36Sopenharmony_ci	return sys_ftruncate64(fd, (loff_t)high << 32 | low);
24762306a36Sopenharmony_ci}
24862306a36Sopenharmony_ci#endif
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ciasmlinkage ssize_t parisc_pread64(unsigned int fd, char __user *buf, size_t count,
25162306a36Sopenharmony_ci					unsigned int high, unsigned int low)
25262306a36Sopenharmony_ci{
25362306a36Sopenharmony_ci	return ksys_pread64(fd, buf, count, (loff_t)high << 32 | low);
25462306a36Sopenharmony_ci}
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ciasmlinkage ssize_t parisc_pwrite64(unsigned int fd, const char __user *buf,
25762306a36Sopenharmony_ci			size_t count, unsigned int high, unsigned int low)
25862306a36Sopenharmony_ci{
25962306a36Sopenharmony_ci	return ksys_pwrite64(fd, buf, count, (loff_t)high << 32 | low);
26062306a36Sopenharmony_ci}
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ciasmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low,
26362306a36Sopenharmony_ci		                    size_t count)
26462306a36Sopenharmony_ci{
26562306a36Sopenharmony_ci	return ksys_readahead(fd, (loff_t)high << 32 | low, count);
26662306a36Sopenharmony_ci}
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ciasmlinkage long parisc_fadvise64_64(int fd,
26962306a36Sopenharmony_ci			unsigned int high_off, unsigned int low_off,
27062306a36Sopenharmony_ci			unsigned int high_len, unsigned int low_len, int advice)
27162306a36Sopenharmony_ci{
27262306a36Sopenharmony_ci	return ksys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
27362306a36Sopenharmony_ci			(loff_t)high_len << 32 | low_len, advice);
27462306a36Sopenharmony_ci}
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ciasmlinkage long parisc_sync_file_range(int fd,
27762306a36Sopenharmony_ci			u32 hi_off, u32 lo_off, u32 hi_nbytes, u32 lo_nbytes,
27862306a36Sopenharmony_ci			unsigned int flags)
27962306a36Sopenharmony_ci{
28062306a36Sopenharmony_ci	return ksys_sync_file_range(fd, (loff_t)hi_off << 32 | lo_off,
28162306a36Sopenharmony_ci			(loff_t)hi_nbytes << 32 | lo_nbytes, flags);
28262306a36Sopenharmony_ci}
28362306a36Sopenharmony_ci
28462306a36Sopenharmony_ciasmlinkage long parisc_fallocate(int fd, int mode, u32 offhi, u32 offlo,
28562306a36Sopenharmony_ci				u32 lenhi, u32 lenlo)
28662306a36Sopenharmony_ci{
28762306a36Sopenharmony_ci	return ksys_fallocate(fd, mode, ((u64)offhi << 32) | offlo,
28862306a36Sopenharmony_ci			      ((u64)lenhi << 32) | lenlo);
28962306a36Sopenharmony_ci}
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ciasmlinkage long parisc_personality(unsigned long personality)
29262306a36Sopenharmony_ci{
29362306a36Sopenharmony_ci	long err;
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci	if (personality(current->personality) == PER_LINUX32
29662306a36Sopenharmony_ci	    && personality(personality) == PER_LINUX)
29762306a36Sopenharmony_ci		personality = (personality & ~PER_MASK) | PER_LINUX32;
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci	err = sys_personality(personality);
30062306a36Sopenharmony_ci	if (personality(err) == PER_LINUX32)
30162306a36Sopenharmony_ci		err = (err & ~PER_MASK) | PER_LINUX;
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci	return err;
30462306a36Sopenharmony_ci}
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_ci/*
30762306a36Sopenharmony_ci * Up to kernel v5.9 we defined O_NONBLOCK as 000200004,
30862306a36Sopenharmony_ci * since then O_NONBLOCK is defined as 000200000.
30962306a36Sopenharmony_ci *
31062306a36Sopenharmony_ci * The following wrapper functions mask out the old
31162306a36Sopenharmony_ci * O_NDELAY bit from calls which use O_NONBLOCK.
31262306a36Sopenharmony_ci *
31362306a36Sopenharmony_ci * XXX: Remove those in year 2022 (or later)?
31462306a36Sopenharmony_ci */
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci#define O_NONBLOCK_OLD		000200004
31762306a36Sopenharmony_ci#define O_NONBLOCK_MASK_OUT	(O_NONBLOCK_OLD & ~O_NONBLOCK)
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_cistatic int FIX_O_NONBLOCK(int flags)
32062306a36Sopenharmony_ci{
32162306a36Sopenharmony_ci	if ((flags & O_NONBLOCK_MASK_OUT) &&
32262306a36Sopenharmony_ci			!test_thread_flag(TIF_NONBLOCK_WARNING)) {
32362306a36Sopenharmony_ci		set_thread_flag(TIF_NONBLOCK_WARNING);
32462306a36Sopenharmony_ci		pr_warn("%s(%d) uses a deprecated O_NONBLOCK value."
32562306a36Sopenharmony_ci			" Please recompile with newer glibc.\n",
32662306a36Sopenharmony_ci			current->comm, current->pid);
32762306a36Sopenharmony_ci	}
32862306a36Sopenharmony_ci	return flags & ~O_NONBLOCK_MASK_OUT;
32962306a36Sopenharmony_ci}
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ciasmlinkage long parisc_timerfd_create(int clockid, int flags)
33262306a36Sopenharmony_ci{
33362306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
33462306a36Sopenharmony_ci	return sys_timerfd_create(clockid, flags);
33562306a36Sopenharmony_ci}
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ciasmlinkage long parisc_signalfd4(int ufd, sigset_t __user *user_mask,
33862306a36Sopenharmony_ci	size_t sizemask, int flags)
33962306a36Sopenharmony_ci{
34062306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
34162306a36Sopenharmony_ci	return sys_signalfd4(ufd, user_mask, sizemask, flags);
34262306a36Sopenharmony_ci}
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci#ifdef CONFIG_COMPAT
34562306a36Sopenharmony_ciasmlinkage long parisc_compat_signalfd4(int ufd,
34662306a36Sopenharmony_ci	compat_sigset_t __user *user_mask,
34762306a36Sopenharmony_ci	compat_size_t sizemask, int flags)
34862306a36Sopenharmony_ci{
34962306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
35062306a36Sopenharmony_ci	return compat_sys_signalfd4(ufd, user_mask, sizemask, flags);
35162306a36Sopenharmony_ci}
35262306a36Sopenharmony_ci#endif
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ciasmlinkage long parisc_eventfd2(unsigned int count, int flags)
35562306a36Sopenharmony_ci{
35662306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
35762306a36Sopenharmony_ci	return sys_eventfd2(count, flags);
35862306a36Sopenharmony_ci}
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ciasmlinkage long parisc_userfaultfd(int flags)
36162306a36Sopenharmony_ci{
36262306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
36362306a36Sopenharmony_ci	return sys_userfaultfd(flags);
36462306a36Sopenharmony_ci}
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ciasmlinkage long parisc_pipe2(int __user *fildes, int flags)
36762306a36Sopenharmony_ci{
36862306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
36962306a36Sopenharmony_ci	return sys_pipe2(fildes, flags);
37062306a36Sopenharmony_ci}
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ciasmlinkage long parisc_inotify_init1(int flags)
37362306a36Sopenharmony_ci{
37462306a36Sopenharmony_ci	flags = FIX_O_NONBLOCK(flags);
37562306a36Sopenharmony_ci	return sys_inotify_init1(flags);
37662306a36Sopenharmony_ci}
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci/*
37962306a36Sopenharmony_ci * madvise() wrapper
38062306a36Sopenharmony_ci *
38162306a36Sopenharmony_ci * Up to kernel v6.1 parisc has different values than all other
38262306a36Sopenharmony_ci * platforms for the MADV_xxx flags listed below.
38362306a36Sopenharmony_ci * To keep binary compatibility with existing userspace programs
38462306a36Sopenharmony_ci * translate the former values to the new values.
38562306a36Sopenharmony_ci *
38662306a36Sopenharmony_ci * XXX: Remove this wrapper in year 2025 (or later)
38762306a36Sopenharmony_ci */
38862306a36Sopenharmony_ci
38962306a36Sopenharmony_ciasmlinkage notrace long parisc_madvise(unsigned long start, size_t len_in, int behavior)
39062306a36Sopenharmony_ci{
39162306a36Sopenharmony_ci	switch (behavior) {
39262306a36Sopenharmony_ci	case 65: behavior = MADV_MERGEABLE;	break;
39362306a36Sopenharmony_ci	case 66: behavior = MADV_UNMERGEABLE;	break;
39462306a36Sopenharmony_ci	case 67: behavior = MADV_HUGEPAGE;	break;
39562306a36Sopenharmony_ci	case 68: behavior = MADV_NOHUGEPAGE;	break;
39662306a36Sopenharmony_ci	case 69: behavior = MADV_DONTDUMP;	break;
39762306a36Sopenharmony_ci	case 70: behavior = MADV_DODUMP;	break;
39862306a36Sopenharmony_ci	case 71: behavior = MADV_WIPEONFORK;	break;
39962306a36Sopenharmony_ci	case 72: behavior = MADV_KEEPONFORK;	break;
40062306a36Sopenharmony_ci	case 73: behavior = MADV_COLLAPSE;	break;
40162306a36Sopenharmony_ci	}
40262306a36Sopenharmony_ci
40362306a36Sopenharmony_ci	return sys_madvise(start, len_in, behavior);
40462306a36Sopenharmony_ci}
405