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/inc/hf/api.h b/inc/hf/api.h
index 514ac2f..5359f86 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -22,15 +22,19 @@
#include "vmapi/hf/call.h"
int64_t api_vm_get_count(void);
-int64_t api_vcpu_get_count(uint32_t vm_id);
+int64_t api_vcpu_get_count(uint32_t vm_id, const struct vcpu *current);
struct hf_vcpu_run_return api_vcpu_run(uint32_t vm_id, uint32_t vcpu_idx,
+ const struct vcpu *current,
struct vcpu **next);
-int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv);
+int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv,
+ const struct vcpu *current);
-int64_t api_mailbox_send(uint32_t vm_id, size_t size, struct vcpu **next);
+int64_t api_mailbox_send(uint32_t vm_id, size_t size, struct vcpu *current,
+ struct vcpu **next);
struct hf_mailbox_receive_return api_mailbox_receive(bool block,
+ struct vcpu *current,
struct vcpu **next);
-int64_t api_mailbox_clear(void);
+int64_t api_mailbox_clear(const struct vcpu *current);
-struct vcpu *api_wait_for_interrupt(void);
-struct vcpu *api_yield(void);
+struct vcpu *api_wait_for_interrupt(struct vcpu *current);
+struct vcpu *api_yield(struct vcpu *current);
diff --git a/inc/hf/cpu.h b/inc/hf/cpu.h
index 809c21e..1d3d640 100644
--- a/inc/hf/cpu.h
+++ b/inc/hf/cpu.h
@@ -45,6 +45,7 @@
struct vcpu {
struct spinlock lock;
enum vcpu_state state;
+ struct cpu *cpu;
struct vm *vm;
struct vcpu *mailbox_next;
struct arch_regs regs;
@@ -55,8 +56,6 @@
/* CPU identifier. Doesn't have to be contiguous. */
size_t id;
- struct vcpu *current;
-
/* Pointer to bottom of the stack. */
void *stack_bottom;