2018-08-22 16:58:18 +02:00
|
|
|
From 579a6f80e0ea312e9c113bd79be8bef36eabb090 Mon Sep 17 00:00:00 2001
|
2018-02-22 23:01:24 +01:00
|
|
|
From: Bruce Rogers <brogers@suse.com>
|
|
|
|
Date: Wed, 21 Feb 2018 14:00:52 -0700
|
|
|
|
Subject: [PATCH] migration: warn about inconsistent spec_ctrl state
|
|
|
|
|
|
|
|
As an attempt to help the user do the right thing, warn if we
|
|
|
|
detect spec_ctrl data in the migration stream, but where the
|
|
|
|
cpu defined doesn't have the feature. This would indicate the
|
|
|
|
migration is from the quick and dirty qemu produced in January
|
|
|
|
2018 to handle Spectre v2. That qemu version exposed the IBRS
|
|
|
|
cpu feature to all vcpu types, which helped in the short term
|
|
|
|
but wasn't a well designed approach.
|
|
|
|
Warn the user that the now migrated guest needs to be restarted
|
|
|
|
as soon as possible, using the spec_ctrl cpu feature flag or a
|
|
|
|
*-IBRS vcpu model specified as appropriate.
|
|
|
|
|
|
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
|
---
|
|
|
|
cpus.c | 12 ++++++++++++
|
|
|
|
include/qemu/thread.h | 1 +
|
|
|
|
migration/migration.c | 8 ++++++++
|
|
|
|
3 files changed, 21 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/cpus.c b/cpus.c
|
2018-08-22 16:58:18 +02:00
|
|
|
index b5844b7103..2717f2e105 100644
|
2018-02-22 23:01:24 +01:00
|
|
|
--- a/cpus.c
|
|
|
|
+++ b/cpus.c
|
2018-08-22 16:58:18 +02:00
|
|
|
@@ -2367,6 +2367,18 @@ exit:
|
2018-02-22 23:01:24 +01:00
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
+bool spec_ctrl_is_inconsistent(void)
|
|
|
|
+{
|
|
|
|
+#if defined(TARGET_I386)
|
|
|
|
+ X86CPU *x86_cpu = X86_CPU(current_cpu);
|
2018-02-23 02:52:34 +01:00
|
|
|
+ CPUX86State *env = x86_cpu != NULL ? &x86_cpu->env : NULL;
|
|
|
|
+ if (env && !(env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_SPEC_CTRL) &&
|
2018-02-22 23:01:24 +01:00
|
|
|
+ env->spec_ctrl)
|
|
|
|
+ return true;
|
|
|
|
+#endif
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void qmp_inject_nmi(Error **errp)
|
|
|
|
{
|
|
|
|
nmi_monitor_handle(monitor_get_cpu_index(), errp);
|
|
|
|
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
|
2018-05-01 17:20:58 +02:00
|
|
|
index ef7bd16123..c4ecb386fe 100644
|
2018-02-22 23:01:24 +01:00
|
|
|
--- a/include/qemu/thread.h
|
|
|
|
+++ b/include/qemu/thread.h
|
2018-05-01 17:20:58 +02:00
|
|
|
@@ -240,4 +240,5 @@ void qemu_lockcnt_inc_and_unlock(QemuLockCnt *lockcnt);
|
2018-02-22 23:01:24 +01:00
|
|
|
*/
|
|
|
|
unsigned qemu_lockcnt_count(QemuLockCnt *lockcnt);
|
|
|
|
|
|
|
|
+bool spec_ctrl_is_inconsistent(void);
|
|
|
|
#endif
|
|
|
|
diff --git a/migration/migration.c b/migration/migration.c
|
2018-08-22 16:58:18 +02:00
|
|
|
index b7d9854bda..31b4d8bd28 100644
|
2018-02-22 23:01:24 +01:00
|
|
|
--- a/migration/migration.c
|
|
|
|
+++ b/migration/migration.c
|
2018-08-22 16:58:18 +02:00
|
|
|
@@ -2575,6 +2575,14 @@ static void migration_completion(MigrationState *s)
|
2018-02-22 23:01:24 +01:00
|
|
|
migrate_set_state(&s->state, current_active_state,
|
|
|
|
MIGRATION_STATUS_COMPLETED);
|
|
|
|
}
|
|
|
|
+ if (spec_ctrl_is_inconsistent()) {
|
|
|
|
+ fprintf(stderr, "WARNING! Migration from qemu with rudimentary "
|
|
|
|
+ "Spectre v2 support to newer qemu\ndetected! To "
|
|
|
|
+ "maintain proper protection, restart the guest as "
|
|
|
|
+ "soon as possible\nusing the spec_ctrl cpu feature "
|
|
|
|
+ "flag or a *-IBRS vcpu model specified\nas appropriate."
|
|
|
|
+ "\n");
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return;
|
|
|
|
|