mirror of https://github.com/xqemu/xqemu.git
hvf: refactor headers, fix gdbstub
This commit is contained in:
parent
8bf48720fb
commit
d07438fa8a
12
cpus.c
12
cpus.c
|
@ -959,10 +959,6 @@ void cpu_synchronize_all_states(void)
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
CPU_FOREACH(cpu) {
|
||||||
cpu_synchronize_state(cpu);
|
cpu_synchronize_state(cpu);
|
||||||
/* TODO: move to cpu_synchronize_state() */
|
|
||||||
if (hvf_enabled()) {
|
|
||||||
hvf_cpu_synchronize_state(cpu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,10 +968,6 @@ void cpu_synchronize_all_post_reset(void)
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
CPU_FOREACH(cpu) {
|
||||||
cpu_synchronize_post_reset(cpu);
|
cpu_synchronize_post_reset(cpu);
|
||||||
/* TODO: move to cpu_synchronize_post_reset() */
|
|
||||||
if (hvf_enabled()) {
|
|
||||||
hvf_cpu_synchronize_post_reset(cpu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,10 +977,6 @@ void cpu_synchronize_all_post_init(void)
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
CPU_FOREACH(cpu) {
|
||||||
cpu_synchronize_post_init(cpu);
|
cpu_synchronize_post_init(cpu);
|
||||||
/* TODO: move to cpu_synchronize_post_init() */
|
|
||||||
if (hvf_enabled()) {
|
|
||||||
hvf_cpu_synchronize_post_init(cpu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
|
|
||||||
extern int hvf_disabled;
|
extern int hvf_disabled;
|
||||||
#ifdef CONFIG_HVF
|
#ifdef CONFIG_HVF
|
||||||
#include <Hypervisor/hv.h>
|
|
||||||
#include <Hypervisor/hv_vmx.h>
|
|
||||||
#include <Hypervisor/hv_error.h>
|
|
||||||
#include "target/i386/cpu.h"
|
|
||||||
#include "hw/hw.h"
|
|
||||||
uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
|
uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
|
||||||
int reg);
|
int reg);
|
||||||
#define hvf_enabled() !hvf_disabled
|
#define hvf_enabled() !hvf_disabled
|
||||||
|
@ -32,41 +27,6 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
|
||||||
#define hvf_get_supported_cpuid(func, idx, reg) 0
|
#define hvf_get_supported_cpuid(func, idx, reg) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* hvf_slot flags */
|
|
||||||
#define HVF_SLOT_LOG (1 << 0)
|
|
||||||
|
|
||||||
typedef struct hvf_slot {
|
|
||||||
uint64_t start;
|
|
||||||
uint64_t size;
|
|
||||||
uint8_t *mem;
|
|
||||||
int slot_id;
|
|
||||||
uint32_t flags;
|
|
||||||
MemoryRegion *region;
|
|
||||||
} hvf_slot;
|
|
||||||
|
|
||||||
typedef struct hvf_vcpu_caps {
|
|
||||||
uint64_t vmx_cap_pinbased;
|
|
||||||
uint64_t vmx_cap_procbased;
|
|
||||||
uint64_t vmx_cap_procbased2;
|
|
||||||
uint64_t vmx_cap_entry;
|
|
||||||
uint64_t vmx_cap_exit;
|
|
||||||
uint64_t vmx_cap_preemption_timer;
|
|
||||||
} hvf_vcpu_caps;
|
|
||||||
|
|
||||||
typedef struct HVFState {
|
|
||||||
AccelState parent;
|
|
||||||
hvf_slot slots[32];
|
|
||||||
int num_slots;
|
|
||||||
|
|
||||||
hvf_vcpu_caps *hvf_caps;
|
|
||||||
} HVFState;
|
|
||||||
extern HVFState *hvf_state;
|
|
||||||
|
|
||||||
void hvf_set_phys_mem(MemoryRegionSection *, bool);
|
|
||||||
void hvf_handle_io(CPUArchState *, uint16_t, void *,
|
|
||||||
int, int, int);
|
|
||||||
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
|
|
||||||
|
|
||||||
/* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported by
|
/* Disable HVF if |disable| is 1, otherwise, enable it iff it is supported by
|
||||||
* the host CPU. Use hvf_enabled() after this to get the result. */
|
* the host CPU. Use hvf_enabled() after this to get the result. */
|
||||||
void hvf_disable(int disable);
|
void hvf_disable(int disable);
|
||||||
|
@ -86,20 +46,9 @@ int hvf_smp_cpu_exec(CPUState *);
|
||||||
void hvf_cpu_synchronize_state(CPUState *);
|
void hvf_cpu_synchronize_state(CPUState *);
|
||||||
void hvf_cpu_synchronize_post_reset(CPUState *);
|
void hvf_cpu_synchronize_post_reset(CPUState *);
|
||||||
void hvf_cpu_synchronize_post_init(CPUState *);
|
void hvf_cpu_synchronize_post_init(CPUState *);
|
||||||
void _hvf_cpu_synchronize_post_init(CPUState *, run_on_cpu_data);
|
|
||||||
|
|
||||||
void hvf_vcpu_destroy(CPUState *);
|
void hvf_vcpu_destroy(CPUState *);
|
||||||
void hvf_raise_event(CPUState *);
|
|
||||||
/* void hvf_reset_vcpu_state(void *opaque); */
|
|
||||||
void hvf_reset_vcpu(CPUState *);
|
void hvf_reset_vcpu(CPUState *);
|
||||||
void vmx_update_tpr(CPUState *);
|
|
||||||
void update_apic_tpr(CPUState *);
|
|
||||||
int hvf_put_registers(CPUState *);
|
int hvf_put_registers(CPUState *);
|
||||||
void vmx_clear_int_window_exiting(CPUState *cpu);
|
|
||||||
|
|
||||||
#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
|
|
||||||
|
|
||||||
#define HVF_STATE(obj) \
|
|
||||||
OBJECT_CHECK(HVFState, (obj), TYPE_HVF_ACCEL)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "sysemu/hax.h"
|
#include "sysemu/hax.h"
|
||||||
#include "sysemu/kvm.h"
|
#include "sysemu/kvm.h"
|
||||||
#include "sysemu/whpx.h"
|
#include "sysemu/whpx.h"
|
||||||
|
#include "sysemu/hvf.h"
|
||||||
|
|
||||||
static inline void cpu_synchronize_state(CPUState *cpu)
|
static inline void cpu_synchronize_state(CPUState *cpu)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +28,9 @@ static inline void cpu_synchronize_state(CPUState *cpu)
|
||||||
if (whpx_enabled()) {
|
if (whpx_enabled()) {
|
||||||
whpx_cpu_synchronize_state(cpu);
|
whpx_cpu_synchronize_state(cpu);
|
||||||
}
|
}
|
||||||
|
if (hvf_enabled()) {
|
||||||
|
hvf_cpu_synchronize_state(cpu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cpu_synchronize_post_reset(CPUState *cpu)
|
static inline void cpu_synchronize_post_reset(CPUState *cpu)
|
||||||
|
@ -40,6 +44,9 @@ static inline void cpu_synchronize_post_reset(CPUState *cpu)
|
||||||
if (whpx_enabled()) {
|
if (whpx_enabled()) {
|
||||||
whpx_cpu_synchronize_post_reset(cpu);
|
whpx_cpu_synchronize_post_reset(cpu);
|
||||||
}
|
}
|
||||||
|
if (hvf_enabled()) {
|
||||||
|
hvf_cpu_synchronize_post_reset(cpu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cpu_synchronize_post_init(CPUState *cpu)
|
static inline void cpu_synchronize_post_init(CPUState *cpu)
|
||||||
|
@ -53,6 +60,9 @@ static inline void cpu_synchronize_post_init(CPUState *cpu)
|
||||||
if (whpx_enabled()) {
|
if (whpx_enabled()) {
|
||||||
whpx_cpu_synchronize_post_init(cpu);
|
whpx_cpu_synchronize_post_init(cpu);
|
||||||
}
|
}
|
||||||
|
if (hvf_enabled()) {
|
||||||
|
hvf_cpu_synchronize_post_init(cpu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cpu_synchronize_pre_loadvm(CPUState *cpu)
|
static inline void cpu_synchronize_pre_loadvm(CPUState *cpu)
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
|
||||||
#include "sysemu/hvf.h"
|
#include "hvf_int.h"
|
||||||
#include "hvf-i386.h"
|
#include "hvf-i386.h"
|
||||||
#include "vmcs.h"
|
#include "vmcs.h"
|
||||||
#include "vmx.h"
|
#include "vmx.h"
|
||||||
|
@ -669,6 +669,8 @@ int hvf_vcpu_exec(CPUState *cpu)
|
||||||
|
|
||||||
cpu->halted = 0;
|
cpu->halted = 0;
|
||||||
|
|
||||||
|
// printf("hvf_vcpu_exec\n");
|
||||||
|
|
||||||
if (hvf_process_events(cpu)) {
|
if (hvf_process_events(cpu)) {
|
||||||
return EXCP_HLT;
|
return EXCP_HLT;
|
||||||
}
|
}
|
||||||
|
@ -706,6 +708,8 @@ int hvf_vcpu_exec(CPUState *cpu)
|
||||||
RFLAGS(env) = rreg(cpu->hvf_fd, HV_X86_RFLAGS);
|
RFLAGS(env) = rreg(cpu->hvf_fd, HV_X86_RFLAGS);
|
||||||
env->eflags = RFLAGS(env);
|
env->eflags = RFLAGS(env);
|
||||||
|
|
||||||
|
// printf("rip 0x%llx, exit 0x%llx qual 0x%llx\n", rip, exit_reason, exit_qual);
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
|
|
||||||
update_apic_tpr(cpu);
|
update_apic_tpr(cpu);
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* QEMU Hypervisor.framework (HVF) support
|
||||||
|
*
|
||||||
|
* Copyright Google Inc., 2017
|
||||||
|
*
|
||||||
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||||
|
* See the COPYING file in the top-level directory.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* header to be included in HVF-specific code */
|
||||||
|
#ifndef _HVF_INT_H
|
||||||
|
#define _HVF_INT_H
|
||||||
|
|
||||||
|
#include "sysemu/hvf.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_HVF
|
||||||
|
#include "target/i386/cpu.h"
|
||||||
|
#include <Hypervisor/hv.h>
|
||||||
|
#include <Hypervisor/hv_vmx.h>
|
||||||
|
#include <Hypervisor/hv_error.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* hvf_slot flags */
|
||||||
|
#define HVF_SLOT_LOG (1 << 0)
|
||||||
|
|
||||||
|
typedef struct hvf_slot {
|
||||||
|
uint64_t start;
|
||||||
|
uint64_t size;
|
||||||
|
uint8_t *mem;
|
||||||
|
int slot_id;
|
||||||
|
uint32_t flags;
|
||||||
|
MemoryRegion *region;
|
||||||
|
} hvf_slot;
|
||||||
|
|
||||||
|
typedef struct hvf_vcpu_caps {
|
||||||
|
uint64_t vmx_cap_pinbased;
|
||||||
|
uint64_t vmx_cap_procbased;
|
||||||
|
uint64_t vmx_cap_procbased2;
|
||||||
|
uint64_t vmx_cap_entry;
|
||||||
|
uint64_t vmx_cap_exit;
|
||||||
|
uint64_t vmx_cap_preemption_timer;
|
||||||
|
} hvf_vcpu_caps;
|
||||||
|
|
||||||
|
typedef struct HVFState {
|
||||||
|
AccelState parent;
|
||||||
|
hvf_slot slots[32];
|
||||||
|
int num_slots;
|
||||||
|
|
||||||
|
hvf_vcpu_caps *hvf_caps;
|
||||||
|
} HVFState;
|
||||||
|
extern HVFState *hvf_state;
|
||||||
|
|
||||||
|
void hvf_set_phys_mem(MemoryRegionSection *, bool);
|
||||||
|
void hvf_handle_io(CPUArchState *, uint16_t, void *,
|
||||||
|
int, int, int);
|
||||||
|
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
|
||||||
|
|
||||||
|
void _hvf_cpu_synchronize_post_init(CPUState *, run_on_cpu_data);
|
||||||
|
|
||||||
|
void vmx_update_tpr(CPUState *);
|
||||||
|
void update_apic_tpr(CPUState *);
|
||||||
|
void vmx_clear_int_window_exiting(CPUState *cpu);
|
||||||
|
|
||||||
|
#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
|
||||||
|
|
||||||
|
#define HVF_STATE(obj) \
|
||||||
|
OBJECT_CHECK(HVFState, (obj), TYPE_HVF_ACCEL)
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue