AArch64 EL2 hypervisor for QEMU virt that boots at EL2
1

Configure Feed

Select the types of activity you want to include in your feed.

ariel / include / hv / vcpu.h
2.2 kB 90 lines
1#ifndef HV_VCPU_H 2#define HV_VCPU_H 3 4#include "hv/types.h" 5 6enum vcpu_run_state { 7 VCPU_CREATED = 0, 8 VCPU_READY, 9 VCPU_RUNNING, 10 VCPU_PAUSED, 11 VCPU_PANICKED, 12}; 13 14struct el1_sysreg_shadow { 15 uint64_t sctlr_el1; 16 uint64_t ttbr0_el1; 17 uint64_t ttbr1_el1; 18 uint64_t tcr_el1; 19 uint64_t mair_el1; 20 uint64_t vbar_el1; 21 uint64_t contextidr_el1; 22 uint64_t tpidr_el1; 23 uint64_t tpidrro_el0; 24 uint64_t cntv_ctl_el0; 25 uint64_t cntv_tval_el0; 26 uint64_t cntv_cval_el0; 27 uint64_t cntkctl_el1; 28 uint64_t cpacr_el1; 29 uint64_t mdscr_el1; 30 uint64_t csselr_el1; 31 uint64_t elr_el1; 32 uint64_t spsr_el1; 33 uint64_t esr_el1; 34 uint64_t far_el1; 35}; 36 37struct vcpu_stats { 38 uint64_t traps; 39 uint64_t sysreg_traps; 40 uint64_t hvc_calls; 41 uint64_t smc_denied; 42 uint64_t wfx_traps; 43 uint64_t data_aborts; 44 uint64_t instruction_aborts; 45 uint64_t unknown_exceptions; 46 uint64_t injected_undefs; 47 uint64_t virtual_irqs_injected; 48 uint64_t virtual_irqs_completed; 49}; 50 51struct vcpu { 52 uint64_t x[31]; 53 uint64_t sp_el0; 54 uint64_t sp_el1; 55 uint64_t pc; 56 uint64_t pstate; 57 struct el1_sysreg_shadow sysregs; 58 uint64_t pending_virtual_irq; 59 uint64_t active_virtual_irq; 60 uint32_t id; 61 enum vcpu_run_state state; 62 uint64_t last_esr; 63 uint64_t last_far; 64 uint64_t last_hpfar; 65 struct vcpu_stats stats; 66}; 67 68struct trap_frame { 69 uint64_t x[31]; 70 uint64_t sp_el0; 71 uint64_t sp_el1; 72 uint64_t elr_el2; 73 uint64_t spsr_el2; 74 uint64_t esr_el2; 75 uint64_t far_el2; 76 uint64_t hpfar_el2; 77}; 78 79void vcpu_init(struct vcpu *vcpu, uint32_t id, uint64_t entry, uint64_t stack_top); 80void vcpu_load_frame(struct vcpu *vcpu, const struct trap_frame *frame); 81void vcpu_store_frame(const struct vcpu *vcpu, struct trap_frame *frame); 82uint64_t vcpu_read_gpr(const struct vcpu *vcpu, uint32_t rt); 83void vcpu_write_gpr(struct vcpu *vcpu, uint32_t rt, uint64_t value); 84void vcpu_set_pending_irq(struct vcpu *vcpu, uint32_t intid); 85void vcpu_clear_pending_irq(struct vcpu *vcpu, uint32_t intid); 86struct vcpu *vcpu_current(void); 87void vcpu_set_current(struct vcpu *vcpu); 88void vcpu_dump(const struct vcpu *vcpu); 89 90#endif