thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
9ae3a8
From 38c385caa32752ef176ffd1448e45e0dc94d5043 Mon Sep 17 00:00:00 2001
9ae3a8
From: Orit Wasserman <owasserm@redhat.com>
9ae3a8
Date: Wed, 9 Oct 2013 10:09:11 +0200
9ae3a8
Subject: [PATCH 16/25] Fix real mode guest segments dpl value in savevm
9ae3a8
9ae3a8
RH-Author: Orit Wasserman <owasserm@redhat.com>
9ae3a8
Message-id: <1381313355-15641-7-git-send-email-owasserm@redhat.com>
9ae3a8
Patchwork-id: 54802
9ae3a8
O-Subject: [RHEL7.0 qemu-kvm v2 06/10] Fix real mode guest segments dpl value in savevm
9ae3a8
Bugzilla: 921465
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Juan Quintela <quintela@redhat.com>
9ae3a8
9ae3a8
Older KVM version put invalid value in the segments registers dpl field for
9ae3a8
real mode guests (0x3).
9ae3a8
This breaks migration from those hosts to hosts with unrestricted guest support.
9ae3a8
We detect it by checking CS dpl value for real mode guest and fix the dpl values
9ae3a8
of all the segment registers.
9ae3a8
9ae3a8
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
Reviewed-by: Juan Quintela <quintela@redhat.com>
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
(cherry picked from commit 3e47c249b93d5cc1e0f9404dbe243682598ba8fb)
9ae3a8
---
9ae3a8
 target-i386/machine.c | 18 ++++++++++++++++++
9ae3a8
 1 file changed, 18 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 target-i386/machine.c |   18 ++++++++++++++++++
9ae3a8
 1 files changed, 18 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/target-i386/machine.c b/target-i386/machine.c
9ae3a8
index 079a132..8faea62 100644
9ae3a8
--- a/target-i386/machine.c
9ae3a8
+++ b/target-i386/machine.c
9ae3a8
@@ -252,6 +252,24 @@ static void cpu_pre_save(void *opaque)
9ae3a8
     }
9ae3a8
 
9ae3a8
     env->fpregs_format_vmstate = 0;
9ae3a8
+
9ae3a8
+    /*
9ae3a8
+     * Real mode guest segments register DPL should be zero.
9ae3a8
+     * Older KVM version were setting it wrongly.
9ae3a8
+     * Fixing it will allow live migration to host with unrestricted guest
9ae3a8
+     * support (otherwise the migration will fail with invalid guest state
9ae3a8
+     * error).
9ae3a8
+     */
9ae3a8
+    if (!(env->cr[0] & CR0_PE_MASK) &&
9ae3a8
+        (env->segs[R_CS].flags >> DESC_DPL_SHIFT & 3) != 0) {
9ae3a8
+        env->segs[R_CS].flags &= ~(env->segs[R_CS].flags & DESC_DPL_MASK);
9ae3a8
+        env->segs[R_DS].flags &= ~(env->segs[R_DS].flags & DESC_DPL_MASK);
9ae3a8
+        env->segs[R_ES].flags &= ~(env->segs[R_ES].flags & DESC_DPL_MASK);
9ae3a8
+        env->segs[R_FS].flags &= ~(env->segs[R_FS].flags & DESC_DPL_MASK);
9ae3a8
+        env->segs[R_GS].flags &= ~(env->segs[R_GS].flags & DESC_DPL_MASK);
9ae3a8
+        env->segs[R_SS].flags &= ~(env->segs[R_SS].flags & DESC_DPL_MASK);
9ae3a8
+    }
9ae3a8
+
9ae3a8
 }
9ae3a8
 
9ae3a8
 static int cpu_post_load(void *opaque, int version_id)
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8