aboutsummaryrefslogtreecommitdiff
path: root/include/sysemu
diff options
context:
space:
mode:
Diffstat (limited to 'include/sysemu')
-rw-r--r--include/sysemu/hax.h1
-rw-r--r--include/sysemu/hvf.h107
-rw-r--r--include/sysemu/iothread.h4
-rw-r--r--include/sysemu/numa.h10
-rw-r--r--include/sysemu/sysemu.h2
-rw-r--r--include/sysemu/tpm.h48
-rw-r--r--include/sysemu/tpm_backend.h50
7 files changed, 173 insertions, 49 deletions
diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h
index 232a68ab1b..f252399623 100644
--- a/include/sysemu/hax.h
+++ b/include/sysemu/hax.h
@@ -22,7 +22,6 @@
#ifndef QEMU_HAX_H
#define QEMU_HAX_H
-#include "config-host.h"
#include "qemu-common.h"
int hax_sync_vcpus(void);
diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
new file mode 100644
index 0000000000..e4e43f6468
--- /dev/null
+++ b/include/sysemu/hvf.h
@@ -0,0 +1,107 @@
+/*
+ * 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 non-HVF-specific code */
+#ifndef _HVF_H
+#define _HVF_H
+
+#include "config-host.h"
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/bitops.h"
+#include "exec/memory.h"
+#include "sysemu/accel.h"
+
+extern int hvf_disabled;
+#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,
+ int reg);
+#define hvf_enabled() !hvf_disabled
+#else
+#define hvf_enabled() 0
+#define hvf_get_supported_cpuid(func, idx, reg) 0
+#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
+ * the host CPU. Use hvf_enabled() after this to get the result. */
+void hvf_disable(int disable);
+
+/* Returns non-0 if the host CPU supports the VMX "unrestricted guest" feature
+ * which allows the virtual CPU to directly run in "real mode". If true, this
+ * allows QEMU to run several vCPU threads in parallel (see cpus.c). Otherwise,
+ * only a a single TCG thread can run, and it will call HVF to run the current
+ * instructions, except in case of "real mode" (paging disabled, typically at
+ * boot time), or MMIO operations. */
+
+int hvf_sync_vcpus(void);
+
+int hvf_init_vcpu(CPUState *);
+int hvf_vcpu_exec(CPUState *);
+int hvf_smp_cpu_exec(CPUState *);
+void hvf_cpu_synchronize_state(CPUState *);
+void hvf_cpu_synchronize_post_reset(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_raise_event(CPUState *);
+/* void hvf_reset_vcpu_state(void *opaque); */
+void hvf_reset_vcpu(CPUState *);
+void vmx_update_tpr(CPUState *);
+void update_apic_tpr(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
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index 110329b2b4..799614ffd2 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -29,7 +29,8 @@ typedef struct {
GOnce once;
QemuMutex init_done_lock;
QemuCond init_done_cond; /* is thread initialization done? */
- bool stopping;
+ bool stopping; /* has iothread_stop() been called? */
+ bool running; /* should iothread_run() continue? */
int thread_id;
/* AioContext poll parameters */
@@ -42,6 +43,7 @@ typedef struct {
OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
char *iothread_get_id(IOThread *iothread);
+IOThread *iothread_by_id(const char *id);
AioContext *iothread_get_aio_context(IOThread *iothread);
void iothread_stop_all(void);
GMainContext *iothread_get_g_main_context(IOThread *iothread);
diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index 5c6df2820b..b3545215f6 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -10,17 +10,10 @@
extern int nb_numa_nodes; /* Number of NUMA nodes */
extern bool have_numa_distance;
-struct numa_addr_range {
- ram_addr_t mem_start;
- ram_addr_t mem_end;
- QLIST_ENTRY(numa_addr_range) entry;
-};
-
struct node_info {
uint64_t node_mem;
struct HostMemoryBackend *node_memdev;
bool present;
- QLIST_HEAD(, numa_addr_range) addr; /* List to store address ranges */
uint8_t distance[MAX_NODES];
};
@@ -33,9 +26,6 @@ extern NodeInfo numa_info[MAX_NODES];
void parse_numa_opts(MachineState *ms);
void query_numa_node_mem(NumaNodeMem node_mem[]);
extern QemuOptsList qemu_numa_opts;
-void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
-void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
-uint32_t numa_get_node(ram_addr_t addr, Error **errp);
void numa_legacy_auto_assign_ram(MachineClass *mc, NodeInfo *nodes,
int nb_nodes, ram_addr_t size);
void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes,
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index c083869fcf..31612caf10 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -166,8 +166,6 @@ extern Chardev *serial_hds[MAX_SERIAL_PORTS];
extern Chardev *parallel_hds[MAX_PARALLEL_PORTS];
-void hmp_usb_add(Monitor *mon, const QDict *qdict);
-void hmp_usb_del(Monitor *mon, const QDict *qdict);
void hmp_info_usb(Monitor *mon, const QDict *qdict);
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index d7a2bd8556..852e02687c 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -12,35 +12,59 @@
#ifndef QEMU_TPM_H
#define QEMU_TPM_H
-#include "qemu/option.h"
#include "qom/object.h"
-
-typedef struct TPMState TPMState;
+#include "qapi-types.h"
int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
int tpm_init(void);
void tpm_cleanup(void);
-typedef enum TPMVersion {
+typedef enum TPMVersion {
TPM_VERSION_UNSPEC = 0,
TPM_VERSION_1_2 = 1,
TPM_VERSION_2_0 = 2,
} TPMVersion;
-TPMVersion tpm_tis_get_tpm_version(Object *obj);
+#define TYPE_TPM_IF "tpm-if"
+#define TPM_IF_CLASS(klass) \
+ OBJECT_CLASS_CHECK(TPMIfClass, (klass), TYPE_TPM_IF)
+#define TPM_IF_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(TPMIfClass, (obj), TYPE_TPM_IF)
+#define TPM_IF(obj) \
+ INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
+
+typedef struct TPMIf {
+ Object parent_obj;
+} TPMIf;
+
+typedef struct TPMIfClass {
+ InterfaceClass parent_class;
+
+ enum TpmModel model;
+ void (*request_completed)(TPMIf *obj);
+ enum TPMVersion (*get_version)(TPMIf *obj);
+} TPMIfClass;
#define TYPE_TPM_TIS "tpm-tis"
-static inline TPMVersion tpm_get_version(void)
+#define TPM_IS_TIS(chr) \
+ object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS)
+
+/* returns NULL unless there is exactly one TPM device */
+static inline TPMIf *tpm_find(void)
{
-#ifdef CONFIG_TPM
- Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
+ Object *obj = object_resolve_path_type("", TYPE_TPM_IF, NULL);
- if (obj) {
- return tpm_tis_get_tpm_version(obj);
+ return TPM_IF(obj);
+}
+
+static inline TPMVersion tpm_get_version(TPMIf *ti)
+{
+ if (!ti) {
+ return TPM_VERSION_UNSPEC;
}
-#endif
- return TPM_VERSION_UNSPEC;
+
+ return TPM_IF_GET_CLASS(ti)->get_version(ti);
}
#endif /* QEMU_TPM_H */
diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
index 03ea5a3400..0d6c994a62 100644
--- a/include/sysemu/tpm_backend.h
+++ b/include/sysemu/tpm_backend.h
@@ -43,14 +43,14 @@ struct TPMBackend {
Object parent;
/*< protected >*/
+ TPMIf *tpmif;
bool opened;
- TPMState *tpm_state;
GThreadPool *thread_pool;
bool had_startup_error;
+ QEMUBH *bh;
/* <public> */
char *id;
- enum TpmModel fe_model;
QLIST_ENTRY(TPMBackend) list;
};
@@ -63,24 +63,27 @@ struct TPMBackendClass {
/* get a descriptive text of the backend to display to the user */
const char *desc;
- TPMBackend *(*create)(QemuOpts *opts, const char *id);
+ TPMBackend *(*create)(QemuOpts *opts);
- /* start up the TPM on the backend */
- int (*startup_tpm)(TPMBackend *t);
+ /* start up the TPM on the backend - optional */
+ int (*startup_tpm)(TPMBackend *t, size_t buffersize);
+ /* optional */
void (*reset)(TPMBackend *t);
void (*cancel_cmd)(TPMBackend *t);
+ /* optional */
bool (*get_tpm_established_flag)(TPMBackend *t);
+ /* optional */
int (*reset_tpm_established_flag)(TPMBackend *t, uint8_t locty);
TPMVersion (*get_tpm_version)(TPMBackend *t);
- TpmTypeOptions *(*get_tpm_options)(TPMBackend *t);
+ size_t (*get_buffer_size)(TPMBackend *t);
- void (*opened)(TPMBackend *s, Error **errp);
+ TpmTypeOptions *(*get_tpm_options)(TPMBackend *t);
void (*handle_request)(TPMBackend *s, TPMBackendCmd *cmd);
};
@@ -96,22 +99,25 @@ enum TpmType tpm_backend_get_type(TPMBackend *s);
/**
* tpm_backend_init:
* @s: the backend to initialized
- * @state: TPMState
+ * @tpmif: TPM interface
* @datacb: callback for sending data to frontend
+ * @errp: a pointer to return the #Error object if an error occurs.
*
* Initialize the backend with the given variables.
*
* Returns 0 on success.
*/
-int tpm_backend_init(TPMBackend *s, TPMState *state);
+int tpm_backend_init(TPMBackend *s, TPMIf *tpmif, Error **errp);
/**
* tpm_backend_startup_tpm:
* @s: the backend whose TPM support is to be started
+ * @buffersize: the buffer size the TPM is supposed to use,
+ * 0 to leave it as-is
*
* Returns 0 on success.
*/
-int tpm_backend_startup_tpm(TPMBackend *s);
+int tpm_backend_startup_tpm(TPMBackend *s, size_t buffersize);
/**
* tpm_backend_had_startup_error:
@@ -171,16 +177,6 @@ bool tpm_backend_get_tpm_established_flag(TPMBackend *s);
int tpm_backend_reset_tpm_established_flag(TPMBackend *s, uint8_t locty);
/**
- * tpm_backend_open:
- * @s: the backend to open
- * @errp: a pointer to return the #Error object if an error occurs.
- *
- * This function will open the backend if it is not already open. Calling this
- * function on an already opened backend will not result in an error.
- */
-void tpm_backend_open(TPMBackend *s, Error **errp);
-
-/**
* tpm_backend_get_tpm_version:
* @s: the backend to call into
*
@@ -191,6 +187,16 @@ void tpm_backend_open(TPMBackend *s, Error **errp);
TPMVersion tpm_backend_get_tpm_version(TPMBackend *s);
/**
+ * tpm_backend_get_buffer_size:
+ * @s: the backend to call into
+ *
+ * Get the TPM's buffer size.
+ *
+ * Returns buffer size.
+ */
+size_t tpm_backend_get_buffer_size(TPMBackend *s);
+
+/**
* tpm_backend_query_tpm:
* @s: the backend
*
@@ -200,8 +206,6 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s);
*/
TPMInfo *tpm_backend_query_tpm(TPMBackend *s);
-TPMBackend *qemu_find_tpm(const char *id);
-
-void tpm_register_model(enum TpmModel model);
+TPMBackend *qemu_find_tpm_be(const char *id);
#endif