mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
exec: always call qemu_get_ram_ptr within rcu_read_lock
Simplify the code and document the assumption. The only caller that is not within rcu_read_lock is memory_region_get_ram_ptr. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c8ee0a445a
commit
49b24afcb1
3 changed files with 22 additions and 23 deletions
14
memory.c
14
memory.c
|
@ -1577,13 +1577,19 @@ int memory_region_get_fd(MemoryRegion *mr)
|
|||
|
||||
void *memory_region_get_ram_ptr(MemoryRegion *mr)
|
||||
{
|
||||
if (mr->alias) {
|
||||
return memory_region_get_ram_ptr(mr->alias) + mr->alias_offset;
|
||||
void *ptr;
|
||||
uint64_t offset = 0;
|
||||
|
||||
rcu_read_lock();
|
||||
while (mr->alias) {
|
||||
offset += mr->alias_offset;
|
||||
mr = mr->alias;
|
||||
}
|
||||
|
||||
assert(mr->ram_addr != RAM_ADDR_INVALID);
|
||||
ptr = qemu_get_ram_ptr(mr->ram_addr & TARGET_PAGE_MASK);
|
||||
rcu_read_unlock();
|
||||
|
||||
return qemu_get_ram_ptr(mr->ram_addr & TARGET_PAGE_MASK);
|
||||
return ptr + offset;
|
||||
}
|
||||
|
||||
void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue