From mboxrd@z Thu Jan 1 00:00:00 1970 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 16FCEC25B74 for ; Thu, 16 May 2024 15:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2F3B4r4h2wwpJMOY/iG7xInxw9k3J3ZuX204IiiGWsY=; b=nPfol+FLbjsrAe bNUnVdVyKrI/m+TjbxmO8I50RGngIwbMYkD+Z2SibeKuJ5dghwQqoNeaGh+ncVzoeynjDnlMlYQ1F 7iGK1sgYmwUhiUkDFjhyRK9ndxcodvClEQzLVKOmvSWI0UayO5L9FiWXyFU+KqFO07jbSMOzjEVvA 1d93xnnmn2zvojAljFtDxku/CaE87ygkekFAq6X66x2JPSpjyeleLaIAloiRtwsAvdW/YN8HXfyKN vZwmyO+rEYytfvuPtNW3FRiAmYy+4UJYXeWaByWZWLKR7Iiy/IFJsg1TUXpFbepFSbm6uYbeKJ6uv KaoRHgudtKVOaBqt6UNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7d0t-00000005Jod-34Te; Thu, 16 May 2024 15:27: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 1s7d0n-00000005JlG-2Zrn for linux-arm-kernel@lists.infradead.org; Thu, 16 May 2024 15:27:20 +0000 Received: from [10.137.186.190] (unknown [131.107.159.62]) by linux.microsoft.com (Postfix) with ESMTPSA id 5FC4B20B915A; Thu, 16 May 2024 08:27:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FC4B20B915A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715873232; bh=VYw2CBFjzoPTujslbESLr1CJ6eokJI9FsmFec2GE+5Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=JzU6VQwPnDgbMyagVyu7XqnShkR+OoIMv1PiyI6c8vySazBXPTP89U3QX55rMeN9P eiLb6A/YK7IWrQgnf8XdBiCzyCtDgr2Dgi8M/N05AinyH7IlTmsfRCLFfFRAmVOAAt YU54Hr3Y0apONAux+8AwswlIiJfpZ8lltciPPiDc= Message-ID: <9b216f16-a2ea-48d7-8986-f0c2e3f3d009@linux.microsoft.com> Date: Thu, 16 May 2024 08:27:12 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/6] arm64/hyperv: Support DeviceTree To: Elliot Berman Cc: 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, mhklinux@outlook.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, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev References: <20240514224508.212318-1-romank@linux.microsoft.com> <20240514224508.212318-2-romank@linux.microsoft.com> <20240515143359142-0700.eberman@hu-eberman-lv.qualcomm.com> Content-Language: en-US From: Roman Kisel In-Reply-To: <20240515143359142-0700.eberman@hu-eberman-lv.qualcomm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_082718_084098_4110D5E4 X-CRM114-Status: GOOD ( 18.71 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/15/2024 3:02 PM, Elliot Berman wrote: > On Tue, May 14, 2024 at 03:43:48PM -0700, Roman Kisel wrote: >> The Virtual Trust Level platforms rely on DeviceTree, and the >> arm64/hyperv code supports ACPI only. Update the logic to >> support DeviceTree on boot as well as ACPI. > > Could you use Call UID query from SMCCC? KVM [1] and Gunyah [2] have > been using this to identify if guest is running under those respective > hypervisors. This works in both DT and ACPI cases. > > [1]: https://lore.kernel.org/all/20210330145430.996981-2-maz@kernel.org/ > [2]: https://lore.kernel.org/all/20240222-gunyah-v17-4-1e9da6763d38@quicinc.com/ That would be very neat indeed, thanks! Talking to the hypervisor folks. >> >> Signed-off-by: Roman Kisel >> --- >> arch/arm64/hyperv/mshyperv.c | 34 +++++++++++++++++++++++++++++----- >> 1 file changed, 29 insertions(+), 5 deletions(-) >> >> diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c >> index b1a4de4eee29..208a3bcb9686 100644 >> --- a/arch/arm64/hyperv/mshyperv.c >> +++ b/arch/arm64/hyperv/mshyperv.c >> @@ -15,6 +15,9 @@ >> #include >> #include >> #include >> +#include >> +#include >> +#include >> #include >> >> static bool hyperv_initialized; >> @@ -27,6 +30,29 @@ int hv_get_hypervisor_version(union hv_hypervisor_version_info *info) >> return 0; >> } >> >> +static bool hyperv_detect_fdt(void) >> +{ >> +#ifdef CONFIG_OF >> + const unsigned long hyp_node = of_get_flat_dt_subnode_by_name( >> + of_get_flat_dt_root(), "hypervisor"); >> + >> + return (hyp_node != -FDT_ERR_NOTFOUND) && >> + of_flat_dt_is_compatible(hyp_node, "microsoft,hyperv"); >> +#else >> + return false; >> +#endif >> +} >> + >> +static bool hyperv_detect_acpi(void) >> +{ >> +#ifdef CONFIG_ACPI >> + return !acpi_disabled && >> + !strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8); >> +#else >> + return false; >> +#endif >> +} >> + >> static int __init hyperv_init(void) >> { >> struct hv_get_vp_registers_output result; >> @@ -35,13 +61,11 @@ static int __init hyperv_init(void) >> >> /* >> * Allow for a kernel built with CONFIG_HYPERV to be running in >> - * a non-Hyper-V environment, including on DT instead of ACPI. >> + * a non-Hyper-V environment. >> + * >> * In such cases, do nothing and return success. >> */ >> - if (acpi_disabled) >> - return 0; >> - >> - if (strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8)) >> + if (!hyperv_detect_fdt() && !hyperv_detect_acpi()) >> return 0; >> >> /* Setup the guest ID */ >> -- >> 2.45.0 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -- Thank you, Roman _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel