xref: /kvm-unit-tests/lib/x86/usermode.h (revision c865f654ffe4c5955038aaf74f702ba62f3eb014)
1 #ifndef _X86_USERMODE_H_
2 #define _X86_USERMODE_H_
3 
4 #include "x86/msr.h"
5 #include "x86/processor.h"
6 #include "x86/apic-defs.h"
7 #include "x86/apic.h"
8 #include "x86/desc.h"
9 #include "x86/isr.h"
10 #include "alloc.h"
11 #include "setjmp.h"
12 
13 #include "libcflat.h"
14 #include <stdint.h>
15 
16 typedef uint64_t (*usermode_func)(void);
17 
18 /*
19  * Run function in user mode
20  * Supports running functions with up to 4 arguments.
21  * fault_vector: exception vector that might get thrown during the function.
22  * raised_vector: outputs true if exception occurred.
23  *
24  * returns: return value returned by function, or 0 if an exception occurred.
25  */
26 uint64_t run_in_user(usermode_func func, unsigned int fault_vector,
27 		uint64_t arg1, uint64_t arg2, uint64_t arg3,
28 		uint64_t arg4, bool *raised_vector);
29 
30 #endif
31