]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/x86/include/asm/jailhouse_hypercall.h
core/driver: Remove multi-arg support for hypercalls
[jailhouse.git] / hypervisor / arch / x86 / include / asm / jailhouse_hypercall.h
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #ifndef __x86_64__
14 #error 64-bit kernel required!
15 #endif
16
17 #define JAILHOUSE_BASE          0xfffffffff0000000
18
19 #define JAILHOUSE_CALL_INS      "vmcall"
20 #define JAILHOUSE_CALL_RESULT   "=a" (result)
21 #define JAILHOUSE_CALL_NUM      "a" (num)
22 #define JAILHOUSE_CALL_ARG      "D" (arg)
23
24 #ifndef __ASSEMBLY__
25
26 static inline __u32 jailhouse_call(__u32 num)
27 {
28         __u32 result;
29
30         asm volatile(JAILHOUSE_CALL_INS
31                 : JAILHOUSE_CALL_RESULT
32                 : JAILHOUSE_CALL_NUM
33                 : "memory");
34         return result;
35 }
36
37 static inline __u32 jailhouse_call_arg(__u32 num, __u32 arg)
38 {
39         __u32 result;
40
41         asm volatile(JAILHOUSE_CALL_INS
42                 : JAILHOUSE_CALL_RESULT
43                 : JAILHOUSE_CALL_NUM, JAILHOUSE_CALL_ARG
44                 : "memory");
45         return result;
46 }
47
48 static inline void
49 jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region,
50                            __u32 msg)
51 {
52         comm_region->reply_from_cell = JAILHOUSE_MSG_NONE;
53         /* ensure reply was cleared before sending new message */
54         asm volatile("mfence" : : : "memory");
55         comm_region->msg_to_cell = msg;
56 }
57
58 static inline void
59 jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
60                                __u32 reply)
61 {
62         comm_region->msg_to_cell = JAILHOUSE_MSG_NONE;
63         /* ensure message was cleared before sending reply */
64         asm volatile("mfence" : : : "memory");
65         comm_region->reply_from_cell = reply;
66 }
67
68 #endif /* !__ASSEMBLY__ */