28 unsigned long fault = 0, tmp;
30 asm volatile(
"1: cpuid; 2:"
32 :
"=a" (tmp),
"+D" (fault)
34 :
"ebx",
"ecx",
"edx");
41 unsigned long fault = 0, tmp;
46 :
"=a" (tmp),
"+D" (fault)
48 :
"ebx",
"ecx",
"edx");
55 unsigned long fault = 0, tmp;
57 asm volatile(
"1: cpuid; 2:"
59 :
"=a" (tmp),
"+D" (fault)
61 :
"ebx",
"ecx",
"edx");
68 unsigned long fault = 0, tmp;
73 :
"=a" (tmp),
"+D" (fault)
75 :
"ebx",
"ecx",
"edx");
92 xtf_failure(
"Fail: kernel emulated cpuid faulted\n");
97 unsigned long exp = exp_faulting ?
EXINFO_SYM(
GP, 0) : 0;
98 const char *exp_fail_str = exp_faulting ?
"didn't fault" :
"faulted";
101 xtf_failure(
"Fail: user cpuid %s\n", exp_fail_str);
104 xtf_failure(
"Fail: user pv cpuid %s\n", exp_fail_str);
107 xtf_failure(
"Fail: user emulated cpuid %s\n", exp_fail_str);
112 uint64_t platform_info, features_enable;
115 xtf_skip(
"FEP support not detected - some tests will be skipped\n");
118 printk(
"Testing CPUID without faulting enabled\n");
124 return xtf_skip(
"Skip: CPUID Faulting unavailable\n");
127 return xtf_error(
"Error: Fault accessing MISC_FEATURES_ENABLES\n");
132 return xtf_failure(
"Fail: Unable to enable CPUID Faulting\n");
135 printk(
"Testing CPUID with faulting enabled\n");
140 return xtf_failure(
"Fail: Unable to disable CPUID Faulting\n");
143 printk(
"Retesting CPUID without faulting enabled\n");
#define _ASM_XEN_FEP
Xen Forced Emulation Prefix.
bool ex_record_fault_edi(struct cpu_regs *regs, const struct extable_entry *ex)
Record the current fault in %edi.
bool xtf_has_fep
Boolean indicating whether generic Force Emulation Prefix support is available for the test to use.
void printk(const char *fmt,...)
static unsigned long stub_user_force_cpuid(void)
void test_main(void)
To be implemented by each test, as its entry point.
const char test_title[]
The title of the test.
static unsigned long stub_cpuid(void)
static void test_cpuid(bool exp_faulting)
static unsigned long stub_force_cpuid(void)
static unsigned long stub_user_cpuid(void)
#define EXINFO_SYM(exc, ec)
#define _ASM_EXTABLE_HANDLER(fault, fixup, handler)
Create an exception table entry with custom handler.
static unsigned long exec_user(unsigned long(*fn)(void))
#define IS_DEFINED(x)
Evalute whether the CONFIG_ token x is defined.
#define MSR_INTEL_MISC_FEATURES_ENABLES
#define MSR_INTEL_PLATFORM_INFO
#define PLATFORM_INFO_CPUID_FAULTING
#define MISC_FEATURES_CPUID_FAULTING
static bool wrmsr_safe(uint32_t idx, uint64_t val)
Wrapper around wrmsr which safely catches #GP[0].
static bool rdmsr_safe(uint32_t idx, uint64_t *val)
Wrapper around rdmsr which safely catches #GP[0].
void xtf_failure(const char *fmt,...)
Report a test failure.
void xtf_error(const char *fmt,...)
Report a test error.
void xtf_skip(const char *fmt,...)
Report a test skip.
void xtf_success(const char *fmt,...)
Report test success.