Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2227573/?format=api
{ "id": 2227573, "url": "http://patchwork.ozlabs.org/api/patches/2227573/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260424000544.9617-3-lucaaamaral@gmail.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260424000544.9617-3-lucaaamaral@gmail.com>", "list_archive_url": null, "date": "2026-04-24T00:05:43", "name": "[v5,2/3] accel/hvf: introduce map granule abstraction and IPA property", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a1cabc6e55fd90544bfdbb79b5567acf6e9e8877", "submitter": { "id": 92822, "url": "http://patchwork.ozlabs.org/api/people/92822/?format=api", "name": "Lucas Amaral", "email": "lucaaamaral@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260424000544.9617-3-lucaaamaral@gmail.com/mbox/", "series": [ { "id": 501263, "url": "http://patchwork.ozlabs.org/api/series/501263/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501263", "date": "2026-04-24T00:05:43", "name": "hvf: map granule abstraction, configurable IPA, and MAP_FIXED alignment fix", "version": 5, "mbox": "http://patchwork.ozlabs.org/series/501263/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2227573/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2227573/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=j6O1imUG;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1tYl0lzvz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 10:07:05 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wG43X-0006gI-L5; Thu, 23 Apr 2026 20:06:03 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <lucaaamaral@gmail.com>)\n id 1wG43W-0006fm-1P\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 20:06:02 -0400", "from mail-dy1-x1336.google.com ([2607:f8b0:4864:20::1336])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <lucaaamaral@gmail.com>)\n id 1wG43T-0000z1-IP\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 20:06:01 -0400", "by mail-dy1-x1336.google.com with SMTP id\n 5a478bee46e88-2d9916deb14so12928898eec.0\n for <qemu-devel@nongnu.org>; Thu, 23 Apr 2026 17:05:59 -0700 (PDT)", "from localhost.localdomain ([2804:7f4:c030:44a8:c4b9:45be:963d:f3a])\n by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2ea8e4b373dsm12958055eec.6.2026.04.23.17.05.54\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Thu, 23 Apr 2026 17:05:57 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1776989158; x=1777593958; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=romhlJbT++e95ezZHaRqmY4KWUmngLYBLnwDrcI19RA=;\n b=j6O1imUGACXpj0y1l+Ez0T5qpdBx5+K5Nlv0Q3muemBZvcc0GnClN+0zwz1znejNmd\n 9r+4GCm467fbXEWqj2zPv8bQkIm8/6fUlqrAfkTuay0wYYneUY0BI4XBtqYzct+/GUEc\n iQ+kAzO7fy7kMWrGxQ09LkFjcIQ0Ttv3LwoLOE1e601Zm6KsAKuOQRuKBJl++sHc4XD/\n ZSCulCttBNDl23TjctYtQc/enKqiVD49flMejKAtE8Yqi2bjledieBmDbEYqpQBQJI6l\n mkdRYGHQwGiriSEtXt5WacqTIK1P7RzWRA4O0IF3CYiisocGNAdoz2fxXZMt5AKOqA1L\n URjQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776989158; x=1777593958;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=romhlJbT++e95ezZHaRqmY4KWUmngLYBLnwDrcI19RA=;\n b=nWagFQDbNjtJLBk7KEUklA8IIrHDFsj5NQlPndKWRPQfeadfIExd5nQCxNGOzUvDlK\n GDIjyr/K44X997vKtkqRt4ExJCR211a0jhOBz0wnE95q4MgygLqI2+zIahU9R91oqg38\n g0Ejpjvn+85bxazkgbCgtFeQljub1mK52jjehTgFe5dA4aiZCSj85U+V+IUnLw302Y79\n XRCDwZ8qzH3EvlN0E1DEuy+wRw2aQSPQYj6XVQKwjdjc16XU43JujHRErkVdS1MYfzKC\n i433HfVN6SLDJj55AooOOwMI+H7Pu3gvkpqsYJkO9YXIlGJUmUBVKe6Bggf8s3A15KRO\n uHcQ==", "X-Gm-Message-State": "AOJu0YxZGa35sGVsPKUqjdKGKFeQ1eaGO6zPKrJXTHB+lj33ozIB4d0F\n ps9WlxuYAvY8d3c3Ypz9TG/AL4O1H4T0DqvEVjO9tFV2+xbL9PiyjmiOPJhfcOrbCio=", "X-Gm-Gg": "AeBDieusfoiXf0UWx+Hre5p5Xra2jeYkKcqVZSVTQS05U9zyKc6d7qMcntB6PZEdxwA\n GezBQ0Lq+/UhoSRMk95ashUVJLyUbXE+9bPN+3jLVUpMqthryD9gaOCAdaeeFSut7xyhI9nFfo/\n wOZqsBCACHqIsgtIHGZhOwaRgKagU7U8ArJvuC9Lbyxpkhd4mKL5MZqTpG3BXn7rZ0qBuJvkRWC\n SWxewU7ov26SfmQE1fDmmW9GkxIPMe3+pMSr0RwU7Bz/78pkMSKxSHtJ+Sr5doPkiK2EdbxTe3t\n RY+8bcwrlqzQuD0bja2VmHhZd7dDZCAjCmaKfj3tuLyyLcLlJrGhvOzQ/tc8aH69tXfS2Pk+6ct\n QdlzldLX6Y8A5yIQHp21CWVzf5Nt138ZnDE8cc4/SHoLcELafrwMuUm9fONt72Mt/7W9059Fhv0\n X1BhxTcDBhEVS6yTs2M//LSCTqpKjj2qPF12Jcg2KyFk5SFfwHcYqYIKFfMBL/ikr8qqtkZGUd", "X-Received": "by 2002:a05:7300:5728:b0:2be:2953:fd74 with SMTP id\n 5a478bee46e88-2e479723e13mr16627599eec.14.1776989157771;\n Thu, 23 Apr 2026 17:05:57 -0700 (PDT)", "From": "Lucas Amaral <lucaaamaral@gmail.com>", "To": "qemu-devel@nongnu.org", "Cc": "qemu-arm@nongnu.org, agraf@csgraf.de, peter.maydell@linaro.org,\n mohamed@unpredictable.fr, alex.bennee@linaro.org,\n Lucas Amaral <lucaaamaral@gmail.com>", "Subject": "[PATCH v5 2/3] accel/hvf: introduce map granule abstraction and IPA\n property", "Date": "Thu, 23 Apr 2026 21:05:43 -0300", "Message-ID": "<20260424000544.9617-3-lucaaamaral@gmail.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260424000544.9617-1-lucaaamaral@gmail.com>", "References": "<20260424000544.9617-1-lucaaamaral@gmail.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2607:f8b0:4864:20::1336;\n envelope-from=lucaaamaral@gmail.com; helo=mail-dy1-x1336.google.com", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Add a map granule abstraction that decouples HVF memory mapping\nalignment from the host page size. On ARM64, Apple Silicon supports\nstage-2 translation with 4KB page granules regardless of the host OS\npage size (16KB on macOS). This allows running guests with 4KB pages\nwithout interior mapping failures.\n\nIntroduce hvf_set_map_granule()/hvf_get_map_granule() in hvf-all.c\nto replace hard-coded qemu_real_host_page_size() references in\ndo_hv_vm_protect() and hvf_set_phys_mem(). When the granule is not\nexplicitly configured, fall back to host page size to preserve the\nprevious behaviour.\n\nAdd an \"ipa-granule\" accelerator property (auto, 4k, 16k) following\nthe established kvm_arch_accel_class_init() pattern: ARM registers\nthe property in hvf_arch_accel_class_init(), x86 provides an empty\nstub. This avoids #ifdef __aarch64__ in common code while keeping\na single hvf-all.c shared by both targets.\n\nFix hvf_set_phys_mem() to return early for non-aligned regions instead\nof clearing the add flag, which previously fell through to an\nincorrect unmap of a region that was never mapped.\n\nSigned-off-by: Lucas Amaral <lucaaamaral@gmail.com>\n---\n accel/hvf/hvf-all.c | 30 +++++++++++++++++++++++++++---\n include/system/hvf.h | 15 +++++++++++++++\n include/system/hvf_int.h | 2 ++\n target/arm/hvf/hvf.c | 40 ++++++++++++++++++++++++++++++++++++++++\n target/i386/hvf/hvf.c | 4 ++++\n 5 files changed, 88 insertions(+), 3 deletions(-)", "diff": "diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c\nindex 5f357c6d..d745fefd 100644\n--- a/accel/hvf/hvf-all.c\n+++ b/accel/hvf/hvf-all.c\n@@ -10,6 +10,8 @@\n \n #include \"qemu/osdep.h\"\n #include \"qemu/error-report.h\"\n+#include \"qemu/units.h\"\n+#include \"qapi/error.h\"\n #include \"accel/accel-ops.h\"\n #include \"exec/cpu-common.h\"\n #include \"system/address-spaces.h\"\n@@ -22,6 +24,21 @@\n \n bool hvf_allowed;\n \n+static uint64_t hvf_map_granule;\n+\n+void hvf_set_map_granule(uint64_t size)\n+{\n+ hvf_map_granule = size;\n+}\n+\n+uint64_t hvf_get_map_granule(void)\n+{\n+ if (!hvf_map_granule) {\n+ return qemu_real_host_page_size();\n+ }\n+ return hvf_map_granule;\n+}\n+\n const char *hvf_return_string(hv_return_t ret)\n {\n switch (ret) {\n@@ -53,7 +70,7 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,\n static void do_hv_vm_protect(hwaddr start, size_t size,\n hv_memory_flags_t flags)\n {\n- intptr_t page_mask = qemu_real_host_page_mask();\n+ intptr_t page_mask = -(intptr_t)hvf_get_map_granule();\n hv_return_t ret;\n \n trace_hvf_vm_protect(start, size, flags,\n@@ -83,7 +100,7 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)\n MemoryRegion *area = section->mr;\n bool writable = !area->readonly && !area->rom_device;\n hv_memory_flags_t flags;\n- uint64_t page_size = qemu_real_host_page_size();\n+ uint64_t page_size = hvf_get_map_granule();\n uint64_t gpa = section->offset_within_address_space;\n uint64_t size = int128_get64(section->size);\n hv_return_t ret;\n@@ -104,7 +121,7 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)\n if (!QEMU_IS_ALIGNED(size, page_size) ||\n !QEMU_IS_ALIGNED(gpa, page_size)) {\n /* Not page aligned, so we can not map as RAM */\n- add = false;\n+ return;\n }\n \n if (!add) {\n@@ -186,6 +203,11 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)\n int pa_range = 36;\n MachineClass *mc = MACHINE_GET_CLASS(ms);\n \n+ /* Resolve ipa-granule=auto → host page size */\n+ if (!s->ipa_granule) {\n+ s->ipa_granule = qemu_real_host_page_size();\n+ }\n+ hvf_set_map_granule(s->ipa_granule);\n \n if (mc->get_physical_address_range) {\n pa_range = mc->get_physical_address_range(ms,\n@@ -223,6 +245,8 @@ static void hvf_accel_class_init(ObjectClass *oc, const void *data)\n ac->init_machine = hvf_accel_init;\n ac->allowed = &hvf_allowed;\n ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;\n+\n+ hvf_arch_accel_class_init(oc);\n }\n \n static const TypeInfo hvf_accel_type = {\ndiff --git a/include/system/hvf.h b/include/system/hvf.h\nindex d3dcf088..3c4c3b89 100644\n--- a/include/system/hvf.h\n+++ b/include/system/hvf.h\n@@ -36,4 +36,19 @@ typedef struct HVFState HVFState;\n DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE,\n TYPE_HVF_ACCEL)\n \n+#ifdef CONFIG_HVF_IS_POSSIBLE\n+/*\n+ * Minimum alignment for hv_vm_map(). Returns the configured IPA granule\n+ * or host page size if not set.\n+ */\n+void hvf_set_map_granule(uint64_t size);\n+uint64_t hvf_get_map_granule(void);\n+#else\n+static inline void hvf_set_map_granule(uint64_t size) {}\n+static inline uint64_t hvf_get_map_granule(void)\n+{\n+ return qemu_real_host_page_size();\n+}\n+#endif\n+\n #endif\ndiff --git a/include/system/hvf_int.h b/include/system/hvf_int.h\nindex 2621164c..9589b022 100644\n--- a/include/system/hvf_int.h\n+++ b/include/system/hvf_int.h\n@@ -38,6 +38,7 @@ struct HVFState {\n \n hvf_vcpu_caps *hvf_caps;\n uint64_t vtimer_offset;\n+ uint32_t ipa_granule;\n QTAILQ_HEAD(, hvf_sw_breakpoint) hvf_sw_breakpoints;\n };\n extern HVFState *hvf_state;\n@@ -57,6 +58,7 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,\n const char *hvf_return_string(hv_return_t ret);\n int hvf_arch_init(void);\n hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);\n+void hvf_arch_accel_class_init(ObjectClass *oc);\n uint32_t hvf_arch_get_default_ipa_bit_size(void);\n uint32_t hvf_arch_get_max_ipa_bit_size(void);\n void hvf_kick_vcpu_thread(CPUState *cpu);\ndiff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c\nindex 000e54bd..1b5860c7 100644\n--- a/target/arm/hvf/hvf.c\n+++ b/target/arm/hvf/hvf.c\n@@ -12,6 +12,8 @@\n #include \"qemu/osdep.h\"\n #include \"qemu/error-report.h\"\n #include \"qemu/log.h\"\n+#include \"qemu/units.h\"\n+#include \"qapi/error.h\"\n \n #include \"system/runstate.h\"\n #include \"system/hvf.h\"\n@@ -1219,6 +1221,44 @@ void hvf_arch_vcpu_destroy(CPUState *cpu)\n assert_hvf_ok(ret);\n }\n \n+static char *hvf_get_ipa_granule(Object *obj, Error **errp)\n+{\n+ HVFState *s = HVF_STATE(obj);\n+\n+ if (s->ipa_granule == 4 * KiB) {\n+ return g_strdup(\"4k\");\n+ }\n+ if (s->ipa_granule == 16 * KiB) {\n+ return g_strdup(\"16k\");\n+ }\n+ return g_strdup(\"auto\");\n+}\n+\n+static void hvf_set_ipa_granule(Object *obj, const char *value, Error **errp)\n+{\n+ HVFState *s = HVF_STATE(obj);\n+\n+ if (!g_strcmp0(value, \"auto\")) {\n+ s->ipa_granule = 0;\n+ } else if (!g_strcmp0(value, \"4k\")) {\n+ s->ipa_granule = 4 * KiB;\n+ } else if (!g_strcmp0(value, \"16k\")) {\n+ s->ipa_granule = 16 * KiB;\n+ } else {\n+ error_setg(errp, \"invalid ipa-granule: '%s' (use auto, 4k, 16k)\",\n+ value);\n+ }\n+}\n+\n+void hvf_arch_accel_class_init(ObjectClass *oc)\n+{\n+ object_class_property_add_str(oc, \"ipa-granule\",\n+ hvf_get_ipa_granule,\n+ hvf_set_ipa_granule);\n+ object_class_property_set_description(oc, \"ipa-granule\",\n+ \"IPA granule for HVF stage-2 translation (auto, 4k, 16k)\");\n+}\n+\n hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)\n {\n hv_return_t ret;\ndiff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c\nindex c0d028b1..565c79b3 100644\n--- a/target/i386/hvf/hvf.c\n+++ b/target/i386/hvf/hvf.c\n@@ -228,6 +228,10 @@ int hvf_arch_init(void)\n return 0;\n }\n \n+void hvf_arch_accel_class_init(ObjectClass *oc)\n+{\n+}\n+\n /* 48-bit on all Intel Macs. Function currently unused. */\n uint32_t hvf_arch_get_default_ipa_bit_size(void)\n {\n", "prefixes": [ "v5", "2/3" ] }