VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
97870c34b4532 arch/um/os-Linux/skas/mem.c    (Alex Dewar                     2019-08-25 10:49:18 +0100   1) // SPDX-License-Identifier: GPL-2.0
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800   2) /*
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700   3)  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700   4)  */
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700   5) 
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700   6) #include <stddef.h>
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700   7) #include <unistd.h>
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700   8) #include <errno.h>
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700   9) #include <string.h>
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700  10) #include <sys/mman.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  11) #include <init.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  12) #include <as-layout.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  13) #include <mm_id.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  14) #include <os.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  15) #include <ptrace_user.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  16) #include <registers.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  17) #include <skas.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  18) #include <sysdep/ptrace.h>
37185b3324087 arch/um/os-Linux/skas/mem.c    (Al Viro                        2012-10-08 03:27:32 +0100  19) #include <sysdep/stub.h>
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700  20) 
5f32943b5e9a4 arch/um/os-Linux/skas/mem.c    (Nicolas Iooss                  2014-10-12 13:02:13 +0200  21) extern char batch_syscall_stub[], __syscall_stub_start[];
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700  22) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  23) extern void wait_stub_done(int pid);
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700  24) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  25) static inline unsigned long *check_init_stack(struct mm_id * mm_idp,
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  26) 					      unsigned long *stack)
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  27) {
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  28) 	if (stack == NULL) {
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  29) 		stack = (unsigned long *) mm_idp->stack + 2;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  30) 		*stack = 0;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  31) 	}
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  32) 	return stack;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  33) }
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  34) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  35) static unsigned long syscall_regs[MAX_REG_NR];
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  36) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  37) static int __init init_syscall_regs(void)
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  38) {
fbfe9c847edf5 arch/um/os-Linux/skas/mem.c    (Ingo van Lil                   2011-09-14 16:21:23 -0700  39) 	get_safe_registers(syscall_regs, NULL);
54ae36f24b103 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:33 -0700  40) 	syscall_regs[REGS_IP_INDEX] = STUB_CODE +
5f32943b5e9a4 arch/um/os-Linux/skas/mem.c    (Nicolas Iooss                  2014-10-12 13:02:13 +0200  41) 		((unsigned long) batch_syscall_stub -
5f32943b5e9a4 arch/um/os-Linux/skas/mem.c    (Nicolas Iooss                  2014-10-12 13:02:13 +0200  42) 		 (unsigned long) __syscall_stub_start);
9f0b4807a44ff arch/um/os-Linux/skas/mem.c    (Johannes Berg                  2021-01-13 22:09:43 +0100  43) 	syscall_regs[REGS_SP_INDEX] = STUB_DATA;
9f0b4807a44ff arch/um/os-Linux/skas/mem.c    (Johannes Berg                  2021-01-13 22:09:43 +0100  44) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  45) 	return 0;
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  46) }
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  47) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  48) __initcall(init_syscall_regs);
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  49) 
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800  50) static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700  51) {
b92c4f922b2e8 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-03-26 21:32:25 -0800  52) 	int n, i;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  53) 	long ret, offset;
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800  54) 	unsigned long * data;
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800  55) 	unsigned long * syscall;
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  56) 	int err, pid = mm_idp->u.pid;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  57) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  58) 	n = ptrace_setregs(pid, syscall_regs);
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  59) 	if (n < 0) {
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  60) 		printk(UM_KERN_ERR "Registers - \n");
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  61) 		for (i = 0; i < MAX_REG_NR; i++)
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  62) 			printk(UM_KERN_ERR "\t%d\t0x%lx\n", i, syscall_regs[i]);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  63) 		panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n",
b92c4f922b2e8 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-03-26 21:32:25 -0800  64) 		      -n);
b92c4f922b2e8 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-03-26 21:32:25 -0800  65) 	}
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  66) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  67) 	err = ptrace(PTRACE_CONT, pid, 0, 0);
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  68) 	if (err)
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  69) 		panic("Failed to continue stub, pid = %d, errno = %d\n", pid,
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  70) 		      errno);
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  71) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700  72) 	wait_stub_done(pid);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  73) 
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  74) 	/*
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  75) 	 * When the stub stops, we find the following values on the
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  76) 	 * beginning of the stack:
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  77) 	 * (long )return_value
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  78) 	 * (long )offset to failed sycall-data (0, if no error)
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  79) 	 */
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  80) 	ret = *((unsigned long *) mm_idp->stack);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  81) 	offset = *((unsigned long *) mm_idp->stack + 1);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  82) 	if (offset) {
54ae36f24b103 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:33 -0700  83) 		data = (unsigned long *)(mm_idp->stack + offset - STUB_DATA);
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  84) 		printk(UM_KERN_ERR "do_syscall_stub : ret = %ld, offset = %ld, "
802e307795c9c arch/um/os-Linux/skas/mem.c    (Paolo 'Blaisorblade' Giarrusso 2006-04-10 22:53:32 -0700  85) 		       "data = %p\n", ret, offset, data);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  86) 		syscall = (unsigned long *)((unsigned long)data + data[0]);
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  87) 		printk(UM_KERN_ERR "do_syscall_stub: syscall %ld failed, "
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  88) 		       "return value = 0x%lx, expected return value = 0x%lx\n",
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  89) 		       syscall[0], ret, syscall[7]);
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  90) 		printk(UM_KERN_ERR "    syscall parameters: "
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  91) 		       "0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  92) 		       syscall[1], syscall[2], syscall[3],
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700  93) 		       syscall[4], syscall[5], syscall[6]);
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  94) 		for (n = 1; n < data[0]/sizeof(long); n++) {
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  95) 			if (n == 1)
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  96) 				printk(UM_KERN_ERR "    additional syscall "
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  97) 				       "data:");
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  98) 			if (n % 4 == 1)
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700  99) 				printk("\n" UM_KERN_ERR "      ");
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 100) 			printk("  0x%lx", data[n]);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 101) 		}
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 102) 		if (n > 1)
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 103) 			printk("\n");
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 104) 	}
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 105) 	else ret = 0;
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 106) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 107) 	*addr = check_init_stack(mm_idp, NULL);
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 108) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 109) 	return ret;
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 110) }
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 111) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 112) long run_syscall_stub(struct mm_id * mm_idp, int syscall,
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 113) 		      unsigned long *args, long expected, void **addr,
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 114) 		      int done)
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 115) {
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 116) 	unsigned long *stack = check_init_stack(mm_idp, *addr);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 117) 
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 118) 	*stack += sizeof(long);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 119) 	stack += *stack / sizeof(long);
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 120) 
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 121) 	*stack++ = syscall;
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 122) 	*stack++ = args[0];
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 123) 	*stack++ = args[1];
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 124) 	*stack++ = args[2];
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 125) 	*stack++ = args[3];
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 126) 	*stack++ = args[4];
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 127) 	*stack++ = args[5];
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 128) 	*stack++ = expected;
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 129) 	*stack = 0;
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 130) 
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 131) 	if (!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) <
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 132) 		     UM_KERN_PAGE_SIZE - 10 * sizeof(long))) {
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 133) 		*addr = stack;
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 134) 		return 0;
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 135) 	}
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 136) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 137) 	return do_syscall_stub(mm_idp, addr);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 138) }
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 139) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 140) long syscall_stub_data(struct mm_id * mm_idp,
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 141) 		       unsigned long *data, int data_count,
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 142) 		       void **addr, void **stub_addr)
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 143) {
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 144) 	unsigned long *stack;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 145) 	int ret = 0;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 146) 
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 147) 	/*
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 148) 	 * If *addr still is uninitialized, it *must* contain NULL.
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 149) 	 * Thus in this case do_syscall_stub correctly won't be called.
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 150) 	 */
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 151) 	if ((((unsigned long) *addr) & ~UM_KERN_PAGE_MASK) >=
c539ab73070b3 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-06-16 10:16:09 -0700 152) 	   UM_KERN_PAGE_SIZE - (10 + data_count) * sizeof(long)) {
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 153) 		ret = do_syscall_stub(mm_idp, addr);
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 154) 		/* in case of error, don't overwrite data on stack */
ba180fd437156 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:00 -0700 155) 		if (ret)
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 156) 			return ret;
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 157) 	}
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700 158) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 159) 	stack = check_init_stack(mm_idp, *addr);
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 160) 	*addr = stack;
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700 161) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 162) 	*stack = data_count * sizeof(long);
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 163) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 164) 	memcpy(stack + 1, data, data_count * sizeof(long));
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 165) 
c539ab73070b3 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-06-16 10:16:09 -0700 166) 	*stub_addr = (void *)(((unsigned long)(stack + 1) &
54ae36f24b103 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-10-16 01:27:33 -0700 167) 			       ~UM_KERN_PAGE_MASK) + STUB_DATA);
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 168) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 169) 	return 0;
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 170) }
c56004901fa5d arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-09-03 15:57:36 -0700 171) 
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700 172) int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len, int prot,
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700 173) 	int phys_fd, unsigned long long offset, int done, void **data)
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 174) {
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700 175) 	int ret;
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 176) 	unsigned long args[] = { virt, len, prot,
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 177) 				 MAP_SHARED | MAP_FIXED, phys_fd,
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 178) 				 MMAP_OFFSET(offset) };
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 179) 
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 180) 	ret = run_syscall_stub(mm_idp, STUB_MMAP_NR, args, virt,
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 181) 			       data, done);
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700 182) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 183) 	return ret;
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 184) }
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 185) 
64f60841c0965 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:45 -0700 186) int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
64f60841c0965 arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:45 -0700 187) 	  int done, void **data)
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 188) {
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 189) 	int ret;
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 190) 	unsigned long args[] = { (unsigned long) addr, len, 0, 0, 0,
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 191) 				 0 };
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 192) 
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 193) 	ret = run_syscall_stub(mm_idp, __NR_munmap, args, 0,
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 194) 			       data, done);
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700 195) 
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 196) 	return ret;
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700 197) }
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 198) 
07bf731e4b95d arch/um/kernel/skas/mem_user.c (Bodo Stroesser                 2005-09-03 15:57:50 -0700 199) int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700 200) 	    unsigned int prot, int done, void **data)
d67b569f5f620 arch/um/kernel/skas/mem_user.c (Jeff Dike                      2005-07-07 17:56:49 -0700 201) {
16dd07bc6404c arch/um/os-Linux/skas/mem.c    (Jeff Dike                      2007-05-06 14:51:48 -0700 202) 	int ret;
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 203) 	unsigned long args[] = { addr, len, prot, 0, 0, 0 };
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 204) 
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 205) 	ret = run_syscall_stub(mm_idp, __NR_mprotect, args, 0,
d0b5e15f0c0fd arch/um/os-Linux/skas/mem.c    (Richard Weinberger             2015-03-18 21:31:27 +0100 206) 			       data, done);
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 207) 
f45d9fc9d8067 arch/um/os-Linux/skas/mem.c    (Gennady Sharapov               2006-01-18 17:42:45 -0800 208) 	return ret;
^1da177e4c3f4 arch/um/kernel/skas/mem_user.c (Linus Torvalds                 2005-04-16 15:20:36 -0700 209) }