From nobody Mon Apr 6 16:46:14 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E49953D75DE; Fri, 3 Apr 2026 19:06:24 +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=1775243186; cv=none; b=ZQMsvqHxlu1a153fhy7DyO00bAmI9lxWokN/6/PqzllIw/xQpOwRypqwJGiQjWWteLuhpVT/KlEnfHruxqMpFtvXl+6mluY0KHVfqDfv7TXtiZ2AB8qaOtgeDJH94HzxaGx38l6SFdiLcj7fnnr3ivzfTs7vfhU7W2WEzKhNXXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775243186; c=relaxed/simple; bh=eJFkaRo9CKhZlto6iDCuLzjnu9hkc3JVC3IjFHx3XJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=osO2NVXq7ijGgvRM634u3ox5Yem2vwcBBtoeSIoZjFde8v8oAqGitGh6uTDQ/0QP02z+TFoMaS7jSQVCJ+Dh7tXQVyHvMXJ0hMsjXTyGgImBS/xVOJ9neaIAoGi3M48YL/zS3J0Az+2qcVM8O+hvuTzmPQ/znPIB5zJdxgrDQDk= 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=HrXi5Jo4; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="HrXi5Jo4" Received: by linux.microsoft.com (Postfix, from userid 1241) id B41D120B6F1F; Fri, 3 Apr 2026 12:06:24 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B41D120B6F1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1775243184; bh=dtJ8seWmbMqGCQ41xKmiIdEUtLNh0z2d7AxXL8JOv/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrXi5Jo4aCtNeQjWW2ySDzF7PLp8VHraU4yAPuAZNZz+1bcBauCDK4A8pW+KSU3dN 7/Po/OVE7lqy/GljJjK3eaLJaoH9Om3iDBykRNAa6KhHkWcRJPzMC1EIG4xnjE0z2s lPR2kiba0B72qk93okoNmRPeIBahvHN6/nsdr1wc= From: Jork Loeser To: linux-hyperv@vger.kernel.org Cc: x86@kernel.org, "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Arnd Bergmann , Michael Kelley , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Jork Loeser Subject: [PATCH v2 6/6] mshv: unmap debugfs stats pages on kexec Date: Fri, 3 Apr 2026 12:06:12 -0700 Message-ID: <20260403190613.47026-7-jloeser@linux.microsoft.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260403190613.47026-1-jloeser@linux.microsoft.com> References: <20260403190613.47026-1-jloeser@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: quoted-printable Content-Type: text/plain; charset="utf-8" On L1VH, debugfs stats pages are overlay pages: the kernel allocates them and registers the GPAs with the hypervisor via HVCALL_MAP_STATS_PAGE2. These overlay mappings persist in the hypervisor across kexec. If the kexec'd kernel reuses those physical pages, the hypervisor's overlay semantics cause a machine check exception. Fix this by calling mshv_debugfs_exit() from the reboot notifier, which issues HVCALL_UNMAP_STATS_PAGE for each mapped stats page before kexec. This releases the overlay bindings so the physical pages can be safely reused. Guard mshv_debugfs_exit() against being called when init failed. Signed-off-by: Jork Loeser --- drivers/hv/mshv_debugfs.c | 7 ++++++- drivers/hv/mshv_root_main.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/hv/mshv_debugfs.c b/drivers/hv/mshv_debugfs.c index ebf2549eb44d..f9a4499cf8f3 100644 --- a/drivers/hv/mshv_debugfs.c +++ b/drivers/hv/mshv_debugfs.c @@ -676,8 +676,10 @@ int __init mshv_debugfs_init(void) =20 mshv_debugfs =3D debugfs_create_dir("mshv", NULL); if (IS_ERR(mshv_debugfs)) { + err =3D PTR_ERR(mshv_debugfs); + mshv_debugfs =3D NULL; pr_err("%s: failed to create debugfs directory\n", __func__); - return PTR_ERR(mshv_debugfs); + return err; } =20 if (hv_root_partition()) { @@ -712,6 +714,9 @@ int __init mshv_debugfs_init(void) =20 void mshv_debugfs_exit(void) { + if (!mshv_debugfs) + return; + mshv_debugfs_parent_partition_remove(); =20 if (hv_root_partition()) { diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c index 281f530b68a9..7038fd830646 100644 --- a/drivers/hv/mshv_root_main.c +++ b/drivers/hv/mshv_root_main.c @@ -2252,6 +2252,7 @@ root_scheduler_deinit(void) static int mshv_reboot_notify(struct notifier_block *nb, unsigned long code, void *unused) { + mshv_debugfs_exit(); cpuhp_remove_state(mshv_cpuhp_online); return 0; } --=20 2.43.0