X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=memory.c;h=75ca281e978efad550afbe1e1223a6412152b310;hb=4458c23672904fa131e69897007eeb7c953be7e5;hp=09e44b84ab399a10383980d5fad1c86d5e7cc18c;hpb=22bde7145495ad78c4bed8bb76d9401ec8d107b2;p=qemu.git diff --git a/memory.c b/memory.c index 09e44b84a..75ca281e9 100644 --- a/memory.c +++ b/memory.c @@ -13,14 +13,14 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "memory.h" -#include "exec-memory.h" -#include "ioport.h" -#include "bitops.h" -#include "kvm.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" +#include "exec/ioport.h" +#include "qemu/bitops.h" +#include "sysemu/kvm.h" #include -#include "memory-internal.h" +#include "exec/memory-internal.h" static unsigned memory_region_transaction_depth; static bool memory_region_update_pending; @@ -855,7 +855,7 @@ static uint64_t memory_region_dispatch_read1(MemoryRegion *mr, } if (!mr->ops->read) { - return mr->ops->old_mmio.read[bitops_ffsl(size)](mr->opaque, addr); + return mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr); } /* FIXME: support unaligned access */ @@ -908,7 +908,7 @@ static void memory_region_dispatch_write(MemoryRegion *mr, adjust_endianness(mr, &data, size); if (!mr->ops->write) { - mr->ops->old_mmio.write[bitops_ffsl(size)](mr->opaque, addr, data); + mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, data); return; } @@ -1081,6 +1081,22 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, return cpu_physical_memory_set_dirty_range(mr->ram_addr + addr, size, -1); } +bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size, unsigned client) +{ + bool ret; + assert(mr->terminates); + ret = cpu_physical_memory_get_dirty(mr->ram_addr + addr, size, + 1 << client); + if (ret) { + cpu_physical_memory_reset_dirty(mr->ram_addr + addr, + mr->ram_addr + addr + size, + 1 << client); + } + return ret; +} + + void memory_region_sync_dirty_bitmap(MemoryRegion *mr) { AddressSpace *as; @@ -1305,7 +1321,7 @@ static void memory_region_add_subregion_common(MemoryRegion *mr, if (subregion->may_overlap || other->may_overlap) { continue; } - if (int128_gt(int128_make64(offset), + if (int128_ge(int128_make64(offset), int128_add(int128_make64(other->addr), other->size)) || int128_le(int128_add(int128_make64(offset), subregion->size), int128_make64(other->addr))) { @@ -1601,7 +1617,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, const MemoryRegion *submr; unsigned int i; - if (!mr) { + if (!mr || !mr->enabled) { return; }