[PATCH] hvf: warn when attempting to add unaligned page size

Joelle van Dyne posted 1 patch 3 days, 18 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251203035847.94102-2-j@getutm.app
Maintainers: Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>
accel/hvf/hvf-all.c | 8 ++++++++
1 file changed, 8 insertions(+)
[PATCH] hvf: warn when attempting to add unaligned page size
Posted by Joelle van Dyne 3 days, 18 hours ago
Instead of silently failing, we should print a warning so it is clear why
a future guest access to that location might cause an exception.

Signed-off-by: Joelle van Dyne <j@getutm.app>
---
 accel/hvf/hvf-all.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 0a4b498e83..7823d8416c 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -112,6 +112,14 @@ 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)) {
+        if (add) {
+            warn_report("Cannot add 0x%016llX:0x%016llX because it is not "
+                        "aligned to page size (0x%X)",
+                        section->offset_within_address_space,
+                        section->offset_within_address_space +
+                        int128_get64(section->size),
+                        (uint32_t)page_size);
+        }
         /* Not page aligned, so we can not map as RAM */
         add = false;
     }
-- 
2.41.0