~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/kernel/sys_riscv.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2012 Regents of the University of California
  4  * Copyright (C) 2014 Darius Rad <darius@bluespec.com>
  5  * Copyright (C) 2017 SiFive
  6  */
  7 
  8 #include <linux/syscalls.h>
  9 #include <asm/cacheflush.h>
 10 
 11 static long riscv_sys_mmap(unsigned long addr, unsigned long len,
 12                            unsigned long prot, unsigned long flags,
 13                            unsigned long fd, off_t offset,
 14                            unsigned long page_shift_offset)
 15 {
 16         if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
 17                 return -EINVAL;
 18 
 19         return ksys_mmap_pgoff(addr, len, prot, flags, fd,
 20                                offset >> (PAGE_SHIFT - page_shift_offset));
 21 }
 22 
 23 #ifdef CONFIG_64BIT
 24 SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
 25         unsigned long, prot, unsigned long, flags,
 26         unsigned long, fd, unsigned long, offset)
 27 {
 28         return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 0);
 29 }
 30 #endif
 31 
 32 #if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
 33 SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
 34         unsigned long, prot, unsigned long, flags,
 35         unsigned long, fd, unsigned long, offset)
 36 {
 37         /*
 38          * Note that the shift for mmap2 is constant (12),
 39          * regardless of PAGE_SIZE
 40          */
 41         return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 12);
 42 }
 43 #endif
 44 
 45 /*
 46  * Allows the instruction cache to be flushed from userspace.  Despite RISC-V
 47  * having a direct 'fence.i' instruction available to userspace (which we
 48  * can't trap!), that's not actually viable when running on Linux because the
 49  * kernel might schedule a process on another hart.  There is no way for
 50  * userspace to handle this without invoking the kernel (as it doesn't know the
 51  * thread->hart mappings), so we've defined a RISC-V specific system call to
 52  * flush the instruction cache.
 53  *
 54  * sys_riscv_flush_icache() is defined to flush the instruction cache over an
 55  * address range, with the flush applying to either all threads or just the
 56  * caller.  We don't currently do anything with the address range, that's just
 57  * in there for forwards compatibility.
 58  */
 59 SYSCALL_DEFINE3(riscv_flush_icache, uintptr_t, start, uintptr_t, end,
 60         uintptr_t, flags)
 61 {
 62         /* Check the reserved flags. */
 63         if (unlikely(flags & ~SYS_RISCV_FLUSH_ICACHE_ALL))
 64                 return -EINVAL;
 65 
 66         flush_icache_mm(current->mm, flags & SYS_RISCV_FLUSH_ICACHE_LOCAL);
 67 
 68         return 0;
 69 }
 70 
 71 /* Not defined using SYSCALL_DEFINE0 to avoid error injection */
 72 asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *__unused)
 73 {
 74         return -ENOSYS;
 75 }
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php