lkml.org 
[lkml]   [2022]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 16/44] KVM: arm64: Unregister perf callbacks if hypervisor finalization fails
From
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: bfa79a805454 ("KVM: arm64: Elevate hypervisor mappings creation at EL2")
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/arm64/kvm/arm.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 73644def7780..f400a8c029dd 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1839,12 +1839,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;
@@ -2237,7 +2246,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();
@@ -2258,7 +2267,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();
--
2.38.1.431.g37b22c650d-goog
\
 
 \ /
  Last update: 2022-11-03 00:23    [W:0.589 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site