mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 16:17:41 -04:00
KVM: arm64: Unregister perf callbacks if hypervisor finalization fails
Undo everything done by init_subsystems() if a later initialization step
fails, i.e. unregister perf callbacks in addition to unregistering the
power management notifier.
Fixes: bfa79a8054 ("KVM: arm64: Elevate hypervisor mappings creation at EL2")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221130230934.1014142-19-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
6baaeda878
commit
78b3bf485d
@@ -1846,12 +1846,21 @@ static int init_subsystems(void)
|
||||
kvm_register_perf_callbacks(NULL);
|
||||
|
||||
out:
|
||||
if (err)
|
||||
hyp_cpu_pm_exit();
|
||||
|
||||
if (err || !is_protected_kvm_enabled())
|
||||
on_each_cpu(_kvm_arch_hardware_disable, NULL, 1);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void teardown_subsystems(void)
|
||||
{
|
||||
kvm_unregister_perf_callbacks();
|
||||
hyp_cpu_pm_exit();
|
||||
}
|
||||
|
||||
static void teardown_hyp_mode(void)
|
||||
{
|
||||
int cpu;
|
||||
@@ -2254,7 +2263,7 @@ int kvm_arch_init(void *opaque)
|
||||
|
||||
err = init_subsystems();
|
||||
if (err)
|
||||
goto out_subs;
|
||||
goto out_hyp;
|
||||
|
||||
if (!in_hyp_mode) {
|
||||
err = finalize_hyp_mode();
|
||||
@@ -2275,7 +2284,7 @@ int kvm_arch_init(void *opaque)
|
||||
return 0;
|
||||
|
||||
out_subs:
|
||||
hyp_cpu_pm_exit();
|
||||
teardown_subsystems();
|
||||
out_hyp:
|
||||
if (!in_hyp_mode)
|
||||
teardown_hyp_mode();
|
||||
|
||||
Reference in New Issue
Block a user