Store current vcpu instead of cpu in tpidr_el2.
This allows us to avoid an extra indirection in the most common paths.
Change-Id: I2ea71ee1a56ee8b94f7f516465081e88e82d8539
diff --git a/src/main.c b/src/main.c
index df27ea2..db191a8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -128,10 +128,10 @@
* The entry point of CPUs when they are turned on. It is supposed to initialise
* all state and return the first vCPU to run.
*/
-struct vcpu *cpu_main(void)
+struct vcpu *cpu_main(struct cpu *c)
{
- struct cpu *c = cpu();
struct vm *primary;
+ struct vcpu *vcpu;
/*
* Do global one-time initialisation just once. We avoid using atomics
@@ -152,5 +152,7 @@
primary = vm_get(HF_PRIMARY_VM_ID);
vm_set_current(primary);
- return &primary->vcpus[cpu_index(c)];
+ vcpu = &primary->vcpus[cpu_index(c)];
+ vcpu->cpu = c;
+ return vcpu;
}