From e120cd03b42467683370c0d07f02d1f9355fce32 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Thu, 11 Jun 2020 20:55:13 +0800 Subject: [PATCH] simplify MemoryRegion --- include/uc_priv.h | 1 - qemu/exec.c | 2 +- qemu/include/exec/memory.h | 31 ------------------------- qemu/memory.c | 47 -------------------------------------- 4 files changed, 1 insertion(+), 80 deletions(-) diff --git a/include/uc_priv.h b/include/uc_priv.h index e27724d9..a86ea04f 100644 --- a/include/uc_priv.h +++ b/include/uc_priv.h @@ -182,7 +182,6 @@ struct uc_struct { RAMList ram_list; // qemu/exec.c BounceBuffer bounce; // qemu/cpu-exec.c volatile sig_atomic_t exit_request; // qemu/cpu-exec.c - bool global_dirty_log; // qemu/memory.c /* This is a multi-level map on the virtual address space. The bottom level has pointers to PageDesc. */ void **l1_map; // qemu/translate-all.c diff --git a/qemu/exec.c b/qemu/exec.c index 0c41b7bc..9dd4f74d 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -287,7 +287,7 @@ static MemoryRegionSection *phys_page_find(PhysPageEntry lp, hwaddr addr, bool memory_region_is_unassigned(struct uc_struct* uc, MemoryRegion *mr) { return mr != &uc->io_mem_rom && mr != &uc->io_mem_notdirty && - !mr->rom_device && mr != &uc->io_mem_watch; + mr != &uc->io_mem_watch; } static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d, diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index de04d6e4..de828116 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -134,21 +134,14 @@ struct MemoryRegion { uint64_t align; bool subpage; bool terminates; - bool romd_mode; bool ram; - bool skip_dump; bool readonly; /* For RAM regions */ bool enabled; - bool rom_device; - bool warning_printed; /* For reservations */ - MemoryRegion *alias; - hwaddr alias_offset; int32_t priority; bool may_overlap; QTAILQ_HEAD(subregions, MemoryRegion) subregions; QTAILQ_ENTRY(MemoryRegion) subregions_link; const char *name; - uint8_t dirty_log_mask; struct uc_struct *uc; uint32_t perms; //all perms, partially redundant with readonly uint64_t end; @@ -168,11 +161,6 @@ struct MemoryListener { void (*region_add)(MemoryListener *listener, MemoryRegionSection *section); void (*region_del)(MemoryListener *listener, MemoryRegionSection *section); void (*region_nop)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_start)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_stop)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_sync)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_global_start)(MemoryListener *listener); - void (*log_global_stop)(MemoryListener *listener); /* Lower = earlier (during add), later (during del) */ unsigned priority; AddressSpace *address_space_filter; @@ -311,16 +299,6 @@ uint64_t memory_region_size(MemoryRegion *mr); */ bool memory_region_is_ram(MemoryRegion *mr); -/** - * memory_region_is_skip_dump: check whether a memory region should not be - * dumped - * - * Returns %true is a memory region should not be dumped(e.g. VFIO BAR MMAP). - * - * @mr: the memory region being queried - */ -bool memory_region_is_skip_dump(MemoryRegion *mr); - /** * memory_region_is_iommu: check whether a memory region is an iommu * @@ -350,15 +328,6 @@ void memory_region_notify_iommu(MemoryRegion *mr, */ const char *memory_region_name(const MemoryRegion *mr); -/** - * memory_region_is_logging: return whether a memory region is logging writes - * - * Returns %true if the memory region is logging writes - * - * @mr: the memory region being queried - */ -bool memory_region_is_logging(MemoryRegion *mr); - /** * memory_region_is_rom: check whether a memory region is ROM * diff --git a/qemu/memory.c b/qemu/memory.c index 3a0ff786..c91631b7 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -263,8 +263,6 @@ struct FlatRange { MemoryRegion *mr; hwaddr offset_in_region; AddrRange addr; - uint8_t dirty_log_mask; - bool romd_mode; bool readonly; }; @@ -288,7 +286,6 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b) return a->mr == b->mr && addrrange_equal(a->addr, b->addr) && a->offset_in_region == b->offset_in_region - && a->romd_mode == b->romd_mode && a->readonly == b->readonly; } @@ -341,8 +338,6 @@ static bool can_merge(FlatRange *r1, FlatRange *r2) && int128_eq(int128_add(int128_make64(r1->offset_in_region), r1->addr.size), int128_make64(r2->offset_in_region)) - && r1->dirty_log_mask == r2->dirty_log_mask - && r1->romd_mode == r2->romd_mode && r1->readonly == r2->readonly; } @@ -543,13 +538,6 @@ static void render_memory_region(FlatView *view, clip = addrrange_intersection(tmp, clip); - if (mr->alias) { - int128_subfrom(&base, int128_make64(mr->alias->addr)); - int128_subfrom(&base, int128_make64(mr->alias_offset)); - render_memory_region(view, mr->alias, base, clip, readonly); - return; - } - /* Render subregions in priority order. */ QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) { render_memory_region(view, subregion, base, clip, readonly); @@ -564,8 +552,6 @@ static void render_memory_region(FlatView *view, remain = clip.size; fr.mr = mr; - fr.dirty_log_mask = mr->dirty_log_mask; - fr.romd_mode = mr->romd_mode; fr.readonly = readonly; /* Render the region itself into any gaps left by the current view. */ @@ -666,11 +652,6 @@ static void address_space_update_topology_pass(AddressSpace *as, if (adding) { MEMORY_LISTENER_UPDATE_REGION(frnew, as, Forward, region_nop); - if (frold->dirty_log_mask && !frnew->dirty_log_mask) { - MEMORY_LISTENER_UPDATE_REGION(frnew, as, Reverse, log_stop); - } else if (frnew->dirty_log_mask && !frold->dirty_log_mask) { - MEMORY_LISTENER_UPDATE_REGION(frnew, as, Forward, log_start); - } } ++iold; @@ -747,7 +728,6 @@ void memory_region_init(struct uc_struct *uc, MemoryRegion *mr, memset(mr, 0, sizeof(*mr)); mr->ops = &unassigned_mem_ops; mr->enabled = true; - mr->romd_mode = true; mr->destructor = memory_region_destructor_none; QTAILQ_INIT(&mr->subregions); @@ -938,26 +918,11 @@ bool memory_region_is_ram(MemoryRegion *mr) return mr->ram; } -bool memory_region_is_skip_dump(MemoryRegion *mr) -{ - return mr->skip_dump; -} - -bool memory_region_is_logging(MemoryRegion *mr) -{ - return mr->dirty_log_mask; -} - bool memory_region_is_rom(MemoryRegion *mr) { return mr->ram && mr->readonly; } -bool memory_region_is_iommu(MemoryRegion *mr) -{ - return mr->iommu_ops != 0; -} - void memory_region_set_readonly(MemoryRegion *mr, bool readonly) { if (mr->readonly != readonly) { @@ -975,12 +940,6 @@ void memory_region_set_readonly(MemoryRegion *mr, bool readonly) void *memory_region_get_ram_ptr(MemoryRegion *mr) { - if (mr->alias) { - return (char*)memory_region_get_ram_ptr(mr->alias) + mr->alias_offset; - } - - assert(mr->terminates); - return qemu_get_ram_ptr(mr->uc, mr->ram_addr & TARGET_PAGE_MASK); } @@ -1178,12 +1137,6 @@ static void listener_add_address_space(MemoryListener *listener, return; } - if (listener->address_space_filter->uc->global_dirty_log) { - if (listener->log_global_start) { - listener->log_global_start(listener); - } - } - view = address_space_get_flatview(as); FOR_EACH_FLAT_RANGE(fr, view) { MemoryRegionSection section = MemoryRegionSection_make(