[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] kvm: x86: Fix initial kvm_has_m
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] kvm: x86: Fix initial kvm_has_msr_star |
Date: |
Sun, 06 Dec 2009 15:54:49 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
Sorry, this is of course a critical fix for all branches that have KVM
support.
Jan
Jan Kiszka wrote:
> 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 <address@hidden>
> ---
>
> target-i386/kvm.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 3b61a7f..88b504c 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) +
>
signature.asc
Description: OpenPGP digital signature