qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collect


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] KVM: dirty ring: Add memory barrier when marking pfn collected
Date: Thu, 22 Sep 2022 23:52:51 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.1

On 22/9/22 23:35, Peter Xu wrote:
Following commit 4802bf910eee9, add the other missing barrier when marking
the PFN as collected.  This will also be required just like 4802bf910eee9
on weak ordering architectures like aarch64.

Cc: Marc Zyngier <maz@kernel.org>
Cc: Gavin Shan <gshan@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
  accel/kvm/kvm-all.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 136c8eaed3..60a044048e 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -728,7 +728,11 @@ static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
  {
-    gfn->flags = KVM_DIRTY_GFN_F_RESET;
+    /*
+     * Write the flags after reading the entry.  Should pair with another
+     * smp_load_acquire() in KVM when reset dirty rings.
+     */
+    qatomic_store_release(&gfn->flags, KVM_DIRTY_GFN_F_RESET);
  }
/*

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]