[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] KVM: dirty ring: add missing memory barrier
From: |
Paolo Bonzini |
Subject: |
[PATCH] KVM: dirty ring: add missing memory barrier |
Date: |
Fri, 26 Aug 2022 13:00:29 +0200 |
The KVM_DIRTY_GFN_F_DIRTY flag ensures that the entry is valid. If
the read of the fields are not ordered after the read of the flag,
QEMU might see stale values.
Cc: Peter Xu <peterx@redhat.com>
Cc: Gavin Shan <gshan@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
accel/kvm/kvm-all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 8d81ab74de..f49643cd24 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -719,7 +719,7 @@ static void kvm_dirty_ring_mark_page(KVMState *s, uint32_t
as_id,
static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
{
- return gfn->flags == KVM_DIRTY_GFN_F_DIRTY;
+ return qatomic_load_acquire(&gfn->flags, KVM_DIRTY_GFN_F_DIRTY);
}
static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
--
2.37.1
- [PATCH] KVM: dirty ring: add missing memory barrier,
Paolo Bonzini <=