From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V19vi-0005R9-DR for qemu-devel@nongnu.org; Mon, 22 Jul 2013 02:49:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V19vh-0000LH-DM for qemu-devel@nongnu.org; Mon, 22 Jul 2013 02:49:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V19vh-0000LD-4X for qemu-devel@nongnu.org; Mon, 22 Jul 2013 02:49:09 -0400 From: Orit Wasserman Date: Mon, 22 Jul 2013 09:49:59 +0300 Message-Id: <1374475799-18523-2-git-send-email-owasserm@redhat.com> In-Reply-To: <1374475799-18523-1-git-send-email-owasserm@redhat.com> References: <1374475799-18523-1-git-send-email-owasserm@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] Fix real mode guest segments dpl value in savevm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, ehabkost@redhat.com, gleb@redhat.com, mtosatti@redhat.com, Orit Wasserman , pbonzini@redhat.com, afaerber@suse.de Older KVM version put invalid value in the segments registers dpl field for real mode guests (0x3). This breaks migration from those hosts to hosts with unrestricted guest support. We detect it by checking CS dpl value for real mode guest and fix the dpl values of all the segment registers. Signed-off-by: Orit Wasserman --- target-i386/machine.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/target-i386/machine.c b/target-i386/machine.c index 7e95829..4e39ca9 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -252,6 +252,24 @@ static void cpu_pre_save(void *opaque) } env->fpregs_format_vmstate = 0; + + /* + Real mode guest segments register DPL should be zero. + Older KVM version were setting it worngly. + Fixing it will allow live migration to host with unrestricted guest + support (otherwise the migration will fail with invalid guest state + error). + */ + if (!(env->cr[0] & CR0_PE_MASK) && + (env->segs[R_CS].flags >> DESC_DPL_SHIFT & 3) != 0) { + env->segs[R_CS].flags &= ~(env->segs[R_CS].flags & DESC_DPL_MASK); + env->segs[R_DS].flags &= ~(env->segs[R_DS].flags & DESC_DPL_MASK); + env->segs[R_ES].flags &= ~(env->segs[R_ES].flags & DESC_DPL_MASK); + env->segs[R_FS].flags &= ~(env->segs[R_FS].flags & DESC_DPL_MASK); + env->segs[R_GS].flags &= ~(env->segs[R_GS].flags & DESC_DPL_MASK); + env->segs[R_SS].flags &= ~(env->segs[R_SS].flags & DESC_DPL_MASK); + } + } static int cpu_post_load(void *opaque, int version_id) -- 1.8.1.4