Commit 78b3bf48 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

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: bfa79a80 ("KVM: arm64: Elevate hypervisor mappings creation at EL2")
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Message-Id: <20221130230934.1014142-19-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 6baaeda8
...@@ -1846,12 +1846,21 @@ static int init_subsystems(void) ...@@ -1846,12 +1846,21 @@ static int init_subsystems(void)
kvm_register_perf_callbacks(NULL); kvm_register_perf_callbacks(NULL);
out: out:
if (err)
hyp_cpu_pm_exit();
if (err || !is_protected_kvm_enabled()) if (err || !is_protected_kvm_enabled())
on_each_cpu(_kvm_arch_hardware_disable, NULL, 1); on_each_cpu(_kvm_arch_hardware_disable, NULL, 1);
return err; return err;
} }
static void teardown_subsystems(void)
{
kvm_unregister_perf_callbacks();
hyp_cpu_pm_exit();
}
static void teardown_hyp_mode(void) static void teardown_hyp_mode(void)
{ {
int cpu; int cpu;
...@@ -2254,7 +2263,7 @@ int kvm_arch_init(void *opaque) ...@@ -2254,7 +2263,7 @@ int kvm_arch_init(void *opaque)
err = init_subsystems(); err = init_subsystems();
if (err) if (err)
goto out_subs; goto out_hyp;
if (!in_hyp_mode) { if (!in_hyp_mode) {
err = finalize_hyp_mode(); err = finalize_hyp_mode();
...@@ -2275,7 +2284,7 @@ int kvm_arch_init(void *opaque) ...@@ -2275,7 +2284,7 @@ int kvm_arch_init(void *opaque)
return 0; return 0;
out_subs: out_subs:
hyp_cpu_pm_exit(); teardown_subsystems();
out_hyp: out_hyp:
if (!in_hyp_mode) if (!in_hyp_mode)
teardown_hyp_mode(); teardown_hyp_mode();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment