aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ene <sebastianene@google.com>2022-03-13 16:19:48 +0000
committerWill Deacon <will@kernel.org>2022-03-21 13:36:29 +0000
commitff6958200c4b3f11ff48c7d25b8757c6316f58e5 (patch)
tree2bb688c526ab16afd4e59867e88545db8762135d
parent95f47968a1d34ea27d4f3ad767f0c2c49f2ffc5b (diff)
downloadkvmtool-ff6958200c4b3f11ff48c7d25b8757c6316f58e5.tar.gz
aarch64: Populate the vCPU struct before target->init()
Move the vCPU structure initialisation before the target->init() call to keep a reference to the kvm structure during init(). This is required by the pvtime peripheral to reserve a memory region while the vCPU is beeing initialised. Reviewed-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://lore.kernel.org/r/20220313161949.3565171-2-sebastianene@google.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arm/kvm-cpu.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 6a2408c6..84ac1e9e 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -116,6 +116,13 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
die("Unable to find matching target");
}
+ /* Populate the vcpu structure. */
+ vcpu->kvm = kvm;
+ vcpu->cpu_id = cpu_id;
+ vcpu->cpu_type = vcpu_init.target;
+ vcpu->cpu_compatible = target->compatible;
+ vcpu->is_running = true;
+
if (err || target->init(vcpu))
die("Unable to initialise vcpu");
@@ -125,13 +132,6 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
vcpu->ring = (void *)vcpu->kvm_run +
(coalesced_offset * PAGE_SIZE);
- /* Populate the vcpu structure. */
- vcpu->kvm = kvm;
- vcpu->cpu_id = cpu_id;
- vcpu->cpu_type = vcpu_init.target;
- vcpu->cpu_compatible = target->compatible;
- vcpu->is_running = true;
-
if (kvm_cpu__configure_features(vcpu))
die("Unable to configure requested vcpu features");