lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  1 Nov 2022 23:24:08 -0700
From:   isaku.yamahata@...el.com
To:     linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        Paolo Bonzini <pbonzini@...hat.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Marc Zyngier <maz@...nel.org>
Cc:     isaku.yamahata@...el.com, isaku.yamahata@...il.com
Subject: [PATCH 1/4] KVM: Remove on_each_cpu(hardware_disable_nolock) in kvm_exit()

From: Isaku Yamahata <isaku.yamahata@...el.com>

hardware_enable/disable_nolock() check if the hardware is already
enabled/disabled and work as nop when they are called multiple times. Also
kvm_usage_count tracks the number of the existing VMs.

When VM is created/destroyed by kvm_create/destroy_vm(),
hardware_enable/disable_all() and module_get/put() are called.  It means
when kvm module is removed, it's guaranteed that there is no vm
(kvm_usage_count = 0) and that hardware_disable_nolock() was called on each
cpus.

Although the module exit function, kvm_exit(), calls
on_each_cpu(hardware_disable_nolock), it's essentially nop.  Eliminate nop
call in kvm_exit() and add WARN_ON(kvm_usage_count) to prove that there is
no remaining VMs.

Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
---
 virt/kvm/kvm_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1376a47fedee..a8c4e62b29ca 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -5945,6 +5945,8 @@ void kvm_exit(void)
 {
 	int cpu;
 
+	WARN_ON(kvm_usage_count);
+
 	debugfs_remove_recursive(kvm_debugfs_dir);
 	misc_deregister(&kvm_dev);
 	for_each_possible_cpu(cpu)
@@ -5954,7 +5956,6 @@ void kvm_exit(void)
 	unregister_syscore_ops(&kvm_syscore_ops);
 	unregister_reboot_notifier(&kvm_reboot_notifier);
 	cpuhp_remove_state_nocalls(CPUHP_AP_KVM_STARTING);
-	on_each_cpu(hardware_disable_nolock, NULL, 1);
 	kvm_arch_hardware_unsetup();
 	kvm_arch_exit();
 	kvm_irqfd_exit();
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