/*1* Permission is hereby granted, free of charge, to any person obtaining a copy2* of this software and associated documentation files (the "Software"), to3* deal in the Software without restriction, including without limitation the4* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or5* sell copies of the Software, and to permit persons to whom the Software is6* furnished to do so, subject to the following conditions:7*8* The above copyright notice and this permission notice shall be included in9* all copies or substantial portions of the Software.10*11* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR12* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,13* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE14* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER15* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING16* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER17* DEALINGS IN THE SOFTWARE.18*19* Copyright (c) 2007, Keir Fraser20*/2122#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__23#define __XEN_PUBLIC_HVM_HVM_OP_H__2425#include "../xen.h"26#include "../trace.h"27#include "../event_channel.h"2829/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */30#define HVMOP_set_param 031#define HVMOP_get_param 132struct xen_hvm_param {33domid_t domid; /* IN */34uint16_t pad;35uint32_t index; /* IN */36uint64_t value; /* IN/OUT */37};38typedef struct xen_hvm_param xen_hvm_param_t;39DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);4041struct xen_hvm_altp2m_suppress_ve {42uint16_t view;43uint8_t suppress_ve; /* Boolean type. */44uint8_t pad1;45uint32_t pad2;46uint64_t gfn;47};4849struct xen_hvm_altp2m_suppress_ve_multi {50uint16_t view;51uint8_t suppress_ve; /* Boolean type. */52uint8_t pad1;53int32_t first_error; /* Should be set to 0. */54uint64_t first_gfn; /* Value may be updated. */55uint64_t last_gfn;56uint64_t first_error_gfn; /* Gfn of the first error. */57};5859#if __XEN_INTERFACE_VERSION__ < 0x000409006061/* Set the logical level of one of a domain's PCI INTx wires. */62#define HVMOP_set_pci_intx_level 263struct xen_hvm_set_pci_intx_level {64/* Domain to be updated. */65domid_t domid;66/* PCI INTx identification in PCI topology (domain:bus:device:intx). */67uint8_t domain, bus, device, intx;68/* Assertion level (0 = unasserted, 1 = asserted). */69uint8_t level;70};71typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;72DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t);7374/* Set the logical level of one of a domain's ISA IRQ wires. */75#define HVMOP_set_isa_irq_level 376struct xen_hvm_set_isa_irq_level {77/* Domain to be updated. */78domid_t domid;79/* ISA device identification, by ISA IRQ (0-15). */80uint8_t isa_irq;81/* Assertion level (0 = unasserted, 1 = asserted). */82uint8_t level;83};84typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t;85DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t);8687#define HVMOP_set_pci_link_route 488struct xen_hvm_set_pci_link_route {89/* Domain to be updated. */90domid_t domid;91/* PCI link identifier (0-3). */92uint8_t link;93/* ISA IRQ (1-15), or 0 (disable link). */94uint8_t isa_irq;95};96typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t;97DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);9899#endif /* __XEN_INTERFACE_VERSION__ < 0x00040900 */100101/* Flushes all VCPU TLBs: @arg must be NULL. */102#define HVMOP_flush_tlbs 5103104/*105* hvmmem_type_t should not be defined when generating the corresponding106* compat header. This will ensure that the improperly named HVMMEM_(*)107* values are defined only once.108*/109#ifndef XEN_GENERATING_COMPAT_HEADERS110111typedef enum {112HVMMEM_ram_rw, /* Normal read/write guest RAM */113HVMMEM_ram_ro, /* Read-only; writes are discarded */114HVMMEM_mmio_dm, /* Reads and write go to the device model */115#if __XEN_INTERFACE_VERSION__ < 0x00040700116HVMMEM_mmio_write_dm, /* Read-only; writes go to the device model */117#else118HVMMEM_unused, /* Placeholder; setting memory to this type119will fail for code after 4.7.0 */120#endif121HVMMEM_ioreq_server /* Memory type claimed by an ioreq server; type122changes to this value are only allowed after123an ioreq server has claimed its ownership.124Only pages with HVMMEM_ram_rw are allowed to125change to this type; conversely, pages with126this type are only allowed to be changed back127to HVMMEM_ram_rw. */128} hvmmem_type_t;129130#endif /* XEN_GENERATING_COMPAT_HEADERS */131132/* Hint from PV drivers for pagetable destruction. */133#define HVMOP_pagetable_dying 9134struct xen_hvm_pagetable_dying {135/* Domain with a pagetable about to be destroyed. */136domid_t domid;137uint16_t pad[3]; /* align next field on 8-byte boundary */138/* guest physical address of the toplevel pagetable dying */139uint64_t gpa;140};141typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t;142DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t);143144/* Get the current Xen time, in nanoseconds since system boot. */145#define HVMOP_get_time 10146struct xen_hvm_get_time {147uint64_t now; /* OUT */148};149typedef struct xen_hvm_get_time xen_hvm_get_time_t;150DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t);151152#define HVMOP_xentrace 11153struct xen_hvm_xentrace {154uint16_t event, extra_bytes;155uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)];156};157typedef struct xen_hvm_xentrace xen_hvm_xentrace_t;158DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t);159160/* Following tools-only interfaces may change in future. */161#if defined(__XEN__) || defined(__XEN_TOOLS__)162163/* Deprecated by XENMEM_access_op_set_access */164#define HVMOP_set_mem_access 12165166/* Deprecated by XENMEM_access_op_get_access */167#define HVMOP_get_mem_access 13168169#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */170171#define HVMOP_get_mem_type 15172/* Return hvmmem_type_t for the specified pfn. */173struct xen_hvm_get_mem_type {174/* Domain to be queried. */175domid_t domid;176/* OUT variable. */177uint16_t mem_type;178uint16_t pad[2]; /* align next field on 8-byte boundary */179/* IN variable. */180uint64_t pfn;181};182typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t;183DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t);184185/* Following tools-only interfaces may change in future. */186#if defined(__XEN__) || defined(__XEN_TOOLS__)187188/*189* Definitions relating to DMOP_create_ioreq_server. (Defined here for190* backwards compatibility).191*/192193#define HVM_IOREQSRV_BUFIOREQ_OFF 0194#define HVM_IOREQSRV_BUFIOREQ_LEGACY 1195/*196* Use this when read_pointer gets updated atomically and197* the pointer pair gets read atomically:198*/199#define HVM_IOREQSRV_BUFIOREQ_ATOMIC 2200201#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */202203#if defined(__i386__) || defined(__x86_64__)204205/*206* HVMOP_set_evtchn_upcall_vector: Set a <vector> that should be used for event207* channel upcalls on the specified <vcpu>. If set,208* this vector will be used in preference to the209* domain global callback via (see210* HVM_PARAM_CALLBACK_IRQ).211*/212#define HVMOP_set_evtchn_upcall_vector 23213struct xen_hvm_evtchn_upcall_vector {214uint32_t vcpu;215uint8_t vector;216};217typedef struct xen_hvm_evtchn_upcall_vector xen_hvm_evtchn_upcall_vector_t;218DEFINE_XEN_GUEST_HANDLE(xen_hvm_evtchn_upcall_vector_t);219220#endif /* defined(__i386__) || defined(__x86_64__) */221222#define HVMOP_guest_request_vm_event 24223224/* HVMOP_altp2m: perform altp2m state operations */225#define HVMOP_altp2m 25226227#define HVMOP_ALTP2M_INTERFACE_VERSION 0x00000001228229struct xen_hvm_altp2m_domain_state {230/* IN or OUT variable on/off */231uint8_t state;232};233typedef struct xen_hvm_altp2m_domain_state xen_hvm_altp2m_domain_state_t;234DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_domain_state_t);235236struct xen_hvm_altp2m_vcpu_enable_notify {237uint32_t vcpu_id;238uint32_t pad;239/* #VE info area gfn */240uint64_t gfn;241};242typedef struct xen_hvm_altp2m_vcpu_enable_notify xen_hvm_altp2m_vcpu_enable_notify_t;243DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_enable_notify_t);244245struct xen_hvm_altp2m_vcpu_disable_notify {246uint32_t vcpu_id;247};248typedef struct xen_hvm_altp2m_vcpu_disable_notify xen_hvm_altp2m_vcpu_disable_notify_t;249DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_disable_notify_t);250251struct xen_hvm_altp2m_view {252/* IN/OUT variable */253uint16_t view;254uint16_t hvmmem_default_access; /* xenmem_access_t */255};256typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t;257DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_view_t);258259#if __XEN_INTERFACE_VERSION__ < 0x00040a00260struct xen_hvm_altp2m_set_mem_access {261/* view */262uint16_t view;263/* Memory type */264uint16_t access; /* xenmem_access_t */265uint32_t pad;266/* gfn */267uint64_t gfn;268};269typedef struct xen_hvm_altp2m_set_mem_access xen_hvm_altp2m_set_mem_access_t;270DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_set_mem_access_t);271#endif /* __XEN_INTERFACE_VERSION__ < 0x00040a00 */272273struct xen_hvm_altp2m_mem_access {274/* view */275uint16_t view;276/* Memory type */277uint16_t access; /* xenmem_access_t */278uint32_t pad;279/* gfn */280uint64_t gfn;281};282typedef struct xen_hvm_altp2m_mem_access xen_hvm_altp2m_mem_access_t;283DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_mem_access_t);284285struct xen_hvm_altp2m_set_mem_access_multi {286/* view */287uint16_t view;288uint16_t pad;289/* Number of pages */290uint32_t nr;291/*292* Used for continuation purposes.293* Must be set to zero upon initial invocation.294*/295uint64_t opaque;296/* List of pfns to set access for */297XEN_GUEST_HANDLE(const_uint64) pfn_list;298/* Corresponding list of access settings for pfn_list */299XEN_GUEST_HANDLE(const_uint8) access_list;300};301302struct xen_hvm_altp2m_change_gfn {303/* view */304uint16_t view;305uint16_t pad1;306uint32_t pad2;307/* old gfn */308uint64_t old_gfn;309/* new gfn, INVALID_GFN (~0UL) means revert */310uint64_t new_gfn;311};312typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t;313DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t);314315struct xen_hvm_altp2m_get_vcpu_p2m_idx {316uint32_t vcpu_id;317uint16_t altp2m_idx;318};319320struct xen_hvm_altp2m_set_visibility {321uint16_t altp2m_idx;322uint8_t visible;323uint8_t pad;324};325326struct xen_hvm_altp2m_op {327uint32_t version; /* HVMOP_ALTP2M_INTERFACE_VERSION */328uint32_t cmd;329/* Get/set the altp2m state for a domain */330#define HVMOP_altp2m_get_domain_state 1331#define HVMOP_altp2m_set_domain_state 2332/* Set a given VCPU to receive altp2m event notifications */333#define HVMOP_altp2m_vcpu_enable_notify 3334/* Create a new view */335#define HVMOP_altp2m_create_p2m 4336/* Destroy a view */337#define HVMOP_altp2m_destroy_p2m 5338/* Switch view for an entire domain */339#define HVMOP_altp2m_switch_p2m 6340/* Notify that a page of memory is to have specific access types */341#define HVMOP_altp2m_set_mem_access 7342/* Change a p2m entry to have a different gfn->mfn mapping */343#define HVMOP_altp2m_change_gfn 8344/* Set access for an array of pages */345#define HVMOP_altp2m_set_mem_access_multi 9346/* Set the "Suppress #VE" bit on a page */347#define HVMOP_altp2m_set_suppress_ve 10348/* Get the "Suppress #VE" bit of a page */349#define HVMOP_altp2m_get_suppress_ve 11350/* Get the access of a page of memory from a certain view */351#define HVMOP_altp2m_get_mem_access 12352/* Disable altp2m event notifications for a given VCPU */353#define HVMOP_altp2m_vcpu_disable_notify 13354/* Get the active vcpu p2m index */355#define HVMOP_altp2m_get_p2m_idx 14356/* Set the "Supress #VE" bit for a range of pages */357#define HVMOP_altp2m_set_suppress_ve_multi 15358/* Set visibility for a given altp2m view */359#define HVMOP_altp2m_set_visibility 16360domid_t domain;361uint16_t pad1;362uint32_t pad2;363union {364struct xen_hvm_altp2m_domain_state domain_state;365struct xen_hvm_altp2m_vcpu_enable_notify enable_notify;366struct xen_hvm_altp2m_view view;367#if __XEN_INTERFACE_VERSION__ < 0x00040a00368struct xen_hvm_altp2m_set_mem_access set_mem_access;369#endif /* __XEN_INTERFACE_VERSION__ < 0x00040a00 */370struct xen_hvm_altp2m_mem_access mem_access;371struct xen_hvm_altp2m_change_gfn change_gfn;372struct xen_hvm_altp2m_set_mem_access_multi set_mem_access_multi;373struct xen_hvm_altp2m_suppress_ve suppress_ve;374struct xen_hvm_altp2m_suppress_ve_multi suppress_ve_multi;375struct xen_hvm_altp2m_vcpu_disable_notify disable_notify;376struct xen_hvm_altp2m_get_vcpu_p2m_idx get_vcpu_p2m_idx;377struct xen_hvm_altp2m_set_visibility set_visibility;378uint8_t pad[64];379} u;380};381typedef struct xen_hvm_altp2m_op xen_hvm_altp2m_op_t;382DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_op_t);383384#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */385386/*387* Local variables:388* mode: C389* c-file-style: "BSD"390* c-basic-offset: 4391* tab-width: 4392* indent-tabs-mode: nil393* End:394*/395396397