]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/x86/include/asm/jailhouse_hypercall.h
core/driver: Reintroduce a second hypercall argument
[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_ARG1     "D" (arg1)
23 #define JAILHOUSE_CALL_ARG2     "S" (arg2)
24
25 #ifndef __ASSEMBLY__
26
27 static inline __u32 jailhouse_call(__u32 num)
28 {
29         __u32 result;
30
31         asm volatile(JAILHOUSE_CALL_INS
32                 : JAILHOUSE_CALL_RESULT
33                 : JAILHOUSE_CALL_NUM
34                 : "memory");
35         return result;
36 }
37
38 static inline __u32 jailhouse_call_arg1(__u32 num, __u32 arg1)
39 {
40         __u32 result;
41
42         asm volatile(JAILHOUSE_CALL_INS
43                 : JAILHOUSE_CALL_RESULT
44                 : JAILHOUSE_CALL_NUM, JAILHOUSE_CALL_ARG1
45                 : "memory");
46         return result;
47 }
48
49 static inline __u32 jailhouse_call_arg2(__u32 num, __u32 arg1, __u32 arg2)
50 {
51         __u32 result;
52
53         asm volatile(JAILHOUSE_CALL_INS
54                 : JAILHOUSE_CALL_RESULT
55                 : JAILHOUSE_CALL_NUM, JAILHOUSE_CALL_ARG1, JAILHOUSE_CALL_ARG2
56                 : "memory");
57         return result;
58 }
59
60 static inline void
61 jailhouse_send_msg_to_cell(struct jailhouse_comm_region *comm_region,
62                            __u32 msg)
63 {
64         comm_region->reply_from_cell = JAILHOUSE_MSG_NONE;
65         /* ensure reply was cleared before sending new message */
66         asm volatile("mfence" : : : "memory");
67         comm_region->msg_to_cell = msg;
68 }
69
70 static inline void
71 jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
72                                __u32 reply)
73 {
74         comm_region->msg_to_cell = JAILHOUSE_MSG_NONE;
75         /* ensure message was cleared before sending reply */
76         asm volatile("mfence" : : : "memory");
77         comm_region->reply_from_cell = reply;
78 }
79
80 #endif /* !__ASSEMBLY__ */