]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: KVM: Register perf callbacks for guest
authorBibo Mao <maobibo@loongson.cn>
Tue, 18 Mar 2025 08:48:08 +0000 (16:48 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Tue, 18 Mar 2025 08:48:08 +0000 (16:48 +0800)
Add selection for GUEST_PERF_EVENTS if KVM is enabled, also add perf
callback register when KVM module is loading.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/Kconfig
arch/loongarch/kvm/main.c

index 97a811077ac3afd6cd3ead400146c05ebde97a1d..40eea6da7c2598eb3accc4fb0c5bda5b9d3e7f4d 100644 (file)
@@ -33,6 +33,7 @@ config KVM
        select KVM_MMIO
        select KVM_XFER_TO_GUEST_WORK
        select SCHED_INFO
+       select GUEST_PERF_EVENTS if PERF_EVENTS
        help
          Support hosting virtualized guest machines using
          hardware virtualization extensions. You will need
index b6864d6e5ec8d2aedf59a6a69777ad0830f5c1a7..d165cd38c6bb38ad3623df186f533cf7b4c3faba 100644 (file)
@@ -394,6 +394,7 @@ static int kvm_loongarch_env_init(void)
        }
 
        kvm_init_gcsr_flag();
+       kvm_register_perf_callbacks(NULL);
 
        /* Register LoongArch IPI interrupt controller interface. */
        ret = kvm_loongarch_register_ipi_device();
@@ -425,6 +426,8 @@ static void kvm_loongarch_env_exit(void)
                }
                kfree(kvm_loongarch_ops);
        }
+
+       kvm_unregister_perf_callbacks();
 }
 
 static int kvm_loongarch_init(void)