aboutsummaryrefslogtreecommitdiff
path: root/translate-all.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-08-12 09:41:40 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-09-09 15:34:55 +0200
commit6940fab84b826175cf90d48d0e3da1b76518f5b4 (patch)
tree05d14ec8c28214f483dbbb7cc384b45a901153b5 /translate-all.c
parent2496ff1311283480f9de3614080b8842d838ade4 (diff)
tcg: add memory barriers in page_find_alloc accesses
page_find is reading the radix tree outside all locks, so it has to use the RCU primitives. It does not need RCU critical sections because the PageDescs are never removed, so there is never a need to wait for the end of code sections that use a PageDesc. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'translate-all.c')
-rw-r--r--translate-all.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/translate-all.c b/translate-all.c
index 37bb56ca42..5329982518 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -431,26 +431,26 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
/* Level 2..N-1. */
for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) {
- void **p = *lp;
+ void **p = atomic_rcu_read(lp);
if (p == NULL) {
if (!alloc) {
return NULL;
}
p = g_new0(void *, V_L2_SIZE);
- *lp = p;
+ atomic_rcu_set(lp, p);
}
lp = p + ((index >> (i * V_L2_BITS)) & (V_L2_SIZE - 1));
}
- pd = *lp;
+ pd = atomic_rcu_read(lp);
if (pd == NULL) {
if (!alloc) {
return NULL;
}
pd = g_new0(PageDesc, V_L2_SIZE);
- *lp = pd;
+ atomic_rcu_set(lp, pd);
}
return pd + (index & (V_L2_SIZE - 1));