xref: /linux/arch/um/include/shared/skas/stub-data.h (revision 2d7eaeb05ae265bd64270376e6a2c0d80244771f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 
4  * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
5  * Copyright (C) 2005 Jeff Dike (jdike@karaya.com)
6  */
7 
8 #ifndef __STUB_DATA_H
9 #define __STUB_DATA_H
10 
11 #include <linux/compiler_types.h>
12 #include <asm/unistd.h>
13 #include <as-layout.h>
14 #include <sysdep/tls.h>
15 #include <sysdep/stub-data.h>
16 #include <mm_id.h>
17 
18 #ifndef __NR_close_range
19 # if defined(__alpha__)
20 #  define __NR_close_range 546
21 # else
22 #  define __NR_close_range 436
23 # endif
24 #endif
25 
26 #define FUTEX_IN_CHILD 0
27 #define FUTEX_IN_KERN 1
28 
29 struct stub_init_data {
30 	int seccomp;
31 
32 	unsigned long stub_start;
33 
34 	int stub_code_fd;
35 	unsigned long stub_code_offset;
36 	int stub_data_fd;
37 	unsigned long stub_data_offset;
38 
39 	unsigned long signal_handler;
40 	unsigned long signal_restorer;
41 };
42 
43 #define STUB_NEXT_SYSCALL(s) \
44 	((struct stub_syscall *) (((unsigned long) s) + (s)->cmd_len))
45 
46 enum stub_syscall_type {
47 	STUB_SYSCALL_UNSET = 0,
48 	STUB_SYSCALL_MMAP,
49 	STUB_SYSCALL_MUNMAP,
50 };
51 
52 struct stub_syscall {
53 	struct {
54 		unsigned long addr;
55 		unsigned long length;
56 		unsigned long offset;
57 		int fd;
58 		int prot;
59 	} mem;
60 
61 	enum stub_syscall_type syscall;
62 };
63 
64 struct stub_data {
65 	long err;
66 
67 	int syscall_data_len;
68 	/* 128 leaves enough room for additional fields in the struct */
69 	struct stub_syscall syscall_data[(UM_KERN_PAGE_SIZE - 128) / sizeof(struct stub_syscall)] __aligned(16);
70 
71 	/* data shared with signal handler (only used in seccomp mode) */
72 	short restart_wait;
73 	unsigned int futex;
74 	int signal;
75 	unsigned short si_offset;
76 	unsigned short mctx_offset;
77 
78 	/* seccomp architecture specific state restore */
79 	struct stub_data_arch arch_data;
80 
81 	/* Stack for our signal handlers and for calling into . */
82 	unsigned char sigstack[UM_KERN_PAGE_SIZE] __aligned(UM_KERN_PAGE_SIZE);
83 };
84 
85 #endif
86