Skip to content

Commit 4eb6486

Browse files
author
Marc Zyngier
committed
KVM: selftests: dirty-log: Upgrade flag accesses to acquire/release semantics
In order to preserve ordering, make sure that the flag accesses in the dirty log are done using acquire/release accessors. 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 671c8c7 commit 4eb6486

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/testing/selftests/kvm/dirty_log_test.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/bitmap.h>
1818
#include <linux/bitops.h>
1919
#include <linux/atomic.h>
20+
#include <asm/barrier.h>
2021

2122
#include "kvm_util.h"
2223
#include "test_util.h"
@@ -279,12 +280,12 @@ static void dirty_ring_create_vm_done(struct kvm_vm *vm)
279280

280281
static inline bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
281282
{
282-
return gfn->flags == KVM_DIRTY_GFN_F_DIRTY;
283+
return smp_load_acquire(&gfn->flags) == KVM_DIRTY_GFN_F_DIRTY;
283284
}
284285

285286
static inline void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
286287
{
287-
gfn->flags = KVM_DIRTY_GFN_F_RESET;
288+
smp_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET);
288289
}
289290

290291
static uint32_t dirty_ring_collect_one(struct kvm_dirty_gfn *dirty_gfns,

0 commit comments

Comments
 (0)