*/
#include <jailhouse/gen-defines.h>
+#include <jailhouse/utils.h>
+#include <asm/percpu.h>
void common(void);
void common(void)
{
+ OFFSET(PERCPU_LINUX_SP, per_cpu, linux_sp);
+ BLANK();
+
+ /* GCC evaluates constant expressions involving built-ins
+ * at compilation time, so this yields computed value.
+ */
+ DEFINE(PERCPU_STACK_END,
+ __builtin_offsetof(struct per_cpu, stack) + \
+ FIELD_SIZEOF(struct per_cpu, stack));
+ DEFINE(PERCPU_SIZE_SHIFT_ASM, PERCPU_SIZE_SHIFT);
}
* the COPYING file in the top-level directory.
*/
+#include <asm/asm-defines.h>
#include <asm/head.h>
#include <asm/percpu.h>
ldr r1, =__page_pool
mov r4, #1
- lsl r4, #PERCPU_SIZE_SHIFT
+ lsl r4, #PERCPU_SIZE_SHIFT_ASM
/*
* percpu data = pool + cpuid * shift
* TODO: handle aff1 and aff2
#define NUM_ENTRY_REGS 13
-/* Keep in sync with struct per_cpu! */
-#define PERCPU_SIZE_SHIFT 13
-#define PERCPU_STACK_END PAGE_SIZE
-#define PERCPU_LINUX_SP PERCPU_STACK_END
-
#ifndef __ASSEMBLY__
#include <jailhouse/cell.h>
#include <asm/spinlock.h>
#include <asm/sysregs.h>
+/* Round up sizeof(struct per_cpu) to the next power of two. */
+#define PERCPU_SIZE_SHIFT \
+ (BITS_PER_LONG - __builtin_clzl(sizeof(struct per_cpu) - 1))
+
struct pending_irq;
struct per_cpu {
- /* Keep these two in sync with defines above! */
u8 stack[PAGE_SIZE];
unsigned long linux_sp;
unsigned long linux_ret;
static inline struct registers *guest_regs(struct per_cpu *cpu_data)
{
/* Assumes that the trap handler is entered with an empty stack */
- return (struct registers *)(cpu_data->stack + PERCPU_STACK_END
+ return (struct registers *)(cpu_data->stack + sizeof(cpu_data->stack)
- sizeof(struct registers));
}
}
unsigned int arm_cpu_virt2phys(struct cell *cell, unsigned int virt_id);
-
-/* Validate defines */
-#define CHECK_ASSUMPTION(assume) ((void)sizeof(char[1 - 2*!(assume)]))
-
-static inline void __check_assumptions(void)
-{
- struct per_cpu cpu_data;
-
- CHECK_ASSUMPTION(sizeof(struct per_cpu) == (1 << PERCPU_SIZE_SHIFT));
- CHECK_ASSUMPTION(sizeof(cpu_data.stack) == PERCPU_STACK_END);
- CHECK_ASSUMPTION(__builtin_offsetof(struct per_cpu, linux_sp) ==
- PERCPU_LINUX_SP);
-}
#endif /* !__ASSEMBLY__ */
#endif /* !_JAILHOUSE_ASM_PERCPU_H */