mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge branch 'xenfv-kvm-15' of git://git.infradead.org/users/dwmw2/qemu into HEAD
This adds support for emulating Xen under Linux/KVM, based on kernel
patches which have been present since Linux v5.12. As with the kernel
support, it's derived from work started by João Martins of Oracle in
2018.
This series just adds the basic platform support — CPUID, hypercalls,
event channels, a stub of XenStore.
A full single-tenant internal implementation of XenStore, and patches
to make QEMU's Xen PV drivers work with this Xen emulation, are waiting
in the wings to be submitted in a follow-on patch series.
As noted in the documentation, it's enabled by setting the xen-version
property on the KVM accelerator, e.g.:
qemu-system-x86_64 -serial mon:stdio -M q35 -display none -m 1G -smp 2 \
-accel kvm,xen-version=0x4000e,kernel-irqchip=split \
-kernel vmlinuz-6.0.7-301.fc37.x86_64 \
-append "console=ttyS0 root=/dev/sda1" \
-drive file=/var/lib/libvirt/images/fedora28.qcow2,if=none,id=disk \
-device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0
Even before this was merged, we've already been using it to find and fix
bugs in the Linux kernel Xen guest support:
https://lore.kernel.org/all/4bffa69a949bfdc92c4a18e5a1c3cbb3b94a0d32.camel@infradead.org/
https://lore.kernel.org/all/871qnunycr.ffs@tglx/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
+6
-2
@@ -123,6 +123,7 @@ M: Richard Henderson <richard.henderson@linaro.org>
|
||||
R: Paolo Bonzini <pbonzini@redhat.com>
|
||||
S: Maintained
|
||||
F: softmmu/cpus.c
|
||||
F: softmmu/watchpoint.c
|
||||
F: cpus-common.c
|
||||
F: page-vary.c
|
||||
F: page-vary-common.c
|
||||
@@ -1679,6 +1680,7 @@ F: hw/i2c/smbus_ich9.c
|
||||
F: hw/acpi/piix4.c
|
||||
F: hw/acpi/ich9*.c
|
||||
F: include/hw/acpi/ich9*.h
|
||||
F: include/hw/southbridge/ich9.h
|
||||
F: include/hw/southbridge/piix.h
|
||||
F: hw/isa/apm.c
|
||||
F: include/hw/isa/apm.h
|
||||
@@ -1711,6 +1713,7 @@ F: include/hw/char/parallel.h
|
||||
F: include/hw/dma/i8257.h
|
||||
F: include/hw/i2c/pm_smbus.h
|
||||
F: include/hw/input/i8042.h
|
||||
F: include/hw/intc/ioapic*
|
||||
F: include/hw/isa/i8259_internal.h
|
||||
F: include/hw/isa/superio.h
|
||||
F: include/hw/timer/hpet.h
|
||||
@@ -1795,7 +1798,7 @@ F: hw/misc/edu.c
|
||||
IDE
|
||||
M: John Snow <jsnow@redhat.com>
|
||||
L: qemu-block@nongnu.org
|
||||
S: Supported
|
||||
S: Odd Fixes
|
||||
F: include/hw/ide.h
|
||||
F: include/hw/ide/
|
||||
F: hw/ide/
|
||||
@@ -1820,7 +1823,7 @@ T: git https://github.com/cminyard/qemu.git master-ipmi-rebase
|
||||
Floppy
|
||||
M: John Snow <jsnow@redhat.com>
|
||||
L: qemu-block@nongnu.org
|
||||
S: Supported
|
||||
S: Odd Fixes
|
||||
F: hw/block/fdc.c
|
||||
F: hw/block/fdc-internal.h
|
||||
F: hw/block/fdc-isa.c
|
||||
@@ -3239,6 +3242,7 @@ S: Supported
|
||||
F: replay/*
|
||||
F: block/blkreplay.c
|
||||
F: net/filter-replay.c
|
||||
F: include/exec/replay-core.h
|
||||
F: include/sysemu/replay.h
|
||||
F: docs/devel/replay.rst
|
||||
F: docs/system/replay.rst
|
||||
|
||||
+7
-4
@@ -2361,13 +2361,13 @@ static int kvm_init(MachineState *ms)
|
||||
static const char upgrade_note[] =
|
||||
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
|
||||
"(see http://sourceforge.net/projects/kvm).\n";
|
||||
struct {
|
||||
const struct {
|
||||
const char *name;
|
||||
int num;
|
||||
} num_cpus[] = {
|
||||
{ "SMP", ms->smp.cpus },
|
||||
{ "hotpluggable", ms->smp.max_cpus },
|
||||
{ NULL, }
|
||||
{ /* end of list */ }
|
||||
}, *nc = num_cpus;
|
||||
int soft_vcpus_limit, hard_vcpus_limit;
|
||||
KVMState *s;
|
||||
@@ -3305,7 +3305,7 @@ bool kvm_supports_guest_debug(void)
|
||||
return kvm_has_guest_debug;
|
||||
}
|
||||
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len)
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
|
||||
{
|
||||
struct kvm_sw_breakpoint *bp;
|
||||
int err;
|
||||
@@ -3343,7 +3343,7 @@ int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len)
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
|
||||
{
|
||||
struct kvm_sw_breakpoint *bp;
|
||||
int err;
|
||||
@@ -3703,6 +3703,9 @@ static void kvm_accel_instance_init(Object *obj)
|
||||
s->kvm_dirty_ring_size = 0;
|
||||
s->notify_vmexit = NOTIFY_VMEXIT_OPTION_RUN;
|
||||
s->notify_window = 0;
|
||||
s->xen_version = 0;
|
||||
s->xen_gnttab_max_frames = 64;
|
||||
s->xen_evtchn_max_pirq = 256;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,8 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_post_init(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu);
|
||||
bool kvm_supports_guest_debug(void);
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
|
||||
void kvm_remove_all_breakpoints(CPUState *cpu);
|
||||
|
||||
#endif /* KVM_CPUS_H */
|
||||
|
||||
+3
-88
@@ -20,7 +20,6 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/qemu-print.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "qapi/type-helpers.h"
|
||||
#include "hw/core/tcg-cpu-ops.h"
|
||||
#include "trace.h"
|
||||
@@ -28,7 +27,6 @@
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "qemu/atomic.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "exec/log.h"
|
||||
#include "qemu/main-loop.h"
|
||||
@@ -38,7 +36,7 @@
|
||||
#include "sysemu/cpus.h"
|
||||
#include "exec/cpu-all.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "exec/helper-proto.h"
|
||||
#include "tb-jmp-cache.h"
|
||||
@@ -64,8 +62,8 @@ typedef struct SyncClocks {
|
||||
#define MAX_DELAY_PRINT_RATE 2000000000LL
|
||||
#define MAX_NB_PRINTS 100
|
||||
|
||||
static int64_t max_delay;
|
||||
static int64_t max_advance;
|
||||
int64_t max_delay;
|
||||
int64_t max_advance;
|
||||
|
||||
static void align_clocks(SyncClocks *sc, CPUState *cpu)
|
||||
{
|
||||
@@ -1072,86 +1070,3 @@ void tcg_exec_unrealizefn(CPUState *cpu)
|
||||
tlb_destroy(cpu);
|
||||
g_free_rcu(cpu->tb_jmp_cache, rcu);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
static void dump_drift_info(GString *buf)
|
||||
{
|
||||
if (!icount_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
|
||||
(cpu_get_clock() - icount_get()) / SCALE_MS);
|
||||
if (icount_align_option) {
|
||||
g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
|
||||
-max_delay / SCALE_MS);
|
||||
g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
|
||||
max_advance / SCALE_MS);
|
||||
} else {
|
||||
g_string_append_printf(buf, "Max guest delay NA\n");
|
||||
g_string_append_printf(buf, "Max guest advance NA\n");
|
||||
}
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_jit(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp, "JIT information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dump_exec_info(buf);
|
||||
dump_drift_info(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_opcount(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp, "Opcode count information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tcg_dump_op_count(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
|
||||
int64_t dev_time;
|
||||
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
static int64_t last_cpu_exec_time;
|
||||
int64_t cpu_exec_time;
|
||||
int64_t delta;
|
||||
|
||||
cpu_exec_time = tcg_cpu_exec_time();
|
||||
delta = cpu_exec_time - last_cpu_exec_time;
|
||||
|
||||
g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
|
||||
dev_time, dev_time / (double)NANOSECONDS_PER_SECOND);
|
||||
g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
|
||||
delta, delta / (double)NANOSECONDS_PER_SECOND);
|
||||
last_cpu_exec_time = cpu_exec_time;
|
||||
dev_time = 0;
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
#else
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
error_setg(errp, "Internal profiler not compiled");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !CONFIG_USER_ONLY */
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "monitor/monitor.h"
|
||||
|
||||
static void hmp_tcg_register(void)
|
||||
{
|
||||
monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
|
||||
monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
|
||||
}
|
||||
|
||||
type_init(hmp_tcg_register);
|
||||
@@ -64,4 +64,7 @@ static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *tb)
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int64_t max_delay;
|
||||
extern int64_t max_advance;
|
||||
|
||||
#endif /* ACCEL_TCG_INTERNAL_H */
|
||||
|
||||
@@ -18,7 +18,7 @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
|
||||
|
||||
specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
|
||||
'cputlb.c',
|
||||
'hmp.c',
|
||||
'monitor.c',
|
||||
))
|
||||
|
||||
tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* QEMU TCG monitor
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/type-helpers.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
static void dump_drift_info(GString *buf)
|
||||
{
|
||||
if (!icount_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
|
||||
(cpu_get_clock() - icount_get()) / SCALE_MS);
|
||||
if (icount_align_option) {
|
||||
g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
|
||||
-max_delay / SCALE_MS);
|
||||
g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
|
||||
max_advance / SCALE_MS);
|
||||
} else {
|
||||
g_string_append_printf(buf, "Max guest delay NA\n");
|
||||
g_string_append_printf(buf, "Max guest advance NA\n");
|
||||
}
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_jit(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp, "JIT information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dump_exec_info(buf);
|
||||
dump_drift_info(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_opcount(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp,
|
||||
"Opcode count information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tcg_dump_op_count(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
|
||||
int64_t dev_time;
|
||||
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
static int64_t last_cpu_exec_time;
|
||||
int64_t cpu_exec_time;
|
||||
int64_t delta;
|
||||
|
||||
cpu_exec_time = tcg_cpu_exec_time();
|
||||
delta = cpu_exec_time - last_cpu_exec_time;
|
||||
|
||||
g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
|
||||
dev_time, dev_time / (double)NANOSECONDS_PER_SECOND);
|
||||
g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
|
||||
delta, delta / (double)NANOSECONDS_PER_SECOND);
|
||||
last_cpu_exec_time = cpu_exec_time;
|
||||
dev_time = 0;
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
#else
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
error_setg(errp, "Internal profiler not compiled");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hmp_tcg_register(void)
|
||||
{
|
||||
monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
|
||||
monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
|
||||
}
|
||||
|
||||
type_init(hmp_tcg_register);
|
||||
@@ -44,7 +44,18 @@
|
||||
|
||||
void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
|
||||
{
|
||||
uint32_t cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
|
||||
uint32_t cflags;
|
||||
|
||||
/*
|
||||
* Include the cluster number in the hash we use to look up TBs.
|
||||
* This is important because a TB that is valid for one cluster at
|
||||
* a given physical address and set of CPU flags is not necessarily
|
||||
* valid for another:
|
||||
* the two clusters may have different views of physical memory, or
|
||||
* may have different CPU features (eg FPU present or absent).
|
||||
*/
|
||||
cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
|
||||
|
||||
cflags |= parallel ? CF_PARALLEL : 0;
|
||||
cflags |= icount_enabled() ? CF_USE_ICOUNT : 0;
|
||||
cpu->tcg_cflags = cflags;
|
||||
@@ -116,7 +127,7 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype)
|
||||
return cputype;
|
||||
}
|
||||
|
||||
static int tcg_insert_breakpoint(CPUState *cs, int type, hwaddr addr, hwaddr len)
|
||||
static int tcg_insert_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
|
||||
{
|
||||
CPUState *cpu;
|
||||
int err = 0;
|
||||
@@ -147,7 +158,7 @@ static int tcg_insert_breakpoint(CPUState *cs, int type, hwaddr addr, hwaddr len
|
||||
}
|
||||
}
|
||||
|
||||
static int tcg_remove_breakpoint(CPUState *cs, int type, hwaddr addr, hwaddr len)
|
||||
static int tcg_remove_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
|
||||
{
|
||||
CPUState *cpu;
|
||||
int err = 0;
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "exec/translator.h"
|
||||
#include "qemu/bitmap.h"
|
||||
#include "qemu/qemu-print.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/cacheinfo.h"
|
||||
#include "exec/log.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "exec/log.h"
|
||||
#include "exec/translator.h"
|
||||
#include "exec/plugin-gen.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "exec/replay-core.h"
|
||||
|
||||
/* Pairs with tcg_clear_temp_count.
|
||||
To be called by #TranslatorOps.{translate_insn,tb_stop} if
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/core/cpu.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "exec/replay-core.h"
|
||||
|
||||
bool enable_cpu_pm = false;
|
||||
|
||||
|
||||
+2
-10
@@ -23,16 +23,6 @@
|
||||
#include "migration/global_state.h"
|
||||
#include "hw/boards.h"
|
||||
|
||||
//#define DEBUG_XEN
|
||||
|
||||
#ifdef DEBUG_XEN
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { } while (0)
|
||||
#endif
|
||||
|
||||
bool xen_allowed;
|
||||
|
||||
xc_interface *xen_xc;
|
||||
@@ -181,6 +171,8 @@ static int xen_init(MachineState *ms)
|
||||
* opt out of system RAM being allocated by generic code
|
||||
*/
|
||||
mc->default_ram_id = NULL;
|
||||
|
||||
xen_mode = XEN_ATTACH;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2784,13 +2784,10 @@ static int handle_commits(BDRVVVFATState* s)
|
||||
fail = -2;
|
||||
break;
|
||||
case ACTION_WRITEOUT: {
|
||||
#ifndef NDEBUG
|
||||
/* these variables are only used by assert() below */
|
||||
direntry_t* entry = array_get(&(s->directory),
|
||||
commit->param.writeout.dir_index);
|
||||
uint32_t begin = begin_of_direntry(entry);
|
||||
mapping_t* mapping = find_mapping_for_cluster(s, begin);
|
||||
#endif
|
||||
|
||||
assert(mapping);
|
||||
assert(mapping->begin == begin);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#endif
|
||||
#include "sysemu/tcg.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "exec/cpu-common.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/translate-all.h"
|
||||
@@ -319,77 +319,6 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Add a breakpoint. */
|
||||
int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
|
||||
CPUBreakpoint **breakpoint)
|
||||
{
|
||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||
CPUBreakpoint *bp;
|
||||
|
||||
if (cc->gdb_adjust_breakpoint) {
|
||||
pc = cc->gdb_adjust_breakpoint(cpu, pc);
|
||||
}
|
||||
|
||||
bp = g_malloc(sizeof(*bp));
|
||||
|
||||
bp->pc = pc;
|
||||
bp->flags = flags;
|
||||
|
||||
/* keep all GDB-injected breakpoints in front */
|
||||
if (flags & BP_GDB) {
|
||||
QTAILQ_INSERT_HEAD(&cpu->breakpoints, bp, entry);
|
||||
} else {
|
||||
QTAILQ_INSERT_TAIL(&cpu->breakpoints, bp, entry);
|
||||
}
|
||||
|
||||
if (breakpoint) {
|
||||
*breakpoint = bp;
|
||||
}
|
||||
|
||||
trace_breakpoint_insert(cpu->cpu_index, pc, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove a specific breakpoint. */
|
||||
int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags)
|
||||
{
|
||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||
CPUBreakpoint *bp;
|
||||
|
||||
if (cc->gdb_adjust_breakpoint) {
|
||||
pc = cc->gdb_adjust_breakpoint(cpu, pc);
|
||||
}
|
||||
|
||||
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
|
||||
if (bp->pc == pc && bp->flags == flags) {
|
||||
cpu_breakpoint_remove_by_ref(cpu, bp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Remove a specific breakpoint by reference. */
|
||||
void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *bp)
|
||||
{
|
||||
QTAILQ_REMOVE(&cpu->breakpoints, bp, entry);
|
||||
|
||||
trace_breakpoint_remove(cpu->cpu_index, bp->pc, bp->flags);
|
||||
g_free(bp);
|
||||
}
|
||||
|
||||
/* Remove all matching breakpoints. */
|
||||
void cpu_breakpoint_remove_all(CPUState *cpu, int mask)
|
||||
{
|
||||
CPUBreakpoint *bp, *next;
|
||||
|
||||
QTAILQ_FOREACH_SAFE(bp, &cpu->breakpoints, entry, next) {
|
||||
if (bp->flags & mask) {
|
||||
cpu_breakpoint_remove_by_ref(cpu, bp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* enable or disable single step mode. EXCP_DEBUG is returned by the
|
||||
CPU loop after each instruction */
|
||||
void cpu_single_step(CPUState *cpu, int enabled)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "hw/core/cpu.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "qemu/lockable.h"
|
||||
#include "trace/trace-root.h"
|
||||
|
||||
static QemuMutex qemu_cpu_list_lock;
|
||||
static QemuCond exclusive_cond;
|
||||
@@ -368,3 +369,74 @@ void process_queued_cpu_work(CPUState *cpu)
|
||||
qemu_mutex_unlock(&cpu->work_mutex);
|
||||
qemu_cond_broadcast(&qemu_work_cond);
|
||||
}
|
||||
|
||||
/* Add a breakpoint. */
|
||||
int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
|
||||
CPUBreakpoint **breakpoint)
|
||||
{
|
||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||
CPUBreakpoint *bp;
|
||||
|
||||
if (cc->gdb_adjust_breakpoint) {
|
||||
pc = cc->gdb_adjust_breakpoint(cpu, pc);
|
||||
}
|
||||
|
||||
bp = g_malloc(sizeof(*bp));
|
||||
|
||||
bp->pc = pc;
|
||||
bp->flags = flags;
|
||||
|
||||
/* keep all GDB-injected breakpoints in front */
|
||||
if (flags & BP_GDB) {
|
||||
QTAILQ_INSERT_HEAD(&cpu->breakpoints, bp, entry);
|
||||
} else {
|
||||
QTAILQ_INSERT_TAIL(&cpu->breakpoints, bp, entry);
|
||||
}
|
||||
|
||||
if (breakpoint) {
|
||||
*breakpoint = bp;
|
||||
}
|
||||
|
||||
trace_breakpoint_insert(cpu->cpu_index, pc, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove a specific breakpoint. */
|
||||
int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags)
|
||||
{
|
||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||
CPUBreakpoint *bp;
|
||||
|
||||
if (cc->gdb_adjust_breakpoint) {
|
||||
pc = cc->gdb_adjust_breakpoint(cpu, pc);
|
||||
}
|
||||
|
||||
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
|
||||
if (bp->pc == pc && bp->flags == flags) {
|
||||
cpu_breakpoint_remove_by_ref(cpu, bp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Remove a specific breakpoint by reference. */
|
||||
void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *bp)
|
||||
{
|
||||
QTAILQ_REMOVE(&cpu->breakpoints, bp, entry);
|
||||
|
||||
trace_breakpoint_remove(cpu->cpu_index, bp->pc, bp->flags);
|
||||
g_free(bp);
|
||||
}
|
||||
|
||||
/* Remove all matching breakpoints. */
|
||||
void cpu_breakpoint_remove_all(CPUState *cpu, int mask)
|
||||
{
|
||||
CPUBreakpoint *bp, *next;
|
||||
|
||||
QTAILQ_FOREACH_SAFE(bp, &cpu->breakpoints, entry, next) {
|
||||
if (bp->flags & mask) {
|
||||
cpu_breakpoint_remove_by_ref(cpu, bp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
Xen HVM guest support
|
||||
=====================
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
KVM has support for hosting Xen guests, intercepting Xen hypercalls and event
|
||||
channel (Xen PV interrupt) delivery. This allows guests which expect to be
|
||||
run under Xen to be hosted in QEMU under Linux/KVM instead.
|
||||
|
||||
Setup
|
||||
-----
|
||||
|
||||
Xen mode is enabled by setting the ``xen-version`` property of the KVM
|
||||
accelerator, for example for Xen 4.10:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
|qemu_system| --accel kvm,xen-version=0x4000a
|
||||
|
||||
Additionally, virtual APIC support can be advertised to the guest through the
|
||||
``xen-vapic`` CPU flag:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
|qemu_system| --accel kvm,xen-version=0x4000a --cpu host,+xen_vapic
|
||||
|
||||
When Xen support is enabled, QEMU changes hypervisor identification (CPUID
|
||||
0x40000000..0x4000000A) to Xen. The KVM identification and features are not
|
||||
advertised to a Xen guest. If Hyper-V is also enabled, the Xen identification
|
||||
moves to leaves 0x40000100..0x4000010A.
|
||||
|
||||
The Xen platform device is enabled automatically for a Xen guest. This allows
|
||||
a guest to unplug all emulated devices, in order to use Xen PV block and network
|
||||
drivers instead. Note that until the Xen PV device back ends are enabled to work
|
||||
with Xen mode in QEMU, that is unlikely to cause significant joy. Linux guests
|
||||
can be dissuaded from this by adding 'xen_emul_unplug=never' on their command
|
||||
line, and it can also be noted that AHCI disk controllers are exempt from being
|
||||
unplugged, as are passthrough VFIO PCI devices.
|
||||
|
||||
Properties
|
||||
----------
|
||||
|
||||
The following properties exist on the KVM accelerator object:
|
||||
|
||||
``xen-version``
|
||||
This property contains the Xen version in ``XENVER_version`` form, with the
|
||||
major version in the top 16 bits and the minor version in the low 16 bits.
|
||||
Setting this property enables the Xen guest support.
|
||||
|
||||
``xen-evtchn-max-pirq``
|
||||
Xen PIRQs represent an emulated physical interrupt, either GSI or MSI, which
|
||||
can be routed to an event channel instead of to the emulated I/O or local
|
||||
APIC. By default, QEMU permits only 256 PIRQs because this allows maximum
|
||||
compatibility with 32-bit MSI where the higher bits of the PIRQ# would need
|
||||
to be in the upper 64 bits of the MSI message. For guests with large numbers
|
||||
of PCI devices (and none which are limited to 32-bit addressing) it may be
|
||||
desirable to increase this value.
|
||||
|
||||
``xen-gnttab-max-frames``
|
||||
Xen grant tables are the means by which a Xen guest grants access to its
|
||||
memory for PV back ends (disk, network, etc.). Since QEMU only supports v1
|
||||
grant tables which are 8 bytes in size, each page (each frame) of the grant
|
||||
table can reference 512 pages of guest memory. The default number of frames
|
||||
is 64, allowing for 32768 pages of guest memory to be accessed by PV backends
|
||||
through simultaneous grants. For guests with large numbers of PV devices and
|
||||
high throughput, it may be desirable to increase this value.
|
||||
|
||||
OS requirements
|
||||
---------------
|
||||
|
||||
The minimal Xen support in the KVM accelerator requires the host to be running
|
||||
Linux v5.12 or newer. Later versions add optimisations: Linux v5.17 added
|
||||
acceleration of interrupt delivery via the Xen PIRQ mechanism, and Linux v5.19
|
||||
accelerated Xen PV timers and inter-processor interrupts (IPIs).
|
||||
@@ -27,6 +27,7 @@ Architectural features
|
||||
|
||||
i386/cpu
|
||||
i386/hyperv
|
||||
i386/xen
|
||||
i386/kvm-pv
|
||||
i386/sgx
|
||||
i386/amd-memory-encryption
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Human Monitor Interface commands
|
||||
* Windows crashdump (Human Monitor Interface commands)
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user