Update to 3.4-final.
[linux-flexiantxendom0-3.2.10.git] / include / xen / interface / hvm / hvm_op.h
1 /*
2  * Permission is hereby granted, free of charge, to any person obtaining a copy
3  * of this software and associated documentation files (the "Software"), to
4  * deal in the Software without restriction, including without limitation the
5  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6  * sell copies of the Software, and to permit persons to whom the Software is
7  * furnished to do so, subject to the following conditions:
8  *
9  * The above copyright notice and this permission notice shall be included in
10  * all copies or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18  * DEALINGS IN THE SOFTWARE.
19  */
20
21 #ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
22 #define __XEN_PUBLIC_HVM_HVM_OP_H__
23
24 #include "../xen.h"
25 #include "../trace.h"
26
27 /* Get/set subcommands: the second argument of the hypercall is a
28  * pointer to a xen_hvm_param struct. */
29 #define HVMOP_set_param           0
30 #define HVMOP_get_param           1
31 struct xen_hvm_param {
32     domid_t  domid;    /* IN */
33     uint32_t index;    /* IN */
34     uint64_t value;    /* IN/OUT */
35 };
36 DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_param);
37 typedef struct xen_hvm_param xen_hvm_param_t;
38 DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);
39
40 /* Set the logical level of one of a domain's PCI INTx wires. */
41 #define HVMOP_set_pci_intx_level  2
42 struct xen_hvm_set_pci_intx_level {
43     /* Domain to be updated. */
44     domid_t  domid;
45     /* PCI INTx identification in PCI topology (domain:bus:device:intx). */
46     uint8_t  domain, bus, device, intx;
47     /* Assertion level (0 = unasserted, 1 = asserted). */
48     uint8_t  level;
49 };
50 typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;
51 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t);
52
53 /* Set the logical level of one of a domain's ISA IRQ wires. */
54 #define HVMOP_set_isa_irq_level   3
55 struct xen_hvm_set_isa_irq_level {
56     /* Domain to be updated. */
57     domid_t  domid;
58     /* ISA device identification, by ISA IRQ (0-15). */
59     uint8_t  isa_irq;
60     /* Assertion level (0 = unasserted, 1 = asserted). */
61     uint8_t  level;
62 };
63 typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t;
64 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t);
65
66 #define HVMOP_set_pci_link_route  4
67 struct xen_hvm_set_pci_link_route {
68     /* Domain to be updated. */
69     domid_t  domid;
70     /* PCI link identifier (0-3). */
71     uint8_t  link;
72     /* ISA IRQ (1-15), or 0 (disable link). */
73     uint8_t  isa_irq;
74 };
75 typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t;
76 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);
77
78 /* Flushes all VCPU TLBs: @arg must be NULL. */
79 #define HVMOP_flush_tlbs          5
80
81 typedef enum {
82     HVMMEM_ram_rw,             /* Normal read/write guest RAM */
83     HVMMEM_ram_ro,             /* Read-only; writes are discarded */
84     HVMMEM_mmio_dm,            /* Reads and write go to the device model */
85 } hvmmem_type_t;
86
87 /* Following tools-only interfaces may change in future. */
88 #if defined(__XEN__) || defined(__XEN_TOOLS__)
89
90 /* Track dirty VRAM. */
91 #define HVMOP_track_dirty_vram    6
92 struct xen_hvm_track_dirty_vram {
93     /* Domain to be tracked. */
94     domid_t  domid;
95     /* First pfn to track. */
96     uint64_aligned_t first_pfn;
97     /* Number of pages to track. */
98     uint64_aligned_t nr;
99     /* OUT variable. */
100     /* Dirty bitmap buffer. */
101     XEN_GUEST_HANDLE_64(uint8) dirty_bitmap;
102 };
103 typedef struct xen_hvm_track_dirty_vram xen_hvm_track_dirty_vram_t;
104 DEFINE_XEN_GUEST_HANDLE(xen_hvm_track_dirty_vram_t);
105
106 /* Notify that some pages got modified by the Device Model. */
107 #define HVMOP_modified_memory    7
108 struct xen_hvm_modified_memory {
109     /* Domain to be updated. */
110     domid_t  domid;
111     /* First pfn. */
112     uint64_aligned_t first_pfn;
113     /* Number of pages. */
114     uint64_aligned_t nr;
115 };
116 typedef struct xen_hvm_modified_memory xen_hvm_modified_memory_t;
117 DEFINE_XEN_GUEST_HANDLE(xen_hvm_modified_memory_t);
118
119 #define HVMOP_set_mem_type    8
120 /* Notify that a region of memory is to be treated in a specific way. */
121 struct xen_hvm_set_mem_type {
122     /* Domain to be updated. */
123     domid_t domid;
124     /* Memory type */
125     uint16_t hvmmem_type;
126     /* Number of pages. */
127     uint32_t nr;
128     /* First pfn. */
129     uint64_aligned_t first_pfn;
130 };
131 typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t;
132 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_mem_type_t);
133
134 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
135
136 /* Hint from PV drivers for pagetable destruction. */
137 #define HVMOP_pagetable_dying       9
138 struct xen_hvm_pagetable_dying {
139     /* Domain with a pagetable about to be destroyed. */
140     domid_t  domid;
141     uint16_t pad[3]; /* align next field on 8-byte boundary */
142     /* guest physical address of the toplevel pagetable dying */
143     uint64_t gpa;
144 };
145 DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_pagetable_dying);
146 typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t;
147 DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t);
148
149 /* Get the current Xen time, in nanoseconds since system boot. */
150 #define HVMOP_get_time              10
151 struct xen_hvm_get_time {
152     uint64_t now;      /* OUT */
153 };
154 typedef struct xen_hvm_get_time xen_hvm_get_time_t;
155 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t);
156
157 #define HVMOP_xentrace              11
158 struct xen_hvm_xentrace {
159     uint16_t event, extra_bytes;
160     uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)];
161 };
162 typedef struct xen_hvm_xentrace xen_hvm_xentrace_t;
163 DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t);
164
165 /* Following tools-only interfaces may change in future. */
166 #if defined(__XEN__) || defined(__XEN_TOOLS__)
167
168 #define HVMOP_set_mem_access        12
169 typedef enum {
170     HVMMEM_access_n,
171     HVMMEM_access_r,
172     HVMMEM_access_w,
173     HVMMEM_access_rw,
174     HVMMEM_access_x,
175     HVMMEM_access_rx,
176     HVMMEM_access_wx,
177     HVMMEM_access_rwx,
178     HVMMEM_access_rx2rw,       /* Page starts off as r-x, but automatically
179                                 * change to r-w on a write */
180     HVMMEM_access_n2rwx,       /* Log access: starts off as n, automatically
181                                 * goes to rwx, generating an event without
182                                 * pausing the vcpu */
183     HVMMEM_access_default      /* Take the domain default */
184 } hvmmem_access_t;
185 /* Notify that a region of memory is to have specific access types */
186 struct xen_hvm_set_mem_access {
187     /* Domain to be updated. */
188     domid_t domid;
189     /* Memory type */
190     uint16_t hvmmem_access; /* hvm_access_t */
191     /* Number of pages, ignored on setting default access */
192     uint32_t nr;
193     /* First pfn, or ~0ull to set the default access for new pages */
194     uint64_aligned_t first_pfn;
195 };
196 typedef struct xen_hvm_set_mem_access xen_hvm_set_mem_access_t;
197 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_mem_access_t);
198
199 #define HVMOP_get_mem_access        13
200 /* Get the specific access type for that region of memory */
201 struct xen_hvm_get_mem_access {
202     /* Domain to be queried. */
203     domid_t domid;
204     /* Memory type: OUT */
205     uint16_t hvmmem_access; /* hvm_access_t */
206     /* pfn, or ~0ull for default access for new pages.  IN */
207     uint64_aligned_t pfn;
208 };
209 typedef struct xen_hvm_get_mem_access xen_hvm_get_mem_access_t;
210 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_access_t);
211
212 #define HVMOP_inject_trap            14
213 /* Inject a trap into a VCPU, which will get taken up on the next
214  * scheduling of it. Note that the caller should know enough of the
215  * state of the CPU before injecting, to know what the effect of
216  * injecting the trap will be.
217  */
218 struct xen_hvm_inject_trap {
219     /* Domain to be queried. */
220     domid_t domid;
221     /* VCPU */
222     uint32_t vcpuid;
223     /* Trap number */
224     uint32_t trap;
225     /* Error code, or -1 to skip */
226     uint32_t error_code;
227     /* CR2 for page faults */
228     uint64_aligned_t cr2;
229 };
230 typedef struct xen_hvm_inject_trap xen_hvm_inject_trap_t;
231 DEFINE_XEN_GUEST_HANDLE(xen_hvm_inject_trap_t);
232
233 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
234
235 #define HVMOP_get_mem_type    15
236 /* Return hvmmem_type_t for the specified pfn. */
237 struct xen_hvm_get_mem_type {
238     /* Domain to be queried. */
239     domid_t domid;
240     /* OUT variable. */
241     uint16_t mem_type;
242     uint16_t pad[2]; /* align next field on 8-byte boundary */
243     /* IN variable. */
244     uint64_t pfn;
245 };
246 typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t;
247 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t);
248
249 /* Following tools-only interfaces may change in future. */
250 #if defined(__XEN__) || defined(__XEN_TOOLS__)
251
252 /* MSI injection for emulated devices */
253 #define HVMOP_inject_msi         16
254 struct xen_hvm_inject_msi {
255     /* Domain to be injected */
256     domid_t   domid;
257     /* Data -- lower 32 bits */
258     uint32_t  data;
259     /* Address (0xfeexxxxx) */
260     uint64_t  addr;
261 };
262 typedef struct xen_hvm_inject_msi xen_hvm_inject_msi_t;
263 DEFINE_XEN_GUEST_HANDLE(xen_hvm_inject_msi_t);
264
265 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
266
267 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */