aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-03-03 16:41:09 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-03-03 16:41:09 +0000
commit5febe7671f5ec0a6842d64edfb920feb7bbb5f1e (patch)
tree4983379122a9105f30b12f57c0449e3d1e684b5c /target
parent5b10b94bd53229540b088342015d69bc5ef2cc1d (diff)
parentf6eb0b319e4bad3d01d74d71e3a6cf40f0ede720 (diff)
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* kernel header update (requested by David and Vijay) * GuestPanicInformation fixups (Anton) * record/replay icount fixes (Pavel) * cpu-exec cleanup, unification of icount_decr with tcg_exit_req (me) * KVM_CAP_IMMEDIATE_EXIT support (me) * vmxcap update (me) * iscsi locking fix (me) * VFIO ram device fix (Yongji) * scsi-hd vs. default CD-ROM (Hervé) * SMI migration fix (Dave) * spice-char segfault (Li Qiang) * improved "info mtree -f" (me) # gpg: Signature made Fri 03 Mar 2017 15:43:04 GMT # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (21 commits) iscsi: fix missing unlock memory: show region offset and ROM/RAM type in "info mtree -f" x86: Work around SMI migration breakages spice-char: fix segfault in char_spice_finalize vl: disable default cdrom when using explicitely scsi-hd memory: Introduce DEVICE_HOST_ENDIAN for ram device qmp-events: fix GUEST_PANICKED description formatting qapi: flatten GuestPanicInformation union vmxcap: update for September 2016 SDM vmxcap: port to Python 3 KVM: use KVM_CAP_IMMEDIATE_EXIT kvm: use atomic_read/atomic_set to access cpu->exit_request KVM: move SIG_IPI handling to kvm-all.c KVM: do not use sigtimedwait to catch SIGBUS KVM: remove kvm_arch_on_sigbus cpus: reorganize signal handling code KVM: x86: cleanup SIGBUS handlers cpus: remove ugly cast on sigbus_handler cpu-exec: remove unnecessary check of cpu->exit_request replay: check icount in cpu exec loop ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target')
-rw-r--r--target/arm/kvm.c10
-rw-r--r--target/i386/cpu.c17
-rw-r--r--target/i386/cpu.h3
-rw-r--r--target/i386/kvm.c88
-rw-r--r--target/mips/kvm.c12
-rw-r--r--target/ppc/kvm.c10
-rw-r--r--target/s390x/kvm.c10
7 files changed, 38 insertions, 112 deletions
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 395e986973..45554682f2 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -560,16 +560,6 @@ int kvm_arch_process_async_events(CPUState *cs)
return 0;
}
-int kvm_arch_on_sigbus_vcpu(CPUState *cs, int code, void *addr)
-{
- return 1;
-}
-
-int kvm_arch_on_sigbus(int code, void *addr)
-{
- return 1;
-}
-
/* The #ifdef protections are until 32bit headers are imported and can
* be removed once both 32 and 64 bit reach feature parity.
*/
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 89421c893b..fba92125ab 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3778,19 +3778,16 @@ static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs)
GuestPanicInformation *panic_info = NULL;
if (env->features[FEAT_HYPERV_EDX] & HV_X64_GUEST_CRASH_MSR_AVAILABLE) {
- GuestPanicInformationHyperV *panic_info_hv =
- g_malloc0(sizeof(GuestPanicInformationHyperV));
panic_info = g_malloc0(sizeof(GuestPanicInformation));
- panic_info->type = GUEST_PANIC_INFORMATION_KIND_HYPER_V;
- panic_info->u.hyper_v.data = panic_info_hv;
+ panic_info->type = GUEST_PANIC_INFORMATION_TYPE_HYPER_V;
assert(HV_X64_MSR_CRASH_PARAMS >= 5);
- panic_info_hv->arg1 = env->msr_hv_crash_params[0];
- panic_info_hv->arg2 = env->msr_hv_crash_params[1];
- panic_info_hv->arg3 = env->msr_hv_crash_params[2];
- panic_info_hv->arg4 = env->msr_hv_crash_params[3];
- panic_info_hv->arg5 = env->msr_hv_crash_params[4];
+ panic_info->u.hyper_v.arg1 = env->msr_hv_crash_params[0];
+ panic_info->u.hyper_v.arg2 = env->msr_hv_crash_params[1];
+ panic_info->u.hyper_v.arg3 = env->msr_hv_crash_params[2];
+ panic_info->u.hyper_v.arg4 = env->msr_hv_crash_params[3];
+ panic_info->u.hyper_v.arg5 = env->msr_hv_crash_params[4];
}
return panic_info;
@@ -3986,6 +3983,8 @@ static Property x86_cpu_properties[] = {
DEFINE_PROP_BOOL("cpuid-0xb", X86CPU, enable_cpuid_0xb, true),
DEFINE_PROP_BOOL("lmce", X86CPU, enable_lmce, false),
DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true),
+ DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration,
+ false),
DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
DEFINE_PROP_END_OF_LIST()
};
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 12a39d590f..ac2ad6d443 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1255,6 +1255,9 @@ struct X86CPU {
/* if true override the phys_bits value with a value read from the host */
bool host_phys_bits;
+ /* Stop SMI delivery for migration compatibility with old machines */
+ bool kvm_no_smi_migration;
+
/* Number of physical address bits supported */
uint32_t phys_bits;
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 27fd0505df..887a81268f 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -64,13 +64,6 @@
* 255 kvm_msr_entry structs */
#define MSR_BUF_SIZE 4096
-#ifndef BUS_MCEERR_AR
-#define BUS_MCEERR_AR 4
-#endif
-#ifndef BUS_MCEERR_AO
-#define BUS_MCEERR_AO 5
-#endif
-
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_INFO(SET_TSS_ADDR),
KVM_CAP_INFO(EXT_CPUID),
@@ -462,70 +455,38 @@ static void hardware_memory_error(void)
exit(1);
}
-int kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr)
+void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr)
{
X86CPU *cpu = X86_CPU(c);
CPUX86State *env = &cpu->env;
ram_addr_t ram_addr;
hwaddr paddr;
- if ((env->mcg_cap & MCG_SER_P) && addr
- && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
+ /* If we get an action required MCE, it has been injected by KVM
+ * while the VM was running. An action optional MCE instead should
+ * be coming from the main thread, which qemu_init_sigbus identifies
+ * as the "early kill" thread.
+ */
+ assert(code == BUS_MCEERR_AR || code == BUS_MCEERR_AO);
+
+ if ((env->mcg_cap & MCG_SER_P) && addr) {
ram_addr = qemu_ram_addr_from_host(addr);
- if (ram_addr == RAM_ADDR_INVALID ||
- !kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)) {
- fprintf(stderr, "Hardware memory error for memory used by "
- "QEMU itself instead of guest system!\n");
- /* Hope we are lucky for AO MCE */
- if (code == BUS_MCEERR_AO) {
- return 0;
- } else {
- hardware_memory_error();
- }
- }
- kvm_hwpoison_page_add(ram_addr);
- kvm_mce_inject(cpu, paddr, code);
- } else {
- if (code == BUS_MCEERR_AO) {
- return 0;
- } else if (code == BUS_MCEERR_AR) {
- hardware_memory_error();
- } else {
- return 1;
+ if (ram_addr != RAM_ADDR_INVALID &&
+ kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)) {
+ kvm_hwpoison_page_add(ram_addr);
+ kvm_mce_inject(cpu, paddr, code);
+ return;
}
- }
- return 0;
-}
-int kvm_arch_on_sigbus(int code, void *addr)
-{
- X86CPU *cpu = X86_CPU(first_cpu);
-
- if ((cpu->env.mcg_cap & MCG_SER_P) && addr && code == BUS_MCEERR_AO) {
- ram_addr_t ram_addr;
- hwaddr paddr;
+ fprintf(stderr, "Hardware memory error for memory used by "
+ "QEMU itself instead of guest system!\n");
+ }
- /* Hope we are lucky for AO MCE */
- ram_addr = qemu_ram_addr_from_host(addr);
- if (ram_addr == RAM_ADDR_INVALID ||
- !kvm_physical_memory_addr_from_host(first_cpu->kvm_state,
- addr, &paddr)) {
- fprintf(stderr, "Hardware memory error for memory used by "
- "QEMU itself instead of guest system!: %p\n", addr);
- return 0;
- }
- kvm_hwpoison_page_add(ram_addr);
- kvm_mce_inject(X86_CPU(first_cpu), paddr, code);
- } else {
- if (code == BUS_MCEERR_AO) {
- return 0;
- } else if (code == BUS_MCEERR_AR) {
- hardware_memory_error();
- } else {
- return 1;
- }
+ if (code == BUS_MCEERR_AR) {
+ hardware_memory_error();
}
- return 0;
+
+ /* Hope we are lucky for AO MCE */
}
static int kvm_inject_mce_oldstyle(X86CPU *cpu)
@@ -2531,7 +2492,12 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level)
events.smi.pending = 0;
events.smi.latched_init = 0;
}
- events.flags |= KVM_VCPUEVENT_VALID_SMM;
+ /* Stop SMI delivery on old machine types to avoid a reboot
+ * on an inward migration of an old VM.
+ */
+ if (!cpu->kvm_no_smi_migration) {
+ events.flags |= KVM_VCPUEVENT_VALID_SMM;
+ }
}
if (level >= KVM_PUT_RESET_STATE) {
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index 998c3412c3..0982e874bb 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -180,18 +180,6 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cs)
return true;
}
-int kvm_arch_on_sigbus_vcpu(CPUState *cs, int code, void *addr)
-{
- DPRINTF("%s\n", __func__);
- return 1;
-}
-
-int kvm_arch_on_sigbus(int code, void *addr)
-{
- DPRINTF("%s\n", __func__);
- return 1;
-}
-
void kvm_arch_init_irq_routing(KVMState *s)
{
}
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index acc40ece65..03f5097eab 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2582,16 +2582,6 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cpu)
return true;
}
-int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr)
-{
- return 1;
-}
-
-int kvm_arch_on_sigbus(int code, void *addr)
-{
- return 1;
-}
-
void kvm_arch_init_irq_routing(KVMState *s)
{
}
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index 5ec050cf89..ac47154b83 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -2140,16 +2140,6 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cpu)
return true;
}
-int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr)
-{
- return 1;
-}
-
-int kvm_arch_on_sigbus(int code, void *addr)
-{
- return 1;
-}
-
void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word)