18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2018 David Abdurachmanov <david.abdurachmanov@gmail.com> 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 68c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License version 2 as 78c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 108c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 118c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 128c2ecf20Sopenharmony_ci * GNU General Public License for more details. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 158c2ecf20Sopenharmony_ci * along with this program. If not, see <https://www.gnu.org/licenses/>. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifdef __LP64__ 198c2ecf20Sopenharmony_ci#define __ARCH_WANT_NEW_STAT 208c2ecf20Sopenharmony_ci#define __ARCH_WANT_SET_GET_RLIMIT 218c2ecf20Sopenharmony_ci#endif /* __LP64__ */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define __ARCH_WANT_SYS_CLONE3 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include <asm-generic/unistd.h> 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci * Allows the instruction cache to be flushed from userspace. Despite RISC-V 298c2ecf20Sopenharmony_ci * having a direct 'fence.i' instruction available to userspace (which we 308c2ecf20Sopenharmony_ci * can't trap!), that's not actually viable when running on Linux because the 318c2ecf20Sopenharmony_ci * kernel might schedule a process on another hart. There is no way for 328c2ecf20Sopenharmony_ci * userspace to handle this without invoking the kernel (as it doesn't know the 338c2ecf20Sopenharmony_ci * thread->hart mappings), so we've defined a RISC-V specific system call to 348c2ecf20Sopenharmony_ci * flush the instruction cache. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * __NR_riscv_flush_icache is defined to flush the instruction cache over an 378c2ecf20Sopenharmony_ci * address range, with the flush applying to either all threads or just the 388c2ecf20Sopenharmony_ci * caller. We don't currently do anything with the address range, that's just 398c2ecf20Sopenharmony_ci * in there for forwards compatibility. 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci#ifndef __NR_riscv_flush_icache 428c2ecf20Sopenharmony_ci#define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15) 438c2ecf20Sopenharmony_ci#endif 448c2ecf20Sopenharmony_ci__SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache) 45