|
|
9bac43 |
From f343747d64a32b4642b7969f97d43d820cc2d8ce Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Date: Thu, 16 Nov 2017 03:07:19 +0100
|
|
|
9bac43 |
Subject: [PATCH 15/30] memory: Switch memory from using AddressSpace to
|
|
|
9bac43 |
FlatView
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Message-id: <20171116030732.8560-10-dgibson@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 77694
|
|
|
9bac43 |
O-Subject: [PATCH 09/22] memory: Switch memory from using AddressSpace to FlatView
|
|
|
9bac43 |
Bugzilla: 1481593
|
|
|
9bac43 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
9bac43 |
|
|
|
9bac43 |
FlatView's will be shared between AddressSpace's and subpage_t
|
|
|
9bac43 |
and MemoryRegionSection cannot store AS anymore, hence this change.
|
|
|
9bac43 |
|
|
|
9bac43 |
In particular, for:
|
|
|
9bac43 |
|
|
|
9bac43 |
typedef struct subpage_t {
|
|
|
9bac43 |
MemoryRegion iomem;
|
|
|
9bac43 |
- AddressSpace *as;
|
|
|
9bac43 |
+ FlatView *fv;
|
|
|
9bac43 |
hwaddr base;
|
|
|
9bac43 |
uint16_t sub_section[];
|
|
|
9bac43 |
} subpage_t;
|
|
|
9bac43 |
|
|
|
9bac43 |
struct MemoryRegionSection {
|
|
|
9bac43 |
MemoryRegion *mr;
|
|
|
9bac43 |
- AddressSpace *address_space;
|
|
|
9bac43 |
+ FlatView *fv;
|
|
|
9bac43 |
hwaddr offset_within_region;
|
|
|
9bac43 |
Int128 size;
|
|
|
9bac43 |
hwaddr offset_within_address_space;
|
|
|
9bac43 |
bool readonly;
|
|
|
9bac43 |
};
|
|
|
9bac43 |
|
|
|
9bac43 |
This should cause no behavioural change.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
9bac43 |
Message-Id: <20170921085110.25598-7-aik@ozlabs.ru>
|
|
|
9bac43 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit 166206845f7fd75e720e6feea0bb01957c8da07f)
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Conflicts:
|
|
|
9bac43 |
exec.c
|
|
|
9bac43 |
|
|
|
9bac43 |
Conflicts because we applied d5e5fafd "exec: add page_mask for
|
|
|
9bac43 |
flatview_do_translate" out of order downstream.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
exec.c | 183 ++++++++++++++++++++++++-----------------
|
|
|
9bac43 |
hw/intc/openpic_kvm.c | 2 +-
|
|
|
9bac43 |
include/exec/memory-internal.h | 2 +-
|
|
|
9bac43 |
include/exec/memory.h | 51 ++++++++----
|
|
|
9bac43 |
memory.c | 33 ++++----
|
|
|
9bac43 |
5 files changed, 161 insertions(+), 110 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/exec.c b/exec.c
|
|
|
9bac43 |
index 6b84771..0eedeb2 100644
|
|
|
9bac43 |
--- a/exec.c
|
|
|
9bac43 |
+++ b/exec.c
|
|
|
9bac43 |
@@ -199,7 +199,7 @@ struct AddressSpaceDispatch {
|
|
|
9bac43 |
#define SUBPAGE_IDX(addr) ((addr) & ~TARGET_PAGE_MASK)
|
|
|
9bac43 |
typedef struct subpage_t {
|
|
|
9bac43 |
MemoryRegion iomem;
|
|
|
9bac43 |
- AddressSpace *as;
|
|
|
9bac43 |
+ FlatView *fv;
|
|
|
9bac43 |
hwaddr base;
|
|
|
9bac43 |
uint16_t sub_section[];
|
|
|
9bac43 |
} subpage_t;
|
|
|
9bac43 |
@@ -469,14 +469,14 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* Called from RCU critical section */
|
|
|
9bac43 |
-static MemoryRegionSection address_space_do_translate(AddressSpace *as,
|
|
|
9bac43 |
- hwaddr addr,
|
|
|
9bac43 |
- hwaddr *xlat,
|
|
|
9bac43 |
- hwaddr *plen_out,
|
|
|
9bac43 |
- hwaddr *page_mask_out,
|
|
|
9bac43 |
- bool is_write,
|
|
|
9bac43 |
- bool is_mmio,
|
|
|
9bac43 |
- AddressSpace **target_as)
|
|
|
9bac43 |
+static MemoryRegionSection flatview_do_translate(FlatView *fv,
|
|
|
9bac43 |
+ hwaddr addr,
|
|
|
9bac43 |
+ hwaddr *xlat,
|
|
|
9bac43 |
+ hwaddr *plen_out,
|
|
|
9bac43 |
+ hwaddr *page_mask_out,
|
|
|
9bac43 |
+ bool is_write,
|
|
|
9bac43 |
+ bool is_mmio,
|
|
|
9bac43 |
+ AddressSpace **target_as)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
IOMMUTLBEntry iotlb;
|
|
|
9bac43 |
MemoryRegionSection *section;
|
|
|
9bac43 |
@@ -490,8 +490,9 @@ static MemoryRegionSection address_space_do_translate(AddressSpace *as,
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
for (;;) {
|
|
|
9bac43 |
- AddressSpaceDispatch *d = address_space_to_dispatch(as);
|
|
|
9bac43 |
- section = address_space_translate_internal(d, addr, &addr, &plen, is_mmio);
|
|
|
9bac43 |
+ section = address_space_translate_internal(
|
|
|
9bac43 |
+ flatview_to_dispatch(fv), addr, &addr,
|
|
|
9bac43 |
+ &plen, is_mmio);
|
|
|
9bac43 |
|
|
|
9bac43 |
iommu_mr = memory_region_get_iommu(section->mr);
|
|
|
9bac43 |
if (!iommu_mr) {
|
|
|
9bac43 |
@@ -509,7 +510,7 @@ static MemoryRegionSection address_space_do_translate(AddressSpace *as,
|
|
|
9bac43 |
goto translate_fail;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
- as = iotlb.target_as;
|
|
|
9bac43 |
+ fv = address_space_to_flatview(iotlb.target_as);
|
|
|
9bac43 |
*target_as = iotlb.target_as;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
@@ -545,8 +546,8 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
* This can never be MMIO, and we don't really care about plen,
|
|
|
9bac43 |
* but page mask.
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
- section = address_space_do_translate(as, addr, &xlat, NULL,
|
|
|
9bac43 |
- &page_mask, is_write, false, &as);
|
|
|
9bac43 |
+ section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat, NULL,
|
|
|
9bac43 |
+ &page_mask, is_write, false, &as);
|
|
|
9bac43 |
|
|
|
9bac43 |
/* Illegal translation */
|
|
|
9bac43 |
if (section.mr == &io_mem_unassigned) {
|
|
|
9bac43 |
@@ -571,16 +572,16 @@ iotlb_fail:
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* Called from RCU critical section */
|
|
|
9bac43 |
-MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- hwaddr *xlat, hwaddr *plen,
|
|
|
9bac43 |
- bool is_write)
|
|
|
9bac43 |
+MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
|
|
|
9bac43 |
+ hwaddr *plen, bool is_write)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
MemoryRegion *mr;
|
|
|
9bac43 |
MemoryRegionSection section;
|
|
|
9bac43 |
+ AddressSpace *as = NULL;
|
|
|
9bac43 |
|
|
|
9bac43 |
/* This can be MMIO, so setup MMIO bit. */
|
|
|
9bac43 |
- section = address_space_do_translate(as, addr, xlat, plen, NULL,
|
|
|
9bac43 |
- is_write, true, &as);
|
|
|
9bac43 |
+ section = flatview_do_translate(fv, addr, xlat, plen, NULL,
|
|
|
9bac43 |
+ is_write, true, &as);
|
|
|
9bac43 |
mr = section.mr;
|
|
|
9bac43 |
|
|
|
9bac43 |
if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
|
|
|
9bac43 |
@@ -1230,7 +1231,7 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,
|
|
|
9bac43 |
} else {
|
|
|
9bac43 |
AddressSpaceDispatch *d;
|
|
|
9bac43 |
|
|
|
9bac43 |
- d = address_space_to_dispatch(section->address_space);
|
|
|
9bac43 |
+ d = flatview_to_dispatch(section->fv);
|
|
|
9bac43 |
iotlb = section - d->map.sections;
|
|
|
9bac43 |
iotlb += xlat;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -1256,7 +1257,7 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,
|
|
|
9bac43 |
|
|
|
9bac43 |
static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
|
|
|
9bac43 |
uint16_t section);
|
|
|
9bac43 |
-static subpage_t *subpage_init(AddressSpace *as, hwaddr base);
|
|
|
9bac43 |
+static subpage_t *subpage_init(FlatView *fv, hwaddr base);
|
|
|
9bac43 |
|
|
|
9bac43 |
static void *(*phys_mem_alloc)(size_t size, uint64_t *align) =
|
|
|
9bac43 |
qemu_anon_ram_alloc;
|
|
|
9bac43 |
@@ -1313,7 +1314,7 @@ static void phys_sections_free(PhysPageMap *map)
|
|
|
9bac43 |
g_free(map->nodes);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-static void register_subpage(AddressSpace *as, AddressSpaceDispatch *d,
|
|
|
9bac43 |
+static void register_subpage(FlatView *fv, AddressSpaceDispatch *d,
|
|
|
9bac43 |
MemoryRegionSection *section)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
subpage_t *subpage;
|
|
|
9bac43 |
@@ -1329,8 +1330,8 @@ static void register_subpage(AddressSpace *as, AddressSpaceDispatch *d,
|
|
|
9bac43 |
assert(existing->mr->subpage || existing->mr == &io_mem_unassigned);
|
|
|
9bac43 |
|
|
|
9bac43 |
if (!(existing->mr->subpage)) {
|
|
|
9bac43 |
- subpage = subpage_init(as, base);
|
|
|
9bac43 |
- subsection.address_space = as;
|
|
|
9bac43 |
+ subpage = subpage_init(fv, base);
|
|
|
9bac43 |
+ subsection.fv = fv;
|
|
|
9bac43 |
subsection.mr = &subpage->iomem;
|
|
|
9bac43 |
phys_page_set(d, base >> TARGET_PAGE_BITS, 1,
|
|
|
9bac43 |
phys_section_add(&d->map, &subsection));
|
|
|
9bac43 |
@@ -1356,7 +1357,7 @@ static void register_multipage(AddressSpaceDispatch *d,
|
|
|
9bac43 |
phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-void mem_add(AddressSpace *as, FlatView *fv, MemoryRegionSection *section)
|
|
|
9bac43 |
+void mem_add(FlatView *fv, MemoryRegionSection *section)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
AddressSpaceDispatch *d = flatview_to_dispatch(fv);
|
|
|
9bac43 |
MemoryRegionSection now = *section, remain = *section;
|
|
|
9bac43 |
@@ -1367,7 +1368,7 @@ void mem_add(AddressSpace *as, FlatView *fv, MemoryRegionSection *section)
|
|
|
9bac43 |
- now.offset_within_address_space;
|
|
|
9bac43 |
|
|
|
9bac43 |
now.size = int128_min(int128_make64(left), now.size);
|
|
|
9bac43 |
- register_subpage(as, d, &now;;
|
|
|
9bac43 |
+ register_subpage(fv, d, &now;;
|
|
|
9bac43 |
} else {
|
|
|
9bac43 |
now.size = int128_zero();
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -1377,10 +1378,10 @@ void mem_add(AddressSpace *as, FlatView *fv, MemoryRegionSection *section)
|
|
|
9bac43 |
remain.offset_within_region += int128_get64(now.size);
|
|
|
9bac43 |
now = remain;
|
|
|
9bac43 |
if (int128_lt(remain.size, page_size)) {
|
|
|
9bac43 |
- register_subpage(as, d, &now;;
|
|
|
9bac43 |
+ register_subpage(fv, d, &now;;
|
|
|
9bac43 |
} else if (remain.offset_within_address_space & ~TARGET_PAGE_MASK) {
|
|
|
9bac43 |
now.size = page_size;
|
|
|
9bac43 |
- register_subpage(as, d, &now;;
|
|
|
9bac43 |
+ register_subpage(fv, d, &now;;
|
|
|
9bac43 |
} else {
|
|
|
9bac43 |
now.size = int128_and(now.size, int128_neg(page_size));
|
|
|
9bac43 |
register_multipage(d, &now;;
|
|
|
9bac43 |
@@ -2511,6 +2512,11 @@ static const MemoryRegionOps watch_mem_ops = {
|
|
|
9bac43 |
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
9bac43 |
};
|
|
|
9bac43 |
|
|
|
9bac43 |
+static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
+ const uint8_t *buf, int len);
|
|
|
9bac43 |
+static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
|
|
|
9bac43 |
+ bool is_write);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data,
|
|
|
9bac43 |
unsigned len, MemTxAttrs attrs)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
@@ -2522,8 +2528,7 @@ static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data,
|
|
|
9bac43 |
printf("%s: subpage %p len %u addr " TARGET_FMT_plx "\n", __func__,
|
|
|
9bac43 |
subpage, len, addr);
|
|
|
9bac43 |
#endif
|
|
|
9bac43 |
- res = address_space_read(subpage->as, addr + subpage->base,
|
|
|
9bac43 |
- attrs, buf, len);
|
|
|
9bac43 |
+ res = flatview_read(subpage->fv, addr + subpage->base, attrs, buf, len);
|
|
|
9bac43 |
if (res) {
|
|
|
9bac43 |
return res;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -2572,8 +2577,7 @@ static MemTxResult subpage_write(void *opaque, hwaddr addr,
|
|
|
9bac43 |
default:
|
|
|
9bac43 |
abort();
|
|
|
9bac43 |
}
|
|
|
9bac43 |
- return address_space_write(subpage->as, addr + subpage->base,
|
|
|
9bac43 |
- attrs, buf, len);
|
|
|
9bac43 |
+ return flatview_write(subpage->fv, addr + subpage->base, attrs, buf, len);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
static bool subpage_accepts(void *opaque, hwaddr addr,
|
|
|
9bac43 |
@@ -2585,8 +2589,8 @@ static bool subpage_accepts(void *opaque, hwaddr addr,
|
|
|
9bac43 |
__func__, subpage, is_write ? 'w' : 'r', len, addr);
|
|
|
9bac43 |
#endif
|
|
|
9bac43 |
|
|
|
9bac43 |
- return address_space_access_valid(subpage->as, addr + subpage->base,
|
|
|
9bac43 |
- len, is_write);
|
|
|
9bac43 |
+ return flatview_access_valid(subpage->fv, addr + subpage->base,
|
|
|
9bac43 |
+ len, is_write);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
static const MemoryRegionOps subpage_ops = {
|
|
|
9bac43 |
@@ -2620,12 +2624,12 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
|
|
|
9bac43 |
return 0;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-static subpage_t *subpage_init(AddressSpace *as, hwaddr base)
|
|
|
9bac43 |
+static subpage_t *subpage_init(FlatView *fv, hwaddr base)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
subpage_t *mmio;
|
|
|
9bac43 |
|
|
|
9bac43 |
mmio = g_malloc0(sizeof(subpage_t) + TARGET_PAGE_SIZE * sizeof(uint16_t));
|
|
|
9bac43 |
- mmio->as = as;
|
|
|
9bac43 |
+ mmio->fv = fv;
|
|
|
9bac43 |
mmio->base = base;
|
|
|
9bac43 |
memory_region_init_io(&mmio->iomem, NULL, &subpage_ops, mmio,
|
|
|
9bac43 |
NULL, TARGET_PAGE_SIZE);
|
|
|
9bac43 |
@@ -2639,12 +2643,11 @@ static subpage_t *subpage_init(AddressSpace *as, hwaddr base)
|
|
|
9bac43 |
return mmio;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-static uint16_t dummy_section(PhysPageMap *map, AddressSpace *as,
|
|
|
9bac43 |
- MemoryRegion *mr)
|
|
|
9bac43 |
+static uint16_t dummy_section(PhysPageMap *map, FlatView *fv, MemoryRegion *mr)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
- assert(as);
|
|
|
9bac43 |
+ assert(fv);
|
|
|
9bac43 |
MemoryRegionSection section = {
|
|
|
9bac43 |
- .address_space = as,
|
|
|
9bac43 |
+ .fv = fv,
|
|
|
9bac43 |
.mr = mr,
|
|
|
9bac43 |
.offset_within_address_space = 0,
|
|
|
9bac43 |
.offset_within_region = 0,
|
|
|
9bac43 |
@@ -2683,16 +2686,17 @@ static void io_mem_init(void)
|
|
|
9bac43 |
|
|
|
9bac43 |
AddressSpaceDispatch *mem_begin(AddressSpace *as)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
+ FlatView *fv = address_space_to_flatview(as);
|
|
|
9bac43 |
AddressSpaceDispatch *d = g_new0(AddressSpaceDispatch, 1);
|
|
|
9bac43 |
uint16_t n;
|
|
|
9bac43 |
|
|
|
9bac43 |
- n = dummy_section(&d->map, as, &io_mem_unassigned);
|
|
|
9bac43 |
+ n = dummy_section(&d->map, fv, &io_mem_unassigned);
|
|
|
9bac43 |
assert(n == PHYS_SECTION_UNASSIGNED);
|
|
|
9bac43 |
- n = dummy_section(&d->map, as, &io_mem_notdirty);
|
|
|
9bac43 |
+ n = dummy_section(&d->map, fv, &io_mem_notdirty);
|
|
|
9bac43 |
assert(n == PHYS_SECTION_NOTDIRTY);
|
|
|
9bac43 |
- n = dummy_section(&d->map, as, &io_mem_rom);
|
|
|
9bac43 |
+ n = dummy_section(&d->map, fv, &io_mem_rom);
|
|
|
9bac43 |
assert(n == PHYS_SECTION_ROM);
|
|
|
9bac43 |
- n = dummy_section(&d->map, as, &io_mem_watch);
|
|
|
9bac43 |
+ n = dummy_section(&d->map, fv, &io_mem_watch);
|
|
|
9bac43 |
assert(n == PHYS_SECTION_WATCH);
|
|
|
9bac43 |
|
|
|
9bac43 |
d->phys_map = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .skip = 1 };
|
|
|
9bac43 |
@@ -2872,11 +2876,11 @@ static bool prepare_mmio_access(MemoryRegion *mr)
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* Called within RCU critical section. */
|
|
|
9bac43 |
-static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- MemTxAttrs attrs,
|
|
|
9bac43 |
- const uint8_t *buf,
|
|
|
9bac43 |
- int len, hwaddr addr1,
|
|
|
9bac43 |
- hwaddr l, MemoryRegion *mr)
|
|
|
9bac43 |
+static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs,
|
|
|
9bac43 |
+ const uint8_t *buf,
|
|
|
9bac43 |
+ int len, hwaddr addr1,
|
|
|
9bac43 |
+ hwaddr l, MemoryRegion *mr)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
uint8_t *ptr;
|
|
|
9bac43 |
uint64_t val;
|
|
|
9bac43 |
@@ -2938,14 +2942,14 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &addr1, &l, true);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &addr1, &l, true);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
return result;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
- const uint8_t *buf, int len)
|
|
|
9bac43 |
+static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
+ const uint8_t *buf, int len)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
hwaddr l;
|
|
|
9bac43 |
hwaddr addr1;
|
|
|
9bac43 |
@@ -2955,20 +2959,27 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
if (len > 0) {
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &addr1, &l, true);
|
|
|
9bac43 |
- result = address_space_write_continue(as, addr, attrs, buf, len,
|
|
|
9bac43 |
- addr1, l, mr);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &addr1, &l, true);
|
|
|
9bac43 |
+ result = flatview_write_continue(fv, addr, attrs, buf, len,
|
|
|
9bac43 |
+ addr1, l, mr);
|
|
|
9bac43 |
rcu_read_unlock();
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
return result;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs,
|
|
|
9bac43 |
+ const uint8_t *buf, int len)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ return flatview_write(address_space_to_flatview(as), addr, attrs, buf, len);
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
/* Called within RCU critical section. */
|
|
|
9bac43 |
-MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- MemTxAttrs attrs, uint8_t *buf,
|
|
|
9bac43 |
- int len, hwaddr addr1, hwaddr l,
|
|
|
9bac43 |
- MemoryRegion *mr)
|
|
|
9bac43 |
+MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs, uint8_t *buf,
|
|
|
9bac43 |
+ int len, hwaddr addr1, hwaddr l,
|
|
|
9bac43 |
+ MemoryRegion *mr)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
uint8_t *ptr;
|
|
|
9bac43 |
uint64_t val;
|
|
|
9bac43 |
@@ -3028,14 +3039,14 @@ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &addr1, &l, false);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &addr1, &l, false);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
return result;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- MemTxAttrs attrs, uint8_t *buf, int len)
|
|
|
9bac43 |
+MemTxResult flatview_read_full(FlatView *fv, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs, uint8_t *buf, int len)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
hwaddr l;
|
|
|
9bac43 |
hwaddr addr1;
|
|
|
9bac43 |
@@ -3045,25 +3056,33 @@ MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
if (len > 0) {
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &addr1, &l, false);
|
|
|
9bac43 |
- result = address_space_read_continue(as, addr, attrs, buf, len,
|
|
|
9bac43 |
- addr1, l, mr);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &addr1, &l, false);
|
|
|
9bac43 |
+ result = flatview_read_continue(fv, addr, attrs, buf, len,
|
|
|
9bac43 |
+ addr1, l, mr);
|
|
|
9bac43 |
rcu_read_unlock();
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
return result;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
- uint8_t *buf, int len, bool is_write)
|
|
|
9bac43 |
+static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
+ uint8_t *buf, int len, bool is_write)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
if (is_write) {
|
|
|
9bac43 |
- return address_space_write(as, addr, attrs, (uint8_t *)buf, len);
|
|
|
9bac43 |
+ return flatview_write(fv, addr, attrs, (uint8_t *)buf, len);
|
|
|
9bac43 |
} else {
|
|
|
9bac43 |
- return address_space_read(as, addr, attrs, (uint8_t *)buf, len);
|
|
|
9bac43 |
+ return flatview_read(fv, addr, attrs, (uint8_t *)buf, len);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs, uint8_t *buf,
|
|
|
9bac43 |
+ int len, bool is_write)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ return flatview_rw(address_space_to_flatview(as),
|
|
|
9bac43 |
+ addr, attrs, buf, len, is_write);
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
|
|
|
9bac43 |
int len, int is_write)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
@@ -3221,7 +3240,8 @@ static void cpu_notify_map_clients(void)
|
|
|
9bac43 |
qemu_mutex_unlock(&map_client_list_lock);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write)
|
|
|
9bac43 |
+static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
|
|
|
9bac43 |
+ bool is_write)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
MemoryRegion *mr;
|
|
|
9bac43 |
hwaddr l, xlat;
|
|
|
9bac43 |
@@ -3229,7 +3249,7 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
while (len > 0) {
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &xlat, &l, is_write);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &xlat, &l, is_write);
|
|
|
9bac43 |
if (!memory_access_is_direct(mr, is_write)) {
|
|
|
9bac43 |
l = memory_access_size(mr, l, addr);
|
|
|
9bac43 |
if (!memory_region_access_valid(mr, xlat, l, is_write)) {
|
|
|
9bac43 |
@@ -3245,8 +3265,16 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_
|
|
|
9bac43 |
return true;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+bool address_space_access_valid(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
+ int len, bool is_write)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ return flatview_access_valid(address_space_to_flatview(as),
|
|
|
9bac43 |
+ addr, len, is_write);
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
static hwaddr
|
|
|
9bac43 |
-address_space_extend_translation(AddressSpace *as, hwaddr addr, hwaddr target_len,
|
|
|
9bac43 |
+flatview_extend_translation(FlatView *fv, hwaddr addr,
|
|
|
9bac43 |
+ hwaddr target_len,
|
|
|
9bac43 |
MemoryRegion *mr, hwaddr base, hwaddr len,
|
|
|
9bac43 |
bool is_write)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
@@ -3263,7 +3291,8 @@ address_space_extend_translation(AddressSpace *as, hwaddr addr, hwaddr target_le
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
len = target_len;
|
|
|
9bac43 |
- this_mr = address_space_translate(as, addr, &xlat, &len, is_write);
|
|
|
9bac43 |
+ this_mr = flatview_translate(fv, addr, &xlat,
|
|
|
9bac43 |
+ &len, is_write);
|
|
|
9bac43 |
if (this_mr != mr || xlat != base + done) {
|
|
|
9bac43 |
return done;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -3286,6 +3315,7 @@ void *address_space_map(AddressSpace *as,
|
|
|
9bac43 |
hwaddr l, xlat;
|
|
|
9bac43 |
MemoryRegion *mr;
|
|
|
9bac43 |
void *ptr;
|
|
|
9bac43 |
+ FlatView *fv = address_space_to_flatview(as);
|
|
|
9bac43 |
|
|
|
9bac43 |
if (len == 0) {
|
|
|
9bac43 |
return NULL;
|
|
|
9bac43 |
@@ -3293,7 +3323,7 @@ void *address_space_map(AddressSpace *as,
|
|
|
9bac43 |
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &xlat, &l, is_write);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &xlat, &l, is_write);
|
|
|
9bac43 |
|
|
|
9bac43 |
if (!memory_access_is_direct(mr, is_write)) {
|
|
|
9bac43 |
if (atomic_xchg(&bounce.in_use, true)) {
|
|
|
9bac43 |
@@ -3309,7 +3339,7 @@ void *address_space_map(AddressSpace *as,
|
|
|
9bac43 |
memory_region_ref(mr);
|
|
|
9bac43 |
bounce.mr = mr;
|
|
|
9bac43 |
if (!is_write) {
|
|
|
9bac43 |
- address_space_read(as, addr, MEMTXATTRS_UNSPECIFIED,
|
|
|
9bac43 |
+ flatview_read(fv, addr, MEMTXATTRS_UNSPECIFIED,
|
|
|
9bac43 |
bounce.buffer, l);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
@@ -3320,7 +3350,8 @@ void *address_space_map(AddressSpace *as,
|
|
|
9bac43 |
|
|
|
9bac43 |
|
|
|
9bac43 |
memory_region_ref(mr);
|
|
|
9bac43 |
- *plen = address_space_extend_translation(as, addr, len, mr, xlat, l, is_write);
|
|
|
9bac43 |
+ *plen = flatview_extend_translation(fv, addr, len, mr, xlat,
|
|
|
9bac43 |
+ l, is_write);
|
|
|
9bac43 |
ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true);
|
|
|
9bac43 |
rcu_read_unlock();
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
|
|
|
9bac43 |
index 0518e01..fa83420 100644
|
|
|
9bac43 |
--- a/hw/intc/openpic_kvm.c
|
|
|
9bac43 |
+++ b/hw/intc/openpic_kvm.c
|
|
|
9bac43 |
@@ -124,7 +124,7 @@ static void kvm_openpic_region_add(MemoryListener *listener,
|
|
|
9bac43 |
uint64_t reg_base;
|
|
|
9bac43 |
int ret;
|
|
|
9bac43 |
|
|
|
9bac43 |
- if (section->address_space != &address_space_memory) {
|
|
|
9bac43 |
+ if (section->fv != address_space_to_flatview(&address_space_memory)) {
|
|
|
9bac43 |
abort();
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
|
|
|
9bac43 |
index 6e08eda..1cf8ad9 100644
|
|
|
9bac43 |
--- a/include/exec/memory-internal.h
|
|
|
9bac43 |
+++ b/include/exec/memory-internal.h
|
|
|
9bac43 |
@@ -27,7 +27,7 @@ extern const MemoryRegionOps unassigned_mem_ops;
|
|
|
9bac43 |
bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,
|
|
|
9bac43 |
unsigned size, bool is_write);
|
|
|
9bac43 |
|
|
|
9bac43 |
-void mem_add(AddressSpace *as, FlatView *fv, MemoryRegionSection *section);
|
|
|
9bac43 |
+void mem_add(FlatView *fv, MemoryRegionSection *section);
|
|
|
9bac43 |
AddressSpaceDispatch *mem_begin(AddressSpace *as);
|
|
|
9bac43 |
void mem_commit(AddressSpaceDispatch *d);
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
|
9bac43 |
index 8f26d63..6715551 100644
|
|
|
9bac43 |
--- a/include/exec/memory.h
|
|
|
9bac43 |
+++ b/include/exec/memory.h
|
|
|
9bac43 |
@@ -48,6 +48,7 @@
|
|
|
9bac43 |
|
|
|
9bac43 |
typedef struct MemoryRegionOps MemoryRegionOps;
|
|
|
9bac43 |
typedef struct MemoryRegionMmio MemoryRegionMmio;
|
|
|
9bac43 |
+typedef struct FlatView FlatView;
|
|
|
9bac43 |
|
|
|
9bac43 |
struct MemoryRegionMmio {
|
|
|
9bac43 |
CPUReadMemoryFunc *read[3];
|
|
|
9bac43 |
@@ -330,6 +331,8 @@ struct AddressSpace {
|
|
|
9bac43 |
QTAILQ_ENTRY(AddressSpace) address_spaces_link;
|
|
|
9bac43 |
};
|
|
|
9bac43 |
|
|
|
9bac43 |
+FlatView *address_space_to_flatview(AddressSpace *as);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
/**
|
|
|
9bac43 |
* MemoryRegionSection: describes a fragment of a #MemoryRegion
|
|
|
9bac43 |
*
|
|
|
9bac43 |
@@ -343,7 +346,7 @@ struct AddressSpace {
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
struct MemoryRegionSection {
|
|
|
9bac43 |
MemoryRegion *mr;
|
|
|
9bac43 |
- AddressSpace *address_space;
|
|
|
9bac43 |
+ FlatView *fv;
|
|
|
9bac43 |
hwaddr offset_within_region;
|
|
|
9bac43 |
Int128 size;
|
|
|
9bac43 |
hwaddr offset_within_address_space;
|
|
|
9bac43 |
@@ -1852,9 +1855,17 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
* @len: pointer to length
|
|
|
9bac43 |
* @is_write: indicates the transfer direction
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
-MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- hwaddr *xlat, hwaddr *len,
|
|
|
9bac43 |
- bool is_write);
|
|
|
9bac43 |
+MemoryRegion *flatview_translate(FlatView *fv,
|
|
|
9bac43 |
+ hwaddr addr, hwaddr *xlat,
|
|
|
9bac43 |
+ hwaddr *len, bool is_write);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+static inline MemoryRegion *address_space_translate(AddressSpace *as,
|
|
|
9bac43 |
+ hwaddr addr, hwaddr *xlat,
|
|
|
9bac43 |
+ hwaddr *len, bool is_write)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ return flatview_translate(address_space_to_flatview(as),
|
|
|
9bac43 |
+ addr, xlat, len, is_write);
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* address_space_access_valid: check for validity of accessing an address
|
|
|
9bac43 |
* space range
|
|
|
9bac43 |
@@ -1905,12 +1916,13 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,
|
|
|
9bac43 |
|
|
|
9bac43 |
|
|
|
9bac43 |
/* Internal functions, part of the implementation of address_space_read. */
|
|
|
9bac43 |
-MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- MemTxAttrs attrs, uint8_t *buf,
|
|
|
9bac43 |
- int len, hwaddr addr1, hwaddr l,
|
|
|
9bac43 |
- MemoryRegion *mr);
|
|
|
9bac43 |
-MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
- MemTxAttrs attrs, uint8_t *buf, int len);
|
|
|
9bac43 |
+MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs, uint8_t *buf,
|
|
|
9bac43 |
+ int len, hwaddr addr1, hwaddr l,
|
|
|
9bac43 |
+ MemoryRegion *mr);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+MemTxResult flatview_read_full(FlatView *fv, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs, uint8_t *buf, int len);
|
|
|
9bac43 |
void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr);
|
|
|
9bac43 |
|
|
|
9bac43 |
static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)
|
|
|
9bac43 |
@@ -1937,8 +1949,8 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)
|
|
|
9bac43 |
* @buf: buffer with the data transferred
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
static inline __attribute__((__always_inline__))
|
|
|
9bac43 |
-MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
- uint8_t *buf, int len)
|
|
|
9bac43 |
+MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
+ uint8_t *buf, int len)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
MemTxResult result = MEMTX_OK;
|
|
|
9bac43 |
hwaddr l, addr1;
|
|
|
9bac43 |
@@ -1949,22 +1961,29 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
|
|
|
9bac43 |
if (len) {
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
l = len;
|
|
|
9bac43 |
- mr = address_space_translate(as, addr, &addr1, &l, false);
|
|
|
9bac43 |
+ mr = flatview_translate(fv, addr, &addr1, &l, false);
|
|
|
9bac43 |
if (len == l && memory_access_is_direct(mr, false)) {
|
|
|
9bac43 |
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
|
|
|
9bac43 |
memcpy(buf, ptr, len);
|
|
|
9bac43 |
} else {
|
|
|
9bac43 |
- result = address_space_read_continue(as, addr, attrs, buf, len,
|
|
|
9bac43 |
- addr1, l, mr);
|
|
|
9bac43 |
+ result = flatview_read_continue(fv, addr, attrs, buf, len,
|
|
|
9bac43 |
+ addr1, l, mr);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
rcu_read_unlock();
|
|
|
9bac43 |
}
|
|
|
9bac43 |
} else {
|
|
|
9bac43 |
- result = address_space_read_full(as, addr, attrs, buf, len);
|
|
|
9bac43 |
+ result = flatview_read_full(fv, addr, attrs, buf, len);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
return result;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+static inline MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
|
|
|
9bac43 |
+ MemTxAttrs attrs, uint8_t *buf,
|
|
|
9bac43 |
+ int len)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ return flatview_read(address_space_to_flatview(as), addr, attrs, buf, len);
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
/**
|
|
|
9bac43 |
* address_space_read_cached: read from a cached RAM region
|
|
|
9bac43 |
*
|
|
|
9bac43 |
diff --git a/memory.c b/memory.c
|
|
|
9bac43 |
index 41e2e67..6678a53 100644
|
|
|
9bac43 |
--- a/memory.c
|
|
|
9bac43 |
+++ b/memory.c
|
|
|
9bac43 |
@@ -154,7 +154,8 @@ enum ListenerDirection { Forward, Reverse };
|
|
|
9bac43 |
/* No need to ref/unref .mr, the FlatRange keeps it alive. */
|
|
|
9bac43 |
#define MEMORY_LISTENER_UPDATE_REGION(fr, as, dir, callback, _args...) \
|
|
|
9bac43 |
do { \
|
|
|
9bac43 |
- MemoryRegionSection mrs = section_from_flat_range(fr, as); \
|
|
|
9bac43 |
+ MemoryRegionSection mrs = section_from_flat_range(fr, \
|
|
|
9bac43 |
+ address_space_to_flatview(as)); \
|
|
|
9bac43 |
MEMORY_LISTENER_CALL(as, callback, dir, &mrs, ##_args); \
|
|
|
9bac43 |
} while(0)
|
|
|
9bac43 |
|
|
|
9bac43 |
@@ -208,7 +209,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a,
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
typedef struct FlatRange FlatRange;
|
|
|
9bac43 |
-typedef struct FlatView FlatView;
|
|
|
9bac43 |
|
|
|
9bac43 |
/* Range of memory in the global map. Addresses are absolute. */
|
|
|
9bac43 |
struct FlatRange {
|
|
|
9bac43 |
@@ -238,11 +238,11 @@ typedef struct AddressSpaceOps AddressSpaceOps;
|
|
|
9bac43 |
for (var = (view)->ranges; var < (view)->ranges + (view)->nr; ++var)
|
|
|
9bac43 |
|
|
|
9bac43 |
static inline MemoryRegionSection
|
|
|
9bac43 |
-section_from_flat_range(FlatRange *fr, AddressSpace *as)
|
|
|
9bac43 |
+section_from_flat_range(FlatRange *fr, FlatView *fv)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
return (MemoryRegionSection) {
|
|
|
9bac43 |
.mr = fr->mr,
|
|
|
9bac43 |
- .address_space = as,
|
|
|
9bac43 |
+ .fv = fv,
|
|
|
9bac43 |
.offset_within_region = fr->offset_in_region,
|
|
|
9bac43 |
.size = fr->addr.size,
|
|
|
9bac43 |
.offset_within_address_space = int128_get64(fr->addr.start),
|
|
|
9bac43 |
@@ -312,7 +312,7 @@ static void flatview_unref(FlatView *view)
|
|
|
9bac43 |
}
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
-static FlatView *address_space_to_flatview(AddressSpace *as)
|
|
|
9bac43 |
+FlatView *address_space_to_flatview(AddressSpace *as)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
return atomic_rcu_read(&as->current_map);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -760,7 +760,7 @@ static void address_space_add_del_ioeventfds(AddressSpace *as,
|
|
|
9bac43 |
fds_new[inew]))) {
|
|
|
9bac43 |
fd = &fds_old[iold];
|
|
|
9bac43 |
section = (MemoryRegionSection) {
|
|
|
9bac43 |
- .address_space = as,
|
|
|
9bac43 |
+ .fv = address_space_to_flatview(as),
|
|
|
9bac43 |
.offset_within_address_space = int128_get64(fd->addr.start),
|
|
|
9bac43 |
.size = fd->addr.size,
|
|
|
9bac43 |
};
|
|
|
9bac43 |
@@ -773,7 +773,7 @@ static void address_space_add_del_ioeventfds(AddressSpace *as,
|
|
|
9bac43 |
fds_old[iold]))) {
|
|
|
9bac43 |
fd = &fds_new[inew];
|
|
|
9bac43 |
section = (MemoryRegionSection) {
|
|
|
9bac43 |
- .address_space = as,
|
|
|
9bac43 |
+ .fv = address_space_to_flatview(as),
|
|
|
9bac43 |
.offset_within_address_space = int128_get64(fd->addr.start),
|
|
|
9bac43 |
.size = fd->addr.size,
|
|
|
9bac43 |
};
|
|
|
9bac43 |
@@ -793,7 +793,7 @@ static FlatView *address_space_get_flatview(AddressSpace *as)
|
|
|
9bac43 |
|
|
|
9bac43 |
rcu_read_lock();
|
|
|
9bac43 |
do {
|
|
|
9bac43 |
- view = atomic_rcu_read(&as->current_map);
|
|
|
9bac43 |
+ view = address_space_to_flatview(as);
|
|
|
9bac43 |
/* If somebody has replaced as->current_map concurrently,
|
|
|
9bac43 |
* flatview_ref returns false.
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
@@ -912,8 +912,8 @@ static void address_space_update_topology(AddressSpace *as)
|
|
|
9bac43 |
new_view->dispatch = mem_begin(as);
|
|
|
9bac43 |
for (i = 0; i < new_view->nr; i++) {
|
|
|
9bac43 |
MemoryRegionSection mrs =
|
|
|
9bac43 |
- section_from_flat_range(&new_view->ranges[i], as);
|
|
|
9bac43 |
- mem_add(as, new_view, &mrs);
|
|
|
9bac43 |
+ section_from_flat_range(&new_view->ranges[i], new_view);
|
|
|
9bac43 |
+ mem_add(new_view, &mrs);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
mem_commit(new_view->dispatch);
|
|
|
9bac43 |
|
|
|
9bac43 |
@@ -1869,7 +1869,7 @@ void memory_region_sync_dirty_bitmap(MemoryRegion *mr)
|
|
|
9bac43 |
view = address_space_get_flatview(as);
|
|
|
9bac43 |
FOR_EACH_FLAT_RANGE(fr, view) {
|
|
|
9bac43 |
if (fr->mr == mr) {
|
|
|
9bac43 |
- MemoryRegionSection mrs = section_from_flat_range(fr, as);
|
|
|
9bac43 |
+ MemoryRegionSection mrs = section_from_flat_range(fr, view);
|
|
|
9bac43 |
listener->log_sync(listener, &mrs);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -1972,7 +1972,7 @@ static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpa
|
|
|
9bac43 |
FOR_EACH_FLAT_RANGE(fr, view) {
|
|
|
9bac43 |
if (fr->mr == mr) {
|
|
|
9bac43 |
section = (MemoryRegionSection) {
|
|
|
9bac43 |
- .address_space = as,
|
|
|
9bac43 |
+ .fv = view,
|
|
|
9bac43 |
.offset_within_address_space = int128_get64(fr->addr.start),
|
|
|
9bac43 |
.size = fr->addr.size,
|
|
|
9bac43 |
};
|
|
|
9bac43 |
@@ -2323,7 +2323,7 @@ static MemoryRegionSection memory_region_find_rcu(MemoryRegion *mr,
|
|
|
9bac43 |
}
|
|
|
9bac43 |
range = addrrange_make(int128_make64(addr), int128_make64(size));
|
|
|
9bac43 |
|
|
|
9bac43 |
- view = atomic_rcu_read(&as->current_map);
|
|
|
9bac43 |
+ view = address_space_to_flatview(as);
|
|
|
9bac43 |
fr = flatview_lookup(view, range);
|
|
|
9bac43 |
if (!fr) {
|
|
|
9bac43 |
return ret;
|
|
|
9bac43 |
@@ -2334,7 +2334,7 @@ static MemoryRegionSection memory_region_find_rcu(MemoryRegion *mr,
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
ret.mr = fr->mr;
|
|
|
9bac43 |
- ret.address_space = as;
|
|
|
9bac43 |
+ ret.fv = view;
|
|
|
9bac43 |
range = addrrange_intersection(range, fr->addr);
|
|
|
9bac43 |
ret.offset_within_region = fr->offset_in_region;
|
|
|
9bac43 |
ret.offset_within_region += int128_get64(int128_sub(range.start,
|
|
|
9bac43 |
@@ -2383,7 +2383,8 @@ void memory_global_dirty_log_sync(void)
|
|
|
9bac43 |
view = address_space_get_flatview(as);
|
|
|
9bac43 |
FOR_EACH_FLAT_RANGE(fr, view) {
|
|
|
9bac43 |
if (fr->dirty_log_mask) {
|
|
|
9bac43 |
- MemoryRegionSection mrs = section_from_flat_range(fr, as);
|
|
|
9bac43 |
+ MemoryRegionSection mrs = section_from_flat_range(fr, view);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
listener->log_sync(listener, &mrs);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
}
|
|
|
9bac43 |
@@ -2468,7 +2469,7 @@ static void listener_add_address_space(MemoryListener *listener,
|
|
|
9bac43 |
FOR_EACH_FLAT_RANGE(fr, view) {
|
|
|
9bac43 |
MemoryRegionSection section = {
|
|
|
9bac43 |
.mr = fr->mr,
|
|
|
9bac43 |
- .address_space = as,
|
|
|
9bac43 |
+ .fv = view,
|
|
|
9bac43 |
.offset_within_region = fr->offset_in_region,
|
|
|
9bac43 |
.size = fr->addr.size,
|
|
|
9bac43 |
.offset_within_address_space = int128_get64(fr->addr.start),
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|