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
|
/* SPDX-License-Identifier: GPL-2.0 */
/*
* ACRN HSM: hypercalls of ACRN Hypervisor
*/
#ifndef __ACRN_HSM_HYPERCALL_H
#define __ACRN_HSM_HYPERCALL_H
#include <asm/acrn.h>
/*
* Hypercall IDs of the ACRN Hypervisor
*/
#define _HC_ID(x, y) (((x) << 24) | (y))
#define HC_ID 0x80UL
#define HC_ID_VM_BASE 0x10UL
#define HC_CREATE_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x00)
#define HC_DESTROY_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x01)
#define HC_START_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x02)
#define HC_PAUSE_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x03)
#define HC_RESET_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x05)
#define HC_SET_VCPU_REGS _HC_ID(HC_ID, HC_ID_VM_BASE + 0x06)
#define HC_ID_IRQ_BASE 0x20UL
#define HC_INJECT_MSI _HC_ID(HC_ID, HC_ID_IRQ_BASE + 0x03)
#define HC_VM_INTR_MONITOR _HC_ID(HC_ID, HC_ID_IRQ_BASE + 0x04)
#define HC_SET_IRQLINE _HC_ID(HC_ID, HC_ID_IRQ_BASE + 0x05)
#define HC_ID_IOREQ_BASE 0x30UL
#define HC_SET_IOREQ_BUFFER _HC_ID(HC_ID, HC_ID_IOREQ_BASE + 0x00)
#define HC_NOTIFY_REQUEST_FINISH _HC_ID(HC_ID, HC_ID_IOREQ_BASE + 0x01)
#define HC_ID_MEM_BASE 0x40UL
#define HC_VM_SET_MEMORY_REGIONS _HC_ID(HC_ID, HC_ID_MEM_BASE + 0x02)
#define HC_ID_PCI_BASE 0x50UL
#define HC_SET_PTDEV_INTR _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x03)
#define HC_RESET_PTDEV_INTR _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x04)
#define HC_ASSIGN_PCIDEV _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x05)
#define HC_DEASSIGN_PCIDEV _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x06)
/**
* hcall_create_vm() - Create a User VM
* @vminfo: Service VM GPA of info of User VM creation
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_create_vm(u64 vminfo)
{
return acrn_hypercall1(HC_CREATE_VM, vminfo);
}
/**
* hcall_start_vm() - Start a User VM
* @vmid: User VM ID
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_start_vm(u64 vmid)
{
return acrn_hypercall1(HC_START_VM, vmid);
}
/**
* hcall_pause_vm() - Pause a User VM
* @vmid: User VM ID
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_pause_vm(u64 vmid)
{
return acrn_hypercall1(HC_PAUSE_VM, vmid);
}
/**
* hcall_destroy_vm() - Destroy a User VM
* @vmid: User VM ID
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_destroy_vm(u64 vmid)
{
return acrn_hypercall1(HC_DESTROY_VM, vmid);
}
/**
* hcall_reset_vm() - Reset a User VM
* @vmid: User VM ID
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_reset_vm(u64 vmid)
{
return acrn_hypercall1(HC_RESET_VM, vmid);
}
/**
* hcall_set_vcpu_regs() - Set up registers of virtual CPU of a User VM
* @vmid: User VM ID
* @regs_state: Service VM GPA of registers state
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_set_vcpu_regs(u64 vmid, u64 regs_state)
{
return acrn_hypercall2(HC_SET_VCPU_REGS, vmid, regs_state);
}
/**
* hcall_inject_msi() - Deliver a MSI interrupt to a User VM
* @vmid: User VM ID
* @msi: Service VM GPA of MSI message
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_inject_msi(u64 vmid, u64 msi)
{
return acrn_hypercall2(HC_INJECT_MSI, vmid, msi);
}
/**
* hcall_vm_intr_monitor() - Set a shared page for User VM interrupt statistics
* @vmid: User VM ID
* @addr: Service VM GPA of the shared page
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_vm_intr_monitor(u64 vmid, u64 addr)
{
return acrn_hypercall2(HC_VM_INTR_MONITOR, vmid, addr);
}
/**
* hcall_set_irqline() - Set or clear an interrupt line
* @vmid: User VM ID
* @op: Service VM GPA of interrupt line operations
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_set_irqline(u64 vmid, u64 op)
{
return acrn_hypercall2(HC_SET_IRQLINE, vmid, op);
}
/**
* hcall_set_ioreq_buffer() - Set up the shared buffer for I/O Requests.
* @vmid: User VM ID
* @buffer: Service VM GPA of the shared buffer
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_set_ioreq_buffer(u64 vmid, u64 buffer)
{
return acrn_hypercall2(HC_SET_IOREQ_BUFFER, vmid, buffer);
}
/**
* hcall_notify_req_finish() - Notify ACRN Hypervisor of I/O request completion.
* @vmid: User VM ID
* @vcpu: The vCPU which initiated the I/O request
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_notify_req_finish(u64 vmid, u64 vcpu)
{
return acrn_hypercall2(HC_NOTIFY_REQUEST_FINISH, vmid, vcpu);
}
/**
* hcall_set_memory_regions() - Inform the hypervisor to set up EPT mappings
* @regions_pa: Service VM GPA of &struct vm_memory_region_batch
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_set_memory_regions(u64 regions_pa)
{
return acrn_hypercall1(HC_VM_SET_MEMORY_REGIONS, regions_pa);
}
/**
* hcall_assign_pcidev() - Assign a PCI device to a User VM
* @vmid: User VM ID
* @addr: Service VM GPA of the &struct acrn_pcidev
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_assign_pcidev(u64 vmid, u64 addr)
{
return acrn_hypercall2(HC_ASSIGN_PCIDEV, vmid, addr);
}
/**
* hcall_deassign_pcidev() - De-assign a PCI device from a User VM
* @vmid: User VM ID
* @addr: Service VM GPA of the &struct acrn_pcidev
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_deassign_pcidev(u64 vmid, u64 addr)
{
return acrn_hypercall2(HC_DEASSIGN_PCIDEV, vmid, addr);
}
/**
* hcall_set_ptdev_intr() - Configure an interrupt for an assigned PCI device.
* @vmid: User VM ID
* @irq: Service VM GPA of the &struct acrn_ptdev_irq
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_set_ptdev_intr(u64 vmid, u64 irq)
{
return acrn_hypercall2(HC_SET_PTDEV_INTR, vmid, irq);
}
/**
* hcall_reset_ptdev_intr() - Reset an interrupt for an assigned PCI device.
* @vmid: User VM ID
* @irq: Service VM GPA of the &struct acrn_ptdev_irq
*
* Return: 0 on success, <0 on failure
*/
static inline long hcall_reset_ptdev_intr(u64 vmid, u64 irq)
{
return acrn_hypercall2(HC_RESET_PTDEV_INTR, vmid, irq);
}
#endif /* __ACRN_HSM_HYPERCALL_H */
|