History

KVM: Add KVM_CAP_DIRTY_LOG_RING_ACQ_REL capability and config option

In order to differenciate between architectures that require no extra synchronisation when accessing the dirty ring and those who do, add a new capability (KVM_CAP_DIRTY_LOG_RING_ACQ_REL) that identify the latter sort. TSO architectures can obviously advertise both, while relaxed architectures must only advertise the ACQ_REL version. This requires some configuration symbol rejigging, with HAVE_KVM_DIRTY_RING being only indirectly selected by two top-level config symbols: - HAVE_KVM_DIRTY_RING_TSO for strongly ordered architectures (x86) - HAVE_KVM_DIRTY_RING_ACQ_REL for weakly ordered architectures (arm64)

Marc Zyngier committed 4 years ago

Commit 17601bf1 parent 8929bc94 files · +24 −2Browse files

Unified · Split

4 files
  1. arch/x86/kvm/Kconfig +1 −1
  2. include/uapi/linux/kvm.h +1 −0
  3. virt/kvm/Kconfig +14 −0
  4. virt/kvm/kvm_main.c +8 −1
arch/x86/kvm/Kconfig+1−1
@@ -28,7 +28,7 @@ config KVM · 27 unmodified lines
2828 select HAVE_KVM_IRQCHIP
2929 select HAVE_KVM_PFNCACHE
3030 select HAVE_KVM_IRQFD
31− select HAVE_KVM_DIRTY_RING
31+ select HAVE_KVM_DIRTY_RING_TSO
3232 select IRQ_BYPASS_MANAGER
3333 select HAVE_KVM_IRQ_BYPASS
3434 select HAVE_KVM_IRQ_ROUTING
include/uapi/linux/kvm.h+1−0
@@ -1177,6 +1177,7 @@ struct kvm_ppc_resize_hpt { · 1176 unmodified lines
11771177 #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
11781178 #define KVM_CAP_S390_ZPCI_OP 221
11791179 #define KVM_CAP_S390_CPU_TOPOLOGY 222
1180+#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
11801181
11811182 #ifdef KVM_CAP_IRQ_ROUTING
11821183
virt/kvm/Kconfig+14−0
@@ -19,6 +19,20 @@ config HAVE_KVM_IRQ_ROUTING · 18 unmodified lines
1919 config HAVE_KVM_DIRTY_RING
2020 bool
2121
22+# Only strongly ordered architectures can select this, as it doesn't
23+# put any explicit constraint on userspace ordering. They can also
24+# select the _ACQ_REL version.
25+config HAVE_KVM_DIRTY_RING_TSO
26+ bool
27+ select HAVE_KVM_DIRTY_RING
28+ depends on X86
29+
30+# Weakly ordered architectures can only select this, advertising
31+# to userspace the additional ordering requirements.
32+config HAVE_KVM_DIRTY_RING_ACQ_REL
33+ bool
34+ select HAVE_KVM_DIRTY_RING
35+
2236 config HAVE_KVM_EVENTFD
2337 bool
2438 select EVENTFD
virt/kvm/kvm_main.c+8−1
@@ -4475,7 +4475,13 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) · 4474 unmodified lines
44754475 case KVM_CAP_NR_MEMSLOTS:
44764476 return KVM_USER_MEM_SLOTS;
44774477 case KVM_CAP_DIRTY_LOG_RING:
4478−#ifdef CONFIG_HAVE_KVM_DIRTY_RING
4478+#ifdef CONFIG_HAVE_KVM_DIRTY_RING_TSO
4479+ return KVM_DIRTY_RING_MAX_ENTRIES * sizeof(struct kvm_dirty_gfn);
4480+#else
4481+ return 0;
4482+#endif
4483+ case KVM_CAP_DIRTY_LOG_RING_ACQ_REL:
4484+#ifdef CONFIG_HAVE_KVM_DIRTY_RING_ACQ_REL
44794485 return KVM_DIRTY_RING_MAX_ENTRIES * sizeof(struct kvm_dirty_gfn);
44804486 #else
44814487 return 0;
@@ -4580,6 +4586,7 @@ static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm, · 98 unmodified lines
45804586 return 0;
45814587 }
45824588 case KVM_CAP_DIRTY_LOG_RING:
4589+ case KVM_CAP_DIRTY_LOG_RING_ACQ_REL:
45834590 return kvm_vm_ioctl_enable_dirty_log_ring(kvm, cap->args[0]);
45844591 default:
45854592 return kvm_vm_ioctl_enable_cap(kvm, cap);