Xen Test Framework
main.c
Go to the documentation of this file.
1 
22 #include <xtf.h>
23 
24 const char test_title[] = "XSA-269 PoC";
25 
26 void test_main(void)
27 {
28  unsigned int i;
29  uint64_t val = 0;
30 
31  /*
32  * If Debug Store is advertised, presume that vPMU is properly configured
33  * for this domain, and that we're trusted not to (mis)use it.
34  */
35  if ( cpu_has_ds )
36  return xtf_skip("Skip: Debug Store is available\n");
37 
38  /*
39  * We cannot rely on CPUID bits, as vPMU is disabled by default. Turn on
40  * each part of BTS individually to reduce the chance of the host hang
41  * being mitigated by a vmentry failure. If vulnerable, we'd expect a
42  * host lockup on the vmentry following the setting of BTS.
43  */
47 
48  /*
49  * If we're still alive, generate a billion jumps to check that BTS really
50  * is disabled.
51  */
52  for ( i = 0; i < GB(1); ++i )
53  barrier();
54 
55  /* If we're still alive at this point, Xen is definitely not vulnerable. */
56 
57  xtf_success("Success: Not vulnerable to XSA-269\n");
58 }
59 
60 /*
61  * Local variables:
62  * mode: C
63  * c-file-style: "BSD"
64  * c-basic-offset: 4
65  * tab-width: 4
66  * indent-tabs-mode: nil
67  * End:
68  */
#define DEBUGCTL_BTINT
Definition: msr-index.h:34
#define barrier()
Definition: compiler.h:30
#define MSR_DEBUGCTL
Definition: msr-index.h:30
#define DEBUGCTL_BTS
Definition: msr-index.h:33
#define DEBUGCTL_TR
Definition: msr-index.h:32
void xtf_success(const char *fmt,...)
Report test success.
Definition: report.c:38
void test_main(void)
To be implemented by each test, as its entry point.
Definition: main.c:137
__UINT64_TYPE__ uint64_t
Definition: stdint.h:17
void xtf_skip(const char *fmt,...)
Report a test skip.
Definition: report.c:66
const char test_title[]
The title of the test.
Definition: main.c:14
#define cpu_has_ds
Definition: cpuid.h:71
#define GB(num)
Express num in Gigabytes.
Definition: numbers.h:29
static bool wrmsr_safe(uint32_t idx, uint64_t val)
Wrapper around wrmsr which safely catches #GP[0].
Definition: msr.h:69