Skip to content

Commit

Permalink
hypervisor: arm64: add percpu.h header file
Browse files Browse the repository at this point in the history
Add the percpu.h header file for the AArch64 implementation. This is
the bare bones version of the header needed to compile a stub
hypervisor binary on AArch64. A lot of these fields could probably
be moved to an arch independent header.

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
  • Loading branch information
tvelocity committed Jan 25, 2016
1 parent 368d3bd commit d5c2fa9
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions hypervisor/arch/arm64/include/asm/percpu.h
@@ -0,0 +1,72 @@
/*
* Jailhouse AArch64 support
*
* Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH
*
* Authors:
* Antonios Motakis <antonios.motakis@huawei.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*/

#ifndef _JAILHOUSE_ASM_PERCPU_H
#define _JAILHOUSE_ASM_PERCPU_H

#include <jailhouse/types.h>
#include <asm/paging.h>

#ifndef __ASSEMBLY__

#include <asm/cell.h>
#include <asm/spinlock.h>

struct per_cpu {
/* common fields */
unsigned int cpu_id;
struct cell *cell;
u32 stats[JAILHOUSE_NUM_CPU_STATS];
int shutdown_state;
bool failed;

bool flush_vcpu_caches;
} __attribute__((aligned(PAGE_SIZE)));

static inline struct per_cpu *this_cpu_data(void)
{
while (1);
return NULL;
}

#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_id)
DEFINE_PER_CPU_ACCESSOR(cell)

static inline struct per_cpu *per_cpu(unsigned int cpu)
{
while (1);
return NULL;
}

static inline unsigned int arm_cpu_phys2virt(unsigned int cpu_id)
{
return per_cpu(cpu_id)->virt_id;
}

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)
{
CHECK_ASSUMPTION(sizeof(unsigned long) == (8));
}
#endif /* !__ASSEMBLY__ */

#endif /* !_JAILHOUSE_ASM_PERCPU_H */

0 comments on commit d5c2fa9

Please sign in to comment.