Skip to content

Commit 4b3402f

Browse files
author
Marc Zyngier
committed
KVM: selftests: dirty-log: Use KVM_CAP_DIRTY_LOG_RING_ACQ_REL if available
Pick KVM_CAP_DIRTY_LOG_RING_ACQ_REL if exposed by the kernel. 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 4eb6486 commit 4b3402f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tools/testing/selftests/kvm/dirty_log_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static void default_after_vcpu_run(struct kvm_vcpu *vcpu, int ret, int err)
265265

266266
static bool dirty_ring_supported(void)
267267
{
268-
return kvm_has_cap(KVM_CAP_DIRTY_LOG_RING);
268+
return (kvm_has_cap(KVM_CAP_DIRTY_LOG_RING) ||
269+
kvm_has_cap(KVM_CAP_DIRTY_LOG_RING_ACQ_REL));
269270
}
270271

271272
static void dirty_ring_create_vm_done(struct kvm_vm *vm)

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ unsigned int kvm_check_cap(long cap)
8282

8383
void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size)
8484
{
85-
vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING, ring_size);
85+
if (vm_check_cap(vm, KVM_CAP_DIRTY_LOG_RING_ACQ_REL))
86+
vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING_ACQ_REL, ring_size);
87+
else
88+
vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING, ring_size);
8689
vm->dirty_ring_size = ring_size;
8790
}
8891

0 commit comments

Comments
 (0)