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 * Copyright (c) 2007, Keir Fraser 21 */ 22 23 #ifndef __XEN_PUBLIC_HVM_HVM_OP_H__ 24 #define __XEN_PUBLIC_HVM_HVM_OP_H__ 25 26 #include "../xen.h" 27 #include "../trace.h" 28 #include "../event_channel.h" 29 30 /* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */ 31 #define HVMOP_set_param 0 32 #define HVMOP_get_param 1 33 struct xen_hvm_param { 34 domid_t domid; /* IN */ 35 uint32_t index; /* IN */ 36 uint64_t value; /* IN/OUT */ 37 }; 38 typedef struct xen_hvm_param xen_hvm_param_t; 39 DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t); 40 41 #if __XEN_INTERFACE_VERSION__ < 0x00040900 42 43 /* Set the logical level of one of a domain's PCI INTx wires. */ 44 #define HVMOP_set_pci_intx_level 2 45 struct xen_hvm_set_pci_intx_level { 46 /* Domain to be updated. */ 47 domid_t domid; 48 /* PCI INTx identification in PCI topology (domain:bus:device:intx). */ 49 uint8_t domain, bus, device, intx; 50 /* Assertion level (0 = unasserted, 1 = asserted). */ 51 uint8_t level; 52 }; 53 typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t; 54 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t); 55 56 /* Set the logical level of one of a domain's ISA IRQ wires. */ 57 #define HVMOP_set_isa_irq_level 3 58 struct xen_hvm_set_isa_irq_level { 59 /* Domain to be updated. */ 60 domid_t domid; 61 /* ISA device identification, by ISA IRQ (0-15). */ 62 uint8_t isa_irq; 63 /* Assertion level (0 = unasserted, 1 = asserted). */ 64 uint8_t level; 65 }; 66 typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t; 67 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t); 68 69 #define HVMOP_set_pci_link_route 4 70 struct xen_hvm_set_pci_link_route { 71 /* Domain to be updated. */ 72 domid_t domid; 73 /* PCI link identifier (0-3). */ 74 uint8_t link; 75 /* ISA IRQ (1-15), or 0 (disable link). */ 76 uint8_t isa_irq; 77 }; 78 typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t; 79 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t); 80 81 #endif /* __XEN_INTERFACE_VERSION__ < 0x00040900 */ 82 83 /* Flushes all VCPU TLBs: @arg must be NULL. */ 84 #define HVMOP_flush_tlbs 5 85 86 /* 87 * hvmmem_type_t should not be defined when generating the corresponding 88 * compat header. This will ensure that the improperly named HVMMEM_(*) 89 * values are defined only once. 90 */ 91 #ifndef XEN_GENERATING_COMPAT_HEADERS 92 93 typedef enum { 94 HVMMEM_ram_rw, /* Normal read/write guest RAM */ 95 HVMMEM_ram_ro, /* Read-only; writes are discarded */ 96 HVMMEM_mmio_dm, /* Reads and write go to the device model */ 97 #if __XEN_INTERFACE_VERSION__ < 0x00040700 98 HVMMEM_mmio_write_dm, /* Read-only; writes go to the device model */ 99 #else 100 HVMMEM_unused, /* Placeholder; setting memory to this type 101 will fail for code after 4.7.0 */ 102 #endif 103 HVMMEM_ioreq_server /* Memory type claimed by an ioreq server; type 104 changes to this value are only allowed after 105 an ioreq server has claimed its ownership. 106 Only pages with HVMMEM_ram_rw are allowed to 107 change to this type; conversely, pages with 108 this type are only allowed to be changed back 109 to HVMMEM_ram_rw. */ 110 } hvmmem_type_t; 111 112 #endif /* XEN_GENERATING_COMPAT_HEADERS */ 113 114 /* Hint from PV drivers for pagetable destruction. */ 115 #define HVMOP_pagetable_dying 9 116 struct xen_hvm_pagetable_dying { 117 /* Domain with a pagetable about to be destroyed. */ 118 domid_t domid; 119 uint16_t pad[3]; /* align next field on 8-byte boundary */ 120 /* guest physical address of the toplevel pagetable dying */ 121 uint64_t gpa; 122 }; 123 typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t; 124 DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t); 125 126 /* Get the current Xen time, in nanoseconds since system boot. */ 127 #define HVMOP_get_time 10 128 struct xen_hvm_get_time { 129 uint64_t now; /* OUT */ 130 }; 131 typedef struct xen_hvm_get_time xen_hvm_get_time_t; 132 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t); 133 134 #define HVMOP_xentrace 11 135 struct xen_hvm_xentrace { 136 uint16_t event, extra_bytes; 137 uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)]; 138 }; 139 typedef struct xen_hvm_xentrace xen_hvm_xentrace_t; 140 DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t); 141 142 /* Following tools-only interfaces may change in future. */ 143 #if defined(__XEN__) || defined(__XEN_TOOLS__) 144 145 /* Deprecated by XENMEM_access_op_set_access */ 146 #define HVMOP_set_mem_access 12 147 148 /* Deprecated by XENMEM_access_op_get_access */ 149 #define HVMOP_get_mem_access 13 150 151 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ 152 153 #define HVMOP_get_mem_type 15 154 /* Return hvmmem_type_t for the specified pfn. */ 155 struct xen_hvm_get_mem_type { 156 /* Domain to be queried. */ 157 domid_t domid; 158 /* OUT variable. */ 159 uint16_t mem_type; 160 uint16_t pad[2]; /* align next field on 8-byte boundary */ 161 /* IN variable. */ 162 uint64_t pfn; 163 }; 164 typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t; 165 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t); 166 167 /* Following tools-only interfaces may change in future. */ 168 #if defined(__XEN__) || defined(__XEN_TOOLS__) 169 170 /* 171 * Definitions relating to DMOP_create_ioreq_server. (Defined here for 172 * backwards compatibility). 173 */ 174 175 #define HVM_IOREQSRV_BUFIOREQ_OFF 0 176 #define HVM_IOREQSRV_BUFIOREQ_LEGACY 1 177 /* 178 * Use this when read_pointer gets updated atomically and 179 * the pointer pair gets read atomically: 180 */ 181 #define HVM_IOREQSRV_BUFIOREQ_ATOMIC 2 182 183 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ 184 185 #if defined(__i386__) || defined(__x86_64__) 186 187 /* 188 * HVMOP_set_evtchn_upcall_vector: Set a <vector> that should be used for event 189 * channel upcalls on the specified <vcpu>. If set, 190 * this vector will be used in preference to the 191 * domain global callback via (see 192 * HVM_PARAM_CALLBACK_IRQ). 193 */ 194 #define HVMOP_set_evtchn_upcall_vector 23 195 struct xen_hvm_evtchn_upcall_vector { 196 uint32_t vcpu; 197 uint8_t vector; 198 }; 199 typedef struct xen_hvm_evtchn_upcall_vector xen_hvm_evtchn_upcall_vector_t; 200 DEFINE_XEN_GUEST_HANDLE(xen_hvm_evtchn_upcall_vector_t); 201 202 #endif /* defined(__i386__) || defined(__x86_64__) */ 203 204 #define HVMOP_guest_request_vm_event 24 205 206 /* HVMOP_altp2m: perform altp2m state operations */ 207 #define HVMOP_altp2m 25 208 209 #define HVMOP_ALTP2M_INTERFACE_VERSION 0x00000001 210 211 struct xen_hvm_altp2m_domain_state { 212 /* IN or OUT variable on/off */ 213 uint8_t state; 214 }; 215 typedef struct xen_hvm_altp2m_domain_state xen_hvm_altp2m_domain_state_t; 216 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_domain_state_t); 217 218 struct xen_hvm_altp2m_vcpu_enable_notify { 219 uint32_t vcpu_id; 220 uint32_t pad; 221 /* #VE info area gfn */ 222 uint64_t gfn; 223 }; 224 typedef struct xen_hvm_altp2m_vcpu_enable_notify xen_hvm_altp2m_vcpu_enable_notify_t; 225 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_enable_notify_t); 226 227 struct xen_hvm_altp2m_view { 228 /* IN/OUT variable */ 229 uint16_t view; 230 /* Create view only: default access type 231 * NOTE: currently ignored */ 232 uint16_t hvmmem_default_access; /* xenmem_access_t */ 233 }; 234 typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t; 235 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_view_t); 236 237 struct xen_hvm_altp2m_set_mem_access { 238 /* view */ 239 uint16_t view; 240 /* Memory type */ 241 uint16_t hvmmem_access; /* xenmem_access_t */ 242 uint32_t pad; 243 /* gfn */ 244 uint64_t gfn; 245 }; 246 typedef struct xen_hvm_altp2m_set_mem_access xen_hvm_altp2m_set_mem_access_t; 247 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_set_mem_access_t); 248 249 struct xen_hvm_altp2m_set_mem_access_multi { 250 /* view */ 251 uint16_t view; 252 uint16_t pad; 253 /* Number of pages */ 254 uint32_t nr; 255 /* 256 * Used for continuation purposes. 257 * Must be set to zero upon initial invocation. 258 */ 259 uint64_t opaque; 260 /* List of pfns to set access for */ 261 XEN_GUEST_HANDLE(const_uint64) pfn_list; 262 /* Corresponding list of access settings for pfn_list */ 263 XEN_GUEST_HANDLE(const_uint8) access_list; 264 }; 265 266 struct xen_hvm_altp2m_change_gfn { 267 /* view */ 268 uint16_t view; 269 uint16_t pad1; 270 uint32_t pad2; 271 /* old gfn */ 272 uint64_t old_gfn; 273 /* new gfn, INVALID_GFN (~0UL) means revert */ 274 uint64_t new_gfn; 275 }; 276 typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t; 277 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t); 278 279 struct xen_hvm_altp2m_op { 280 uint32_t version; /* HVMOP_ALTP2M_INTERFACE_VERSION */ 281 uint32_t cmd; 282 /* Get/set the altp2m state for a domain */ 283 #define HVMOP_altp2m_get_domain_state 1 284 #define HVMOP_altp2m_set_domain_state 2 285 /* Set the current VCPU to receive altp2m event notifications */ 286 #define HVMOP_altp2m_vcpu_enable_notify 3 287 /* Create a new view */ 288 #define HVMOP_altp2m_create_p2m 4 289 /* Destroy a view */ 290 #define HVMOP_altp2m_destroy_p2m 5 291 /* Switch view for an entire domain */ 292 #define HVMOP_altp2m_switch_p2m 6 293 /* Notify that a page of memory is to have specific access types */ 294 #define HVMOP_altp2m_set_mem_access 7 295 /* Change a p2m entry to have a different gfn->mfn mapping */ 296 #define HVMOP_altp2m_change_gfn 8 297 /* Set access for an array of pages */ 298 #define HVMOP_altp2m_set_mem_access_multi 9 299 domid_t domain; 300 uint16_t pad1; 301 uint32_t pad2; 302 union { 303 struct xen_hvm_altp2m_domain_state domain_state; 304 struct xen_hvm_altp2m_vcpu_enable_notify enable_notify; 305 struct xen_hvm_altp2m_view view; 306 struct xen_hvm_altp2m_set_mem_access set_mem_access; 307 struct xen_hvm_altp2m_change_gfn change_gfn; 308 struct xen_hvm_altp2m_set_mem_access_multi set_mem_access_multi; 309 uint8_t pad[64]; 310 } u; 311 }; 312 typedef struct xen_hvm_altp2m_op xen_hvm_altp2m_op_t; 313 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_op_t); 314 315 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ 316 317 /* 318 * Local variables: 319 * mode: C 320 * c-file-style: "BSD" 321 * c-basic-offset: 4 322 * tab-width: 4 323 * indent-tabs-mode: nil 324 * End: 325 */ 326