Skip to content

Commit 671c8c7

Browse files
author
Marc Zyngier
committed
KVM: Document weakly ordered architecture requirements for dirty ring
Now that the kernel can expose to userspace that its dirty ring management relies on explicit ordering, document these new requirements for VMMs to do the right thing. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Reviewed-by: Peter Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fc0693d commit 671c8c7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8019,8 +8019,8 @@ guest according to the bits in the KVM_CPUID_FEATURES CPUID leaf
80198019
(0x40000001). Otherwise, a guest may use the paravirtual features
80208020
regardless of what has actually been exposed through the CPUID leaf.
80218021

8022-
8.29 KVM_CAP_DIRTY_LOG_RING
8023-
---------------------------
8022+
8.29 KVM_CAP_DIRTY_LOG_RING/KVM_CAP_DIRTY_LOG_RING_ACQ_REL
8023+
----------------------------------------------------------
80248024

80258025
:Architectures: x86
80268026
:Parameters: args[0] - size of the dirty log ring
@@ -8078,6 +8078,11 @@ on to the next GFN. The userspace should continue to do this until the
80788078
flags of a GFN have the DIRTY bit cleared, meaning that it has harvested
80798079
all the dirty GFNs that were available.
80808080

8081+
Note that on weakly ordered architectures, userspace accesses to the
8082+
ring buffer (and more specifically the 'flags' field) must be ordered,
8083+
using load-acquire/store-release accessors when available, or any
8084+
other memory barrier that will ensure this ordering.
8085+
80818086
It's not necessary for userspace to harvest the all dirty GFNs at once.
80828087
However it must collect the dirty GFNs in sequence, i.e., the userspace
80838088
program cannot skip one dirty GFN to collect the one next to it.
@@ -8106,6 +8111,14 @@ KVM_CAP_DIRTY_LOG_RING with an acceptable dirty ring size, the virtual
81068111
machine will switch to ring-buffer dirty page tracking and further
81078112
KVM_GET_DIRTY_LOG or KVM_CLEAR_DIRTY_LOG ioctls will fail.
81088113

8114+
NOTE: KVM_CAP_DIRTY_LOG_RING_ACQ_REL is the only capability that
8115+
should be exposed by weakly ordered architecture, in order to indicate
8116+
the additional memory ordering requirements imposed on userspace when
8117+
reading the state of an entry and mutating it from DIRTY to HARVESTED.
8118+
Architecture with TSO-like ordering (such as x86) are allowed to
8119+
expose both KVM_CAP_DIRTY_LOG_RING and KVM_CAP_DIRTY_LOG_RING_ACQ_REL
8120+
to userspace.
8121+
81098122
8.30 KVM_CAP_XEN_HVM
81108123
--------------------
81118124

0 commit comments

Comments
 (0)