Commit 1dc0f02d authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: arm64: Do arm/arch initialization without bouncing through kvm_init()

Do arm/arch specific initialization directly in arm's module_init(), now
called kvm_arm_init(), instead of bouncing through kvm_init() to reach
kvm_arch_init().  Invoking kvm_arch_init() is the very first action
performed by kvm_init(), so from a initialization perspective this is a
glorified nop.

Avoiding kvm_arch_init() also fixes a mostly benign bug as kvm_arch_exit()
doesn't properly unwind if a later stage of kvm_init() fails.  While the
soon-to-be-deleted comment about compiling as a module being unsupported
is correct, kvm_arch_exit() can still be called by kvm_init() if any step
after the call to kvm_arch_init() succeeds.

Add a FIXME to call out that pKVM initialization isn't unwound if
kvm_init() fails, which is a pre-existing problem inherited from
kvm_arch_exit().

Making kvm_arch_init() a nop will also allow dropping kvm_arch_init() and
kvm_arch_exit() entirely once all other architectures follow suit.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Message-Id: <20221130230934.1014142-20-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 78b3bf48
...@@ -2207,7 +2207,7 @@ void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *cons) ...@@ -2207,7 +2207,7 @@ void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *cons)
/** /**
* Initialize Hyp-mode and memory mappings on all CPUs. * Initialize Hyp-mode and memory mappings on all CPUs.
*/ */
int kvm_arch_init(void *opaque) int kvm_arm_init(void)
{ {
int err; int err;
bool in_hyp_mode; bool in_hyp_mode;
...@@ -2281,6 +2281,14 @@ int kvm_arch_init(void *opaque) ...@@ -2281,6 +2281,14 @@ int kvm_arch_init(void *opaque)
kvm_info("Hyp mode initialized successfully\n"); kvm_info("Hyp mode initialized successfully\n");
} }
/*
* FIXME: Do something reasonable if kvm_init() fails after pKVM
* hypervisor protection is finalized.
*/
err = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
if (err)
goto out_subs;
return 0; return 0;
out_subs: out_subs:
...@@ -2293,10 +2301,15 @@ int kvm_arch_init(void *opaque) ...@@ -2293,10 +2301,15 @@ int kvm_arch_init(void *opaque)
return err; return err;
} }
int kvm_arch_init(void *opaque)
{
return 0;
}
/* NOP: Compiling as a module not supported */ /* NOP: Compiling as a module not supported */
void kvm_arch_exit(void) void kvm_arch_exit(void)
{ {
kvm_unregister_perf_callbacks();
} }
static int __init early_kvm_mode_cfg(char *arg) static int __init early_kvm_mode_cfg(char *arg)
...@@ -2337,10 +2350,4 @@ enum kvm_mode kvm_get_mode(void) ...@@ -2337,10 +2350,4 @@ enum kvm_mode kvm_get_mode(void)
return kvm_mode; return kvm_mode;
} }
static int arm_init(void) module_init(kvm_arm_init);
{
int rc = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
return rc;
}
module_init(arm_init);
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