diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-12-16 10:30:47 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-12-17 17:33:48 +0100 |
commit | 49b24afcb11d682d82747f706e3bd6174fe84062 (patch) | |
tree | 21df80016e7b1139a9d4619f5e2c0f7345449673 /memory.c | |
parent | c8ee0a445a6a85635e962c0346bc7b1259c1a3f5 (diff) | |
download | qemu-49b24afcb11d682d82747f706e3bd6174fe84062.tar.gz qemu-49b24afcb11d682d82747f706e3bd6174fe84062.tar.bz2 qemu-49b24afcb11d682d82747f706e3bd6174fe84062.zip |
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>
Diffstat (limited to 'memory.c')
-rw-r--r-- | memory.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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) |