cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-Fix-real-mode-guest-segments-dpl-value-in-savevm.patch

218e99
From 38c385caa32752ef176ffd1448e45e0dc94d5043 Mon Sep 17 00:00:00 2001
218e99
From: Orit Wasserman <owasserm@redhat.com>
218e99
Date: Wed, 9 Oct 2013 10:09:11 +0200
218e99
Subject: [PATCH 16/25] Fix real mode guest segments dpl value in savevm
218e99
218e99
RH-Author: Orit Wasserman <owasserm@redhat.com>
218e99
Message-id: <1381313355-15641-7-git-send-email-owasserm@redhat.com>
218e99
Patchwork-id: 54802
218e99
O-Subject: [RHEL7.0 qemu-kvm v2 06/10] Fix real mode guest segments dpl value in savevm
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 version put invalid value in the segments registers dpl field for
218e99
real mode guests (0x3).
218e99
This breaks migration from those hosts to hosts with unrestricted guest support.
218e99
We detect it by checking CS dpl value for real mode guest and fix the dpl values
218e99
of all the segment registers.
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 3e47c249b93d5cc1e0f9404dbe243682598ba8fb)
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 079a132..8faea62 100644
218e99
--- a/target-i386/machine.c
218e99
+++ b/target-i386/machine.c
218e99
@@ -252,6 +252,24 @@ static void cpu_pre_save(void *opaque)
218e99
     }
218e99
 
218e99
     env->fpregs_format_vmstate = 0;
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 to host with unrestricted guest
218e99
+     * support (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
 }
218e99
 
218e99
 static int cpu_post_load(void *opaque, int version_id)
218e99
-- 
218e99
1.7.1
218e99