|
|
9ae3a8 |
From f53b97e4cda28b911c11400a985bcff587b2df34 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 21 Aug 2019 14:30:06 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 2/3] target-i386: block migration and savevm if invariant tsc
|
|
|
9ae3a8 |
is exposed
|
|
|
9ae3a8 |
MIME-Version: 1.0
|
|
|
9ae3a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9ae3a8 |
Content-Transfer-Encoding: 8bit
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20190821143006.23516-3-ehabkost@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 90102
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.8 qemu-kvm PATCH 2/2] target-i386: block migration and savevm if invariant tsc is exposed
|
|
|
9ae3a8 |
Bugzilla: 1626871
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Bandan Das <bsd@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Marcelo Tosatti <mtosatti@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Invariant TSC documentation mentions that "invariant TSC will run at a
|
|
|
9ae3a8 |
constant rate in all ACPI P-, C-. and T-states".
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This is not the case if migration to a host with different TSC frequency
|
|
|
9ae3a8 |
is allowed, or if savevm is performed. So block migration/savevm.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
[AF+mtosatti: Updated error message]
|
|
|
9ae3a8 |
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
|
9ae3a8 |
(cherry picked from commit 68bfd0ad4a1dcc4c328d5db85dc746b49c1ec07e)
|
|
|
9ae3a8 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
target-i386/cpu-qom.h | 2 +-
|
|
|
9ae3a8 |
target-i386/kvm.c | 15 +++++++++++++++
|
|
|
9ae3a8 |
target-i386/machine.c | 2 +-
|
|
|
9ae3a8 |
3 files changed, 17 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
|
|
|
9ae3a8 |
index 0b01e8f..89dd29a 100644
|
|
|
9ae3a8 |
--- a/target-i386/cpu-qom.h
|
|
|
9ae3a8 |
+++ b/target-i386/cpu-qom.h
|
|
|
9ae3a8 |
@@ -94,7 +94,7 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env)
|
|
|
9ae3a8 |
#define ENV_OFFSET offsetof(X86CPU, env)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#ifndef CONFIG_USER_ONLY
|
|
|
9ae3a8 |
-extern const struct VMStateDescription vmstate_x86_cpu;
|
|
|
9ae3a8 |
+extern struct VMStateDescription vmstate_x86_cpu;
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/**
|
|
|
9ae3a8 |
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
|
|
|
9ae3a8 |
index d5f6deb..b6c76f1 100644
|
|
|
9ae3a8 |
--- a/target-i386/kvm.c
|
|
|
9ae3a8 |
+++ b/target-i386/kvm.c
|
|
|
9ae3a8 |
@@ -33,6 +33,8 @@
|
|
|
9ae3a8 |
#include "exec/ioport.h"
|
|
|
9ae3a8 |
#include <asm/hyperv.h>
|
|
|
9ae3a8 |
#include "hw/pci/pci.h"
|
|
|
9ae3a8 |
+#include "migration/migration.h"
|
|
|
9ae3a8 |
+#include "qapi/qmp/qerror.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
//#define DEBUG_KVM
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -449,6 +451,8 @@ static bool hyperv_enabled(X86CPU *cpu)
|
|
|
9ae3a8 |
cpu->hyperv_relaxed_timing);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static Error *invtsc_mig_blocker;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
#define KVM_MAX_CPUID_ENTRIES 100
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int kvm_arch_init_vcpu(CPUState *cs)
|
|
|
9ae3a8 |
@@ -698,6 +702,17 @@ int kvm_arch_init_vcpu(CPUState *cs)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu_add_vm_change_state_handler(cpu_update_state, env);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ c = cpuid_find_entry(&cpuid_data.cpuid, 0x80000007, 0);
|
|
|
9ae3a8 |
+ if (c && (c->edx & 1<<8) && invtsc_mig_blocker == NULL) {
|
|
|
9ae3a8 |
+ /* for migration */
|
|
|
9ae3a8 |
+ error_setg(&invtsc_mig_blocker,
|
|
|
9ae3a8 |
+ "State blocked by non-migratable CPU device"
|
|
|
9ae3a8 |
+ " (invtsc flag)");
|
|
|
9ae3a8 |
+ migrate_add_blocker(invtsc_mig_blocker);
|
|
|
9ae3a8 |
+ /* for savevm */
|
|
|
9ae3a8 |
+ vmstate_x86_cpu.unmigratable = 1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
cpuid_data.cpuid.padding = 0;
|
|
|
9ae3a8 |
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
|
|
|
9ae3a8 |
if (r) {
|
|
|
9ae3a8 |
diff --git a/target-i386/machine.c b/target-i386/machine.c
|
|
|
9ae3a8 |
index 507ab1a..cd2cf6f 100644
|
|
|
9ae3a8 |
--- a/target-i386/machine.c
|
|
|
9ae3a8 |
+++ b/target-i386/machine.c
|
|
|
9ae3a8 |
@@ -778,7 +778,7 @@ static const VMStateDescription vmstate_msr_virt_ssbd = {
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-const VMStateDescription vmstate_x86_cpu = {
|
|
|
9ae3a8 |
+VMStateDescription vmstate_x86_cpu = {
|
|
|
9ae3a8 |
.name = "cpu",
|
|
|
9ae3a8 |
.version_id = 12,
|
|
|
9ae3a8 |
.minimum_version_id = 3,
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|