118f90d37SArnaldo Carvalho de Melo /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 218f90d37SArnaldo Carvalho de Melo /* 318f90d37SArnaldo Carvalho de Melo * Copyright (C) 2018 David Abdurachmanov <david.abdurachmanov@gmail.com> 418f90d37SArnaldo Carvalho de Melo * 518f90d37SArnaldo Carvalho de Melo * This program is free software; you can redistribute it and/or modify 618f90d37SArnaldo Carvalho de Melo * it under the terms of the GNU General Public License version 2 as 718f90d37SArnaldo Carvalho de Melo * published by the Free Software Foundation. 818f90d37SArnaldo Carvalho de Melo * 918f90d37SArnaldo Carvalho de Melo * This program is distributed in the hope that it will be useful, 1018f90d37SArnaldo Carvalho de Melo * but WITHOUT ANY WARRANTY; without even the implied warranty of 1118f90d37SArnaldo Carvalho de Melo * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1218f90d37SArnaldo Carvalho de Melo * GNU General Public License for more details. 1318f90d37SArnaldo Carvalho de Melo * 1418f90d37SArnaldo Carvalho de Melo * You should have received a copy of the GNU General Public License 15*8e0c02f2SAlexander A. Klimov * along with this program. If not, see <https://www.gnu.org/licenses/>. 1618f90d37SArnaldo Carvalho de Melo */ 1718f90d37SArnaldo Carvalho de Melo 1818f90d37SArnaldo Carvalho de Melo #ifdef __LP64__ 1918f90d37SArnaldo Carvalho de Melo #define __ARCH_WANT_NEW_STAT 2018f90d37SArnaldo Carvalho de Melo #define __ARCH_WANT_SET_GET_RLIMIT 2118f90d37SArnaldo Carvalho de Melo #endif /* __LP64__ */ 2218f90d37SArnaldo Carvalho de Melo 2318f90d37SArnaldo Carvalho de Melo #include <asm-generic/unistd.h> 2418f90d37SArnaldo Carvalho de Melo 2518f90d37SArnaldo Carvalho de Melo /* 2618f90d37SArnaldo Carvalho de Melo * Allows the instruction cache to be flushed from userspace. Despite RISC-V 2718f90d37SArnaldo Carvalho de Melo * having a direct 'fence.i' instruction available to userspace (which we 2818f90d37SArnaldo Carvalho de Melo * can't trap!), that's not actually viable when running on Linux because the 2918f90d37SArnaldo Carvalho de Melo * kernel might schedule a process on another hart. There is no way for 3018f90d37SArnaldo Carvalho de Melo * userspace to handle this without invoking the kernel (as it doesn't know the 3118f90d37SArnaldo Carvalho de Melo * thread->hart mappings), so we've defined a RISC-V specific system call to 3218f90d37SArnaldo Carvalho de Melo * flush the instruction cache. 3318f90d37SArnaldo Carvalho de Melo * 3418f90d37SArnaldo Carvalho de Melo * __NR_riscv_flush_icache is defined to flush the instruction cache over an 3518f90d37SArnaldo Carvalho de Melo * address range, with the flush applying to either all threads or just the 3618f90d37SArnaldo Carvalho de Melo * caller. We don't currently do anything with the address range, that's just 3718f90d37SArnaldo Carvalho de Melo * in there for forwards compatibility. 3818f90d37SArnaldo Carvalho de Melo */ 3918f90d37SArnaldo Carvalho de Melo #ifndef __NR_riscv_flush_icache 4018f90d37SArnaldo Carvalho de Melo #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15) 4118f90d37SArnaldo Carvalho de Melo #endif 4218f90d37SArnaldo Carvalho de Melo __SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache) 43