* [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload
@ 2025-03-15 3:10 Sean Christopherson
2025-04-28 11:40 ` Joerg Roedel
2025-09-18 13:03 ` Hou Wenlong
0 siblings, 2 replies; 5+ messages in thread
From: Sean Christopherson @ 2025-03-15 3:10 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, Sean Christopherson
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>
---
drivers/iommu/amd/iommu.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index b48a72bd7b23..b314523d9194 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -982,6 +982,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);
base-commit: ea9bd29a9c0d757b3384ae3e633e6bbaddf00725
--
2.49.0.rc1.451.g8f38331e32-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload
2025-03-15 3:10 [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload Sean Christopherson
@ 2025-04-28 11:40 ` Joerg Roedel
2025-09-18 13:03 ` Hou Wenlong
1 sibling, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2025-04-28 11:40 UTC (permalink / raw)
To: Sean Christopherson; +Cc: iommu, linux-kernel
On Fri, Mar 14, 2025 at 08:10:48PM -0700, Sean Christopherson wrote:
> drivers/iommu/amd/iommu.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload
2025-03-15 3:10 [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload Sean Christopherson
2025-04-28 11:40 ` Joerg Roedel
@ 2025-09-18 13:03 ` Hou Wenlong
2025-10-07 17:54 ` Sean Christopherson
1 sibling, 1 reply; 5+ messages in thread
From: Hou Wenlong @ 2025-09-18 13:03 UTC (permalink / raw)
To: Sean Christopherson; +Cc: Joerg Roedel, iommu, linux-kernel
On Fri, Mar 14, 2025 at 08:10:48PM -0700, Sean Christopherson wrote:
> 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>
> ---
> drivers/iommu/amd/iommu.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index b48a72bd7b23..b314523d9194 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -982,6 +982,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);
>
> base-commit: ea9bd29a9c0d757b3384ae3e633e6bbaddf00725
> --
> 2.49.0.rc1.451.g8f38331e32-goog
>
>
Hi Sean,
Sorry to bother you. I'm reworking the hardware_setup() path in our
internal multi-KVM, but I didn't see any usage of
'amd_iommu_register_ga_log_notifier(NULL)' in the KVM code for now. Has
it not been committed?
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload
2025-09-18 13:03 ` Hou Wenlong
@ 2025-10-07 17:54 ` Sean Christopherson
2025-10-27 11:13 ` Joerg Roedel
0 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2025-10-07 17:54 UTC (permalink / raw)
To: Hou Wenlong; +Cc: Joerg Roedel, iommu, linux-kernel
On Thu, Sep 18, 2025, Hou Wenlong wrote:
> On Fri, Mar 14, 2025 at 08:10:48PM -0700, Sean Christopherson wrote:
> > 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>
> > ---
> > drivers/iommu/amd/iommu.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> > index b48a72bd7b23..b314523d9194 100644
> > --- a/drivers/iommu/amd/iommu.c
> > +++ b/drivers/iommu/amd/iommu.c
> > @@ -982,6 +982,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);
> >
> > base-commit: ea9bd29a9c0d757b3384ae3e633e6bbaddf00725
> > --
> > 2.49.0.rc1.451.g8f38331e32-goog
> >
> >
> Hi Sean,
>
> Sorry to bother you. I'm reworking the hardware_setup() path in our
> internal multi-KVM, but I didn't see any usage of
> 'amd_iommu_register_ga_log_notifier(NULL)' in the KVM code for now. Has
> it not been committed?
Huh. I completely forgot to send (or even write?) the patch. I'll send one
shortly.
Thanks much!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload
2025-10-07 17:54 ` Sean Christopherson
@ 2025-10-27 11:13 ` Joerg Roedel
0 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2025-10-27 11:13 UTC (permalink / raw)
To: Sean Christopherson; +Cc: Hou Wenlong, iommu, linux-kernel
On Tue, Oct 07, 2025 at 10:54:41AM -0700, Sean Christopherson wrote:
> Huh. I completely forgot to send (or even write?) the patch. I'll send one
> shortly.
When you do, can you please add
Vasant Hegde <vasant.hegde@amd.com> and
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
on Cc as well? Their reviews are important in moving this forward.
Thanks,
Joerg
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-27 11:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 3:10 [PATCH] iommu/amd: Ensure GA log notifier callbacks finish running before module unload Sean Christopherson
2025-04-28 11:40 ` Joerg Roedel
2025-09-18 13:03 ` Hou Wenlong
2025-10-07 17:54 ` Sean Christopherson
2025-10-27 11:13 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox