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
28 select HAVE_KVM_IRQCHIP28 select HAVE_KVM_IRQCHIP
29 select HAVE_KVM_PFNCACHE29 select HAVE_KVM_PFNCACHE
30 select HAVE_KVM_IRQFD30 select HAVE_KVM_IRQFD
31 select HAVE_KVM_DIRTY_RING31 select HAVE_KVM_DIRTY_RING_TSO
32 select IRQ_BYPASS_MANAGER32 select IRQ_BYPASS_MANAGER
33 select HAVE_KVM_IRQ_BYPASS33 select HAVE_KVM_IRQ_BYPASS
34 select HAVE_KVM_IRQ_ROUTING34 select HAVE_KVM_IRQ_ROUTING
include/uapi/linux/kvm.h+1−0
@@ -1177,6 +1177,7 @@ struct kvm_ppc_resize_hpt { · 1176 unmodified lines
1177#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 2201177#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
1178#define KVM_CAP_S390_ZPCI_OP 2211178#define KVM_CAP_S390_ZPCI_OP 221
1179#define KVM_CAP_S390_CPU_TOPOLOGY 2221179#define KVM_CAP_S390_CPU_TOPOLOGY 222
1180#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
1180 1181
1181#ifdef KVM_CAP_IRQ_ROUTING1182#ifdef KVM_CAP_IRQ_ROUTING
1182 1183
virt/kvm/Kconfig+14−0
@@ -19,6 +19,20 @@ config HAVE_KVM_IRQ_ROUTING · 18 unmodified lines
19config HAVE_KVM_DIRTY_RING19config HAVE_KVM_DIRTY_RING
20 bool20 bool
21 21
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.
25config 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.
32config HAVE_KVM_DIRTY_RING_ACQ_REL
33 bool
34 select HAVE_KVM_DIRTY_RING
35
22config HAVE_KVM_EVENTFD36config HAVE_KVM_EVENTFD
23 bool37 bool
24 select EVENTFD38 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
4475 case KVM_CAP_NR_MEMSLOTS:4475 case KVM_CAP_NR_MEMSLOTS:
4476 return KVM_USER_MEM_SLOTS;4476 return KVM_USER_MEM_SLOTS;
4477 case KVM_CAP_DIRTY_LOG_RING:4477 case KVM_CAP_DIRTY_LOG_RING:
4478#ifdef CONFIG_HAVE_KVM_DIRTY_RING4478#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
4479 return KVM_DIRTY_RING_MAX_ENTRIES * sizeof(struct kvm_dirty_gfn);4485 return KVM_DIRTY_RING_MAX_ENTRIES * sizeof(struct kvm_dirty_gfn);
4480#else4486#else
4481 return 0;4487 return 0;
@@ -4580,6 +4586,7 @@ static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm, · 98 unmodified lines
4580 return 0;4586 return 0;
4581 }4587 }
4582 case KVM_CAP_DIRTY_LOG_RING:4588 case KVM_CAP_DIRTY_LOG_RING:
4589 case KVM_CAP_DIRTY_LOG_RING_ACQ_REL:
4583 return kvm_vm_ioctl_enable_dirty_log_ring(kvm, cap->args[0]);4590 return kvm_vm_ioctl_enable_dirty_log_ring(kvm, cap->args[0]);
4584 default:4591 default:
4585 return kvm_vm_ioctl_enable_cap(kvm, cap);4592 return kvm_vm_ioctl_enable_cap(kvm, cap);