19 printk(
"Test: Xenstore read\n");
24 return xtf_failure(
"Fail: No domid value returned\n");
26 if ( domid_str[0] ==
'\0' )
30 for ( i = 0; domid_str[i]; ++i )
32 if ( domid_str[i] <
'0' || domid_str[i] >
'9' )
33 return xtf_failure(
"Fail: unexpected domid value '%s'\n",
37 printk(
" Found domid %s\n", domid_str);
42 printk(
"Test: Exception Table\n");
48 asm volatile (
"1: ud2a; 2:"
67 printk(
"Test: Userspace execution\n");
92 printk(
"Test: NULL unmapped\n");
94 asm volatile (
"1: mov 0, %[tmp]; 2:"
107 extern unsigned long hook_fault[], hook_fixup[];
112 if (
_p(regs->ip) != hook_fault )
114 xtf_failure(
"Fail: Expected fault at %p, got %p\n",
115 hook_fault,
_p(regs->ip));
119 regs->ip =
_u(hook_fixup);
125 printk(
"Test: Unhandled Exception Hook\n");
129 asm volatile (
"hook_fault: ud2a; hook_fixup:");
138 regs->ip = ex->
fixup;
144 printk(
"Test: Exception Table Handler\n");
146 asm volatile (
"1: ud2a; 2:"
155asm (
"test_idte_handler:;"
156#if defined (CONFIG_PV) && defined (CONFIG_64BIT)
157 "pop %rcx; pop %r11;"
159 "mov $0x1e51c0de, %eax;"
160#if defined (CONFIG_HVM)
166 "jmp HYPERCALL_iret;"
179 printk(
"Test: Custom IDT entry\n");
184 return xtf_failure(
"Fail: xtf_set_idte() returned %d\n", rc);
187 asm volatile (
"int $%c[vec]"
192 if ( res != 0x1e51c0de )
200 printk(
"Test: Driver basic initialisation\n");
210 xtf_failure(
"Fail: apic_init(XAPIC) returned %d\n", rc);
217 xtf_failure(
"Fail: apic_init(X2APIC) returned %d\n", rc);
222 if ( rc && rc != -
ENODEV )
223 xtf_failure(
"Fail: hpet_init() returned %d\n", rc);
226 if ( rc && rc != -
ENODEV )
227 xtf_failure(
"Fail: ioapic_init() returned %d\n", rc);
232 if ( rc && rc != -
ENODEV )
233 xtf_failure(
"Fail: xenstore_init() returned %d\n", rc);
237 xtf_failure(
"Fail: xtf_init_grant_table(1) returned %d\n", rc);
240 if ( rc && rc != -
ENODEV )
241 xtf_failure(
"Fail: xtf_init_grant_table(2) returned %d\n", rc);
252 rc =
vsnprintf(buf,
sizeof(buf), fmt, args);
256 return xtf_failure(
"Fail: '%s', expected length 1, got %d\n", fmt, rc);
258 return xtf_failure(
"Fail: '%s', expected \"\\n\", got %*ph\n",
259 fmt, (
int)
sizeof(buf), buf);
266 return xtf_failure(
"Fail: '%s', expected length 2, got %d\n", fmt, rc);
267 if (
strcmp(buf,
"\r\n") )
268 return xtf_failure(
"Fail: '%s', expected \"\\r\\n\", got %*ph\n",
269 fmt, (
int)
sizeof(buf), buf);
274 printk(
"Test: vsnprintf() with CRLF expansion\n");
289 unsigned long cr4 =
read_cr4(), ocr4 = cr4;
302 if ( CONFIG_PAGING_LEVELS > 0 )
331 unsigned long tmp = 0xdead0000c0deULL;
int apic_init(enum apic_mode mode)
Discover and initialise the local APIC to the requested mode.
bool ex_record_fault_eax(struct cpu_regs *regs, const struct extable_entry *ex)
Record the current fault in %eax.
static void write_cs(unsigned long cs)
static unsigned int read_cs(void)
static unsigned long read_cr4(void)
static unsigned long read_flags(void)
static void write_cr4(unsigned long cr4)
static void write_flags(unsigned long flags)
int xtf_init_grant_table(unsigned int version)
Initialise XTF's grant infrastructure.
void printk(const char *fmt,...)
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.
int hpet_init(void)
Discover and initialise the HPET.
int xtf_set_idte(unsigned int vector, const struct xtf_idte *idte)
Set up an IDT Entry, in a guest agnostic way.
#define X86_VEC_AVAIL
Available for test use.
#define _ASM_EXTABLE_HANDLER(fault, fixup, handler)
Create an exception table entry with custom handler.
#define _ASM_EXTABLE(fault, fixup)
Create an exception table entry.
static unsigned long exec_user(unsigned long(*fn)(void))
int ioapic_init(void)
Discover and initialise the IO-APIC.
static int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
#define IS_DEFINED(x)
Evalute whether the CONFIG_ token x is defined.
bool do_unhandled_exception(struct cpu_regs *regs)
May be implemented by a guest to provide custom exception handling.
#define _p(v)
Express an abitrary integer v as void *.
#define _u(v)
Express an arbitrary value v as unsigned long.
void xtf_failure(const char *fmt,...)
Report a test failure.
void xtf_success(const char *fmt,...)
Report test success.
static void test_driver_init(void)
static void test_vsnprintf_crlf(void)
static void test_unhandled_exception_hook(void)
void test_idte_handler(void)
static void test_vsnprintf_crlf_one(const char *fmt,...)
static void test_custom_idte(void)
static bool test_extable_handler_handler_run
static volatile bool test_hook_active
static void test_exec_user(void)
static bool test_extable_handler_handler(struct cpu_regs *regs, const struct extable_entry *ex)
static void test_extable(void)
static void test_extable_handler(void)
static void test_NULL_unmapped(void)
static void test_xenstore(void)
static const struct xtf_idte idte
static unsigned long test_exec_user_cpl3(void)
static void asm_checks(void)
__builtin_va_list va_list
unsigned long fixup
Fixup address.
A guest agnostic represention of IDT information.
int vsnprintf_internal(char *buf, size_t size, const char *fmt, va_list args, unsigned int caller_flags)
const char * xenstore_read(const char *path)
Issue a XS_READ operation for key, waiting synchronously for the reply.
int xenstore_init(void)
Initialise XTF ready for xenstore communication.