]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
arm: Implement per-cpu accessors
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 26 Sep 2014 19:46:36 +0000 (21:46 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Fri, 19 Dec 2014 08:57:47 +0000 (09:57 +0100)
TPIDR_EL2 already holds a reference to the current per_cpu data
structure. Return it from this_cpu_data and build the other accessors on
top.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/arm/include/asm/percpu.h

index 128cb9f104faba1c2bc78e524397851a7b92a3c2..0c764528cbb119236674bad84d03203a60ab67ad 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef __ASSEMBLY__
 
 #include <asm/cell.h>
+#include <asm/sysregs.h>
 
 struct per_cpu {
        /* Keep these two in sync with defines above! */
@@ -35,7 +36,6 @@ struct per_cpu {
        unsigned long linux_flags;
        unsigned long linux_reg[NUM_ENTRY_REGS];
 
-       struct per_cpu *cpu_data;
        unsigned int cpu_id;
 //     u32 apic_id;
        struct cell *cell;
@@ -50,15 +50,20 @@ struct per_cpu {
        bool failed;
 } __attribute__((aligned(PAGE_SIZE)));
 
-#define DEFINE_PER_CPU_ACCESSOR(field)                                     \
-static inline typeof(((struct per_cpu *)0)->field) this_##field(void)      \
-{                                                                          \
-       typeof(((struct per_cpu *)0)->field) tmp = 0;                       \
-                                                                           \
-       return tmp;                                                         \
+static inline struct per_cpu *this_cpu_data(void)
+{
+       struct per_cpu *cpu_data;
+
+       arm_read_sysreg(TPIDR_EL2, cpu_data);
+       return cpu_data;
+}
+
+#define DEFINE_PER_CPU_ACCESSOR(field)                                 \
+static inline typeof(((struct per_cpu *)0)->field) this_##field(void)  \
+{                                                                      \
+       return this_cpu_data()->field;                                  \
 }
 
-DEFINE_PER_CPU_ACCESSOR(cpu_data)
 DEFINE_PER_CPU_ACCESSOR(cpu_id)
 DEFINE_PER_CPU_ACCESSOR(cell)