All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] exec.c: Use atomic_rcu_read() to access dispatch in memory_region_section_get_iotlb()
@ 2015-07-20 11:27 Peter Maydell
  2015-07-21  8:50 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2015-07-20 11:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, patches

When accessing the dispatch pointer in an AddressSpace within an RCU
critical section we should always use atomic_rcu_read(). Fix an
access within memory_region_section_get_iotlb() which was incorrectly
doing a direct pointer access.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I discussed this on IRC with Paolo a while back, and IIRC he said
that although this is a bug it's not one that can currently have
any ill effects, though I forget why (probably because this code
path is TCG only and TCG is single-threaded right now).

 exec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index 7d60e15..0a4a0c5 100644
--- a/exec.c
+++ b/exec.c
@@ -954,7 +954,10 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,
             iotlb |= PHYS_SECTION_ROM;
         }
     } else {
-        iotlb = section - section->address_space->dispatch->map.sections;
+        AddressSpaceDispatch *d;
+
+        d = atomic_rcu_read(&section->address_space->dispatch);
+        iotlb = section - d->map.sections;
         iotlb += xlat;
     }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] exec.c: Use atomic_rcu_read() to access dispatch in memory_region_section_get_iotlb()
  2015-07-20 11:27 [Qemu-devel] [PATCH] exec.c: Use atomic_rcu_read() to access dispatch in memory_region_section_get_iotlb() Peter Maydell
@ 2015-07-21  8:50 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-07-21  8:50 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches



On 20/07/2015 13:27, Peter Maydell wrote:
> When accessing the dispatch pointer in an AddressSpace within an RCU
> critical section we should always use atomic_rcu_read(). Fix an
> access within memory_region_section_get_iotlb() which was incorrectly
> doing a direct pointer access.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I discussed this on IRC with Paolo a while back, and IIRC he said
> that although this is a bug it's not one that can currently have
> any ill effects, though I forget why (probably because this code
> path is TCG only and TCG is single-threaded right now).
> 
>  exec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/exec.c b/exec.c
> index 7d60e15..0a4a0c5 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -954,7 +954,10 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,
>              iotlb |= PHYS_SECTION_ROM;
>          }
>      } else {
> -        iotlb = section - section->address_space->dispatch->map.sections;
> +        AddressSpaceDispatch *d;
> +
> +        d = atomic_rcu_read(&section->address_space->dispatch);
> +        iotlb = section - d->map.sections;
>          iotlb += xlat;
>      }
>  

Thanks, queued for next 2.4 pull request.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-21  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 11:27 [Qemu-devel] [PATCH] exec.c: Use atomic_rcu_read() to access dispatch in memory_region_section_get_iotlb() Peter Maydell
2015-07-21  8:50 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.