Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DABC5F513F4 for ; Fri, 6 Mar 2026 04:18:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyMdV-0005dl-RJ; Thu, 05 Mar 2026 23:18:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyMdU-0005dI-IE for qemu-devel@nongnu.org; Thu, 05 Mar 2026 23:18:00 -0500 Received: from p-west2-cluster1-host7-snip4-10.eps.apple.com ([57.103.68.93] helo=outbound.mr.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyMdS-0002Qe-4d for qemu-devel@nongnu.org; Thu, 05 Mar 2026 23:18:00 -0500 Received: from outbound.mr.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-2a-100-percent-2 (Postfix) with ESMTPS id 26DCD180013E; Fri, 6 Mar 2026 04:17:52 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772770674; x=1775362674; bh=Gj4SAZMfuDyLfgzfiqpovYCwZ+A55iQdCFE1LWWTQPg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=UvRZfooWlhDdANZsF5lX6O+mlsT+ykkr5RLPh0Y6HKQ8G3ER6Wiv3K8Yzb9ZPVeBgnKBgPdzZ8EFzyoKjBvSUZbbTXUm5dzi6NUBuf6wqHIIzLjoSWTTV/JfrH6NaDCXnNXexZiLHJmGitAMnObDtMkIt+NFU5sMHUIiG1D2c9gIiivneU2LzR660qXy5WuY9ve23zTzLJuLeE5PWtHG2/GT2deJVqB8/iwpzbS+FTEPXCslvQNdo4yb3Z4jwguaRao3ALcggb84nq1xRQ2I2sFlqL5LkkDU79Ce6buRRKfK1ancFxYjhJc22uOafMF0n/WUw0AUjSBmY2EQ6iha1A== mail-alias-created-date: 1752046281608 Received: from localhost.localdomain (unknown [17.57.152.38]) by p00-icloudmta-asmtp-us-west-2a-100-percent-2 (Postfix) with ESMTPSA id 5F829180013D; Fri, 6 Mar 2026 04:17:50 +0000 (UTC) From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexander Graf , Paolo Bonzini , Mads Ynddal , qemu-arm@nongnu.org, Phil Dennis-Jordan , Cameron Esfahani , Roman Bolshakov , Peter Maydell , Mohamed Mediouni Subject: [PATCH v12 00/15] HVF: Add support for platform vGIC and nested virtualisation Date: Fri, 6 Mar 2026 05:17:31 +0100 Message-ID: <20260306041747.54554-1-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Authority-Info-Out: v=2.4 cv=aZhsXBot c=1 sm=1 tr=0 ts=69aa5572 cx=c_apl:c_pps:t_out a=9OgfyREA4BUYbbCgc0Y0oA==:117 a=9OgfyREA4BUYbbCgc0Y0oA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=NEAV23lmAAAA:8 a=jwI92-NncrociDarPsAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 02JnnOKcqiKgD9vjT8wom9MSVhlKX1CI X-Proofpoint-ORIG-GUID: 02JnnOKcqiKgD9vjT8wom9MSVhlKX1CI X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDAzOCBTYWx0ZWRfX8onoGvHOWl8T nJDMfI9EoZzx90BTNPNp3Q09TE5jJl3noqKniFNigiIMeSeOPxvQSNE4K2Miz1jC/Yxpabzgg8G bwREC6I/IQvmWXvKDgPSr9dHyo9kTz9F2DJL4PVYEZUZP37bvqLHrk2awb1PFOx2oNIrMj7jjs2 1y9NmtOWEtiXnP4R4PeNOO3XE5+QGB2FIrLmK1WGzzl0fddkvUeXlzDZkvVkSlhmP5bblII5faK eTR8hei8vbH5w+vAcher8MluJgGag5GHziWAbudKXLKQY/60hbFCxe70cW9zUUhZ5F3leaxhejp gTWT/MIIWSd1FpLN4KoCQX0JTAHClpOSy/cyZ1w9x391FG3SncVAkgb0/7QJL8= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_01,2026-03-04_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1030 bulkscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060038 X-JNJ: AAAAAAABd3U1BbWX7gOOjqANvpHwmGMBMZsjtovG64tp/sAsnN2J+G5bLaQrmcPxF7FL40hLZ19vvSSxjnfiW3SXs3fi1kz9anm2lrVQy5sw4IS3H7d2NU03ln9pr6KEQq41wLVxGUjHLAlWXmy+bxe/p/hBE4sPjUOEOrppwOOzviERtvJKwgYPgbSIarm3BnYqwnlE5bJDl56kFduOCq363kUCAgR2BGZIEBvx3m5DuZoIcsokafe9N8YW5xVoMH7q+IspTAppwFvcua3RDcSJeTnDETJ3JamBUtZrk0C1djKxjPvwWuvseiYHY3y0H3pjRPGy7KQUM9y7GqmBiLY7SVgF2baBEyvxWIYfAEfeqULXr+/p7TGSdW+EmdtU80iQuQ9BTViTb/d1K25lkPPldjckB8cMbM991FYLazDT0FgCwGGnUQ3uXtwUDCnK1qkCLdsokn/1HGMUvjs4N4vp2OCyjZO1AcDyzVtmBg7til6zsJqUHIfgPKgrpe6GXc2B54Uz1gJn1mEcGBmjq62hBrxnVkeNLeZkWVJGYsaq4g42i677LukQha/GZ/JiJp2XariJcG20BpR7AKAOw+t6mdvCLaeirFAFms9UfYCz48q64tjBA9Ph/NYpO1C9t4y4x48xmYKaA6xA1GGeY4Sy2TvWk7HuemsHSOetJ0CEYezkja5tsUcnrCTYFOhwBsJPTlSFRTpYl4zFEVREdAplKfbJYZ+fWaicQnpcQep0J6CJAt4ku4y7O1IB++yTCrFdnv3NZOMO6EiVmECBUDy0EBdcvfFw Received-SPF: pass client-ip=57.103.68.93; envelope-from=mohamed@unpredictable.fr; helo=outbound.mr.icloud.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.892, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.622, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Link to branch: https://github.com/mediouni-m/qemu hvf-irqchip-and-nested (tag for this submission: hvf-irqchip-and-nested-v12) This series adds supports for nested virtualisation when using HVF on arm64 Macs. Reviews would be very welcome :-) It's maybe a bit unlikely that this will make it to QEMU 11.0 I might as well try. Patches pending review: "hvf: sync registers used at EL2" and "hvf: arm: SME2 availability fixes" It has two parts: - Apple vGICv3 support and necessary infrastructure changes for it - Nested virtualisation support. Note that the nested virtualisation implementation shipping as of macOS 26.3 is nVHE only (but it _does_ use VNCR as shipped). This series doesn't contain EL2 physical timer emulation, which is needed if not leveraging the Apple vGIC. As such, nested virt requires kernel-irqchip=on. Known issues: - when nested virt is enabled, no UI response within EDK2 and a permanent wait. Workaround: -boot menu=on,splash-time=0. Apple Feedback Assistant item: FB21649319 When the VM is running at EL2 at the very moment the virtual timer fires: HV_EXIT_REASON_VTIMER_ACTIVATED doesn’t fire (when not using the provided vGIC) - using a GICv2 doesn’t require having transition notifiers which Hypervisor.framework doesn’t have…) and when using the provided vGIC, the interrupt never gets delivered back to the guest Linux as a guest OS is fine with this… but the reference ArmVirtQemu edk2 build always uses the virtual timer even when running EFI at EL2, so it gets broken unless this patch is applied to edk2: diff of ArmVirtPkg/ArmVirt.dsc.inc: - ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf + ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf^M Changelog: v1->v2: Oops. I did a mistake when preparing my patches. - Add hvf_arm_el2_enable(_) call to virt_set_virt - Fix nested virt support check to add HVF v2->v3: - LORC_EL1 patch was merged separately, remove from this series. - fix LPIs when kernel-irqchip disabled and using TCG - remove spurious if case in vGIC supported version detection (inapplicable now) - Add hvf_enabled() check in combination with hvf kernel-irqchip checks - cleanly fail on attempt to use the platform vGIC together with ITS v3->v4: - GIC state save improvements, including saving the opaque Apple-specific state - Saving HVF system register state when using the vGIC and/or EL2 v5: - oops, fixed up save/restore to be functional - misc changes otherwise v6: - Addressing review comments v7: - Address review comments, adapt around Qemu changes and bugfixes. v8: - Rebase, and misc fixes v9: - Misc fixes from WHPX review comments - Split enablement commit for EL2 into its own separate commit v10: - A bit of changes across the board - move HVF irqchip save/restore into irqchip code - block nested virt support when kernel-irqchip=off with a GICv2 as we don't implement an emulated physical timer yet. v11: - fixups for the save/restore Apple GIC state patch - block the same registers as the revert in 28b0ed32b32c7e5094cf2f1ec9c0645c65fad2aa for "hvf: sync registers used at EL2" - drop patch that warns instead of aborts on mismatch v12: - Have the SME2 series at the start of this. - Adaptation for the SME2 series. Manos Pitsidianakis (2): hvf/arm: handle FEAT_SME2 migration hvf/arm: expose FEAT_SME2 to guest if available Mohamed Mediouni (13): hw/intc: Add hvf vGIC interrupt controller support hw/intc: arm_gicv3_hvf: save/restore Apple GIC state accel, hw/arm, include/system/hvf: infrastructure changes for HVF vGIC target/arm: hvf: instantiate GIC early hw/arm, target/arm: nested virtualisation on HVF hvf: only call hvf_sync_vtimer() when running without the platform vGIC hvf: gate ARM_FEATURE_PMU register emulation behind not being at EL2 hvf: arm: allow exposing minimal PMU when running with nested virt on target/arm: hvf: add asserts for code paths not leveraged when using the vGIC hvf: sync registers used at EL2 target/arm: hvf: pass through CNTHCTL_EL2 and MDCCINT_EL1 hvf: arm: SME2 availability fixes hvf: enable nested virtualisation support accel/hvf/hvf-all.c | 51 ++ accel/stubs/hvf-stub.c | 2 + hw/arm/virt.c | 37 +- hw/intc/arm_gicv3_common.c | 4 + hw/intc/arm_gicv3_hvf.c | 822 +++++++++++++++++++++++++++++ hw/intc/arm_gicv3_hvf_stub.c | 25 + hw/intc/meson.build | 2 + include/hw/intc/arm_gicv3_common.h | 4 + include/system/hvf.h | 8 + system/vl.c | 2 + target/arm/hvf/hvf.c | 449 +++++++++++++++- target/arm/hvf/hvf_sme_stubs.h | 158 ++++++ target/arm/hvf/sysreg.c.inc | 52 ++ target/arm/hvf_arm.h | 46 ++ target/arm/machine.c | 2 +- 15 files changed, 1638 insertions(+), 26 deletions(-) create mode 100644 hw/intc/arm_gicv3_hvf.c create mode 100644 hw/intc/arm_gicv3_hvf_stub.c create mode 100644 target/arm/hvf/hvf_sme_stubs.h -- 2.50.1 (Apple Git-155)