Xen Test Framework
tests
xsa-261
main.c
Go to the documentation of this file.
1
20
#include <xtf.h>
21
22
const
char
test_title
[] =
"XSA-261 PoC"
;
23
24
void
test_main
(
void
)
25
{
26
unsigned
int
timer, irq;
27
28
if
(
hpet_init
() || !
hpet_nr_timers
)
29
return
xtf_skip
(
"Skip: No working HPET\n"
);
30
31
if
(
ioapic_init
() )
32
return
xtf_skip
(
"Skip: No working IO-APIC\n"
);
33
34
/*
35
* Attempt to test all timers using non-ISA IRQs, regardless of whether
36
* the timer supports them or not.
37
*/
38
for
( timer = 0; timer <
hpet_nr_timers
; timer++ )
39
{
40
for
( irq = 16; irq < 32; irq++ )
41
{
42
if
(
ioapic_set_mask
(irq,
false
) )
43
return
xtf_error
(
"Error: cannot unmask IRQ %u on the IO APIC\n"
,
44
irq);
45
46
hpet_init_timer
(timer, irq, 1,
false
,
false
,
false
);
47
48
while
(
hpet_read_counter
() < 1 );
49
}
50
}
51
52
/* Xen still hasn't crashed? Most likely not vulnerable. */
53
xtf_success
(
"Success: Probably not vulnerable to XSA-261\n"
);
54
}
55
56
/*
57
* Local variables:
58
* mode: C
59
* c-file-style: "BSD"
60
* c-basic-offset: 4
61
* tab-width: 4
62
* indent-tabs-mode: nil
63
* End:
64
*/
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
hpet_init_timer
void hpet_init_timer(unsigned int nr, unsigned int irq, uint64_t ticks, bool level, bool periodic, bool mode32bit)
Setup and enable a specific HPET timer.
Definition:
hpet.c:49
hpet_init
int hpet_init(void)
Discover and initialise the HPET.
Definition:
hpet.c:29
hpet_nr_timers
unsigned int hpet_nr_timers
Definition:
hpet.c:13
hpet_read_counter
static uint64_t hpet_read_counter(void)
Fetch the HPET main counter register.
Definition:
hpet.h:62
ioapic_set_mask
int ioapic_set_mask(unsigned int entry, bool mask)
Set the mask bit on a redirection entry.
Definition:
io-apic.c:29
ioapic_init
int ioapic_init(void)
Discover and initialise the IO-APIC.
Definition:
io-apic.c:15
xtf_error
void xtf_error(const char *fmt,...)
Report a test error.
Definition:
report.c:80
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
Generated by
1.9.4