]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
hvf: Avoid mapping regions < PAGE_SIZE as ram
authorAlexander Graf <agraf@csgraf.de>
Mon, 25 Oct 2021 13:21:47 +0000 (15:21 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 2 Nov 2021 14:57:27 +0000 (15:57 +0100)
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211025132147.28308-1-agraf@csgraf.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
accel/hvf/hvf-accel-ops.c

index 2b2c411076d0b0ed434fb362d1a38fcf1f910497..54457c76c2f3a45ee95eecf57dd2e202f51c17d1 100644 (file)
@@ -122,6 +122,7 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
     MemoryRegion *area = section->mr;
     bool writeable = !area->readonly && !area->rom_device;
     hv_memory_flags_t flags;
+    uint64_t page_size = qemu_real_host_page_size;
 
     if (!memory_region_is_ram(area)) {
         if (writeable) {
@@ -135,6 +136,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
         }
     }
 
+    if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
+        !QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
+        /* 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));