All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Amaral <lucaaamaral@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, agraf@csgraf.de,
	Lucas Amaral <lucaaamaral@gmail.com>
Subject: [PATCH 2/2] target/arm/hvf: set 4KB IPA granule on macOS 26
Date: Mon,  9 Mar 2026 18:49:06 -0300	[thread overview]
Message-ID: <20260309214906.92578-3-lucaaamaral@gmail.com> (raw)
In-Reply-To: <20260309214906.92578-1-lucaaamaral@gmail.com>

macOS 26 introduces hv_vm_config_set_ipa_granule() which allows
configuring 4KB IPA granularity for HVF virtual machines.  This
enables hv_vm_map() to accept 4KB-aligned addresses, matching
the guest kernel's page size.

Without this, virtio-gpu blob BAR offsets that are 4KB-aligned but
not 16KB-aligned cannot be mapped into the guest, falling back to
slow MMIO emulation.

Gated behind MAC_OS_VERSION_26_0 compile-time and __builtin_available
runtime checks.  Falls back to the default 16KB granule on older
macOS versions.

Signed-off-by: Lucas Amaral <lucaaamaral@gmail.com>
---
 target/arm/hvf/hvf.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 87ddcdb..b71a98a 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -960,6 +960,20 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
     }
     chosen_ipa_bit_size = pa_range;
 
+#ifdef MAC_OS_VERSION_26_0
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
+    if (__builtin_available(macOS 26, *)) {
+        ret = hv_vm_config_set_ipa_granule(config, HV_IPA_GRANULE_4KB);
+        if (ret != HV_SUCCESS) {
+            error_report("HVF: failed to set 4KB IPA granule: %s",
+                         hvf_return_string(ret));
+            goto cleanup;
+        }
+        hvf_set_map_granule(4096);
+    }
+#endif
+#endif
+
     ret = hv_vm_create(config);
 
 cleanup:
-- 
2.52.0



  parent reply	other threads:[~2026-03-09 22:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 21:49 [PATCH 0/2] hvf: map granule abstraction and macOS 26 4KB IPA Lucas Amaral
2026-03-09 21:49 ` [PATCH 1/2] accel/hvf: introduce map granule abstraction Lucas Amaral
2026-03-09 21:49 ` Lucas Amaral [this message]
2026-03-10  1:25   ` [PATCH 2/2] target/arm/hvf: set 4KB IPA granule on macOS 26 Mohamed Mediouni
2026-03-11  2:27 ` [PATCH v2 0/2] hvf: map granule abstraction and configurable IPA Lucas Amaral
2026-03-11  2:27   ` [PATCH v2 1/2] accel/hvf: introduce map granule abstraction and IPA property Lucas Amaral
2026-03-11  4:38     ` Mohamed Mediouni
2026-03-11  2:27   ` [PATCH v2 2/2] target/arm/hvf: configure IPA granule on macOS 26 Lucas Amaral
2026-03-11  4:41     ` Mohamed Mediouni
2026-03-15  3:41   ` [PATCH v3 0/3] hvf: map granule abstraction, configurable IPA, and MAP_FIXED alignment fix Lucas Amaral
2026-03-15  3:41     ` [PATCH 1/3] virtio-gpu: validate host page alignment for MAP_FIXED blobs Lucas Amaral
2026-03-15  3:41     ` [PATCH 2/3] accel/hvf: introduce map granule abstraction and IPA property Lucas Amaral
2026-03-15  3:41     ` [PATCH 3/3] target/arm/hvf: configure IPA granule on macOS 26 Lucas Amaral

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260309214906.92578-3-lucaaamaral@gmail.com \
    --to=lucaaamaral@gmail.com \
    --cc=agraf@csgraf.de \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.