[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 01/22] as_flat_walk
From: |
Steve Sistare |
Subject: |
[PATCH V2 01/22] as_flat_walk |
Date: |
Tue, 5 Jan 2021 07:41:49 -0800 |
Add an iterator over the sections of a flattened address space.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/exec/memory.h | 3 +++
softmmu/memory.c | 17 +++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 307e527..8dba065 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1894,6 +1894,9 @@ bool memory_region_present(MemoryRegion *container,
hwaddr addr);
*/
bool memory_region_is_mapped(MemoryRegion *mr);
+typedef int (*qemu_flat_walk_cb)(MemoryRegionSection *s, void *handle);
+int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, void *handle);
+
/**
* memory_region_find: translate an address/size relative to a
* MemoryRegion into a #MemoryRegionSection.
diff --git a/softmmu/memory.c b/softmmu/memory.c
index af25987..8cac3bc 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2513,6 +2513,23 @@ bool memory_region_is_mapped(MemoryRegion *mr)
return mr->container ? true : false;
}
+int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, void *handle)
+{
+ FlatView *view = address_space_get_flatview(as);
+ FlatRange *fr;
+ int ret;
+
+ FOR_EACH_FLAT_RANGE(fr, view) {
+ MemoryRegionSection section = section_from_flat_range(fr, view);
+ ret = func(§ion, handle);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
/* Same as memory_region_find, but it does not add a reference to the
* returned region. It must be called from an RCU critical section.
*/
--
1.8.3.1
- Re: [PATCH V2 18/22] chardev: cpr for sockets, (continued)
- [PATCH V2 19/22] monitor: cpr support, Steve Sistare, 2021/01/05
- [PATCH V2 17/22] chardev: socket accept subroutine, Steve Sistare, 2021/01/05
- [PATCH V2 20/22] cpr: only-cpr-capable option, Steve Sistare, 2021/01/05
- [PATCH V2 22/22] simplify savevm, Steve Sistare, 2021/01/05
- [PATCH V2 14/22] chardev: cpr framework, Steve Sistare, 2021/01/05
- [PATCH V2 21/22] cpr: maintainers, Steve Sistare, 2021/01/05
- [PATCH V2 02/22] qemu_ram_volatile, Steve Sistare, 2021/01/05
- [PATCH V2 13/22] vhost: reset vhost devices upon cprsave, Steve Sistare, 2021/01/05
- [PATCH V2 01/22] as_flat_walk,
Steve Sistare <=
- [PATCH V2 11/22] vfio-pci: refactor for cpr, Steve Sistare, 2021/01/05
- [PATCH V2 15/22] chardev: cpr for simple devices, Steve Sistare, 2021/01/05