• Michael Chapman's avatar
    target-i386: kvm: clear unusable segments' flags in migration · 4cae9c97
    Michael Chapman authored
    This commit fixes migration of a QEMU/KVM guest from kernel >= v3.9 to
    kernel <= v3.7 (e.g. from RHEL 7 to RHEL 6). Without this commit a guest
    migrated across these kernel versions fails to resume on the target host
    as its segment descriptors are invalid.
    
    Two separate kernel commits combined together to result in this bug:
    
      commit f0495f9b9992f80f82b14306946444b287193390
      Author: Avi Kivity <avi@redhat.com>
      Date:   Thu Jun 7 17:06:10 2012 +0300
    
          KVM: VMX: Relax check on unusable segment
    
          Some userspace (e.g. QEMU 1.1) munge the d and g bits of segment
          descriptors, causing us not to recognize them as unusable segments
          with emulate_invalid_guest_state=1.  Relax the check by testing for
          segment not present (a non-present segment cannot be usable).
    Signed-off-by: 's avatarAvi Kivity <avi@redhat.com>
    
      commit 25391454e73e3156202264eb3c473825afe4bc94
      Author: Gleb Natapov <gleb@redhat.com>
      Date:   Mon Jan 21 15:36:46 2013 +0200
    
          KVM: VMX: don't clobber segment AR of unusable segments.
    
          Usability is returned in unusable field, so not need to clobber entire
          AR. Callers have to know how to deal with unusable segments already
          since if emulate_invalid_guest_state=true AR is not zeroed.
    Signed-off-by: 's avatarGleb Natapov <gleb@redhat.com>
    Signed-off-by: 's avatarMarcelo Tosatti <mtosatti@redhat.com>
    
    The first commit changed the KVM_SET_SREGS ioctl so that it did no treat
    segment flags == 0 as an unusable segment, instead only looking at the
    "present" flag.
    
    The second commit changed KVM_GET_SREGS so that it did not clear the
    flags of an unusable segment.
    
    Since QEMU does not itself maintain the "unusable" flag across a
    migration, the end result is that unusable segments read from a kernel
    with these commits and loaded into a kernel without these commits are
    not properly recognised as being unusable.
    
    This commit updates both get_seg and set_seg so that the problem is
    avoided even when migrating to or migrating from a QEMU without this
    commit. In get_seg, we clear the segment flags if the segment is marked
    unusable. In set_seg, we mark the segment unusable if the segment's
    "present" flag is not set.
    Signed-off-by: 's avatarMichael Chapman <mike@very.puzzling.org>
    Message-Id: <1449464047-17467-1-git-send-email-mike@very.puzzling.org>
    Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
    4cae9c97
