qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] exec.c: Replace memory_region_is_unassigned() with memory_region_is_ram_backed()
@ 2018-07-09 15:58 Peter Maydell
  2018-07-09 17:23 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2018-07-09 15:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Paolo Bonzini, Richard Henderson

The function memory_region_is_unassigned() is rather misnamed, because
what it is actually testing is whether the memory region is backed
by host RAM, and so whether get_page_addr_code() can find a ram_addr_t
corresponding to the guest address.

Replace it with memory_region_is_ram_backed(), which has a name
better matching its actual semantics.  (We invert the sense of the
return value to avoid having a _not_ in the function name.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
The difference between this and memory_region_is_ram() is pretty
subtle, to the extent I'm not completely sure exactly what it is;
io_mem_notdirty and io_mem_watch at least won't be considered as
"ram" by memory_region_is_ram(), though. Somebody with a better
grasp of the various different kinds of memory regions might be
able to suggest better documentation and/or a way to avoid this
oddball TCG-only function?

 include/exec/exec-all.h | 9 ++++++++-
 accel/tcg/cputlb.c      | 2 +-
 exec.c                  | 6 +++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index da73e3bfed2..7de4e4646f6 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -502,7 +502,14 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,
                                        hwaddr paddr, hwaddr xlat,
                                        int prot,
                                        target_ulong *address);
-bool memory_region_is_unassigned(MemoryRegion *mr);
+/**
+ * memory_region_is_ram_backed:
+ * @mr: Memory region
+ *
+ * Return true if this memory region is backed by host RAM that we
+ * can directly execute guest code from.
+ */
+bool memory_region_is_ram_backed(MemoryRegion *mr);
 
 #endif
 
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 20c147d6554..e5e3bf76298 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1001,7 +1001,7 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
     iotlbentry = &env->iotlb[mmu_idx][index];
     section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs);
     mr = section->mr;
-    if (memory_region_is_unassigned(mr)) {
+    if (!memory_region_is_ram_backed(mr)) {
         qemu_mutex_lock_iothread();
         if (memory_region_request_mmio_ptr(mr, addr)) {
             qemu_mutex_unlock_iothread();
diff --git a/exec.c b/exec.c
index 4f5df07b6a2..6aea975c266 100644
--- a/exec.c
+++ b/exec.c
@@ -402,10 +402,10 @@ static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr addr)
     }
 }
 
-bool memory_region_is_unassigned(MemoryRegion *mr)
+bool memory_region_is_ram_backed(MemoryRegion *mr)
 {
-    return mr != &io_mem_rom && mr != &io_mem_notdirty && !mr->rom_device
-        && mr != &io_mem_watch;
+    return !(mr != &io_mem_rom && mr != &io_mem_notdirty && !mr->rom_device
+             && mr != &io_mem_watch);
 }
 
 /* Called from RCU critical section */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-10 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-09 15:58 [Qemu-devel] [PATCH] exec.c: Replace memory_region_is_unassigned() with memory_region_is_ram_backed() Peter Maydell
2018-07-09 17:23 ` Richard Henderson
2018-07-09 17:33   ` Peter Maydell
2018-07-09 17:50     ` Richard Henderson
2018-07-10 10:56       ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).