1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
*/
#ifndef __HH_HCALL_H
#define __HH_HCALL_H
#include <linux/err.h>
#include <linux/types.h>
#include <linux/haven/hcall_common.h>
#include <linux/haven/hh_common.h>
#include <asm/haven/hcall.h>
struct hh_hcall_hyp_identify_resp {
u64 api_info;
u64 flags[3];
};
static inline int hh_hcall_hyp_identify(struct hh_hcall_hyp_identify_resp *resp)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6000,
(struct hh_hcall_args){ 0 },
&_resp);
if (resp) {
resp->api_info = _resp.resp0;
resp->flags[0] = _resp.resp1;
resp->flags[1] = _resp.resp2;
resp->flags[2] = _resp.resp3;
}
return 0;
}
static inline int hh_hcall_dbl_bind(hh_capid_t dbl_capid, hh_capid_t vic_capid,
hh_virq_handle_t virq_info)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6010,
(struct hh_hcall_args){ dbl_capid, vic_capid, virq_info },
&_resp);
return ret;
}
static inline int hh_hcall_dbl_unbind(hh_capid_t dbl_capid)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6011,
(struct hh_hcall_args){ dbl_capid },
&_resp);
return ret;
}
struct hh_hcall_dbl_send_resp {
u64 old_flags;
};
static inline int hh_hcall_dbl_send(hh_capid_t dbl_capid,
hh_dbl_flags_t new_flags,
struct hh_hcall_dbl_send_resp *resp)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6012,
(struct hh_hcall_args){ dbl_capid, new_flags },
&_resp);
if (!ret && resp)
resp->old_flags = _resp.resp1;
return ret;
}
struct hh_hcall_dbl_recv_resp {
u64 old_flags;
};
static inline int hh_hcall_dbl_recv(hh_capid_t dbl_capid,
hh_dbl_flags_t clear_flags,
struct hh_hcall_dbl_recv_resp *resp)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6013,
(struct hh_hcall_args){ dbl_capid, clear_flags },
&_resp);
if (!ret && resp)
resp->old_flags = _resp.resp1;
return ret;
}
static inline int hh_hcall_dbl_reset(hh_capid_t dbl_capid)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6014,
(struct hh_hcall_args){ dbl_capid },
&_resp);
return ret;
}
static inline int hh_hcall_dbl_mask(hh_capid_t dbl_capid,
hh_dbl_flags_t enable_mask,
hh_dbl_flags_t ack_mask)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6015,
(struct hh_hcall_args){ dbl_capid, enable_mask, ack_mask },
&_resp);
return ret;
}
static inline int hh_hcall_msgq_bind_send(hh_capid_t msgq_capid,
hh_capid_t vic_capid,
hh_virq_handle_t virq_info)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6017,
(struct hh_hcall_args){ msgq_capid, vic_capid, virq_info },
&_resp);
return ret;
}
static inline int hh_hcall_msgq_bind_recv(hh_capid_t msgq_capid,
hh_capid_t vic_capid,
hh_virq_handle_t virq_info)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6018,
(struct hh_hcall_args){ msgq_capid, vic_capid, virq_info },
&_resp);
return ret;
}
static inline int hh_hcall_msgq_unbind_send(hh_capid_t msgq_capid)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6019,
(struct hh_hcall_args){ msgq_capid },
&_resp);
return ret;
}
static inline int hh_hcall_msgq_unbind_recv(hh_capid_t msgq_capid)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x601A,
(struct hh_hcall_args){ msgq_capid },
&_resp);
return ret;
}
struct hh_hcall_msgq_send_resp {
bool not_full;
};
static inline int hh_hcall_msgq_send(hh_capid_t msgq_capid, size_t size,
void *data, u64 send_flags,
struct hh_hcall_msgq_send_resp *resp)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x601B,
(struct hh_hcall_args){ msgq_capid, size, (unsigned long)data,
send_flags },
&_resp);
if (resp)
resp->not_full = _resp.resp1;
return ret;
}
struct hh_hcall_msgq_recv_resp {
size_t recv_size;
bool not_empty;
};
static inline int hh_hcall_msgq_recv(hh_capid_t msgq_capid, void *buffer,
size_t max_size,
struct hh_hcall_msgq_recv_resp *resp)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x601C,
(struct hh_hcall_args){ msgq_capid, (unsigned long)buffer,
max_size },
&_resp);
if (!ret && resp) {
resp->recv_size = _resp.resp1;
resp->not_empty = _resp.resp2;
}
return ret;
}
static inline int hh_hcall_msgq_flush(hh_capid_t msgq_capid)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x601D,
(struct hh_hcall_args){ msgq_capid },
&_resp);
return ret;
}
static inline int hh_hcall_msgq_configure_send(hh_capid_t msgq_capid,
long not_full_threshold,
long not_full_delay)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x601F,
(struct hh_hcall_args){ msgq_capid, not_full_threshold,
not_full_delay, -1 },
&_resp);
return ret;
}
static inline int hh_hcall_msgq_configure_recv(hh_capid_t msgq_capid,
long not_empty_threshold,
long not_empty_delay)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x6020,
(struct hh_hcall_args){ msgq_capid, not_empty_threshold,
not_empty_delay, -1 },
&_resp);
return ret;
}
static inline int hh_hcall_vcpu_affinity_set(hh_capid_t vcpu_capid,
uint32_t cpu_index)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x603d,
(struct hh_hcall_args){ vcpu_capid, cpu_index, -1 },
&_resp);
return ret;
}
static inline int hh_hcall_trace_update_class_flags(
uint64_t set_flags, uint64_t clear_flags,
uint64_t *new_flags)
{
int ret;
struct hh_hcall_resp _resp = {0};
ret = _hh_hcall(0x603f,
(struct hh_hcall_args){ set_flags, clear_flags, 0 },
&_resp);
if (!ret && new_flags)
*new_flags = _resp.resp1;
return ret;
}
#endif
|