From: Philippe Mathieu-Daudé Date: Mon, 29 Sep 2025 08:31:00 +0000 (+0200) Subject: accel/hvf: Enforce host alignment in hv_vm_protect() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b36673c27d30edd6b186d2912fcc9ed569577cc;p=thirdparty%2Fqemu.git accel/hvf: Enforce host alignment in hv_vm_protect() hv_vm_protect() arguments must be aligned to host page. Suggested-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki Message-ID: <20260112103034.65310-4-philmd@linaro.org> --- diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 741b4bdc4f..96ed79108a 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "accel/accel-ops.h" +#include "exec/cpu-common.h" #include "system/address-spaces.h" #include "system/memory.h" #include "system/hvf.h" @@ -61,12 +62,15 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line, static void do_hv_vm_protect(hwaddr start, size_t size, hv_memory_flags_t flags) { + intptr_t page_mask = qemu_real_host_page_mask(); hv_return_t ret; trace_hvf_vm_protect(start, size, flags, flags & HV_MEMORY_READ ? 'R' : '-', flags & HV_MEMORY_WRITE ? 'W' : '-', flags & HV_MEMORY_EXEC ? 'X' : '-'); + g_assert(!((uintptr_t)start & ~page_mask)); + g_assert(!(size & ~page_mask)); ret = hv_vm_protect(start, size, flags); assert_hvf_ok(ret);