]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/amd: Ensure GA log notifier callbacks finish running before module unload
authorSean Christopherson <seanjc@google.com>
Sat, 15 Mar 2025 03:10:48 +0000 (20:10 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:04:19 +0000 (11:04 +0100)
[ Upstream commit 94c721ea03c7078163f41dbaa101ac721ddac329 ]

Synchronize RCU when unregistering KVM's GA log notifier to ensure all
in-flight interrupt handlers complete before KVM-the module is unloaded.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20250315031048.2374109-1-seanjc@google.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/amd/iommu.c

index a9a3f9c649c7e67930806108e85b34bd756bcd4e..334303b1d27bb7186e60bfc7818449a59cc3fb7b 100644 (file)
@@ -750,6 +750,14 @@ int amd_iommu_register_ga_log_notifier(int (*notifier)(u32))
 {
        iommu_ga_log_notifier = notifier;
 
+       /*
+        * Ensure all in-flight IRQ handlers run to completion before returning
+        * to the caller, e.g. to ensure module code isn't unloaded while it's
+        * being executed in the IRQ handler.
+        */
+       if (!notifier)
+               synchronize_rcu();
+
        return 0;
 }
 EXPORT_SYMBOL(amd_iommu_register_ga_log_notifier);