xref: /kvm-unit-tests/lib/x86/fault_test.h (revision c865f654ffe4c5955038aaf74f702ba62f3eb014)
1*c865f654SCornelia Huck #ifndef _X86_FAULT_TEST_H_
2*c865f654SCornelia Huck #define _X86_FAULT_TEST_H_
32bac6249SArbel Moshe 
42bac6249SArbel Moshe #include "x86/msr.h"
52bac6249SArbel Moshe #include "x86/processor.h"
62bac6249SArbel Moshe #include "x86/apic-defs.h"
72bac6249SArbel Moshe #include "x86/apic.h"
82bac6249SArbel Moshe #include "x86/desc.h"
92bac6249SArbel Moshe #include "x86/isr.h"
102bac6249SArbel Moshe #include "alloc.h"
112bac6249SArbel Moshe #include "setjmp.h"
122bac6249SArbel Moshe #include "usermode.h"
132bac6249SArbel Moshe 
142bac6249SArbel Moshe #include "libcflat.h"
152bac6249SArbel Moshe #include <stdint.h>
162bac6249SArbel Moshe 
172bac6249SArbel Moshe #define FAULT_TEST(nm, a) { .name = nm, .arg = a}
182bac6249SArbel Moshe 
192bac6249SArbel Moshe struct fault_test_arg;
202bac6249SArbel Moshe 
212bac6249SArbel Moshe typedef uint64_t (*test_fault_func)(uint64_t arg1, uint64_t arg2,
222bac6249SArbel Moshe 		uint64_t arg3, uint64_t arg4);
232bac6249SArbel Moshe typedef bool (*test_fault_callback)(struct fault_test_arg *arg);
242bac6249SArbel Moshe 
252bac6249SArbel Moshe struct fault_test_arg {
262bac6249SArbel Moshe 	bool usermode;
272bac6249SArbel Moshe 	unsigned int fault_vector;
282bac6249SArbel Moshe 	bool should_fault;
292bac6249SArbel Moshe 	uint64_t arg[4];
302bac6249SArbel Moshe 	uint64_t retval;
312bac6249SArbel Moshe 	test_fault_func func;
322bac6249SArbel Moshe 	test_fault_callback callback;
332bac6249SArbel Moshe };
342bac6249SArbel Moshe 
352bac6249SArbel Moshe struct fault_test {
362bac6249SArbel Moshe 	const char *name;
372bac6249SArbel Moshe 	struct fault_test_arg arg;
382bac6249SArbel Moshe };
392bac6249SArbel Moshe 
402bac6249SArbel Moshe void test_run(struct fault_test *test);
412bac6249SArbel Moshe 
422bac6249SArbel Moshe #endif
43