Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: Add cacheflush() syscall

Signed-off-by: Helge Deller <deller@gmx.de>

+62
+12
arch/parisc/include/uapi/asm/cachectl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + #ifndef _ASM_CACHECTL 3 + #define _ASM_CACHECTL 4 + 5 + /* 6 + * Options for cacheflush system call 7 + */ 8 + #define ICACHE (1<<0) /* flush instruction cache */ 9 + #define DCACHE (1<<1) /* writeback and flush data cache */ 10 + #define BCACHE (ICACHE|DCACHE) /* flush both caches */ 11 + 12 + #endif /* _ASM_CACHECTL */
+49
arch/parisc/kernel/cache.c
··· 19 19 #include <linux/pagemap.h> 20 20 #include <linux/sched.h> 21 21 #include <linux/sched/mm.h> 22 + #include <linux/syscalls.h> 22 23 #include <asm/pdc.h> 23 24 #include <asm/cache.h> 24 25 #include <asm/cacheflush.h> ··· 29 28 #include <asm/sections.h> 30 29 #include <asm/shmparam.h> 31 30 #include <asm/mmu_context.h> 31 + #include <asm/cachectl.h> 32 32 33 33 int split_tlb __ro_after_init; 34 34 int dcache_stride __ro_after_init; ··· 792 790 flush_tlb_kernel_range(start, end); 793 791 } 794 792 EXPORT_SYMBOL(invalidate_kernel_vmap_range); 793 + 794 + 795 + SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes, 796 + unsigned int, cache) 797 + { 798 + unsigned long start, end; 799 + ASM_EXCEPTIONTABLE_VAR(error); 800 + 801 + if (bytes == 0) 802 + return 0; 803 + if (!access_ok((void __user *) addr, bytes)) 804 + return -EFAULT; 805 + 806 + end = addr + bytes; 807 + 808 + if (cache & DCACHE) { 809 + start = addr; 810 + __asm__ __volatile__ ( 811 + #ifdef CONFIG_64BIT 812 + "1: cmpb,*<<,n %0,%2,1b\n" 813 + #else 814 + "1: cmpb,<<,n %0,%2,1b\n" 815 + #endif 816 + " fic,m %3(%4,%0)\n" 817 + "2: sync\n" 818 + ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 2b) 819 + : "+r" (start), "+r" (error) 820 + : "r" (end), "r" (dcache_stride), "i" (SR_USER)); 821 + } 822 + 823 + if (cache & ICACHE && error == 0) { 824 + start = addr; 825 + __asm__ __volatile__ ( 826 + #ifdef CONFIG_64BIT 827 + "1: cmpb,*<<,n %0,%2,1b\n" 828 + #else 829 + "1: cmpb,<<,n %0,%2,1b\n" 830 + #endif 831 + " fdc,m %3(%4,%0)\n" 832 + "2: sync\n" 833 + ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 2b) 834 + : "+r" (start), "+r" (error) 835 + : "r" (end), "r" (icache_stride), "i" (SR_USER)); 836 + } 837 + 838 + return error; 839 + }
+1
arch/parisc/kernel/syscalls/syscall.tbl
··· 400 400 353 common pkey_free sys_pkey_free 401 401 354 common rseq sys_rseq 402 402 355 common kexec_file_load sys_kexec_file_load sys_kexec_file_load 403 + 356 common cacheflush sys_cacheflush 403 404 # up to 402 is unassigned and reserved for arch specific syscalls 404 405 403 32 clock_gettime64 sys_clock_gettime sys_clock_gettime 405 406 404 32 clock_settime64 sys_clock_settime sys_clock_settime