All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 09/16] Switch cpu_register_physical_memory_log() to use MemoryRegions
Date: Mon,  2 Jan 2012 18:33:28 +0200	[thread overview]
Message-ID: <1325522015-503-10-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1325522015-503-1-git-send-email-avi@redhat.com>

Still internally using ram_addr.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 exec-obsolete.h |   24 +++---------------------
 exec.c          |   24 +++++++++++++++++++-----
 memory.c        |   44 ++++++++++++++++----------------------------
 3 files changed, 38 insertions(+), 54 deletions(-)

diff --git a/exec-obsolete.h b/exec-obsolete.h
index 79f989c..e08e750 100644
--- a/exec-obsolete.h
+++ b/exec-obsolete.h
@@ -36,27 +36,9 @@ int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read,
                            void *opaque);
 void cpu_unregister_io_memory(int table_address);
 
-void cpu_register_physical_memory_log(target_phys_addr_t start_addr,
-                                      ram_addr_t size,
-                                      ram_addr_t phys_offset,
-                                      ram_addr_t region_offset,
-                                      bool log_dirty);
-
-static inline void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
-                                                       ram_addr_t size,
-                                                       ram_addr_t phys_offset,
-                                                       ram_addr_t region_offset)
-{
-    cpu_register_physical_memory_log(start_addr, size, phys_offset,
-                                     region_offset, false);
-}
-
-static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,
-                                                ram_addr_t size,
-                                                ram_addr_t phys_offset)
-{
-    cpu_register_physical_memory_offset(start_addr, size, phys_offset, 0);
-}
+struct MemoryRegionSection;
+void cpu_register_physical_memory_log(struct MemoryRegionSection *section,
+                                      bool readable, bool readonly);
 
 void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
 void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
diff --git a/exec.c b/exec.c
index 2c2ba0e..c8c839a 100644
--- a/exec.c
+++ b/exec.c
@@ -2510,18 +2510,32 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
    start_addr and region_offset are rounded down to a page boundary
    before calculating this offset.  This should not be a problem unless
    the low bits of start_addr and region_offset differ.  */
-void cpu_register_physical_memory_log(target_phys_addr_t start_addr,
-                                         ram_addr_t size,
-                                         ram_addr_t phys_offset,
-                                         ram_addr_t region_offset,
-                                         bool log_dirty)
+void cpu_register_physical_memory_log(MemoryRegionSection *section,
+                                      bool readable, bool readonly)
 {
+    target_phys_addr_t start_addr = section->offset_within_address_space;
+    ram_addr_t size = section->size;
+    ram_addr_t phys_offset = section->mr->ram_addr;
+    ram_addr_t region_offset = section->offset_within_region;
     target_phys_addr_t addr, end_addr;
     PhysPageDesc *p;
     CPUState *env;
     ram_addr_t orig_size = size;
     subpage_t *subpage;
 
+    if (memory_region_is_ram(section->mr)) {
+        phys_offset += region_offset;
+        region_offset = 0;
+    }
+
+    if (!readable) {
+        phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD;
+    }
+
+    if (readonly) {
+        phys_offset |= io_mem_rom.ram_addr;
+    }
+
     assert(size);
 
     if (phys_offset == io_mem_unassigned.ram_addr) {
diff --git a/memory.c b/memory.c
index a6c37c9..e34bc65 100644
--- a/memory.c
+++ b/memory.c
@@ -305,38 +305,26 @@ static void access_with_adjusted_size(target_phys_addr_t addr,
 
 static void as_memory_range_add(AddressSpace *as, FlatRange *fr)
 {
-    ram_addr_t phys_offset, region_offset;
-
-    phys_offset = fr->mr->ram_addr;
-    region_offset = fr->offset_in_region;
-    /* cpu_register_physical_memory_log() wants region_offset for
-     * mmio, but prefers offseting phys_offset for RAM.  Humour it.
-     */
-    if (memory_region_is_ram(fr->mr)) {
-        phys_offset += region_offset;
-        region_offset = 0;
-    }
-
-    if (!fr->readable) {
-        phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD;
-    }
-
-    if (fr->readonly) {
-        phys_offset |= io_mem_rom.ram_addr;
-    }
+    MemoryRegionSection section = {
+        .mr = fr->mr,
+        .offset_within_address_space = int128_get64(fr->addr.start),
+        .offset_within_region = fr->offset_in_region,
+        .size = int128_get64(fr->addr.size),
+    };
 
-    cpu_register_physical_memory_log(int128_get64(fr->addr.start),
-                                     int128_get64(fr->addr.size),
-                                     phys_offset,
-                                     region_offset,
-                                     fr->dirty_log_mask);
+    cpu_register_physical_memory_log(&section, fr->readable, fr->readonly);
 }
 
 static void as_memory_range_del(AddressSpace *as, FlatRange *fr)
 {
-    cpu_register_physical_memory(int128_get64(fr->addr.start),
-                                 int128_get64(fr->addr.size),
-                                 io_mem_unassigned.ram_addr);
+    MemoryRegionSection section = {
+        .mr = &io_mem_unassigned,
+        .offset_within_address_space = int128_get64(fr->addr.start),
+        .offset_within_region = int128_get64(fr->addr.start),
+        .size = int128_get64(fr->addr.size),
+    };
+
+    cpu_register_physical_memory_log(&section, true, false);
 }
 
 static void as_memory_log_start(AddressSpace *as, FlatRange *fr)
-- 
1.7.7.1

  parent reply	other threads:[~2012-01-02 16:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02 16:33 [Qemu-devel] [PATCH 00/16] Kill old-style I/O dispatch Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 01/16] memory: move endianness compensation to memory core Avi Kivity
2012-01-05 18:26   ` Andreas Färber
2012-01-07  7:52   ` Andreas Färber
2012-01-02 16:33 ` [Qemu-devel] [PATCH 02/16] exec: make phys_page_find() return a temporary Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 03/16] memory: move mmio access to functions Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 04/16] memory: remove MemoryRegion::backend_registered Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 05/16] Fix wrong region_offset when overlaying a page with another Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 06/16] Avoid range comparisons on io index types Avi Kivity
2012-01-02 21:58   ` Richard Henderson
2012-01-03  8:46     ` Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 07/16] Uninline get_page_addr_code() Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 08/16] Convert IO_MEM_{RAM, ROM, UNASSIGNED, NOTDIRTY} to MemoryRegions Avi Kivity
2012-01-02 22:16   ` Richard Henderson
2012-01-03  8:54     ` Avi Kivity
2012-01-06  8:31   ` Stefan Hajnoczi
2012-01-02 16:33 ` Avi Kivity [this message]
2012-01-02 16:33 ` [Qemu-devel] [PATCH 10/16] Convert the subpage wrapper to be a MemoryRegion Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 11/16] Convert IO_MEM_SUBPAGE_RAM " Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 12/16] Convert io_mem_watch " Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 13/16] Direct dispatch through MemoryRegion Avi Kivity
2012-01-07  7:55   ` Andreas Färber
2012-01-02 16:33 ` [Qemu-devel] [PATCH 14/16] Remove IO_MEM_SUBPAGE Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 15/16] Drop IO_MEM_ROMD Avi Kivity
2012-01-02 16:33 ` [Qemu-devel] [PATCH 16/16] Remove IO_MEM_SHIFT Avi Kivity
2012-01-02 22:36 ` [Qemu-devel] [PATCH 00/16] Kill old-style I/O dispatch Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325522015-503-10-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.