Name
Last commit
Last update
audio Loading commit data...
backends Loading commit data...
block Loading commit data...
bsd-user Loading commit data...
contrib Loading commit data...
crypto Loading commit data...
default-configs Loading commit data...
disas Loading commit data...
docs Loading commit data...
dtc @ 65cc4d27 Loading commit data...
fpu Loading commit data...
fsdev Loading commit data...
gdb-xml Loading commit data...
hw Loading commit data...
include Loading commit data...
libdecnumber Loading commit data...
linux-headers Loading commit data...
linux-user Loading commit data...
migration Loading commit data...
net Loading commit data...
pc-bios Loading commit data...
pixman @ 87eea99e Loading commit data...
po Loading commit data...
qapi Loading commit data...
qga Loading commit data...
qobject Loading commit data...
qom Loading commit data...
replay Loading commit data...
roms Loading commit data...
scripts Loading commit data...
slirp Loading commit data...
stubs Loading commit data...
target-alpha Loading commit data...
target-arm Loading commit data...
target-cris Loading commit data...
target-i386 Loading commit data...
target-lm32 Loading commit data...
target-m68k Loading commit data...
target-microblaze Loading commit data...
target-mips Loading commit data...
target-moxie Loading commit data...
target-openrisc Loading commit data...
target-ppc Loading commit data...
target-s390x Loading commit data...
target-sh4 Loading commit data...
target-sparc Loading commit data...
target-tilegx Loading commit data...
target-tricore Loading commit data...
target-unicore32 Loading commit data...
target-xtensa Loading commit data...
tcg Loading commit data...
tests Loading commit data...
trace Loading commit data...
ui Loading commit data...
util Loading commit data...
.dir-locals.el Loading commit data...
.exrc Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
CODING_STYLE Loading commit data...
COPYING Loading commit data...
COPYING.LIB Loading commit data...
Changelog Loading commit data...
HACKING Loading commit data...
LICENSE Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
Makefile.objs Loading commit data...
Makefile.target Loading commit data...
README Loading commit data...
VERSION Loading commit data...
accel.c Loading commit data...
aio-posix.c Loading commit data...
aio-win32.c Loading commit data...
arch_init.c Loading commit data...
async.c Loading commit data...
balloon.c Loading commit data...
block.c Loading commit data...
blockdev-nbd.c Loading commit data...
blockdev.c Loading commit data...
blockjob.c Loading commit data...
bootdevice.c Loading commit data...
bt-host.c Loading commit data...
bt-vhci.c Loading commit data...
configure Loading commit data...
cpu-exec-common.c Loading commit data...
cpu-exec.c Loading commit data...
cpus.c Loading commit data...
cputlb.c Loading commit data...
device-hotplug.c Loading commit data...
device_tree.c Loading commit data...
disas.c Loading commit data...
dma-helpers.c Loading commit data...
dump.c Loading commit data...
exec.c Loading commit data...
gdbstub.c Loading commit data...
hmp-commands-info.hx Loading commit data...
hmp-commands.hx Loading commit data...
hmp.c Loading commit data...
hmp.h Loading commit data...
iohandler.c Loading commit data...
ioport.c Loading commit data...
iothread.c Loading commit data...
kvm-all.c Loading commit data...
kvm-stub.c Loading commit data...
main-loop.c Loading commit data...
memory.c Loading commit data...
memory_mapping.c Loading commit data...
module-common.c Loading commit data...
monitor.c Loading commit data...
nbd.c Loading commit data...
numa.c Loading commit data...
os-posix.c Loading commit data...
os-win32.c Loading commit data...
page_cache.c Loading commit data...
qapi-schema.json Loading commit data...
qdev-monitor.c Loading commit data...
qdict-test-data.txt Loading commit data...
qemu-bridge-helper.c Loading commit data...
qemu-char.c Loading commit data...
qemu-doc.texi Loading commit data...
qemu-ga.texi Loading commit data...
qemu-img-cmds.hx Loading commit data...
qemu-img.c Loading commit data...
qemu-img.texi Loading commit data...
qemu-io-cmds.c Loading commit data...
qemu-io.c Loading commit data...
qemu-log.c Loading commit data...
qemu-nbd.c Loading commit data...
qemu-nbd.texi Loading commit data...
qemu-options-wrapper.h Loading commit data...
qemu-options.h Loading commit data...
qemu-options.hx Loading commit data...
qemu-seccomp.c Loading commit data...
qemu-tech.texi Loading commit data...
qemu-timer.c Loading commit data...
qemu.nsi Loading commit data...
qemu.sasl Loading commit data...
qjson.c Loading commit data...
qmp-commands.hx Loading commit data...
qmp.c Loading commit data...
qtest.c Loading commit data...
rules.mak Loading commit data...
softmmu_template.h Loading commit data...
spice-qemu-char.c Loading commit data...
tcg-runtime.c Loading commit data...
tci.c Loading commit data...
thread-pool.c Loading commit data...
thunk.c Loading commit data...
tpm.c Loading commit data...
trace-events Loading commit data...
translate-all.c Loading commit data...
translate-all.h Loading commit data...
translate-common.c Loading commit data...
user-exec.c Loading commit data...
version.rc Loading commit data...
vl.c Loading commit data...
xen-common-stub.c Loading commit data...
xen-common.c Loading commit data...
xen-hvm-stub.c Loading commit data...
xen-hvm.c Loading commit data...
xen-mapcache.c Loading commit data...