|
|
37e7a1 |
From 2f3881255e6a50d9821f390972b07c1e9d9de626 Mon Sep 17 00:00:00 2001
|
|
|
37e7a1 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
37e7a1 |
Date: Thu, 8 Mar 2018 15:58:15 +0100
|
|
|
37e7a1 |
Subject: [PATCH 02/17] address_space_write: address_space_to_flatview needs
|
|
|
37e7a1 |
RCU lock
|
|
|
37e7a1 |
|
|
|
37e7a1 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
37e7a1 |
Message-id: <20180308155819.20598-3-pbonzini@redhat.com>
|
|
|
37e7a1 |
Patchwork-id: 79191
|
|
|
37e7a1 |
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 2/6] address_space_write: address_space_to_flatview needs RCU lock
|
|
|
37e7a1 |
Bugzilla: 1554930
|
|
|
37e7a1 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
37e7a1 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
37e7a1 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
37e7a1 |
|
|
|
37e7a1 |
address_space_write is calling address_space_to_flatview but it can
|
|
|
37e7a1 |
be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock
|
|
|
37e7a1 |
pair up from flatview_write to address_space_write.
|
|
|
37e7a1 |
|
|
|
37e7a1 |
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
37e7a1 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
37e7a1 |
(cherry pick from commit 4c6ebbb364aa6f42c5d8e83e932e967eb83f0e44)
|
|
|
37e7a1 |
|
|
|
37e7a1 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
37e7a1 |
---
|
|
|
37e7a1 |
exec.c | 37 ++++++++++++++++++++++---------------
|
|
|
37e7a1 |
1 file changed, 22 insertions(+), 15 deletions(-)
|
|
|
37e7a1 |
|
|
|
37e7a1 |
diff --git a/exec.c b/exec.c
|
|
|
37e7a1 |
index 5a12e55..8b50133 100644
|
|
|
37e7a1 |
--- a/exec.c
|
|
|
37e7a1 |
+++ b/exec.c
|
|
|
37e7a1 |
@@ -2942,6 +2942,7 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,
|
|
|
37e7a1 |
return result;
|
|
|
37e7a1 |
}
|
|
|
37e7a1 |
|
|
|
37e7a1 |
+/* Called from RCU critical section. */
|
|
|
37e7a1 |
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
|
|
37e7a1 |
const uint8_t *buf, int len)
|
|
|
37e7a1 |
{
|
|
|
37e7a1 |
@@ -2950,25 +2951,14 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
|
|
37e7a1 |
MemoryRegion *mr;
|
|
|
37e7a1 |
MemTxResult result = MEMTX_OK;
|
|
|
37e7a1 |
|
|
|
37e7a1 |
- if (len > 0) {
|
|
|
37e7a1 |
- rcu_read_lock();
|
|
|
37e7a1 |
- l = len;
|
|
|
37e7a1 |
- mr = flatview_translate(fv, addr, &addr1, &l, true);
|
|
|
37e7a1 |
- result = flatview_write_continue(fv, addr, attrs, buf, len,
|
|
|
37e7a1 |
- addr1, l, mr);
|
|
|
37e7a1 |
- rcu_read_unlock();
|
|
|
37e7a1 |
- }
|
|
|
37e7a1 |
+ l = len;
|
|
|
37e7a1 |
+ mr = flatview_translate(fv, addr, &addr1, &l, true);
|
|
|
37e7a1 |
+ result = flatview_write_continue(fv, addr, attrs, buf, len,
|
|
|
37e7a1 |
+ addr1, l, mr);
|
|
|
37e7a1 |
|
|
|
37e7a1 |
return result;
|
|
|
37e7a1 |
}
|
|
|
37e7a1 |
|
|
|
37e7a1 |
-MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
|
|
|
37e7a1 |
- MemTxAttrs attrs,
|
|
|
37e7a1 |
- const uint8_t *buf, int len)
|
|
|
37e7a1 |
-{
|
|
|
37e7a1 |
- return flatview_write(address_space_to_flatview(as), addr, attrs, buf, len);
|
|
|
37e7a1 |
-}
|
|
|
37e7a1 |
-
|
|
|
37e7a1 |
/* Called within RCU critical section. */
|
|
|
37e7a1 |
MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
|
|
|
37e7a1 |
MemTxAttrs attrs, uint8_t *buf,
|
|
|
37e7a1 |
@@ -3077,6 +3067,23 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,
|
|
|
37e7a1 |
addr, attrs, buf, len, is_write);
|
|
|
37e7a1 |
}
|
|
|
37e7a1 |
|
|
|
37e7a1 |
+MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
|
|
|
37e7a1 |
+ MemTxAttrs attrs,
|
|
|
37e7a1 |
+ const uint8_t *buf, int len)
|
|
|
37e7a1 |
+{
|
|
|
37e7a1 |
+ MemTxResult result = MEMTX_OK;
|
|
|
37e7a1 |
+ FlatView *fv;
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ if (len > 0) {
|
|
|
37e7a1 |
+ rcu_read_lock();
|
|
|
37e7a1 |
+ fv = address_space_to_flatview(as);
|
|
|
37e7a1 |
+ result = flatview_write(fv, addr, attrs, buf, len);
|
|
|
37e7a1 |
+ rcu_read_unlock();
|
|
|
37e7a1 |
+ }
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ return result;
|
|
|
37e7a1 |
+}
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
|
|
|
37e7a1 |
int len, int is_write)
|
|
|
37e7a1 |
{
|
|
|
37e7a1 |
--
|
|
|
37e7a1 |
1.8.3.1
|
|
|
37e7a1 |
|