qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram
@ 2021-10-25  8:25 Alexander Graf
  2021-10-25 10:56 ` Philippe Mathieu-Daudé
  2021-10-25 17:11 ` Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Graf @ 2021-10-25  8:25 UTC (permalink / raw)
  To: Cameron Esfahani; +Cc: Paolo Bonzini, Roman Bolshakov, qemu-devel

HVF has generic memory listener code that adds all RAM regions as HVF RAM
regions. However, HVF can only handle page aligned, page granule regions.

So let's ignore regions that are not page aligned and sized. They will be
trapped as MMIO instead.

Signed-off-by: Alexander Graf <agraf@csgraf.de>
---
 accel/hvf/hvf-accel-ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 6bf319d34c..090155853a 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
         }
     }
 
+    if (int128_get64(section->size) & (qemu_real_host_page_size - 1) ||
+        section->offset_within_address_space & (qemu_real_host_page_size - 1)) {
+        /* Not page aligned, so we can not map as RAM */
+        add = false;
+    }
+
     mem = hvf_find_overlap_slot(
             section->offset_within_address_space,
             int128_get64(section->size));
-- 
2.30.1 (Apple Git-130)



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

end of thread, other threads:[~2021-10-26 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  8:25 [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram Alexander Graf
2021-10-25 10:56 ` Philippe Mathieu-Daudé
2021-10-25 17:11 ` Paolo Bonzini
2021-10-25 19:10   ` Alexander Graf
2021-10-26 16:34     ` Paolo Bonzini

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).