^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct thread_info *ti = task_thread_info(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct pt_regs *reg = current_pt_regs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) reg->tls = addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) ti->tp_value = addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) SYSCALL_DEFINE6(mmap2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) unsigned long, addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) unsigned long, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned long, prot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) unsigned long, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) off_t, offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if (unlikely(offset & (~PAGE_MASK >> 12)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return ksys_mmap_pgoff(addr, len, prot, flags, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) offset >> (PAGE_SHIFT - 12));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * for abiv1 the 64bits args should be even th, So we need mov the advice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * forward.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) SYSCALL_DEFINE4(csky_fadvise64_64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int, fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int, advice,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) loff_t, offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) loff_t, len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return ksys_fadvise64_64(fd, offset, len, advice);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }