Skip to content

Commit

Permalink
Fix real mode guest segments dpl value in savevm
Browse files Browse the repository at this point in the history
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 <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
oritwas authored and Juan Quintela committed Jul 23, 2013
1 parent 444ba67 commit 3e47c24
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions target-i386/machine.c
Expand Up @@ -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 wrongly.
* 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)
Expand Down

0 comments on commit 3e47c24

Please sign in to comment.