17const char test_title[] =
"User-Mode Instruction Prevention Tests";
21 unsigned long fault = 0;
24 asm volatile(
"testb $1, %b[fep];"
29 :
"+a" (fault), [tmp]
"=m" (tmp)
38 unsigned long fault = 0;
41 asm volatile(
"testb $1, %b[fep];"
46 :
"+a" (fault), [tmp]
"=m" (tmp)
55 unsigned long fault = 0;
58 asm volatile(
"testb $1, %b[fep];"
63 :
"+a" (fault), [tmp]
"=r" (tmp)
70static unsigned long stub_str(
unsigned long force)
72 unsigned long fault = 0;
75 asm volatile(
"testb $1, %b[fep];"
80 :
"+a" (fault), [tmp]
"=r" (tmp)
89 unsigned long fault = 0;
92 asm volatile(
"testb $1, %b[fep];"
97 :
"+a" (fault), [tmp]
"=r" (tmp)
106 unsigned long fault = 0;
109 asm volatile(
"testb $1, %b[fep];"
114 :
"+a" (fault), [tmp]
"=m" (tmp)
115 : [fep]
"rm" (force),
123 unsigned long fault = 0;
126 asm volatile(
"testb $1, %b[fep];"
131 :
"+a" (fault), [tmp]
"=m" (tmp)
132 : [fep]
"rm" (force),
140 unsigned long fault = 0;
143 asm volatile(
"testb $1, %b[fep];"
148 :
"+a" (fault), [tmp]
"=r" (tmp)
149 : [fep]
"rm" (force),
157 unsigned long fault = 0;
160 asm volatile(
"testb $1, %b[fep];"
165 :
"+a" (fault), [tmp]
"=r" (tmp)
166 : [fep]
"rm" (force),
174 unsigned long fault = 0;
177 asm volatile(
"testb $1, %b[fep];"
182 :
"+a" (fault), [tmp]
"=r" (tmp)
183 : [fep]
"rm" (force),
190 unsigned long (*
fn)(
unsigned long);
227 xtf_skip(
"Skip: Emulator doesn't implement %s\n", s->
name);
238 user ?
"user" :
"supervisor", s->
name,
239 umip_active ?
'+' :
'-',
260 xtf_skip(
"FEP support not detected - some tests will be skipped\n");
266 xtf_skip(
"UMIP is not supported, skip the rest of test\n");
269 xtf_failure(
"UMIP unsupported, but setting CR4 bit succeeded\n");
276 return xtf_failure(
"Fail: Unable to activate UMIP\n");
282 return xtf_failure(
"Fail: Unable to deactivate UMIP\n");
#define _ASM_XEN_FEP
Xen Forced Emulation Prefix.
bool ex_record_fault_eax(struct cpu_regs *regs, const struct extable_entry *ex)
Record the current fault in %eax.
static unsigned long read_cr4(void)
static bool write_cr4_safe(unsigned long cr4)
bool xtf_has_fep
Boolean indicating whether generic Force Emulation Prefix support is available for the test to use.
void test_main(void)
To be implemented by each test, as its entry point.
const char test_title[]
The title of the test.
#define EXINFO_SYM(exc, ec)
unsigned int exinfo_t
Packed exception and error code information.
#define _ASM_EXTABLE_HANDLER(fault, fixup, handler)
Create an exception table entry with custom handler.
unsigned long exec_user_param(unsigned long(*fn)(unsigned long), unsigned long p1)
Execute fn(p1) at user privilege, passing its return value back.
#define _p(v)
Express an abitrary integer v as void *.
void xtf_failure(const char *fmt,...)
Report a test failure.
void xtf_skip(const char *fmt,...)
Report a test skip.
void xtf_success(const char *fmt,...)
Report test success.
unsigned long(* user_fn)(unsigned long)
unsigned long(* fn)(unsigned long)
static unsigned long stub_str(unsigned long force)
static unsigned long stub_sgdt(unsigned long force)
static unsigned long stub_user_sgdt(unsigned long force)
static unsigned long stub_sldt(unsigned long force)
static void test_umip(bool umip_active)
static unsigned long stub_sidt(unsigned long force)
static unsigned long stub_smsw(unsigned long force)
static unsigned long stub_user_str(unsigned long force)
static unsigned long stub_user_sldt(unsigned long force)
static void test_insns(bool umip_active, bool force)
static unsigned long stub_user_smsw(unsigned long force)
static const struct stub stubs[]
static unsigned long stub_user_sidt(unsigned long force)