qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] Fix real mode guest migration


From: Gleb Natapov
Subject: Re: [Qemu-devel] [PATCH 1/2] Fix real mode guest migration
Date: Mon, 22 Jul 2013 13:50:55 +0300

On Mon, Jul 22, 2013 at 12:33:31PM +0200, Andreas Färber wrote:
> Am 22.07.2013 11:49, schrieb Paolo Bonzini:
> > 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 <address@hidden>
> >> ---
> >>  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?
> 
> Having the code here does not look wrong to me, to enforce a consistent
> state inside QEMU.
> 
> However I wonder what happens without this patch on Westmere? Might it
Guest entry fails (but it is very hard to hit in practise since
migration has to happen while guest is in real mode).

> make sense to sanitize or at least "assert" (whatever the kernel
> equivalent is ;)) in the ioctl setting X86CPU state to the vCPU that the
> incoming values will be valid for the host CPU? And optionally in QEMU's
In a perfect world kvm would have return an error if wrong state is
loaded, but in reality the number of checks that have to be done is huge
and it is too late to add it now since this breaks ABI: old userspace
will start to get errors (and make it right from the first time is
practically impossible and each bug fix would have broke ABI too :)).

--
                        Gleb.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]