Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2972364lqo; Tue, 14 May 2024 15:46:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXd12J5Z7ck0khB07ijm5CV5mOZR7eMaIiohcn4VoJEvrse+72/C2Pjgf5093O/2VgBIS58J2kH9pnTCcUiiivcaZz89a8vhyQ8mXNk7g== X-Google-Smtp-Source: AGHT+IFxyWbUFNyZ8rXPsn381Hmgf/8bcXHI4jb8NBaEBw9jKCWWY5oLWDdWrhZnsNhP0/Kpoxcy X-Received: by 2002:a05:6512:ba3:b0:518:8d15:8810 with SMTP id 2adb3069b0e04-5220fc7354cmr11977276e87.14.1715726811237; Tue, 14 May 2024 15:46:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715726811; cv=pass; d=google.com; s=arc-20160816; b=Ixs22RJQjXnPw9Am1bIAv7fbrWlSIV1e/4ZPVL7XvayBnL7zNCLDJEdkmnY0ZEoOfo HlYtYcBz6kOJlPzNS4A5E4+5f9ndQ0Nd9uTMVT6R/f4w3pA0Pa7gI+Y3Kq/9WjPilb1h sIrr+8QsyljFarlo8dM3of4zCvGUVU/q8Vt9EtIabgm504FPAfkQrAWFFzzF3Dv4KdBM YdA5Z5PqdNX79U9hRQzFstEYzjERs+a1wPhp53QBZWwACSTVN4jW1pum7fsquYdO7kn3 p99dUTV/pCFizBAFf+M0OE9QnBveteAbg5S1xhzetUYGLTw1MIv3UzBFrph2ECdjsDR/ eiWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=gy5I6n1XdVqSkd/zdu3TEf1Kw11JgiudWXaTRTptXPI=; fh=5+mhPmlvReuuO3ip8XQ+GwIQVcZGbRQ3OJ50BSBicsY=; b=tfPayIZi96YZpDoW/Ow34hBQ3cYAR8m0ACHqq9nQNbK/wrBwanXeGqBTKXDPIY8kgb pzMxSK2NaOzk9oZRaEnFam20+ZXzCS+UPyA316lsb2Lmo+OD1swSNcKghjemHj0uA4ZO 2B1iSvEYQIazg10oyV2yJHj6nfE5okTbm1jRfX7vngAeu7RK/d4X3HSGptlM7oq0hr6u UMCtbZr8ReOq2l+1v/DdTqH9pjyWSXV7yYKdYV3pgzYjqXWmfGeRGbu+ZalFsw8vH60u zldjKwItajhkJIakxdBy4xoOuvG8sopEYqZdDUWJPp42c7YqxEGSxdqTXdDoaN5B1N8D zn8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=kkK+sB9O; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-179235-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17bd55c7si650913466b.700.2024.05.14.15.46.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 15:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179235-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=kkK+sB9O; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-179235-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F31A01F221C4 for ; Tue, 14 May 2024 22:46:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4442A184135; Tue, 14 May 2024 22:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="kkK+sB9O" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B93D181D08; Tue, 14 May 2024 22:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715726730; cv=none; b=Ico4/m1RTYbgJMjvrlRG7q2Zp8gG+RGFqzoKC+D9GUHKlZnmuY4LRHPBU1pOAVmzHq95Limu26i+cv2Ayi2zvvoX6wub7ZneFP+Vc/tOpDBIEDUBXBkXn9iXgx7ngbhtJKH24+NkblC+IEc/WgPz5FR4CPaBEx/TXIQS3BUpkB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715726730; c=relaxed/simple; bh=LxzjesEa2yrOp7NiBZaeavpLyG8UmGpbdareqGavSSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iAHtQP4VRfigbWOysbdqf+CIS3i1J64P7uWuoCzsZ3AbDjJ2aAmBBrdY4R8MQtpm6zGTJRos7XjpFe1StYgorWV0QXxz/IUvhig0ZBFxt44Av5CNISZNbqu+7CAsrtMQZZVL5Ni05bU0SlbY4QKuCcVL3McbKyDbvgaRNDZrCsw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=kkK+sB9O; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from xps-8930.corp.microsoft.com (unknown [131.107.160.48]) by linux.microsoft.com (Postfix) with ESMTPSA id CEA242095D0B; Tue, 14 May 2024 15:45:20 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CEA242095D0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715726721; bh=gy5I6n1XdVqSkd/zdu3TEf1Kw11JgiudWXaTRTptXPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kkK+sB9Ob6YQYJHnZe+I7bfizHzznTUhZEzNZYosbYY9NSZiLEGrYc+XgvtsCC65p ZeXmurF1PgbwOg9frqVYVBYJNQXp8OPnu+2+qge5d/vDvBkEW9yj3wY/CduAq4tscq 5f2yr0cYzCE254biGL/prCEZ2KvXAIOrOSNILTf4= 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, 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 Cc: ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v2 1/6] arm64/hyperv: Support DeviceTree Date: Tue, 14 May 2024 15:43:48 -0700 Message-ID: <20240514224508.212318-2-romank@linux.microsoft.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514224508.212318-1-romank@linux.microsoft.com> References: <20240514224508.212318-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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