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)
Unified · Split
| @@ -28,7 +28,7 @@ config KVM · 27 unmodified lines | ||
| 28 | 28 | select HAVE_KVM_IRQCHIP |
| 29 | 29 | select HAVE_KVM_PFNCACHE |
| 30 | 30 | select HAVE_KVM_IRQFD |
| 31 | − select HAVE_KVM_DIRTY_RING | |
| 31 | + select HAVE_KVM_DIRTY_RING_TSO | |
| 32 | 32 | select IRQ_BYPASS_MANAGER |
| 33 | 33 | select HAVE_KVM_IRQ_BYPASS |
| 34 | 34 | select HAVE_KVM_IRQ_ROUTING |
| @@ -1177,6 +1177,7 @@ struct kvm_ppc_resize_hpt { · 1176 unmodified lines | ||
| 1177 | 1177 | #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 |
| 1178 | 1178 | #define KVM_CAP_S390_ZPCI_OP 221 |
| 1179 | 1179 | #define KVM_CAP_S390_CPU_TOPOLOGY 222 |
| 1180 | +#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 | |
| 1180 | 1181 | |
| 1181 | 1182 | #ifdef KVM_CAP_IRQ_ROUTING |
| 1182 | 1183 | |
| @@ -19,6 +19,20 @@ config HAVE_KVM_IRQ_ROUTING · 18 unmodified lines | ||
| 19 | 19 | config HAVE_KVM_DIRTY_RING |
| 20 | 20 | 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. | |
| 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 | + | |
| 22 | 36 | config HAVE_KVM_EVENTFD |
| 23 | 37 | bool |
| 24 | 38 | select EVENTFD |
| @@ -4475,7 +4475,13 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) · 4474 unmodified lines | ||
| 4475 | 4475 | case KVM_CAP_NR_MEMSLOTS: |
| 4476 | 4476 | return KVM_USER_MEM_SLOTS; |
| 4477 | 4477 | 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 | |
| 4479 | 4485 | return KVM_DIRTY_RING_MAX_ENTRIES * sizeof(struct kvm_dirty_gfn); |
| 4480 | 4486 | #else |
| 4481 | 4487 | return 0; |
| @@ -4580,6 +4586,7 @@ static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm, · 98 unmodified lines | ||
| 4580 | 4586 | return 0; |
| 4581 | 4587 | } |
| 4582 | 4588 | case KVM_CAP_DIRTY_LOG_RING: |
| 4589 | + case KVM_CAP_DIRTY_LOG_RING_ACQ_REL: | |
| 4583 | 4590 | return kvm_vm_ioctl_enable_dirty_log_ring(kvm, cap->args[0]); |
| 4584 | 4591 | default: |
| 4585 | 4592 | return kvm_vm_ioctl_enable_cap(kvm, cap); |