From nobody Tue Nov 01 14:15:06 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N1sVM2fRMz4gQgG; Tue, 1 Nov 2022 14:15:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N1sVM1lyCz3lMJ; Tue, 1 Nov 2022 14:15:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667312107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rkMzMg5a0pxNzN8qsax9nqRbGwyFkvLYSilwdKAw91Y=; b=fp8ok6GEMv1xTvqV4qs79X02CG7fFfSglRyxs3AJSg/ft4LyNCMluTFmH15Fiw2rtxeMKB LSwfQq53vmD4+zFLSydV5wA/UNui4AHj0qGViMacIFvGi35VHJD+602lsyXk+iw/BQZ+Kq lMoFw+/1mHoVtRAXoLLmArj3z83wttGSX8co+liJgYwjFDsO1yPInyA2JmO7ghRJ/ewOIx fLhqKn9YetfwA5c4jP/qxRLagFL7aP74UDtBomQ0HrvkkKukFiXikpkATIZVF37Atq6xQ3 ZvPHjtaitgjK7uO3Qt40/6wCRe402Nu6cHxUZmQJqD0/UpKn/w+btHMYEBF+pA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N1sVM0V4TzKBJ; Tue, 1 Nov 2022 14:15:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A1EF67O088502; Tue, 1 Nov 2022 14:15:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A1EF6MH088501; Tue, 1 Nov 2022 14:15:06 GMT (envelope-from git) Date: Tue, 1 Nov 2022 14:15:06 GMT Message-Id: <202211011415.2A1EF6MH088501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wei Hu Subject: git: 654749832b89 - main - arm64: Hyper-V: fixing hung issue during Hyper-V initialization List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: whu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 654749832b8900656b40d317a3ad9beab2413a8d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667312107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rkMzMg5a0pxNzN8qsax9nqRbGwyFkvLYSilwdKAw91Y=; b=V74Y5HxWyHKplJjV8VrgSmC3oN7j9sv6xIzPp8DgiKrpk8Ue7ozVpdvC8sGWAlt9FZX0l5 8rP11VY247jE+GwghLOaJ7Jnx2RSruBsZ33yMG1skbpTAflmpHGZIvsyhkpxyPgDZyKShx d7+I1TW/5GjongrMpT6cJAKYaG36dkxIW4IklcaMh1aZsDgHuYJgKk35tmJKJUw2Eqm9Uo XdB0sBiX3VRLTp9MdN3/SgBfV+v9lXYWQCfrcMsHBDva8wTOlm53l6DwBdM2TZ23bn4dPN sC8/4dwuDQVUKc+ew1ytiV1h+O0a+q25EXj/oSyopa7+cVqccHJ9N0yoMYSAtw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667312107; a=rsa-sha256; cv=none; b=XURzsVUYWVTAryK1Vt3HLlVC3nRQvYFC/DQPTSS289jo41jaAQLjfSeLUbgo1xUs+5jk/w 22LsJIYclhtb27esJKIkmYwXgNZ5hlwKcfHASV/weyJRsxdMxkBgo71BwQifbXqSWpyKjx hpv8tExZXyWuneEe9Wpxxc8rvr9eiLNoO9JwSMsII0j4cPX4t1KzpEkePw0X0a3sp0k1vT ORbGZqeCnPcth8dtEp9PHrPnWbBfZoIYDdOmZgStSy4wpCtdxxWiF/ipNor8evHPhDq+0o 35jIhN349WPwtjZks+Dw9FwPT+BMzGBpIqUXniBjxX1/Do6CN6TEzaU/SM6LWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=654749832b8900656b40d317a3ad9beab2413a8d commit 654749832b8900656b40d317a3ad9beab2413a8d Author: Souradeep Chakrabarti AuthorDate: 2022-11-01 14:06:01 +0000 Commit: Wei Hu CommitDate: 2022-11-01 14:13:50 +0000 arm64: Hyper-V: fixing hung issue during Hyper-V initialization In non-Hyper-V systems during Hyper-V initialization, system initialization was getting hung, as hyperv_identify(), was returning successful irrespective of the type of the platform. Reviewed by: andrew, whu Fixes: 9729f076e4d Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D37219 --- sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c b/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c index eb915131fb6f..47390ad35c0f 100644 --- a/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c +++ b/sys/dev/hyperv/vmbus/aarch64/hyperv_aarch64.c @@ -50,12 +50,15 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include void hyperv_init_tc(void); int hypercall_page_setup(vm_paddr_t); void hypercall_disable(void); bool hyperv_identify_features(void); +static bool is_hyperv(void); + u_int hyperv_ver_major; u_int hyperv_features; u_int hyperv_recommends; @@ -80,12 +83,49 @@ hypercall_disable(void) return; } +/* + * This function verifies if the platform is Hyper-V or not. + * To do that we are using ACPI FADT and for that, acpi + * fadt is mapped first. + */ +static bool +is_hyperv(void) +{ + ACPI_TABLE_FADT *fadt; + vm_paddr_t physaddr; + uint64_t hypervid; + bool ret; + + physaddr = acpi_find_table(ACPI_SIG_FADT); + if (physaddr == 0) + return (false); + + fadt = acpi_map_table(physaddr, ACPI_SIG_FADT); + if (fadt == NULL) { + printf("hyperv: Unable to map the FADT\n"); + return (false); + } + + hypervid = fadt->HypervisorId; + acpi_unmap_table(fadt); + ret = strncmp((char *)&hypervid, "MsHyperV", 8) == 0 ? true : false; + return (ret); +} + bool hyperv_identify_features(void) { struct hv_get_vp_registers_output result; - vm_guest = VM_GUEST_HV; + if (resource_disabled("acpi", 0)) + return (false); + if (!is_hyperv()) + return (false); + + vm_guest = VM_GUEST_HV; + /* use MSRs to get the hyperv specific + * attributes. + */ hv_get_vpreg_128(CPUID_LEAF_HV_FEATURES, &result); hyperv_features = result.as32.a; hv_get_vpreg_128(CPUID_LEAF_HV_IDENTITY, &result);