1 /* 2 * QEMU Hypervisor.framework (HVF) support 3 * 4 * Copyright 2017 Google Inc 5 * 6 * Adapted from target-i386/hax-i386.h: 7 * Copyright (c) 2011 Intel Corporation 8 * Written by: 9 * Jiang Yunhong<yunhong.jiang@intel.com> 10 * 11 * This work is licensed under the terms of the GNU GPL, version 2 or later. 12 * See the COPYING file in the top-level directory. 13 * 14 */ 15 16 #ifndef HVF_I386_H 17 #define HVF_I386_H 18 19 #include "qemu/accel.h" 20 #include "sysemu/hvf.h" 21 #include "cpu.h" 22 #include "x86.h" 23 24 #define HVF_MAX_VCPU 0x10 25 26 extern struct hvf_state hvf_global; 27 28 struct hvf_vm { 29 int id; 30 struct hvf_vcpu_state *vcpus[HVF_MAX_VCPU]; 31 }; 32 33 struct hvf_state { 34 uint32_t version; 35 struct hvf_vm *vm; 36 uint64_t mem_quota; 37 }; 38 39 /* hvf_slot flags */ 40 #define HVF_SLOT_LOG (1 << 0) 41 42 typedef struct hvf_slot { 43 uint64_t start; 44 uint64_t size; 45 uint8_t *mem; 46 int slot_id; 47 uint32_t flags; 48 MemoryRegion *region; 49 } hvf_slot; 50 51 typedef struct hvf_vcpu_caps { 52 uint64_t vmx_cap_pinbased; 53 uint64_t vmx_cap_procbased; 54 uint64_t vmx_cap_procbased2; 55 uint64_t vmx_cap_entry; 56 uint64_t vmx_cap_exit; 57 uint64_t vmx_cap_preemption_timer; 58 } hvf_vcpu_caps; 59 60 struct HVFState { 61 AccelState parent; 62 hvf_slot slots[32]; 63 int num_slots; 64 65 hvf_vcpu_caps *hvf_caps; 66 }; 67 extern HVFState *hvf_state; 68 69 void hvf_set_phys_mem(MemoryRegionSection *, bool); 70 void hvf_handle_io(CPUArchState *, uint16_t, void *, int, int, int); 71 hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); 72 73 #ifdef NEED_CPU_H 74 /* Functions exported to host specific mode */ 75 76 /* Host specific functions */ 77 int hvf_inject_interrupt(CPUArchState *env, int vector); 78 int hvf_vcpu_run(struct hvf_vcpu_state *vcpu); 79 #endif 80 81 #endif 82