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