]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mshv: unmap debugfs stats pages on kexec
authorJork Loeser <jloeser@linux.microsoft.com>
Mon, 27 Apr 2026 21:38:54 +0000 (14:38 -0700)
committerWei Liu <wei.liu@kernel.org>
Wed, 29 Apr 2026 22:56:53 +0000 (22:56 +0000)
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 <jloeser@linux.microsoft.com>
Reviewed-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/mshv_debugfs.c
drivers/hv/mshv_synic.c

index 418b6dc8f3c2a1052c3e13860b2941a700a0b4e7..3c3e02237ae94503a82ec2137e49f26119a32fe5 100644 (file)
@@ -674,8 +674,10 @@ int __init mshv_debugfs_init(void)
 
        mshv_debugfs = debugfs_create_dir("mshv", NULL);
        if (IS_ERR(mshv_debugfs)) {
+               err = PTR_ERR(mshv_debugfs);
+               mshv_debugfs = NULL;
                pr_err("%s: failed to create debugfs directory\n", __func__);
-               return PTR_ERR(mshv_debugfs);
+               return err;
        }
 
        if (hv_root_partition()) {
@@ -710,6 +712,9 @@ remove_mshv_dir:
 
 void mshv_debugfs_exit(void)
 {
+       if (!mshv_debugfs)
+               return;
+
        mshv_debugfs_parent_partition_remove();
 
        if (hv_root_partition()) {
index 978a1cace3410bf53e438156bd1721f94c0c1e9e..88170ce6b83f073782bdb9d724c8f983baa29035 100644 (file)
@@ -723,6 +723,7 @@ mshv_unregister_doorbell(u64 partition_id, int doorbell_portid)
 static int mshv_synic_reboot_notify(struct notifier_block *nb,
                              unsigned long code, void *unused)
 {
+       mshv_debugfs_exit();
        cpuhp_remove_state(synic_cpuhp_online);
        return 0;
 }