{"id":2227574,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2227574/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260424000544.9617-4-lucaaamaral@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","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":""},"msgid":"<20260424000544.9617-4-lucaaamaral@gmail.com>","date":"2026-04-24T00:05:44","name":"[v5,3/3] target/arm/hvf: configure IPA granule on macOS 26","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"239b1ece83676a83ea0c8320ec978c3051d5deed","submitter":{"id":92822,"url":"http://patchwork.ozlabs.org/api/1.1/people/92822/?format=json","name":"Lucas Amaral","email":"lucaaamaral@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260424000544.9617-4-lucaaamaral@gmail.com/mbox/","series":[{"id":501263,"url":"http://patchwork.ozlabs.org/api/1.1/series/501263/?format=json","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/2227574/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2227574/checks/","tags":{},"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=HkUuW2i9;\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 4g1tYl1Dlhz1yJn\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 1wG43c-0006hd-QC; Thu, 23 Apr 2026 20:06:08 -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 1wG43Z-0006gr-0g\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 20:06:05 -0400","from mail-dy1-x1335.google.com ([2607:f8b0:4864:20::1335])\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 1wG43X-0000zO-Gq\n for qemu-devel@nongnu.org; Thu, 23 Apr 2026 20:06:04 -0400","by mail-dy1-x1335.google.com with SMTP id\n 5a478bee46e88-2ba895adfeaso8087510eec.0\n for <qemu-devel@nongnu.org>; Thu, 23 Apr 2026 17:06:03 -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.58\n (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);\n Thu, 23 Apr 2026 17:06:01 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1776989162; x=1777593962; 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=R9pycH1vrpngd62Fq+G7Rj4pLVjPW3yDgHDKQsT+bWY=;\n b=HkUuW2i9cWbX9o+aadbLE8r6bqZ+HMln5icK1XGv4LJKuQlsPBJEHWJveoeEqGoPMY\n 51xqBxinLb0LSWSdeRw7Jd9+G9O6XqPm3iZONOmijN0+gg07Zd7nQmNur7MgTplZH7yt\n xZDkvEuc9imqr8+2MzUgS8NTQh98MOxNDICB/8TBEJwqlhoSn7joBxsykO07UPgrVGaD\n nNt+olbyFYk/9BjRQGSfjdL40Qar+mFD2ixqt+mM4AKUvkgjKkQOd2AQ8tLQxYiew+Mu\n 4NiWuf4x9nCeAnjERSU71F+Qx5+icFXruze5Auu2lvFmvSON7BpmG1jRKsWqOYeQ705Z\n c9OQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776989162; x=1777593962;\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=R9pycH1vrpngd62Fq+G7Rj4pLVjPW3yDgHDKQsT+bWY=;\n b=IhP1eai7703W0E+anDuDLp9Ee0TxuZqXY7k5lP+UNQBpDz5xrbc2VuUFafLDG2Iu9Z\n GnL21LKMV44ggTq3ieq9o+21idly3UKm5ojHIhBwCBGkek796qRAqIrDbkO54Mwa9KBT\n DoSCtLkNUEifB1MEzHfAJBou2Ks5+Ds/pgK6h4ILTZ+xhwvF9kbvhy7gyWAnAfI62CQ1\n VRE+wgZ/P0VPx2xVvVU2pmh5WMCtGiaR7gzYquiT2l5zkBKZEsVyGCjg5PhdZC0IR1J+\n vOz4pdw6Fld7pw+4zLFVcZ2xHq4aPAAPV95hJsdsb1GeSUtXI6b9SPkABh7lbxPdg+Vq\n b0IA==","X-Gm-Message-State":"AOJu0YwAbo8nWWseeKIre2w0uNFQ7vHOMUvMNi3tk+tzHQTDUqWsRRaP\n cwKvqDkGhwKtZA4TQIkDHh5LP9sxD9qlpG0AE0UfxoWYblNfxPowQu32iBP2WOm6jWM=","X-Gm-Gg":"AeBDiesI6Ya/eQ04fz9rUNZBXix0+4T4PgRkotSaA4LBKphrv/ll7V8q0mWiqfaA4oq\n 3bHLwRZMw6JcCnA+17AaTEa9x09XykkP9AsUHhf0/yY/qYEnBH5F8UuRGKPuBzZK6nwkMuf0i8o\n dQEj6EtwzmPE8voODDjOkglOCsvyKlPxVT4w3cgw2VYCxp+DiHa3T/CqXfwpR1fwi0CpyMumr97\n Mt/FIRIOLa9ajceSgcr4v3QxtCo7DqHqAieb60vx5QiIwF8WXFprvmSy/afHq1r8IXqDqv2dfhs\n zNlYO/m6YLxBzVn7liEXtf85yZQf2m35/Ei70ESrkOoSJzP7cW9mCuXCAz4AS6E9ZnblzctFoKL\n +wxyfK2s252rmUiC882OoAIlFEBmo/Gc2EdQq+lD+B/wcomreIxuu6aZ8JSaUQCfzV3E2Nkrx2x\n PpGp53FPG6LJf+QD7cLTl1Vf3Aw/Rv5cGKV6JR2xxU/ZXkRh3pgBpFb53OIS3no4xGFA2nYym2","X-Received":"by 2002:a05:693c:2c0f:b0:2d3:4252:b127 with SMTP id\n 5a478bee46e88-2e479017537mr15538048eec.26.1776989161517;\n Thu, 23 Apr 2026 17:06:01 -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 3/3] target/arm/hvf: configure IPA granule on macOS 26","Date":"Thu, 23 Apr 2026 21:05:44 -0300","Message-ID":"<20260424000544.9617-4-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-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::1335;\n envelope-from=lucaaamaral@gmail.com; helo=mail-dy1-x1335.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=unavailable 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":"Read the ipa-granule property (set by hvf_accel_init) and configure\nthe HVF stage-2 translation granule via hv_vm_config_set_ipa_granule()\non macOS 26+.  When ipa-granule=4k, use HV_IPA_GRANULE_4KB to allow\nHVF to map memory at 4KB granularity, matching 4KB-page guests on\nhosts with larger page sizes.\n\nIf macOS < 26 and a sub-host-page granule was requested, warn and\nfall back to the host page size.\n\nSigned-off-by: Lucas Amaral <lucaaamaral@gmail.com>\n---\n target/arm/hvf/hvf.c | 32 ++++++++++++++++++++++++++++++++\n 1 file changed, 32 insertions(+)","diff":"diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c\nindex 1b5860c7..f506fc01 100644\n--- a/target/arm/hvf/hvf.c\n+++ b/target/arm/hvf/hvf.c\n@@ -1270,6 +1270,38 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)\n     }\n     chosen_ipa_bit_size = pa_range;\n \n+    /*\n+     * Configure IPA granule from the ipa-granule property.\n+     * hvf_get_map_granule() was set by hvf_accel_init() before this call.\n+     */\n+    {\n+        uint64_t granule = hvf_get_map_granule();\n+        bool granule_set = false;\n+\n+#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \\\n+    (__MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0)\n+        if (__builtin_available(macOS 26, *)) {\n+            hv_ipa_granule_t hv_gran = (granule <= 4 * KiB)\n+                ? HV_IPA_GRANULE_4KB : HV_IPA_GRANULE_16KB;\n+            ret = hv_vm_config_set_ipa_granule(config, hv_gran);\n+            if (ret != HV_SUCCESS) {\n+                error_report(\"HVF: failed to set IPA granule: %s\",\n+                             hvf_return_string(ret));\n+                goto cleanup;\n+            }\n+            granule_set = true;\n+        }\n+#endif\n+\n+        if (!granule_set && granule < qemu_real_host_page_size()) {\n+            warn_report(\"HVF: ipa-granule=%zuKB requested but macOS < 26; \"\n+                        \"falling back to host page size (%zuKB)\",\n+                        (size_t)(granule / KiB),\n+                        (size_t)(qemu_real_host_page_size() / KiB));\n+            hvf_set_map_granule(qemu_real_host_page_size());\n+        }\n+    }\n+\n     ret = hv_vm_create(config);\n \n cleanup:\n","prefixes":["v5","3/3"]}