From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1KPB-00082G-9S for qemu-devel@nongnu.org; Mon, 22 Jul 2013 14:00:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1KP9-0005a0-Sk for qemu-devel@nongnu.org; Mon, 22 Jul 2013 14:00:17 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:47725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1KFj-0001sv-V6 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 13:50:32 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Jul 2013 13:50:31 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 053E238C8059 for ; Mon, 22 Jul 2013 13:50:27 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6MHoRSk191900 for ; Mon, 22 Jul 2013 13:50:27 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6MHoRUX002751 for ; Mon, 22 Jul 2013 14:50:27 -0300 From: Anthony Liguori In-Reply-To: <51ED0025.7090805@redhat.com> References: <1374475799-18523-1-git-send-email-owasserm@redhat.com> <51ED0025.7090805@redhat.com> Date: Mon, 22 Jul 2013 12:50:23 -0500 Message-ID: <87li4yjxgg.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 1/2] Fix real mode guest migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Orit Wasserman Cc: ehabkost@redhat.com, mtosatti@redhat.com, qemu-devel@nongnu.org, gleb@redhat.com, afaerber@suse.de Paolo Bonzini writes: > Il 22/07/2013 08:49, Orit Wasserman ha scritto: >> Older KVM versions save CS dpl value to an invalid value for real mode guests >> (0x3). This patch detect this situation when loading CPU state and set all the >> segments dpl to zero. >> This will allow migration from older KVM on host without unrestricted guest >> to hosts with restricted guest support. >> For example migration from a Penryn host (with kernel 2.6.32) to >> a Westmere host. >> >> 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 3659db9..7e95829 100644 >> --- a/target-i386/machine.c >> +++ b/target-i386/machine.c >> @@ -260,6 +260,24 @@ static int cpu_post_load(void *opaque, int version_id) >> CPUX86State *env = &cpu->env; >> int i; >> >> + /* >> + Real mode guest segments register DPL should be zero. >> + Older KVM version were setting it worngly. >> + Fixing it will allow live migration from such host that don't have >> + restricted guest support to an host with unrestricted guest support >> + (otherwise the migration will fail with invalid guest state >> + error). >> + */ > > Coding standard asks for *s on every line. > > As discussed offlist, I would prefer to have this in the kernel since > that's where the bug is. Gleb disagrees. > > We need to find a third person who mediates... Anthony, Eduardo, what > do you think? I can rationalize the post_load part. We may get garbage state via live migration, we fix it up. The pre_save part troubles me though. Is the kernel actively returning invalid space to userspace? If so, this needs to be fixed. That's clearly a bug. Or is this expected to work around an old kernel? If so, is the kernel advertising that it now handles this state correctly via a capability? If not, it probably should. Regards, Anthony Liguori > > Paolo > >> + 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); >> + } >> + >> /* XXX: restore FPU round state */ >> env->fpstt = (env->fpus_vmstate >> 11) & 7; >> env->fpus = env->fpus_vmstate & ~0x3800; >>