xref: /freebsd/sys/x86/include/sysarch.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1dfb1c113STijl Coosemans /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4dfb1c113STijl Coosemans  * Copyright (c) 1993 The Regents of the University of California.
5dfb1c113STijl Coosemans  * All rights reserved.
6dfb1c113STijl Coosemans  *
7dfb1c113STijl Coosemans  * Redistribution and use in source and binary forms, with or without
8dfb1c113STijl Coosemans  * modification, are permitted provided that the following conditions
9dfb1c113STijl Coosemans  * are met:
10dfb1c113STijl Coosemans  * 1. Redistributions of source code must retain the above copyright
11dfb1c113STijl Coosemans  *    notice, this list of conditions and the following disclaimer.
12dfb1c113STijl Coosemans  * 2. Redistributions in binary form must reproduce the above copyright
13dfb1c113STijl Coosemans  *    notice, this list of conditions and the following disclaimer in the
14dfb1c113STijl Coosemans  *    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
16dfb1c113STijl Coosemans  *    may be used to endorse or promote products derived from this software
17dfb1c113STijl Coosemans  *    without specific prior written permission.
18dfb1c113STijl Coosemans  *
19dfb1c113STijl Coosemans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20dfb1c113STijl Coosemans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21dfb1c113STijl Coosemans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22dfb1c113STijl Coosemans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23dfb1c113STijl Coosemans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24dfb1c113STijl Coosemans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25dfb1c113STijl Coosemans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26dfb1c113STijl Coosemans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27dfb1c113STijl Coosemans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28dfb1c113STijl Coosemans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29dfb1c113STijl Coosemans  * SUCH DAMAGE.
30dfb1c113STijl Coosemans  */
31dfb1c113STijl Coosemans 
32dfb1c113STijl Coosemans /*
33dfb1c113STijl Coosemans  * Architecture specific syscalls (X86)
34dfb1c113STijl Coosemans  */
35dfb1c113STijl Coosemans #ifndef _MACHINE_SYSARCH_H_
36dfb1c113STijl Coosemans #define _MACHINE_SYSARCH_H_
37dfb1c113STijl Coosemans 
38dfb1c113STijl Coosemans #include <sys/cdefs.h>
39dfb1c113STijl Coosemans 
40dfb1c113STijl Coosemans #define I386_GET_LDT	0
41dfb1c113STijl Coosemans #define I386_SET_LDT	1
42dfb1c113STijl Coosemans #define	LDT_AUTO_ALLOC	0xffffffff
43dfb1c113STijl Coosemans 				/* I386_IOPL */
44dfb1c113STijl Coosemans #define I386_GET_IOPERM	3
45dfb1c113STijl Coosemans #define I386_SET_IOPERM	4
46dfb1c113STijl Coosemans 				/* xxxxx */
47dfb1c113STijl Coosemans #define	I386_VM86		6	/* XXX Not implementable on amd64 */
48dfb1c113STijl Coosemans #define	I386_GET_FSBASE		7
49dfb1c113STijl Coosemans #define	I386_SET_FSBASE		8
50dfb1c113STijl Coosemans #define	I386_GET_GSBASE		9
51dfb1c113STijl Coosemans #define	I386_SET_GSBASE		10
52dfb1c113STijl Coosemans #define	I386_GET_XFPUSTATE	11
53e7a9df16SKonstantin Belousov #define	I386_SET_PKRU		12
54e7a9df16SKonstantin Belousov #define	I386_CLEAR_PKRU		13
55dfb1c113STijl Coosemans 
56dfb1c113STijl Coosemans /* Leave space for 0-127 for to avoid translating syscalls */
57dfb1c113STijl Coosemans #define	AMD64_GET_FSBASE	128
58dfb1c113STijl Coosemans #define	AMD64_SET_FSBASE	129
59dfb1c113STijl Coosemans #define	AMD64_GET_GSBASE	130
60dfb1c113STijl Coosemans #define	AMD64_SET_GSBASE	131
61dfb1c113STijl Coosemans #define	AMD64_GET_XFPUSTATE	132
62e7a9df16SKonstantin Belousov #define	AMD64_SET_PKRU		133
63e7a9df16SKonstantin Belousov #define	AMD64_CLEAR_PKRU	134
64e7a9df16SKonstantin Belousov 
65e7a9df16SKonstantin Belousov /* Flags for AMD64_SET_PKRU */
66e7a9df16SKonstantin Belousov #define	AMD64_PKRU_EXCL		0x0001
67e7a9df16SKonstantin Belousov #define	AMD64_PKRU_PERSIST	0x0002
68dfb1c113STijl Coosemans 
69dfb1c113STijl Coosemans struct i386_ioperm_args {
70dfb1c113STijl Coosemans 	unsigned int start;
71dfb1c113STijl Coosemans 	unsigned int length;
72dfb1c113STijl Coosemans 	int	enable;
73dfb1c113STijl Coosemans };
74dfb1c113STijl Coosemans 
75dfb1c113STijl Coosemans #ifdef __i386__
76dfb1c113STijl Coosemans struct i386_ldt_args {
77dfb1c113STijl Coosemans 	unsigned int start;
78dfb1c113STijl Coosemans 	union descriptor *descs;
79dfb1c113STijl Coosemans 	unsigned int num;
80dfb1c113STijl Coosemans };
81dfb1c113STijl Coosemans 
82dfb1c113STijl Coosemans struct i386_vm86_args {
83dfb1c113STijl Coosemans 	int	sub_op;			/* sub-operation to perform */
84dfb1c113STijl Coosemans 	char	*sub_args;		/* args */
85dfb1c113STijl Coosemans };
86dfb1c113STijl Coosemans 
87dfb1c113STijl Coosemans struct i386_get_xfpustate {
88dfb1c113STijl Coosemans 	void *addr;
89dfb1c113STijl Coosemans 	int len;
90dfb1c113STijl Coosemans };
91dfb1c113STijl Coosemans #else
92dfb1c113STijl Coosemans struct i386_ldt_args {
93dfb1c113STijl Coosemans 	unsigned int start;
94dfb1c113STijl Coosemans 	struct user_segment_descriptor *descs __packed;
95dfb1c113STijl Coosemans 	unsigned int num;
96dfb1c113STijl Coosemans };
97dfb1c113STijl Coosemans 
98dfb1c113STijl Coosemans struct i386_get_xfpustate {
99dfb1c113STijl Coosemans 	unsigned int addr;
100dfb1c113STijl Coosemans 	int len;
101dfb1c113STijl Coosemans };
102dfb1c113STijl Coosemans 
103e7a9df16SKonstantin Belousov struct i386_set_pkru {
104e7a9df16SKonstantin Belousov 	unsigned int addr;
105e7a9df16SKonstantin Belousov 	unsigned int len;
106e7a9df16SKonstantin Belousov 	unsigned int keyidx;
107e7a9df16SKonstantin Belousov 	int flags;
108e7a9df16SKonstantin Belousov };
109e7a9df16SKonstantin Belousov 
110dfb1c113STijl Coosemans struct amd64_get_xfpustate {
111dfb1c113STijl Coosemans 	void *addr;
112dfb1c113STijl Coosemans 	int len;
113dfb1c113STijl Coosemans };
114dfb1c113STijl Coosemans #endif
115dfb1c113STijl Coosemans 
116e7a9df16SKonstantin Belousov struct amd64_set_pkru {
117e7a9df16SKonstantin Belousov 	void *addr;
118e7a9df16SKonstantin Belousov 	unsigned long len;
119e7a9df16SKonstantin Belousov 	unsigned int keyidx;
120e7a9df16SKonstantin Belousov 	int flags;
121e7a9df16SKonstantin Belousov };
122e7a9df16SKonstantin Belousov 
123dfb1c113STijl Coosemans #ifndef _KERNEL
124dfb1c113STijl Coosemans union descriptor;
125dfb1c113STijl Coosemans struct dbreg;
126dfb1c113STijl Coosemans 
127dfb1c113STijl Coosemans __BEGIN_DECLS
128dfb1c113STijl Coosemans int i386_get_ldt(int, union descriptor *, int);
129dfb1c113STijl Coosemans int i386_set_ldt(int, union descriptor *, int);
130dfb1c113STijl Coosemans int i386_get_ioperm(unsigned int, unsigned int *, int *);
131dfb1c113STijl Coosemans int i386_set_ioperm(unsigned int, unsigned int, int);
132dfb1c113STijl Coosemans int i386_vm86(int, void *);
133dfb1c113STijl Coosemans int i386_get_fsbase(void **);
134dfb1c113STijl Coosemans int i386_get_gsbase(void **);
135dfb1c113STijl Coosemans int i386_set_fsbase(void *);
136dfb1c113STijl Coosemans int i386_set_gsbase(void *);
137dfb1c113STijl Coosemans int i386_set_watch(int, unsigned int, int, int, struct dbreg *);
138dfb1c113STijl Coosemans int i386_clr_watch(int, struct dbreg *);
139dfb1c113STijl Coosemans int amd64_get_fsbase(void **);
140dfb1c113STijl Coosemans int amd64_get_gsbase(void **);
141dfb1c113STijl Coosemans int amd64_set_fsbase(void *);
142dfb1c113STijl Coosemans int amd64_set_gsbase(void *);
143*a2d95495SKonstantin Belousov int x86_pkru_get_perm(unsigned int keyidx, int *access, int *modify);
144*a2d95495SKonstantin Belousov int x86_pkru_set_perm(unsigned int keyidx, int access, int modify);
145*a2d95495SKonstantin Belousov int x86_pkru_protect_range(void *addr, unsigned long len, unsigned int keyidx,
146*a2d95495SKonstantin Belousov     int flag);
147*a2d95495SKonstantin Belousov int x86_pkru_unprotect_range(void *addr, unsigned long len);
148dfb1c113STijl Coosemans int sysarch(int, void *);
149dfb1c113STijl Coosemans __END_DECLS
150dfb1c113STijl Coosemans #else
151dfb1c113STijl Coosemans struct thread;
152dfb1c113STijl Coosemans union descriptor;
153dfb1c113STijl Coosemans 
154dfb1c113STijl Coosemans int i386_get_ldt(struct thread *, struct i386_ldt_args *);
155dfb1c113STijl Coosemans int i386_set_ldt(struct thread *, struct i386_ldt_args *, union descriptor *);
156dfb1c113STijl Coosemans int i386_get_ioperm(struct thread *, struct i386_ioperm_args *);
157dfb1c113STijl Coosemans int i386_set_ioperm(struct thread *, struct i386_ioperm_args *);
158dfb1c113STijl Coosemans int amd64_get_ldt(struct thread *, struct i386_ldt_args *);
159dfb1c113STijl Coosemans int amd64_set_ldt(struct thread *, struct i386_ldt_args *,
160dfb1c113STijl Coosemans     struct user_segment_descriptor *);
161dfb1c113STijl Coosemans int amd64_get_ioperm(struct thread *, struct i386_ioperm_args *);
162dfb1c113STijl Coosemans int amd64_set_ioperm(struct thread *, struct i386_ioperm_args *);
163dfb1c113STijl Coosemans #endif
164dfb1c113STijl Coosemans 
165dfb1c113STijl Coosemans #endif /* !_MACHINE_SYSARCH_H_ */
166