AArch64 EL2 hypervisor for QEMU virt that boots at EL2
1#include "hv/arch.h"
2#include "hv/log.h"
3#include "hv/panic.h"
4#include "hv/uart.h"
5#include "hv/vcpu.h"
6
7void panic_with_code(const char *reason, uint64_t code)
8{
9 struct log_event ev;
10 ev.seq = 0;
11 ev.cpu = 0;
12 ev.vcpu = vcpu_current() != (struct vcpu *)0 ? vcpu_current()->id : UINT64_MAX;
13 ev.timestamp = 0;
14 ev.kind = LOG_PANIC;
15 ev.ec = 0;
16 ev.iss = code;
17 ev.elr = 0;
18 ev.far = 0;
19 ev.hpfar = 0;
20 ev.sysreg_key = 0;
21 ev.is_read = 0;
22 ev.rt = 0;
23 ev.operand = code;
24 ev.result = 0;
25 ev.action = LOG_ACT_PANIC;
26 ev.reason = 999u;
27 ev.pstate = 0;
28 ev.name = reason;
29 log_event_commit(&ev);
30
31 uart_puts("\nPANIC reason=");
32 uart_puts(reason);
33 uart_puts(" code=");
34 uart_put_hex64(code);
35 uart_puts(" current_el=");
36 uart_put_dec64(arch_current_el());
37 uart_puts("\n");
38 arch_dump_el2_state();
39 vcpu_dump(vcpu_current());
40 uart_puts("recent log:\n");
41 log_dump(32u);
42 arch_halt();
43}
44
45void panic(const char *reason)
46{
47 panic_with_code(reason, 0u);
48}