cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From c576ee9550d38273808c2055803f3a254655753e Mon Sep 17 00:00:00 2001
218e99
From: Orit Wasserman <owasserm@redhat.com>
218e99
Date: Wed, 9 Oct 2013 10:09:10 +0200
218e99
Subject: [PATCH 15/25] Fix real mode guest migration
218e99
218e99
RH-Author: Orit Wasserman <owasserm@redhat.com>
218e99
Message-id: <1381313355-15641-6-git-send-email-owasserm@redhat.com>
218e99
Patchwork-id: 54801
218e99
O-Subject: [RHEL7.0 qemu-kvm v2 05/10] Fix real mode guest migration
218e99
Bugzilla: 921465
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
RH-Acked-by: Juan Quintela <quintela@redhat.com>
218e99
218e99
Older KVM versions save CS dpl value to an invalid value for real mode guests
218e99
(0x3). This patch detect this situation when loading CPU state and set all the
218e99
segments dpl to zero.
218e99
This will allow migration from older KVM on host without unrestricted guest
218e99
to hosts with restricted guest support.
218e99
For example migration from a Penryn host (with kernel 2.6.32) to
218e99
a Westmere host (for real mode guest) will fail with "kvm: unhandled exit 80000021".
218e99
218e99
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
218e99
Reviewed-by: Juan Quintela <quintela@redhat.com>
218e99
Signed-off-by: Juan Quintela <quintela@redhat.com>
218e99
(cherry picked from commit 444ba6797ef6ef331fe9fd34309b1ec59caaede3)
218e99
---
218e99
 target-i386/machine.c | 18 ++++++++++++++++++
218e99
 1 file changed, 18 insertions(+)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 target-i386/machine.c |   18 ++++++++++++++++++
218e99
 1 files changed, 18 insertions(+), 0 deletions(-)
218e99
218e99
diff --git a/target-i386/machine.c b/target-i386/machine.c
218e99
index ecf1617..079a132 100644
218e99
--- a/target-i386/machine.c
218e99
+++ b/target-i386/machine.c
218e99
@@ -260,6 +260,24 @@ static int cpu_post_load(void *opaque, int version_id)
218e99
     CPUX86State *env = &cpu->env;
218e99
     int i;
218e99
 
218e99
+    /*
218e99
+     * Real mode guest segments register DPL should be zero.
218e99
+     * Older KVM version were setting it wrongly.
218e99
+     * Fixing it will allow live migration from such host that don't have
218e99
+     * restricted guest support to a host with unrestricted guest support
218e99
+     * (otherwise the migration will fail with invalid guest state
218e99
+     * error).
218e99
+     */
218e99
+    if (!(env->cr[0] & CR0_PE_MASK) &&
218e99
+        (env->segs[R_CS].flags >> DESC_DPL_SHIFT & 3) != 0) {
218e99
+        env->segs[R_CS].flags &= ~(env->segs[R_CS].flags & DESC_DPL_MASK);
218e99
+        env->segs[R_DS].flags &= ~(env->segs[R_DS].flags & DESC_DPL_MASK);
218e99
+        env->segs[R_ES].flags &= ~(env->segs[R_ES].flags & DESC_DPL_MASK);
218e99
+        env->segs[R_FS].flags &= ~(env->segs[R_FS].flags & DESC_DPL_MASK);
218e99
+        env->segs[R_GS].flags &= ~(env->segs[R_GS].flags & DESC_DPL_MASK);
218e99
+        env->segs[R_SS].flags &= ~(env->segs[R_SS].flags & DESC_DPL_MASK);
218e99
+    }
218e99
+
218e99
     /* XXX: restore FPU round state */
218e99
     env->fpstt = (env->fpus_vmstate >> 11) & 7;
218e99
     env->fpus = env->fpus_vmstate & ~0x3800;
218e99
-- 
218e99
1.7.1
218e99