Skip to contentSkip to conversation

docs: kvm: Fix KVM_KVMCLOCK_CTRL API doc

PATCH Superseded Joshua Abraham 2 participants 6 messages May 1, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: kvm: Fix KVM_KVMCLOCK_CTRL API doc

The KVM_KVMCLOCK_CTRL ioctl signals to supported KVM guests that the hypervisor has paused it. This updates the documentation to reflect that the guest, not the host is notified by this API.

---
 Documentation/virt/kvm/api.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/virt/kvm/api.rst +1 -1
index efbbe570aa9b..06a4d9bfc6e5 100644
@@ -2572,7 +2572,7 @@ list in 4.68.
 :Parameters: None
 :Returns: 0 on success, -1 on error
 
-This signals to the host kernel that the specified guest is being paused by
+This signals to the guest kernel that the specified guest is being paused by
 userspace.  The host will set a flag in the pvclock structure that is checked
 from the soft lockup watchdog.  The flag is part of the pvclock structure that
 is shared between guest and host, specifically the second bit of the flags
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Joshua Abraham

The KVM_KVMCLOCK_CTRL ioctl signals to supported KVM guests that the hypervisor has paused it. This updates the documentation to reflect that the guest, not the host is notified by this API.

No, the current documentation is correct. It's probably not as clear as it could be, but it's accurate as written. More below.

Quoted 10 lines
---
 Documentation/virt/kvm/api.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/virt/kvm/api.rst +0 -0
index efbbe570aa9b..06a4d9bfc6e5 100644

Documentation/virt/kvm/api.rst list in 4.68. · line 2576

Quoted 6 lines
Documentation/virt/kvm/api.rst +1 -1
@@ -2572,7 +2572,7 @@ list in 4.68.
 :Parameters: None
 :Returns: 0 on success, -1 on error
 
-This signals to the host kernel that the specified guest is being paused by
+This signals to the guest kernel that the specified guest is being paused by
 userspace.

The ioctl() signals to the host kernel that host userspace has paused the vCPU.

Documentation/virt/kvm/api.rst list in 4.68. · line 2577

Quoted 1 line
Documentation/virt/kvm/api.rst +0 -0
 The host will set a flag in the pvclock structure that is checked

The host kernel, i.e. KVM, then takes that information and forwards it to the guest kernel via the aforementioned pvclock flag.

The proposed change would imply the ioctl() is somehow getting routed directly to the guest, which is wrong.

Quoted 5 lines
Documentation/virt/kvm/api.rst +0 -0
 from the soft lockup watchdog.  The flag is part of the pvclock structure that

is shared between guest and host, specifically the second bit of the flags

Signature · 1 line
2.17.1
#2 lore raw
Quoted 6 lines · Sean Christopherson

No, the current documentation is correct. It's probably not as clear as it could be, but it's accurate as written. More below.

The ioctl() signals to the host kernel that host userspace has paused the vCPU.

Quoted 7 lines
Quoted 1 line

The host will set a flag in the pvclock structure that is checked

The host kernel, i.e. KVM, then takes that information and forwards it to the guest kernel via the aforementioned pvclock flag.

The proposed change would imply the ioctl() is somehow getting routed directly to the guest, which is wrong.

The rationale is that the guest is what consumes the pvclock flag, the host kernel does nothing interesting (from the API caller perspective) besides setting up the kvmclock update. The ioctl calls kvm_set_guest_paused() which even has a comment saying "[it] indicates to the guest kernel that it has been stopped by the hypervisor." I think that the docs first sentence should clearly reflect that the API tells the guest that it has been paused.

-Josh

#3 lore raw
Quoted 15 lines · Joshua Abraham
Quoted 6 lines · Sean Christopherson

No, the current documentation is correct. It's probably not as clear as it could be, but it's accurate as written. More below.

The ioctl() signals to the host kernel that host userspace has paused the vCPU.

Quoted 7 lines
Quoted 1 line

The host will set a flag in the pvclock structure that is checked

The host kernel, i.e. KVM, then takes that information and forwards it to the guest kernel via the aforementioned pvclock flag.

The proposed change would imply the ioctl() is somehow getting routed directly to the guest, which is wrong.

Quoted 6 lines

The rationale is that the guest is what consumes the pvclock flag, the host kernel does nothing interesting (from the API caller perspective) besides setting up the kvmclock update. The ioctl calls kvm_set_guest_paused() which even has a comment saying "[it] indicates to the guest kernel that it has been stopped by the hypervisor." I think that the docs first sentence should clearly reflect that the API tells the guest that it has been paused.

I don't disagree, but simply doing s/host/guest yields a misleading sentence and inconsistencies with the rest of the paragraph.

#4 lore raw
Quoted 2 lines · Sean Christopherson

I don't disagree, but simply doing s/host/guest yields a misleading sentence and inconsistencies with the rest of the paragraph.

I see your point. Would this wording be clearer:

"This ioctl sets a flag accessible to the guest indicating that it has been paused from the host userspace.

The host will set a flag in the pvclock structure that is checked from the soft lockup watchdog. The flag is part of the pvclock structure that is shared between guest and host, specifically the second bit of the flags field of the pvclock_vcpu_time_info structure. It will be set exclusively by the host and read/cleared exclusively by the guest. The guest operation of checking and clearing the flag must be an atomic operation so load-link/store-conditional, or equivalent must be used. There are two cases where the guest will clear the flag: when the soft lockup watchdog timer resets itself or when a soft lockup is detected. This ioctl can be called any time after pausing the vcpu, but before it is resumed."

#5 lore raw
Quoted 8 lines · Joshua Abraham
Quoted 2 lines · Sean Christopherson

I don't disagree, but simply doing s/host/guest yields a misleading sentence and inconsistencies with the rest of the paragraph.

I see your point. Would this wording be clearer:

"This ioctl sets a flag accessible to the guest indicating that it has been paused from the host userspace.

Ya. Minor nit, probably worth clarifying that 'it' refers to the vCPU, e.g.

This ioctl sets a flag accessible to the guest indicating that the specified vCPU has been paused by the host userspace.

Quoted 11 lines

The host will set a flag in the pvclock structure that is checked from the soft lockup watchdog. The flag is part of the pvclock structure that is shared between guest and host, specifically the second bit of the flags field of the pvclock_vcpu_time_info structure. It will be set exclusively by the host and read/cleared exclusively by the guest. The guest operation of checking and clearing the flag must be an atomic operation so load-link/store-conditional, or equivalent must be used. There are two cases where the guest will clear the flag: when the soft lockup watchdog timer resets itself or when a soft lockup is detected. This ioctl can be called any time after pausing the vcpu, but before it is resumed."