OSDN Git Service

i386/cpu/kvm: look at PMU's CPUID before setting MSRs
authorJan Dakinevich <jan.dakinevich@virtuozzo.com>
Wed, 27 Dec 2017 14:04:26 +0000 (17:04 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 12 Jan 2018 12:22:02 +0000 (13:22 +0100)
commit0b368a10c71af96f6cf93b0ba5c2ee3bdbd50e96
tree3c855ef8c583e7f31d9cf1ae164b122e9e5c3b74
parent829600a519386c7b188d5d813e78ba69bf0bd323
i386/cpu/kvm: look at PMU's CPUID before setting MSRs

Certain PMU-related MSRs are not supported for CPUs with PMU
architecture below version 2. KVM rejects any access to them (see
intel_is_valid_msr_idx routine in KVM), and QEMU fails on the following
assertion:

  kvm_put_msrs: Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed.

QEMU also could fail if KVM exposes less fixed counters then 3. It could
happen if host system run inside another hypervisor, which is tweaking
PMU-related CPUID. To prevent possible fail, number of fixed counters now is
obtained in the same way as number of GP counters.

Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
Message-Id: <1514383466-7257-1-git-send-email-jan.dakinevich@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/kvm.c