1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/Documentation/virt/kvm/devices
Nico Boehr 6973091d1b KVM: s390: pv: don't allow userspace to set the clock under PV
When running under PV, the guest's TOD clock is under control of the
ultravisor and the hypervisor isn't allowed to change it. Hence, don't
allow userspace to change the guest's TOD clock by returning
-EOPNOTSUPP.

When userspace changes the guest's TOD clock, KVM updates its
kvm.arch.epoch field and, in addition, the epoch field in all state
descriptions of all VCPUs.

But, under PV, the ultravisor will ignore the epoch field in the state
description and simply overwrite it on next SIE exit with the actual
guest epoch. This leads to KVM having an incorrect view of the guest's
TOD clock: it has updated its internal kvm.arch.epoch field, but the
ultravisor ignores the field in the state description.

Whenever a guest is now waiting for a clock comparator, KVM will
incorrectly calculate the time when the guest should wake up, possibly
causing the guest to sleep for much longer than expected.

With this change, kvm_s390_set_tod() will now take the kvm->lock to be
able to call kvm_s390_pv_is_protected(). Since kvm_s390_set_tod_clock()
also takes kvm->lock, use __kvm_s390_set_tod_clock() instead.

The function kvm_s390_set_tod_clock is now unused, hence remove it.
Update the documentation to indicate the TOD clock attr calls can now
return -EOPNOTSUPP.

Fixes: 0f30350471 ("KVM: s390: protvirt: Do only reset registers that are accessible")
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20221011160712.928239-2-nrb@linux.ibm.com
Message-Id: <20221011160712.928239-2-nrb@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
2022-11-07 10:14:15 +01:00
..
arm-vgic-its.rst KVM: arm64: GICv4.1: Give a chance to save VLPI state 2021-03-24 18:12:21 +00:00
arm-vgic-v3.rst docs: kvm: devices/arm-vgic-v3: enhance KVM_DEV_ARM_VGIC_CTRL_INIT doc 2021-04-06 14:51:38 +01:00
arm-vgic.rst docs: kvm: convert devices/arm-vgit.txt to ReST 2020-02-12 20:09:53 +01:00
index.rst docs: kvm: convert devices/xive.txt to ReST 2020-02-12 20:09:58 +01:00
mpic.rst docs: kvm: convert devices/mpic.txt to ReST 2020-02-12 20:09:54 +01:00
README Documentation: move Documentation/virtual to Documentation/virt 2019-07-24 10:52:11 +02:00
s390_flic.rst KVM: s390/interrupt: do not pin adapter interrupt pages 2020-02-27 19:47:10 +01:00
vcpu.rst Merge branch kvm-arm64/misc-5.18 into kvmarm-master/next 2022-03-09 11:16:48 +00:00
vfio.rst docs: kvm: convert devices/vfio.txt to ReST 2020-02-12 20:09:56 +01:00
vm.rst KVM: s390: pv: don't allow userspace to set the clock under PV 2022-11-07 10:14:15 +01:00
xics.rst kvm: rename KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS 2021-09-30 04:27:05 -04:00
xive.rst kvm: rename KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS 2021-09-30 04:27:05 -04:00

This directory contains specific device bindings for KVM_CAP_DEVICE_CTRL.