|
|
c7c90d |
From 026e3aa58780db72c38618e576f4c6029e3b029a Mon Sep 17 00:00:00 2001
|
|
|
c7c90d |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
c7c90d |
Date: Thu, 8 Mar 2018 15:58:17 +0100
|
|
|
c7c90d |
Subject: [PATCH 04/17] address_space_access_valid: address_space_to_flatview
|
|
|
c7c90d |
needs RCU lock
|
|
|
c7c90d |
|
|
|
c7c90d |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
c7c90d |
Message-id: <20180308155819.20598-5-pbonzini@redhat.com>
|
|
|
c7c90d |
Patchwork-id: 79195
|
|
|
c7c90d |
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 4/6] address_space_access_valid: address_space_to_flatview needs RCU lock
|
|
|
c7c90d |
Bugzilla: 1554930
|
|
|
c7c90d |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
c7c90d |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
c7c90d |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
c7c90d |
|
|
|
c7c90d |
address_space_access_valid is calling address_space_to_flatview but it can
|
|
|
c7c90d |
be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock
|
|
|
c7c90d |
pair up from flatview_access_valid to address_space_access_valid.
|
|
|
c7c90d |
|
|
|
c7c90d |
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
c7c90d |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
c7c90d |
(cherry pick from commit 11e732a5ed46903f997985bed4c3767ca28a7eb6)
|
|
|
c7c90d |
|
|
|
c7c90d |
[squashed fix for rcu_read_unlock() that should have been removed,
|
|
|
c7c90d |
for which I'll send a pull request upstream tomorrow]
|
|
|
c7c90d |
|
|
|
c7c90d |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
c7c90d |
---
|
|
|
c7c90d |
exec.c | 13 ++++++++-----
|
|
|
c7c90d |
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
c7c90d |
|
|
|
c7c90d |
diff --git a/exec.c b/exec.c
|
|
|
c7c90d |
index 43c66da..431b85b 100644
|
|
|
c7c90d |
--- a/exec.c
|
|
|
c7c90d |
+++ b/exec.c
|
|
|
c7c90d |
@@ -3259,14 +3259,12 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
|
|
|
c7c90d |
MemoryRegion *mr;
|
|
|
c7c90d |
hwaddr l, xlat;
|
|
|
c7c90d |
|
|
|
c7c90d |
- rcu_read_lock();
|
|
|
c7c90d |
while (len > 0) {
|
|
|
c7c90d |
l = len;
|
|
|
c7c90d |
mr = flatview_translate(fv, addr, &xlat, &l, is_write);
|
|
|
c7c90d |
if (!memory_access_is_direct(mr, is_write)) {
|
|
|
c7c90d |
l = memory_access_size(mr, l, addr);
|
|
|
c7c90d |
if (!memory_region_access_valid(mr, xlat, l, is_write)) {
|
|
|
c7c90d |
- rcu_read_unlock();
|
|
|
c7c90d |
return false;
|
|
|
c7c90d |
}
|
|
|
c7c90d |
}
|
|
|
c7c90d |
@@ -3274,15 +3272,20 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
|
|
|
c7c90d |
len -= l;
|
|
|
c7c90d |
addr += l;
|
|
|
c7c90d |
}
|
|
|
c7c90d |
- rcu_read_unlock();
|
|
|
c7c90d |
return true;
|
|
|
c7c90d |
}
|
|
|
c7c90d |
|
|
|
c7c90d |
bool address_space_access_valid(AddressSpace *as, hwaddr addr,
|
|
|
c7c90d |
int len, bool is_write)
|
|
|
c7c90d |
{
|
|
|
c7c90d |
- return flatview_access_valid(address_space_to_flatview(as),
|
|
|
c7c90d |
- addr, len, is_write);
|
|
|
c7c90d |
+ FlatView *fv;
|
|
|
c7c90d |
+ bool result;
|
|
|
c7c90d |
+
|
|
|
c7c90d |
+ rcu_read_lock();
|
|
|
c7c90d |
+ fv = address_space_to_flatview(as);
|
|
|
c7c90d |
+ result = flatview_access_valid(fv, addr, len, is_write);
|
|
|
c7c90d |
+ rcu_read_unlock();
|
|
|
c7c90d |
+ return result;
|
|
|
c7c90d |
}
|
|
|
c7c90d |
|
|
|
c7c90d |
static hwaddr
|
|
|
c7c90d |
--
|
|
|
c7c90d |
1.8.3.1
|
|
|
c7c90d |
|