]> git.proxmox.com Git - mirror_qemu.git/commitdiff
kvm: x86: Fix initial kvm_has_msr_star
authorJan Kiszka <jan.kiszka@web.de>
Sun, 6 Dec 2009 14:51:24 +0000 (15:51 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 7 Dec 2009 14:45:47 +0000 (08:45 -0600)
KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
small for all MSRs. But this is precisely the error we trigger with the
initial request in order to obtain that size. Do not fail in that case.

This caused a subtle corruption of the guest state as MSR_STAR was not
properly saved/restored. The corruption became visible with latest kvm
optimizing the MSR updates.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
target-i386/kvm.c

index 3b61a7fc5de3b653e45dfc56caf3030d2cf8e807..88b504c34ec82cba350e9e12d5dd179397b2936b 100644 (file)
@@ -244,9 +244,9 @@ static int kvm_has_msr_star(CPUState *env)
          * save/restore */
         msr_list.nmsrs = 0;
         ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);
-        if (ret < 0)
+        if (ret < 0 && ret != -E2BIG) {
             return 0;
-
+        }
         /* Old kernel modules had a bug and could write beyond the provided
            memory. Allocate at least a safe amount of 1K. */
         kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +