Skip to content

Commit

Permalink
KVM: selftests: dirty-log: Use KVM_CAP_DIRTY_LOG_RING_ACQ_REL if avai…
Browse files Browse the repository at this point in the history
…lable

Pick KVM_CAP_DIRTY_LOG_RING_ACQ_REL if exposed by the kernel.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/20220926145120.27974-7-maz@kernel.org
  • Loading branch information
Marc Zyngier committed Sep 29, 2022
1 parent 4eb6486 commit 4b3402f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tools/testing/selftests/kvm/dirty_log_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ static void default_after_vcpu_run(struct kvm_vcpu *vcpu, int ret, int err)

static bool dirty_ring_supported(void)
{
return kvm_has_cap(KVM_CAP_DIRTY_LOG_RING);
return (kvm_has_cap(KVM_CAP_DIRTY_LOG_RING) ||
kvm_has_cap(KVM_CAP_DIRTY_LOG_RING_ACQ_REL));
}

static void dirty_ring_create_vm_done(struct kvm_vm *vm)
Expand Down
5 changes: 4 additions & 1 deletion tools/testing/selftests/kvm/lib/kvm_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ unsigned int kvm_check_cap(long cap)

void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size)
{
vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING, ring_size);
if (vm_check_cap(vm, KVM_CAP_DIRTY_LOG_RING_ACQ_REL))
vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING_ACQ_REL, ring_size);
else
vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING, ring_size);
vm->dirty_ring_size = ring_size;
}

Expand Down

0 comments on commit 4b3402f

Please sign in to comment.