qemu/include/sysemu/hvf.h
<<
>>
Prefs
   1/*
   2 * QEMU Hypervisor.framework (HVF) support
   3 *
   4 * Copyright Google Inc., 2017
   5 *
   6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
   7 * See the COPYING file in the top-level directory.
   8 *
   9 */
  10
  11/* header to be included in non-HVF-specific code */
  12
  13#ifndef HVF_H
  14#define HVF_H
  15
  16#include "qemu/bitops.h"
  17#include "exec/memory.h"
  18#include "sysemu/accel.h"
  19
  20extern bool hvf_allowed;
  21#ifdef CONFIG_HVF
  22#include <Hypervisor/hv.h>
  23#include <Hypervisor/hv_vmx.h>
  24#include <Hypervisor/hv_error.h>
  25#include "target/i386/cpu.h"
  26#include "hw/hw.h"
  27uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
  28                                 int reg);
  29#define hvf_enabled() (hvf_allowed)
  30#else
  31#define hvf_enabled() 0
  32#define hvf_get_supported_cpuid(func, idx, reg) 0
  33#endif
  34
  35/* hvf_slot flags */
  36#define HVF_SLOT_LOG (1 << 0)
  37
  38typedef struct hvf_slot {
  39    uint64_t start;
  40    uint64_t size;
  41    uint8_t *mem;
  42    int slot_id;
  43    uint32_t flags;
  44    MemoryRegion *region;
  45} hvf_slot;
  46
  47typedef struct hvf_vcpu_caps {
  48    uint64_t vmx_cap_pinbased;
  49    uint64_t vmx_cap_procbased;
  50    uint64_t vmx_cap_procbased2;
  51    uint64_t vmx_cap_entry;
  52    uint64_t vmx_cap_exit;
  53    uint64_t vmx_cap_preemption_timer;
  54} hvf_vcpu_caps;
  55
  56typedef struct HVFState {
  57    AccelState parent;
  58    hvf_slot slots[32];
  59    int num_slots;
  60
  61    hvf_vcpu_caps *hvf_caps;
  62} HVFState;
  63extern HVFState *hvf_state;
  64
  65void hvf_set_phys_mem(MemoryRegionSection *, bool);
  66void hvf_handle_io(CPUArchState *, uint16_t, void *,
  67                  int, int, int);
  68hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
  69
  70/* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported by
  71 * the host CPU. Use hvf_enabled() after this to get the result. */
  72void hvf_disable(int disable);
  73
  74/* Returns non-0 if the host CPU supports the VMX "unrestricted guest" feature
  75 * which allows the virtual CPU to directly run in "real mode". If true, this
  76 * allows QEMU to run several vCPU threads in parallel (see cpus.c). Otherwise,
  77 * only a a single TCG thread can run, and it will call HVF to run the current
  78 * instructions, except in case of "real mode" (paging disabled, typically at
  79 * boot time), or MMIO operations. */
  80
  81int hvf_sync_vcpus(void);
  82
  83int hvf_init_vcpu(CPUState *);
  84int hvf_vcpu_exec(CPUState *);
  85int hvf_smp_cpu_exec(CPUState *);
  86void hvf_cpu_synchronize_state(CPUState *);
  87void hvf_cpu_synchronize_post_reset(CPUState *);
  88void hvf_cpu_synchronize_post_init(CPUState *);
  89void _hvf_cpu_synchronize_post_init(CPUState *, run_on_cpu_data);
  90
  91void hvf_vcpu_destroy(CPUState *);
  92void hvf_raise_event(CPUState *);
  93/* void hvf_reset_vcpu_state(void *opaque); */
  94void hvf_reset_vcpu(CPUState *);
  95void vmx_update_tpr(CPUState *);
  96void update_apic_tpr(CPUState *);
  97int hvf_put_registers(CPUState *);
  98void vmx_clear_int_window_exiting(CPUState *cpu);
  99
 100#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
 101
 102#define HVF_STATE(obj) \
 103    OBJECT_CHECK(HVFState, (obj), TYPE_HVF_ACCEL)
 104
 105#endif
 106