summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2009-12-06 15:51:24 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-07 16:36:46 -0600
commit20c1a35211a2500935e15b5f30a98b555ebeb2ff (patch)
tree093a2d5a12b3e5d320794d23d3032020e37360c1 /target-i386
parentUpdate OpenBIOS images to r640 (diff)
downloadqemu-kvm-20c1a35211a2500935e15b5f30a98b555ebeb2ff.tar.gz
qemu-kvm-20c1a35211a2500935e15b5f30a98b555ebeb2ff.tar.bz2
qemu-kvm-20c1a35211a2500935e15b5f30a98b555ebeb2ff.zip
kvm: x86: Fix initial kvm_has_msr_star
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> (cherry picked from commit 6fb6d245546d3ae48c4cb764b3593e4739aa1364)
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/kvm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 3b61a7fc5..88b504c34 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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) +