From patchwork Sat Mar 15 00:19:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kisel X-Patchwork-Id: 14017634 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9A952C282EC for ; Sat, 15 Mar 2025 00:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=IFDGTilfS/bhksZe1/+y1s5O6KhZVkjslHMlSRzOeLw=; b=l+naf9IsT7WXsAU4JFHuMY0Gxz MMuejvgQLUQhSA5Fm+VccEdMhm4ChiXHyL+XWyrjNB+ahiF/zVVx2wWjnGUPu0KYXVJW1vq6gNKS3 wo7ugHBBuDKy+HW/8dNPt9uP3nXz0JebVxfRfMfSRhe/j4YemCqxw3Dsh/loPWvW3S1tPCqKvZ45P 6j0oah8yiC81IzqWBitgipjGpnF3wrbS7Gfswud7fvn4RI/1CkddPs9Q4J2qxx+ZFlf/fhZHoFEfz SZ4CC0A3FOmyp+vqIQs/Cf/XS8hU3Gii+dJ53A4oCRKBUMaSupj4UzluL0rh5G79BAVB0JIsTrkMl Wxx5bCRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1ttFHD-0000000Fa0W-3uqI; Sat, 15 Mar 2025 00:21:19 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1ttFFW-0000000FZQQ-2p9V for linux-arm-kernel@lists.infradead.org; Sat, 15 Mar 2025 00:19:35 +0000 Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id D4EB02033459; Fri, 14 Mar 2025 17:19:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D4EB02033459 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1741997973; bh=IFDGTilfS/bhksZe1/+y1s5O6KhZVkjslHMlSRzOeLw=; h=From:To:Cc:Subject:Date:From; b=AHVPYberswjwKcT6Z77GLpqu3dEV9bow+4NNwPmPVXC8jNOSVCwAftXKyFC4iOBwa 6zVpXN4gOHy9ZubjASdeyzlqaN2gCJZAfAzmNxPZICtqSWezuX/ebu5eyWbfKQ1DAI 7kvgRfFBf6WbJLAIeBc05WzefEpZfCws0jVyHsd0= From: Roman Kisel To: arnd@arndb.de, bhelgaas@google.com, bp@alien8.de, catalin.marinas@arm.com, conor+dt@kernel.org, dan.carpenter@linaro.org, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, joey.gouly@arm.com, krzk+dt@kernel.org, kw@linux.com, kys@microsoft.com, lenb@kernel.org, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, mark.rutland@arm.com, maz@kernel.org, mingo@redhat.com, oliver.upton@linux.dev, rafael@kernel.org, robh@kernel.org, ssengar@linux.microsoft.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tglx@linutronix.de, wei.liu@kernel.org, will@kernel.org, yuzenghui@huawei.com, devicetree@vger.kernel.org, kvmarm@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v6 00/11] arm64: hyperv: Support Virtual Trust Level Boot Date: Fri, 14 Mar 2025 17:19:20 -0700 Message-ID: <20250315001931.631210-1-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250314_171934_767086_DF78F2D5 X-CRM114-Status: GOOD ( 33.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch set allows the Hyper-V code to boot on ARM64 inside a Virtual Trust Level. These levels are a part of the Virtual Secure Mode documented in the Top-Level Functional Specification available at https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/vsm. The OpenHCL paravisor https://github.com/microsoft/openvmm/tree/main/openhcl can serve as a practical application of these patches on ARM64. For validation, I built kernels for the {x86_64, ARM64} x {VTL0, VTL2} set with a small initrd embedded into the kernel and booted VMs managed by Hyper-V and OpenVMM off of that. Starting from V5, the patch series includes a non-functional change to KVM on arm64 which I tested as well. [V6] - Use more intuitive Kconfig update. - Remove ifdef for getting IRQ number ** Thank you, Arnd! ** - Simplify code for finding the parent IRQ domain. ** Thank you, Bjorn! ** - Remove a superfluous check. ** Thank you, Dan! ** - Make the commit title and descrtiption legible. - Don't set additionalProperties to true. ** Thank you, Krzysztof! ** - Fix spelling in the commit title and description. - Trade-offs for options in Kconfig. - Export the new symbol as hyperv-pci can be built as a module. ** Thank you, Michael! ** - Simplify code for getting IRQ number. ** Thank you, Rob! ** - Add comment to clarify when running in VTL mode is reported. ** Thank you, Wei! ** [V5] https://lore.kernel.org/linux-hyperv/20250307220304.247725-1-romank@linux.microsoft.com/ - Provide and use a common SMCCC-based infra for the arm64 hypervisor guests to detect hypervisor presence. ** Thank you, Arnd! ** - Fix line wraps to follow the rest of the code. - Open-code getting IRQ domain parent in the ACPI case to make the code better. ** Thank you, Bjorn! ** - Test the binding with the latest dtschema. - Clean up the commit title and description. - Use proper defines for known constants. ** Thank you, Krzysztof! ** - Extend comment on why ACPI v6 is checked for. - Reorder patches to make sure that even with partial series application the compilation succeeds. - Report VTL the kernel runs in. - Use "X86_64" in Kconfig rather than "X86". - Extract a non-functional change for hv_get_vmbus_root_device() into a separate patch. ** Thank you, Michael! ** [V4] https://lore.kernel.org/linux-hyperv/20250212014321.1108840-1-romank@linux.microsoft.com/ - Fixed wording to match acronyms defined in the "Terms and Abbreviations" section of the SMCCC specification throughout the patch series. **Thank you, Michael!** - Replaced the hypervisor ID containing ASCII with an UUID as required by the specification. **Thank you, Michael!** - Added an explicit check for `SMCCC_RET_NOT_SUPPORTED` when discovering the hypervisor presence to make the backward compatibility obvious. **Thank you, Saurabh!** - Split the fix for `get_vtl(void)` out to make it easier to backport. - Refactored the configuration options as requested to eliminate the risk of building non-functional kernels with randomly selected options. **Thank you, Michael!** - Refactored the changes not to introduce an additional file with a one-line function. **Thank you, Wei!** - Fixed change description for the VMBus DeviceTree changes, used `scripts/get_maintainers.pl` on the latest kernel to get the up-to-date list of maintainers as requested. **Thank you, Krzysztof!** - Removed the added (paranoidal+superfluous) checks for DMA coherence in the VMBus driver and instead relied on the DMA and the OF subsystem code. **Thank you, Arnd, Krzysztof, Michael!** - Used another set of APIs for discovering the hardware interrupt number in the VMBus driver to be able to build the driver as a module. **Thank you, Michael, Saurabh!** - Renamed the newly introduced `get_vmbus_root_device(void)` function to `hv_get_vmbus_root_device(void)` as requested. **Thank you, Wei!** - Applied the suggested small-scale refactoring to simplify changes to the Hyper-V PCI driver. Taking the offered liberty of doing the large scale refactoring in another patch series. **Thank you, Michael!** - Added a fix for the issue discovered internally where the CPU would not get the interrupt from a PCI device attached to VTL2 as the shared peripheral interrupt number (SPI) was not offset by 32 (the first valid SPI number). **Thank you, Brian!** [V3] https://lore.kernel.org/lkml/20240726225910.1912537-1-romank@linux.microsoft.com/ - Employed the SMCCC function recently implemented in the Microsoft Hyper-V hypervisor to detect running on Hyper-V/arm64. No dependence on ACPI/DT is needed anymore although the source code still falls back to ACPI as the new hypervisor might be available only in the Windows Insiders channel just yet. - As a part of the above, refactored detecting the hypervisor via ACPI FADT. - There was a suggestion to explore whether it is feasible or not to express that ACPI must be absent for the VTL mode and present for the regular guests in the Hyper-V Kconfig file. My current conclusion is that this will require refactoring in many places. That becomes especially convoluted on x86_64 due to the MSI and APIC dependencies. I'd ask to let us tackle that in another patch series (or chalk up to nice-have's rather than fires to put out) to separate concerns and decrease chances of breakage. - While refactoring `get_vtl(void)` and the related code, fixed the hypercall output address not to overlap with the input as the Hyper-V TLFS mandates: "The input and output parameter lists cannot overlap or cross page boundaries." See https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/hypercall-interface for more. Some might argue that should've been a topic for a separate patch series; I'd counter that the change is well-contained (one line), has no dependencies, and makes the code legal. - Made the VTL boot code (c)leaner as was suggested. - Set DMA cache coherency for the VMBus. - Updated DT bindings in the VMBus documentation (separated out into a new patch). - Fixed `vmbus_set_irq` to use the API that works both for the ACPI and OF. - Reworked setting up the vPCI MSI IRQ domain in the non-ACPI case. The logic looks a bit fiddly/ad-hoc as I couldn't find the API that would fit the bill. Added comments to explain myself. [V2] https://lore.kernel.org/all/20240514224508.212318-1-romank@linux.microsoft.com/ - Decreased number of #ifdef's - Updated the wording in the commit messages to adhere to the guidlines - Sending to the correct set of maintainers and mail lists [V1] https://lore.kernel.org/all/20240510160602.1311352-1-romank@linux.microsoft.com/ Roman Kisel (11): arm64: kvm, smccc: Introduce and use API for detecting hypervisor presence arm64: hyperv: Use SMCCC to detect hypervisor presence Drivers: hv: Enable VTL mode for arm64 Drivers: hv: Provide arch-neutral implementation of get_vtl() arm64: hyperv: Initialize the Virtual Trust Level field arm64, x86: hyperv: Report the VTL the system boots in dt-bindings: microsoft,vmbus: Add interrupt and DMA coherence properties Drivers: hv: vmbus: Get the IRQ number from DeviceTree Drivers: hv: vmbus: Introduce hv_get_vmbus_root_device() ACPI: irq: Introduce acpi_get_gsi_dispatcher() PCI: hv: Get vPCI MSI IRQ domain from DeviceTree .../bindings/bus/microsoft,vmbus.yaml | 17 ++++- arch/arm64/hyperv/mshyperv.c | 46 ++++++++++-- arch/arm64/kvm/hypercalls.c | 5 +- arch/x86/hyperv/hv_init.c | 34 --------- arch/x86/hyperv/hv_vtl.c | 7 +- drivers/acpi/irq.c | 15 +++- drivers/firmware/smccc/kvm_guest.c | 10 +-- drivers/firmware/smccc/smccc.c | 19 +++++ drivers/hv/Kconfig | 6 +- drivers/hv/hv_common.c | 31 ++++++++ drivers/hv/vmbus_drv.c | 53 ++++++++++++-- drivers/pci/controller/pci-hyperv.c | 73 +++++++++++++++++-- include/asm-generic/mshyperv.h | 6 ++ include/hyperv/hvgdk_mini.h | 2 +- include/linux/acpi.h | 5 +- include/linux/arm-smccc.h | 55 +++++++++++++- include/linux/hyperv.h | 2 + 17 files changed, 307 insertions(+), 79 deletions(-) base-commit: d9608f6dc3e3229a40e1db1dab573d6882f38c2a