[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/30] exec: change well-known physical sections to
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 20/30] exec: change well-known physical sections to macros |
Date: |
Fri, 28 Jun 2013 20:26:39 +0200 |
From: Liu Ping Fan <address@hidden>
Sections like phys_section_unassigned always have fixed address
in phys_sections. Declared as macro, so we can use them
when having more than one phys_sections array.
Signed-off-by: Liu Ping Fan <address@hidden>
Signed-off-by: Liu Ping Fan <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/exec.c b/exec.c
index a788981..7ad513c 100644
--- a/exec.c
+++ b/exec.c
@@ -113,10 +113,10 @@ typedef struct subpage_t {
static MemoryRegionSection *phys_sections;
static unsigned phys_sections_nb, phys_sections_nb_alloc;
-static uint16_t phys_section_unassigned;
-static uint16_t phys_section_notdirty;
-static uint16_t phys_section_rom;
-static uint16_t phys_section_watch;
+#define PHYS_SECTION_UNASSIGNED 0
+#define PHYS_SECTION_NOTDIRTY 1
+#define PHYS_SECTION_ROM 2
+#define PHYS_SECTION_WATCH 3
/* Simple allocator for PhysPageEntry nodes */
static PhysPageEntry (*phys_map_nodes)[L2_SIZE];
@@ -174,7 +174,7 @@ static void phys_page_set_level(PhysPageEntry *lp, hwaddr
*index,
if (level == 0) {
for (i = 0; i < L2_SIZE; i++) {
p[i].is_leaf = 1;
- p[i].ptr = phys_section_unassigned;
+ p[i].ptr = PHYS_SECTION_UNASSIGNED;
}
}
} else {
@@ -213,7 +213,7 @@ static MemoryRegionSection
*phys_page_find(AddressSpaceDispatch *d, hwaddr index
for (i = P_L2_LEVELS - 1; i >= 0 && !lp.is_leaf; i--) {
if (lp.ptr == PHYS_MAP_NODE_NIL) {
- return &phys_sections[phys_section_unassigned];
+ return &phys_sections[PHYS_SECTION_UNASSIGNED];
}
p = phys_map_nodes[lp.ptr];
lp = p[(index >> (i * L2_BITS)) & (L2_SIZE - 1)];
@@ -731,9 +731,9 @@ hwaddr memory_region_section_get_iotlb(CPUArchState *env,
iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
+ xlat;
if (!section->readonly) {
- iotlb |= phys_section_notdirty;
+ iotlb |= PHYS_SECTION_NOTDIRTY;
} else {
- iotlb |= phys_section_rom;
+ iotlb |= PHYS_SECTION_ROM;
}
} else {
iotlb = section - phys_sections;
@@ -746,7 +746,7 @@ hwaddr memory_region_section_get_iotlb(CPUArchState *env,
if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) {
/* Avoid trapping reads of pages with a write breakpoint. */
if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) {
- iotlb = phys_section_watch + paddr;
+ iotlb = PHYS_SECTION_WATCH + paddr;
*address |= TLB_MMIO;
break;
}
@@ -1670,7 +1670,7 @@ static subpage_t *subpage_init(AddressSpace *as, hwaddr
base)
printf("%s: %p base " TARGET_FMT_plx " len %08x %d\n", __func__,
mmio, base, TARGET_PAGE_SIZE, subpage_memory);
#endif
- subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, phys_section_unassigned);
+ subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, PHYS_SECTION_UNASSIGNED);
return mmio;
}
@@ -1712,11 +1712,17 @@ static void mem_begin(MemoryListener *listener)
static void core_begin(MemoryListener *listener)
{
+ uint16_t n;
+
phys_sections_clear();
- phys_section_unassigned = dummy_section(&io_mem_unassigned);
- phys_section_notdirty = dummy_section(&io_mem_notdirty);
- phys_section_rom = dummy_section(&io_mem_rom);
- phys_section_watch = dummy_section(&io_mem_watch);
+ n = dummy_section(&io_mem_unassigned);
+ assert(n == PHYS_SECTION_UNASSIGNED);
+ n = dummy_section(&io_mem_notdirty);
+ assert(n == PHYS_SECTION_NOTDIRTY);
+ n = dummy_section(&io_mem_rom);
+ assert(n == PHYS_SECTION_ROM);
+ n = dummy_section(&io_mem_watch);
+ assert(n == PHYS_SECTION_WATCH);
}
static void tcg_commit(MemoryListener *listener)
--
1.8.1.4
- [Qemu-devel] [PATCH 11/30] rcu: add rcutorture, (continued)
- [Qemu-devel] [PATCH 11/30] rcu: add rcutorture, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 13/30] qemu-thread: report RCU quiescent states, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 08/30] rcu: add rcu library, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 14/30] event loop: report RCU quiescent states, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 10/30] rcu: add call_rcu, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 15/30] cpus: report RCU quiescent states, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 16/30] block: report RCU quiescent states, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 17/30] migration: report RCU quiescent states, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 19/30] memory: avoid ref/unref in memory_region_find, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 18/30] memory: protect current_map by RCU, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 20/30] exec: change well-known physical sections to macros,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 21/30] exec: separate current memory map from the one being built, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 22/30] memory: move MemoryListener declaration earlier, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 23/30] exec: move listener from AddressSpaceDispatch to AddressSpace, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 24/30] exec: separate current radix tree from the one being built, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 26/30] exec: remove cur_map, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 25/30] exec: put memory map in AddressSpaceDispatch, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 27/30] exec: change some APIs to take AddressSpaceDispatch, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 28/30] exec: change iotlb APIs to take AddressSpaceDispatch, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 29/30] exec: add a reference to the region returned by address_space_translate, Paolo Bonzini, 2013/06/28
- [Qemu-devel] [PATCH 30/30] exec: put address space dispatch under RCU critical section, Paolo Bonzini, 2013/06/28