Message ID | 20230303171939.237819-9-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
Series | Fix missing memory barriers on ARM | expand |
On 3/3/23 09:19, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > softmmu/physmem.c | 3 +++ > 1 file changed, 3 insertions(+) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~ > > diff --git a/softmmu/physmem.c b/softmmu/physmem.c > index 47143edb4f6c..a6efd8e8dd11 100644 > --- a/softmmu/physmem.c > +++ b/softmmu/physmem.c > @@ -2927,6 +2927,8 @@ void cpu_register_map_client(QEMUBH *bh) > qemu_mutex_lock(&map_client_list_lock); > client->bh = bh; > QLIST_INSERT_HEAD(&map_client_list, client, link); > + /* Write map_client_list before reading in_use. */ > + smp_mb(); > if (!qatomic_read(&bounce.in_use)) { > cpu_notify_map_clients_locked(); > } > @@ -3116,6 +3118,7 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, > qemu_vfree(bounce.buffer); > bounce.buffer = NULL; > memory_region_unref(bounce.mr); > + /* Clear in_use before reading map_client_list. */ > qatomic_mb_set(&bounce.in_use, false); > cpu_notify_map_clients(); > }
On 03.03.23 18:19, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- Reviewed-by: David Hildenbrand <david@redhat.com>
diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 47143edb4f6c..a6efd8e8dd11 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2927,6 +2927,8 @@ void cpu_register_map_client(QEMUBH *bh) qemu_mutex_lock(&map_client_list_lock); client->bh = bh; QLIST_INSERT_HEAD(&map_client_list, client, link); + /* Write map_client_list before reading in_use. */ + smp_mb(); if (!qatomic_read(&bounce.in_use)) { cpu_notify_map_clients_locked(); } @@ -3116,6 +3118,7 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, qemu_vfree(bounce.buffer); bounce.buffer = NULL; memory_region_unref(bounce.mr); + /* Clear in_use before reading map_client_list. */ qatomic_mb_set(&bounce.in_use, false); cpu_notify_map_clients(); }
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- softmmu/physmem.c | 3 +++ 1 file changed, 3 insertions(+)