Skip to content

Commit

Permalink
arm64: add jailhouse_hypercall.h header file
Browse files Browse the repository at this point in the history
Add the jailhouse_hypercall.h header file for AArch64. We will need
this also from the Linux side, in order to load Jailhouse in memory
and to issue hypercalls to an already loaded instance of the
hypervisor.

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
  • Loading branch information
tvelocity authored and jan-kiszka committed Jun 27, 2016
1 parent 12429e3 commit 194bc1f
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions hypervisor/arch/arm64/include/asm/jailhouse_hypercall.h
@@ -0,0 +1,91 @@
/*
* 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.
*/

#include <jailhouse/config.h>

#define JAILHOUSE_CALL_INS "hvc #0x4a48"
#define JAILHOUSE_CALL_NUM_RESULT "x0"
#define JAILHOUSE_CALL_ARG1 "x1"
#define JAILHOUSE_CALL_ARG2 "x2"

/* CPU statistics */
#define JAILHOUSE_CPU_STAT_VMEXITS_MAINTENANCE JAILHOUSE_GENERIC_CPU_STATS
#define JAILHOUSE_CPU_STAT_VMEXITS_VIRQ JAILHOUSE_GENERIC_CPU_STATS + 1
#define JAILHOUSE_CPU_STAT_VMEXITS_VSGI JAILHOUSE_GENERIC_CPU_STATS + 2
#define JAILHOUSE_NUM_CPU_STATS JAILHOUSE_GENERIC_CPU_STATS + 3

#ifndef __ASSEMBLY__

struct jailhouse_comm_region {
COMM_REGION_GENERIC_HEADER;
};

static inline __u64 jailhouse_call(__u64 num)
{
register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;

asm volatile(
JAILHOUSE_CALL_INS
: "=r" (num_result)
: "r" (num_result)
: "memory");
return num_result;
}

static inline __u64 jailhouse_call_arg1(__u64 num, __u64 arg1)
{
register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
register __u64 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1;

asm volatile(
JAILHOUSE_CALL_INS
: "=r" (num_result)
: "r" (num_result), "r" (__arg1)
: "memory");
return num_result;
}

static inline __u64 jailhouse_call_arg2(__u64 num, __u64 arg1, __u64 arg2)
{
register __u64 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
register __u64 __arg1 asm(JAILHOUSE_CALL_ARG1) = arg1;
register __u64 __arg2 asm(JAILHOUSE_CALL_ARG2) = arg2;

asm volatile(
JAILHOUSE_CALL_INS
: "=r" (num_result)
: "r" (num_result), "r" (__arg1), "r" (__arg2)
: "memory");
return num_result;
}

static inline void
jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region,
__u64 msg)
{
comm_region->reply_from_cell = JAILHOUSE_MSG_NONE;
/* ensure reply was cleared before sending new message */
asm volatile("dmb ishst" : : : "memory");
comm_region->msg_to_cell = msg;
}

static inline void
jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
__u64 reply)
{
comm_region->msg_to_cell = JAILHOUSE_MSG_NONE;
/* ensure message was cleared before sending reply */
asm volatile("dmb ishst" : : : "memory");
comm_region->reply_from_cell = reply;
}

#endif /* !__ASSEMBLY__ */

0 comments on commit 194bc1f

Please sign in to comment.