Skip to content

Commit adc6ae9

Browse files
committed
KVM: SVM: Unregister KVM's GALog notifier on kvm-amd.ko exit
Unregister the GALog notifier (used to get notified of wake events for blocking vCPUs) on kvm-amd.ko exit so that a KVM or IOMMU driver bug that results in a spurious GALog event "only" results in a spurious IRQ, and doesn't trigger a use-after-free due to executing unloaded module code. Fixes: 5881f73 ("svm: Introduce AMD IOMMU avic_ga_log_notifier") Reported-by: Hou Wenlong <houwenlong.hwl@antgroup.com> Closes: https://lore.kernel.org/all/20250918130320.GA119526@k08j02272.eu95sqa Link: https://patch.msgid.link/20251016190643.80529-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 59a217c commit adc6ae9

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,3 +1243,9 @@ bool __init avic_hardware_setup(void)
12431243

12441244
return true;
12451245
}
1246+
1247+
void avic_hardware_unsetup(void)
1248+
{
1249+
if (avic)
1250+
amd_iommu_register_ga_log_notifier(NULL);
1251+
}

arch/x86/kvm/svm/svm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,8 @@ static void svm_hardware_unsetup(void)
921921
{
922922
int cpu;
923923

924+
avic_hardware_unsetup();
925+
924926
sev_hardware_unsetup();
925927

926928
for_each_possible_cpu(cpu)

arch/x86/kvm/svm/svm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ extern struct kvm_x86_nested_ops svm_nested_ops;
805805
)
806806

807807
bool __init avic_hardware_setup(void);
808+
void avic_hardware_unsetup(void);
808809
int avic_ga_log_notifier(u32 ga_tag);
809810
void avic_vm_destroy(struct kvm *kvm);
810811
int avic_vm_init(struct kvm *kvm);

0 commit comments

Comments
 (0)