From patchwork Fri Jul 26 22:59:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kisel X-Patchwork-Id: 13743242 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 B90A6C3DA4A for ; Fri, 26 Jul 2024 23:00:34 +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=Wo4Fp8TkCmVn8yH86WMFCY2WsxtnZocfrfH2vYB+z7M=; b=ITfzhCrKKleCdZRUV99K5QLYAq Ek9AKzGpQ2fhPieTv42Evfc2E+5i0w+Myf/BEUFOEi0hJv3MQmS2EWZkZCsTCcNFdehnRCXv8s56+ 0cyVwCl7LIfFDXba5HzZF6ML9TRLVvyV9/toWcIXBbSqnJCGNZaip2rlzlzT1m2J2dWL6eI77QpBm 08fKEvjleA1n3AXvJB/WhzLdrzoGTkx5maIhNvZud74qRogeqKrXsxE4hDFR4PpNFyXC+lGOuebC8 R3qQDQUyHtyT085wjYU5J+tUlkQrc40ewbi4cGrZcCat6CIWGIP47c2B+8PqSphAmC5LbSt4bGWnL iGDGayKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXTvD-00000005Hex-12BB; Fri, 26 Jul 2024 23:00:23 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXTuN-00000005HGj-0cD1 for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 22:59:33 +0000 Received: from romank-3650.corp.microsoft.com (unknown [131.107.159.62]) by linux.microsoft.com (Postfix) with ESMTPSA id C7BA020B7165; Fri, 26 Jul 2024 15:59:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C7BA020B7165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1722034768; bh=Wo4Fp8TkCmVn8yH86WMFCY2WsxtnZocfrfH2vYB+z7M=; h=From:To:Cc:Subject:Date:From; b=VRl6Q+mz2n9h+9OGx5PWEpyDLC1OWxflY56xHNQnyn+5WmwekkTVJNNi8kVco/EM6 DwJOCvFgdznYbNiTdIXbVD0HmIAmzYjW8C5obazj4d2I1Fb+VBfNID9SmVF7awhopk XIIZnXy/HCpf4N6jXHvRENN2Wgdqh5fcgVng8qOA= From: Roman Kisel To: arnd@arndb.de, bhelgaas@google.com, bp@alien8.de, catalin.marinas@arm.com, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kw@linux.com, kys@microsoft.com, lenb@kernel.org, lpieralisi@kernel.org, mingo@redhat.com, rafael@kernel.org, robh@kernel.org, tglx@linutronix.de, wei.liu@kernel.org, will@kernel.org, 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, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v3 0/7] arm64: hyperv: Support Virtual Trust Level Boot Date: Fri, 26 Jul 2024 15:59:03 -0700 Message-Id: <20240726225910.1912537-1-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_155931_383806_29723579 X-CRM114-Status: GOOD ( 20.97 ) 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 enables 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 [V3] - Employed the SMC 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/ For validation, I built kernels for the arch'es in question with the small initrd embedded into the kernel and booted the Hyper-V VMs off of that. Roman Kisel (7): arm64: hyperv: Use SMC to detect hypervisor presence Drivers: hv: Enable VTL mode for arm64 Drivers: hv: Provide arch-neutral implementation of get_vtl() arm64: hyperv: Boot in a Virtual Trust Level dt-bindings: bus: Add Hyper-V VMBus cache coherency and IRQs Drivers: hv: vmbus: Get the IRQ number from DT PCI: hv: Get vPCI MSI IRQ domain from DT .../bindings/bus/microsoft,vmbus.yaml | 11 +++ arch/arm64/hyperv/Makefile | 1 + arch/arm64/hyperv/hv_vtl.c | 13 ++++ arch/arm64/hyperv/mshyperv.c | 40 +++++++++-- arch/arm64/include/asm/mshyperv.h | 12 ++++ arch/x86/hyperv/hv_init.c | 34 --------- arch/x86/include/asm/hyperv-tlfs.h | 7 -- drivers/hv/Kconfig | 6 +- drivers/hv/hv_common.c | 47 +++++++++++- drivers/hv/vmbus_drv.c | 72 ++++++++++++++++--- drivers/pci/controller/pci-hyperv.c | 55 +++++++++++++- include/asm-generic/hyperv-tlfs.h | 7 ++ include/asm-generic/mshyperv.h | 6 ++ include/linux/hyperv.h | 2 + 14 files changed, 251 insertions(+), 62 deletions(-) create mode 100644 arch/arm64/hyperv/hv_vtl.c base-commit: 831bcbcead6668ebf20b64fdb27518f1362ace3a