[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/46] hyperv: set partition-wide MSRs only on first
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 09/46] hyperv: set partition-wide MSRs only on first vcpu |
Date: |
Wed, 20 Dec 2017 18:14:21 +0100 |
From: Evgeny Yakovlev <address@hidden>
Hyper-V has a notion of partition-wide MSRs. Those MSRs are read and
written as usual on each VCPU, however the hypervisor maintains a single
global value for all VCPUs. Thus writing such an MSR from any single
VCPU affects the global value that is read by all other VCPUs.
This leads to an issue during VCPU hotplug: the zero-initialzied values
of those MSRs get synced into KVM and override the global values as has
already been set by the guest.
This change makes the partition-wide MSRs only be synchronized on the
first vcpu.
Signed-off-by: Evgeny Yakovlev <address@hidden>
Signed-off-by: Roman Kagan <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
target/i386/cpu.h | 5 ++++-
target/i386/kvm.c | 23 +++++++++++++++--------
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index cdbf8b0..17f1bb7 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1097,10 +1097,13 @@ typedef struct CPUX86State {
uint64_t async_pf_en_msr;
uint64_t pv_eoi_en_msr;
+ /* Partition-wide HV MSRs, will be updated only on the first vcpu */
uint64_t msr_hv_hypercall;
uint64_t msr_hv_guest_os_id;
- uint64_t msr_hv_vapic;
uint64_t msr_hv_tsc;
+
+ /* Per-VCPU HV MSRs */
+ uint64_t msr_hv_vapic;
uint64_t msr_hv_crash_params[HV_CRASH_PARAMS];
uint64_t msr_hv_runtime;
uint64_t msr_hv_synic_control;
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index d4b2ce2..89fa65e 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -1678,19 +1678,26 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL,
env->msr_global_ctrl);
}
- if (has_msr_hv_hypercall) {
- kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID,
- env->msr_hv_guest_os_id);
- kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL,
- env->msr_hv_hypercall);
+ /*
+ * Hyper-V partition-wide MSRs: to avoid clearing them on cpu hot-add,
+ * only sync them to KVM on the first cpu
+ */
+ if (current_cpu == first_cpu) {
+ if (has_msr_hv_hypercall) {
+ kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID,
+ env->msr_hv_guest_os_id);
+ kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL,
+ env->msr_hv_hypercall);
+ }
+ if (cpu->hyperv_time) {
+ kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC,
+ env->msr_hv_tsc);
+ }
}
if (cpu->hyperv_vapic) {
kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE,
env->msr_hv_vapic);
}
- if (cpu->hyperv_time) {
- kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, env->msr_hv_tsc);
- }
if (has_msr_hv_crash) {
int j;
--
1.8.3.1
- [Qemu-devel] [PULL 00/46] First batch of misc patches for QEMU 2.12, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 01/46] memfd: fix configure test, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 02/46] qemu-thread: fix races on threads that exit very quickly, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 03/46] qemu-pr-helper: miscellaneous fixes, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 04/46] contrib: add systemd unit files, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 06/46] scsi-block: Add share-rw option, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 05/46] Revert "docker: Enable features explicitly in test-full", Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 07/46] MAITAINERS: List Fam Zheng as reviewer for SCSI patches, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 09/46] hyperv: set partition-wide MSRs only on first vcpu,
Paolo Bonzini <=
- [Qemu-devel] [PULL 10/46] hyperv: ensure SINTx msrs are reset properly, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 08/46] x86/cpu: Enable new SSE/AVX/AVX512 cpu features, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 12/46] cpus: make pause_all_cpus() play with SMP on single threaded TCG, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 13/46] cpu-exec: fix missed CPU kick during interrupt injection, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 11/46] hyperv: make SynIC version msr constant, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 14/46] target/i386: Fix compiler warnings, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 15/46] baum: Truncate braille device size to 84x1, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 18/46] tests/boot-serial-test: Make sure that we check the timeout regularly, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 17/46] target/i386: Fix handling of VEX prefixes, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 19/46] tests/boot-serial-test: Add code to allow to specify our own kernel or bios, Paolo Bonzini, 2017/12/20