* [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU
@ 2016-10-21 15:34 Alex Bennée
2016-10-24 14:17 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Alex Bennée @ 2016-10-21 15:34 UTC (permalink / raw)
To: pbonzini; +Cc: qemu-devel, Alex Bennée, Peter Crosthwaite,
Richard Henderson
The memory_dispatch field is meant to be protected by RCU so we should
use the correct primitives when accessing it. This race was flagged up
by the ThreadSanitizer.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
exec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/exec.c b/exec.c
index 738e8ba..c5e4073 100644
--- a/exec.c
+++ b/exec.c
@@ -459,7 +459,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
hwaddr *xlat, hwaddr *plen)
{
MemoryRegionSection *section;
- AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;
+ AddressSpaceDispatch *d = atomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch);
section = address_space_translate_internal(d, addr, xlat, plen, false);
@@ -2342,7 +2342,7 @@ static void tcg_commit(MemoryListener *listener)
* may have split the RCU critical section.
*/
d = atomic_rcu_read(&cpuas->as->dispatch);
- cpuas->memory_dispatch = d;
+ atomic_rcu_set(&cpuas->memory_dispatch, d);
tlb_flush(cpuas->cpu, 1);
}
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU
2016-10-21 15:34 [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU Alex Bennée
@ 2016-10-24 14:17 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2016-10-24 14:17 UTC (permalink / raw)
To: Alex Bennée; +Cc: qemu-devel, Peter Crosthwaite, Richard Henderson
On 21/10/2016 17:34, Alex Bennée wrote:
> The memory_dispatch field is meant to be protected by RCU so we should
> use the correct primitives when accessing it. This race was flagged up
> by the ThreadSanitizer.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> exec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index 738e8ba..c5e4073 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -459,7 +459,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
> hwaddr *xlat, hwaddr *plen)
> {
> MemoryRegionSection *section;
> - AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;
> + AddressSpaceDispatch *d = atomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch);
>
> section = address_space_translate_internal(d, addr, xlat, plen, false);
>
> @@ -2342,7 +2342,7 @@ static void tcg_commit(MemoryListener *listener)
> * may have split the RCU critical section.
> */
> d = atomic_rcu_read(&cpuas->as->dispatch);
> - cpuas->memory_dispatch = d;
> + atomic_rcu_set(&cpuas->memory_dispatch, d);
> tlb_flush(cpuas->cpu, 1);
> }
>
>
Oops, this missed today's pull request but it's a bug so it can go in later.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-24 14:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-21 15:34 [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU Alex Bennée
2016-10-24 14:17 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).