]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Move per_cpu::cpu_id initialization out of assembly code
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 9 Feb 2014 10:08:27 +0000 (11:08 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Sun, 9 Feb 2014 10:08:27 +0000 (11:08 +0100)
We can trivially initialize this field during early setup if we pass the
value to entry(). Removes one offset define that needs to be kept in
manual sync with struct per_cpu.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/arm/include/asm/percpu.h
hypervisor/arch/x86/entry.S
hypervisor/arch/x86/include/asm/percpu.h
hypervisor/include/jailhouse/entry.h
hypervisor/setup.c

index f7b9bfdfe30624a0713fde2b5627fe3c844cb2d9..66ecdd58b05c7bad2079ae75fa54354548f67b3c 100644 (file)
 #define PERCPU_SIZE_SHIFT              13
 #define PERCPU_STACK_END               PAGE_SIZE
 #define PERCPU_LINUX_SP                        PERCPU_STACK_END
-#define PERCPU_CPU_ID                  (PERCPU_LINUX_SP + 4)
 
 #ifndef __ASSEMBLY__
 
 #include <asm/cell.h>
 
 struct per_cpu {
-       /* Keep these three in sync with defines above! */
+       /* Keep these two in sync with defines above! */
        u8 stack[PAGE_SIZE];
        unsigned long linux_sp;
-       unsigned int cpu_id;
 
+       unsigned int cpu_id;
 //     u32 apic_id;
        struct cell *cell;
 
@@ -69,8 +68,6 @@ static inline void __check_assumptions(void)
        CHECK_ASSUMPTION(sizeof(cpu_data.stack) == PERCPU_STACK_END);
        CHECK_ASSUMPTION(__builtin_offsetof(struct per_cpu, linux_sp) ==
                         PERCPU_LINUX_SP);
-       CHECK_ASSUMPTION(__builtin_offsetof(struct per_cpu, cpu_id) ==
-                        PERCPU_CPU_ID);
 }
 #endif /* !__ASSEMBLY__ */
 
index 7c86535c7d4f00ac405546aee4bec99b69e27e58..6af22dfe912027c5ac19e1a7ef5468672e927c00 100644 (file)
@@ -25,23 +25,22 @@ arch_entry:
        push %r14
        push %r15
 
-       mov %rdi,%rdx
-       shl $PERCPU_SIZE_SHIFT,%rdi
+       mov %rdi,%rsi
+       shl $PERCPU_SIZE_SHIFT,%rsi
        lea __page_pool(%rip),%rax
-       add %rax,%rdi
+       add %rax,%rsi
 
-       mov %rsp,PERCPU_LINUX_SP(%rdi)
-       mov %edx,PERCPU_CPU_ID(%rdi)
+       mov %rsp,PERCPU_LINUX_SP(%rsi)
 
-       lea PERCPU_STACK_END-8(%rdi),%rsp
+       lea PERCPU_STACK_END-8(%rsi),%rsp
 
-       push %rdi
+       push %rsi
 
        call entry
 
-       pop %rdi
+       pop %rsi
 
-       mov PERCPU_LINUX_SP(%rdi),%rsp
+       mov PERCPU_LINUX_SP(%rsi),%rsp
 
        pop %r15
        pop %r14
index 95eb18268d34e9a3514de8bedc087a06cd0e9d24..0ef208afcedc15e0b644d72fc133dbe206af8c5e 100644 (file)
@@ -23,7 +23,6 @@
 #define PERCPU_SIZE_SHIFT              14
 #define PERCPU_STACK_END               PAGE_SIZE
 #define PERCPU_LINUX_SP                        PERCPU_STACK_END
-#define PERCPU_CPU_ID                  (PERCPU_LINUX_SP + 8)
 
 #ifndef __ASSEMBLY__
 
@@ -38,11 +37,11 @@ struct vmcs {
 } __attribute__((packed));
 
 struct per_cpu {
-       /* Keep these three in sync with defines above! */
+       /* Keep these two in sync with defines above! */
        u8 stack[PAGE_SIZE];
        unsigned long linux_sp;
-       unsigned int cpu_id;
 
+       unsigned int cpu_id;
        u32 apic_id;
        struct cell *cell;
 
@@ -111,8 +110,6 @@ static inline void __check_assumptions(void)
        CHECK_ASSUMPTION(sizeof(cpu_data.stack) == PERCPU_STACK_END);
        CHECK_ASSUMPTION(__builtin_offsetof(struct per_cpu, linux_sp) ==
                         PERCPU_LINUX_SP);
-       CHECK_ASSUMPTION(__builtin_offsetof(struct per_cpu, cpu_id) ==
-                        PERCPU_CPU_ID);
 }
 #endif /* !__ASSEMBLY__ */
 
index d0109f180baf702cbd5ac644c7b3a4eb0e99e247..6f4b264f0d998992c54da9b64a8c1958804a078c 100644 (file)
@@ -39,7 +39,7 @@ extern void *config_memory;
 int arch_entry(unsigned int cpu_id);
 void vm_exit(void);
 
-int entry(struct per_cpu *cpu_data);
+int entry(unsigned int cpu_id, struct per_cpu *cpu_data);
 
 int arch_init_early(struct cell *linux_cell);
 int arch_cpu_init(struct per_cpu *cpu_data);
index 5912e3d78a1f662def3fbce4b6f7f0d42fdb8a05..7eeacdc87abc6413ee70610a2e37c79a2a38f94d 100644 (file)
@@ -155,15 +155,17 @@ static void init_late(void)
        printk("Initializing remaining processors:\n");
 }
 
-int entry(struct per_cpu *cpu_data)
+int entry(unsigned int cpu_id, struct per_cpu *cpu_data)
 {
        bool master = false;
 
+       cpu_data->cpu_id = cpu_id;
+
        spin_lock(&init_lock);
 
        if (master_cpu_id == -1) {
                master = true;
-               init_early(cpu_data->cpu_id);
+               init_early(cpu_id);
        }
 
        if (!error) {