xemu/target/i386/kvm
Maciej S. Szmigiero 2dc652961d target/i386: Reset TSCs of parked vCPUs too on VM reset
Since commit 5286c36622 ("target/i386: properly reset TSC on reset")
QEMU writes the special value of "1" to each online vCPU TSC on VM reset
to reset it.

However parked vCPUs don't get that handling and due to that their TSCs
get desynchronized when the VM gets reset.
This in turn causes KVM to turn off PVCLOCK_TSC_STABLE_BIT in its exported
PV clock.
Note that KVM has no understanding of vCPU being currently parked.

Without PVCLOCK_TSC_STABLE_BIT the sched clock is marked unstable in
the guest's kvm_sched_clock_init().
This causes a performance regressions to show in some tests.

Fix this issue by writing the special value of "1" also to TSCs of parked
vCPUs on VM reset.

Reproducing the issue:
1) Boot a VM with "-smp 2,maxcpus=3" or similar

2) device_add host-x86_64-cpu,id=vcpu,node-id=0,socket-id=0,core-id=2,thread-id=0

3) Wait a few seconds

4) device_del vcpu

5) Inside the VM run:
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
Observe the sched_clock_stable() value is 1.

6) Reboot the VM

7) Once the VM boots once again run inside it:
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
Observe the sched_clock_stable() value is now 0.

Fixes: 5286c36622 ("target/i386: properly reset TSC on reset")
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Link: https://lore.kernel.org/r/5a605a88e9a231386dc803c60f5fed9b48108139.1734014926.git.maciej.szmigiero@oracle.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 3f2a05b31ee9ce2ddb6c75a9bc3f5e7f7af9a76f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2024-12-22 11:18:15 +03:00
..
hyperv-proto.h i386: Hyper-V Direct TLB flush hypercall 2022-05-25 21:26:35 +02:00
hyperv-stub.c target/i386: hyperv: add stub for hyperv_syndbg_query_options 2024-11-18 13:44:54 +01:00
hyperv.c target/i386: Make sure SynIC state is really updated before KVM_RUN 2024-10-17 12:30:21 +02:00
hyperv.h vmbus: Print a warning when enabled without the recommended set of features 2024-03-08 14:18:56 +01:00
kvm-cpu.c target/i386: do not rely on ExtSaveArea for accelerator-supported XCR0 bits 2024-10-31 18:28:33 +01:00
kvm.c target/i386: Reset TSCs of parked vCPUs too on VM reset 2024-12-22 11:18:15 +03:00
kvm_i386.h kvm/i386: make kvm_filter_msr() and related definitions private to kvm module 2024-10-02 12:58:46 +02:00
meson.build Add support for RAPL MSRs in KVM/Qemu 2024-07-22 19:19:37 +02:00
trace-events i386/kvm: Add KVM_EXIT_HYPERCALL handling for KVM_HC_MAP_GPA_RANGE 2024-06-05 11:01:06 +02:00
trace.h i386: move kvm accel files into kvm/ 2020-12-16 14:06:52 -05:00
vmsr_energy.c kvm/i386: fix return values of is_host_cpu_intel() 2024-10-02 12:58:46 +02:00
vmsr_energy.h Add support for RAPL MSRs in KVM/Qemu 2024-07-22 19:19:37 +02:00
xen-compat.h i386/xen: Implement HYPERVISOR_physdev_op 2023-03-01 09:08:26 +00:00
xen-emu.c hw/i386/fw_cfg: Add etc/e820 to fw_cfg late 2024-07-03 18:14:06 -04:00
xen-emu.h hw/xen: Support HVM_PARAM_CALLBACK_TYPE_GSI callback 2023-03-01 09:06:44 +00:00