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

LoongArch: Adjust system call for 32BIT/64BIT

Adjust system call for both 32BIT and 64BIT, including: add the uapi
unistd_{32,64}.h and syscall_table_{32,64}.h inclusion, add sys_mmap2()
definition, change the system call entry routines, etc.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

+33 -11
+1
arch/loongarch/include/asm/Kbuild
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 + syscall-y += syscall_table_32.h 2 3 syscall-y += syscall_table_64.h 3 4 generated-y += orc_hash.h 4 5
+1
arch/loongarch/include/uapi/asm/Kbuild
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 + syscall-y += unistd_32.h 2 3 syscall-y += unistd_64.h
+6
arch/loongarch/include/uapi/asm/unistd.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 2 3 + #include <asm/bitsperlong.h> 4 + 5 + #if __BITS_PER_LONG == 32 6 + #include <asm/unistd_32.h> 7 + #else 3 8 #include <asm/unistd_64.h> 9 + #endif
+1
arch/loongarch/kernel/Makefile.syscalls
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 3 # No special ABIs on loongarch so far 4 + syscall_abis_32 += 4 5 syscall_abis_64 +=
+11 -11
arch/loongarch/kernel/entry.S
··· 23 23 UNWIND_HINT_UNDEFINED 24 24 csrrd t0, PERCPU_BASE_KS 25 25 la.pcrel t1, kernelsp 26 - add.d t1, t1, t0 26 + PTR_ADD t1, t1, t0 27 27 move t2, sp 28 - ld.d sp, t1, 0 28 + PTR_L sp, t1, 0 29 29 30 - addi.d sp, sp, -PT_SIZE 30 + PTR_ADDI sp, sp, -PT_SIZE 31 31 cfi_st t2, PT_R3 32 32 cfi_rel_offset sp, PT_R3 33 - st.d zero, sp, PT_R0 33 + LONG_S zero, sp, PT_R0 34 34 csrrd t2, LOONGARCH_CSR_PRMD 35 - st.d t2, sp, PT_PRMD 35 + LONG_S t2, sp, PT_PRMD 36 36 csrrd t2, LOONGARCH_CSR_CRMD 37 - st.d t2, sp, PT_CRMD 37 + LONG_S t2, sp, PT_CRMD 38 38 csrrd t2, LOONGARCH_CSR_EUEN 39 - st.d t2, sp, PT_EUEN 39 + LONG_S t2, sp, PT_EUEN 40 40 csrrd t2, LOONGARCH_CSR_ECFG 41 - st.d t2, sp, PT_ECFG 41 + LONG_S t2, sp, PT_ECFG 42 42 csrrd t2, LOONGARCH_CSR_ESTAT 43 - st.d t2, sp, PT_ESTAT 43 + LONG_S t2, sp, PT_ESTAT 44 44 cfi_st ra, PT_R1 45 45 cfi_st a0, PT_R4 46 46 cfi_st a1, PT_R5 ··· 51 51 cfi_st a6, PT_R10 52 52 cfi_st a7, PT_R11 53 53 csrrd ra, LOONGARCH_CSR_ERA 54 - st.d ra, sp, PT_ERA 54 + LONG_S ra, sp, PT_ERA 55 55 cfi_rel_offset ra, PT_ERA 56 56 57 57 cfi_st tp, PT_R2 ··· 67 67 #endif 68 68 69 69 move u0, t0 70 - li.d tp, ~_THREAD_MASK 70 + LONG_LI tp, ~_THREAD_MASK 71 71 and tp, tp, sp 72 72 73 73 move a0, sp
+13
arch/loongarch/kernel/syscall.c
··· 34 34 return ksys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); 35 35 } 36 36 37 + SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, unsigned long, 38 + prot, unsigned long, flags, unsigned long, fd, unsigned long, offset) 39 + { 40 + if (offset & (~PAGE_MASK >> 12)) 41 + return -EINVAL; 42 + 43 + return ksys_mmap_pgoff(addr, len, prot, flags, fd, offset >> (PAGE_SHIFT - 12)); 44 + } 45 + 37 46 void *sys_call_table[__NR_syscalls] = { 38 47 [0 ... __NR_syscalls - 1] = sys_ni_syscall, 48 + #ifdef CONFIG_32BIT 49 + #include <asm/syscall_table_32.h> 50 + #else 39 51 #include <asm/syscall_table_64.h> 52 + #endif 40 53 }; 41 54 42 55 typedef long (*sys_call_fn)(unsigned long, unsigned long,