address_space_access_valid: address_space_to_flatview needs RCU lock

address_space_access_valid is calling address_space_to_flatview but it can
be called outside the RCU lock.  To fix it, push the rcu_read_lock/unlock
pair up from flatview_access_valid to address_space_access_valid.

Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2018-03-05 00:23:26 +01:00
parent b2a44fcad7
commit 11e732a5ed

12
exec.c
View File

@ -3395,7 +3395,6 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
MemoryRegion *mr; MemoryRegion *mr;
hwaddr l, xlat; hwaddr l, xlat;
rcu_read_lock();
while (len > 0) { while (len > 0) {
l = len; l = len;
mr = flatview_translate(fv, addr, &xlat, &l, is_write); mr = flatview_translate(fv, addr, &xlat, &l, is_write);
@ -3410,15 +3409,20 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
len -= l; len -= l;
addr += l; addr += l;
} }
rcu_read_unlock();
return true; return true;
} }
bool address_space_access_valid(AddressSpace *as, hwaddr addr, bool address_space_access_valid(AddressSpace *as, hwaddr addr,
int len, bool is_write) int len, bool is_write)
{ {
return flatview_access_valid(address_space_to_flatview(as), FlatView *fv;
addr, len, is_write); bool result;
rcu_read_lock();
fv = address_space_to_flatview(as);
result = flatview_access_valid(fv, addr, len, is_write);
rcu_read_unlock();
return result;
} }
static hwaddr static hwaddr