/* SPDX-License-Identifier: MIT */1/******************************************************************************2* xen.h3*4* Guest OS interface to Xen.5*6* Copyright (c) 2004, K A Fraser7*/89#ifndef __XEN_PUBLIC_XEN_H__10#define __XEN_PUBLIC_XEN_H__1112#include <asm/xen/interface.h>1314/*15* XEN "SYSTEM CALLS" (a.k.a. HYPERCALLS).16*/1718/*19* x86_32: EAX = vector; EBX, ECX, EDX, ESI, EDI = args 1, 2, 3, 4, 5.20* EAX = return value21* (argument registers may be clobbered on return)22* x86_64: RAX = vector; RDI, RSI, RDX, R10, R8, R9 = args 1, 2, 3, 4, 5, 6.23* RAX = return value24* (argument registers not clobbered on return; RCX, R11 are)25*/26#define __HYPERVISOR_set_trap_table 027#define __HYPERVISOR_mmu_update 128#define __HYPERVISOR_set_gdt 229#define __HYPERVISOR_stack_switch 330#define __HYPERVISOR_set_callbacks 431#define __HYPERVISOR_fpu_taskswitch 532#define __HYPERVISOR_sched_op_compat 633#define __HYPERVISOR_platform_op 734#define __HYPERVISOR_set_debugreg 835#define __HYPERVISOR_get_debugreg 936#define __HYPERVISOR_update_descriptor 1037#define __HYPERVISOR_memory_op 1238#define __HYPERVISOR_multicall 1339#define __HYPERVISOR_update_va_mapping 1440#define __HYPERVISOR_set_timer_op 1541#define __HYPERVISOR_event_channel_op_compat 1642#define __HYPERVISOR_xen_version 1743#define __HYPERVISOR_console_io 1844#define __HYPERVISOR_physdev_op_compat 1945#define __HYPERVISOR_grant_table_op 2046#define __HYPERVISOR_vm_assist 2147#define __HYPERVISOR_update_va_mapping_otherdomain 2248#define __HYPERVISOR_iret 23 /* x86 only */49#define __HYPERVISOR_vcpu_op 2450#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */51#define __HYPERVISOR_mmuext_op 2652#define __HYPERVISOR_xsm_op 2753#define __HYPERVISOR_nmi_op 2854#define __HYPERVISOR_sched_op 2955#define __HYPERVISOR_callback_op 3056#define __HYPERVISOR_xenoprof_op 3157#define __HYPERVISOR_event_channel_op 3258#define __HYPERVISOR_physdev_op 3359#define __HYPERVISOR_hvm_op 3460#define __HYPERVISOR_sysctl 3561#define __HYPERVISOR_domctl 3662#define __HYPERVISOR_kexec_op 3763#define __HYPERVISOR_tmem_op 3864#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */65#define __HYPERVISOR_xenpmu_op 4066#define __HYPERVISOR_dm_op 416768/* Architecture-specific hypercall definitions. */69#define __HYPERVISOR_arch_0 4870#define __HYPERVISOR_arch_1 4971#define __HYPERVISOR_arch_2 5072#define __HYPERVISOR_arch_3 5173#define __HYPERVISOR_arch_4 5274#define __HYPERVISOR_arch_5 5375#define __HYPERVISOR_arch_6 5476#define __HYPERVISOR_arch_7 557778/*79* VIRTUAL INTERRUPTS80*81* Virtual interrupts that a guest OS may receive from Xen.82* In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a83* global VIRQ. The former can be bound once per VCPU and cannot be re-bound.84* The latter can be allocated only once per guest: they must initially be85* allocated to VCPU0 but can subsequently be re-bound.86*/87#define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */88#define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */89#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */90#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */91#define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */92#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */93#define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */94#define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */95#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */96#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */97#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */98#define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */99#define VIRQ_XENPMU 13 /* PMC interrupt */100101/* Architecture-specific VIRQ definitions. */102#define VIRQ_ARCH_0 16103#define VIRQ_ARCH_1 17104#define VIRQ_ARCH_2 18105#define VIRQ_ARCH_3 19106#define VIRQ_ARCH_4 20107#define VIRQ_ARCH_5 21108#define VIRQ_ARCH_6 22109#define VIRQ_ARCH_7 23110111#define NR_VIRQS 24112113/*114* enum neg_errnoval HYPERVISOR_mmu_update(const struct mmu_update reqs[],115* unsigned count, unsigned *done_out,116* unsigned foreigndom)117* @reqs is an array of mmu_update_t structures ((ptr, val) pairs).118* @count is the length of the above array.119* @pdone is an output parameter indicating number of completed operations120* @foreigndom[15:0]: FD, the expected owner of data pages referenced in this121* hypercall invocation. Can be DOMID_SELF.122* @foreigndom[31:16]: PFD, the expected owner of pagetable pages referenced123* in this hypercall invocation. The value of this field124* (x) encodes the PFD as follows:125* x == 0 => PFD == DOMID_SELF126* x != 0 => PFD == x - 1127*128* Sub-commands: ptr[1:0] specifies the appropriate MMU_* command.129* -------------130* ptr[1:0] == MMU_NORMAL_PT_UPDATE:131* Updates an entry in a page table belonging to PFD. If updating an L1 table,132* and the new table entry is valid/present, the mapped frame must belong to133* FD. If attempting to map an I/O page then the caller assumes the privilege134* of the FD.135* FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.136* FD == DOMID_XEN: Map restricted areas of Xen's heap space.137* ptr[:2] -- Machine address of the page-table entry to modify.138* val -- Value to write.139*140* There also certain implicit requirements when using this hypercall. The141* pages that make up a pagetable must be mapped read-only in the guest.142* This prevents uncontrolled guest updates to the pagetable. Xen strictly143* enforces this, and will disallow any pagetable update which will end up144* mapping pagetable page RW, and will disallow using any writable page as a145* pagetable. In practice it means that when constructing a page table for a146* process, thread, etc, we MUST be very dilligient in following these rules:147* 1). Start with top-level page (PGD or in Xen language: L4). Fill out148* the entries.149* 2). Keep on going, filling out the upper (PUD or L3), and middle (PMD150* or L2).151* 3). Start filling out the PTE table (L1) with the PTE entries. Once152* done, make sure to set each of those entries to RO (so writeable bit153* is unset). Once that has been completed, set the PMD (L2) for this154* PTE table as RO.155* 4). When completed with all of the PMD (L2) entries, and all of them have156* been set to RO, make sure to set RO the PUD (L3). Do the same157* operation on PGD (L4) pagetable entries that have a PUD (L3) entry.158* 5). Now before you can use those pages (so setting the cr3), you MUST also159* pin them so that the hypervisor can verify the entries. This is done160* via the HYPERVISOR_mmuext_op(MMUEXT_PIN_L4_TABLE, guest physical frame161* number of the PGD (L4)). And this point the HYPERVISOR_mmuext_op(162* MMUEXT_NEW_BASEPTR, guest physical frame number of the PGD (L4)) can be163* issued.164* For 32-bit guests, the L4 is not used (as there is less pagetables), so165* instead use L3.166* At this point the pagetables can be modified using the MMU_NORMAL_PT_UPDATE167* hypercall. Also if so desired the OS can also try to write to the PTE168* and be trapped by the hypervisor (as the PTE entry is RO).169*170* To deallocate the pages, the operations are the reverse of the steps171* mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the172* pagetable MUST not be in use (meaning that the cr3 is not set to it).173*174* ptr[1:0] == MMU_MACHPHYS_UPDATE:175* Updates an entry in the machine->pseudo-physical mapping table.176* ptr[:2] -- Machine address within the frame whose mapping to modify.177* The frame must belong to the FD, if one is specified.178* val -- Value to write into the mapping entry.179*180* ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD:181* As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed182* with those in @val.183*184* @val is usually the machine frame number along with some attributes.185* The attributes by default follow the architecture defined bits. Meaning that186* if this is a X86_64 machine and four page table layout is used, the layout187* of val is:188* - 63 if set means No execute (NX)189* - 46-13 the machine frame number190* - 12 available for guest191* - 11 available for guest192* - 10 available for guest193* - 9 available for guest194* - 8 global195* - 7 PAT (PSE is disabled, must use hypercall to make 4MB or 2MB pages)196* - 6 dirty197* - 5 accessed198* - 4 page cached disabled199* - 3 page write through200* - 2 userspace accessible201* - 1 writeable202* - 0 present203*204* The one bits that does not fit with the default layout is the PAGE_PSE205* also called PAGE_PAT). The MMUEXT_[UN]MARK_SUPER arguments to the206* HYPERVISOR_mmuext_op serve as mechanism to set a pagetable to be 4MB207* (or 2MB) instead of using the PAGE_PSE bit.208*209* The reason that the PAGE_PSE (bit 7) is not being utilized is due to Xen210* using it as the Page Attribute Table (PAT) bit - for details on it please211* refer to Intel SDM 10.12. The PAT allows to set the caching attributes of212* pages instead of using MTRRs.213*214* The PAT MSR is as follows (it is a 64-bit value, each entry is 8 bits):215* PAT4 PAT0216* +-----+-----+----+----+----+-----+----+----+217* | UC | UC- | WC | WB | UC | UC- | WC | WB | <= Linux218* +-----+-----+----+----+----+-----+----+----+219* | UC | UC- | WT | WB | UC | UC- | WT | WB | <= BIOS (default when machine boots)220* +-----+-----+----+----+----+-----+----+----+221* | rsv | rsv | WP | WC | UC | UC- | WT | WB | <= Xen222* +-----+-----+----+----+----+-----+----+----+223*224* The lookup of this index table translates to looking up225* Bit 7, Bit 4, and Bit 3 of val entry:226*227* PAT/PSE (bit 7) ... PCD (bit 4) .. PWT (bit 3).228*229* If all bits are off, then we are using PAT0. If bit 3 turned on,230* then we are using PAT1, if bit 3 and bit 4, then PAT2..231*232* As you can see, the Linux PAT1 translates to PAT4 under Xen. Which means233* that if a guest that follows Linux's PAT setup and would like to set Write234* Combined on pages it MUST use PAT4 entry. Meaning that Bit 7 (PAGE_PAT) is235* set. For example, under Linux it only uses PAT0, PAT1, and PAT2 for the236* caching as:237*238* WB = none (so PAT0)239* WC = PWT (bit 3 on)240* UC = PWT | PCD (bit 3 and 4 are on).241*242* To make it work with Xen, it needs to translate the WC bit as so:243*244* PWT (so bit 3 on) --> PAT (so bit 7 is on) and clear bit 3245*246* And to translate back it would:247*248* PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7.249*/250#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */251#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */252#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */253#define MMU_PT_UPDATE_NO_TRANSLATE 3 /* checked '*ptr = val'. ptr is MA. */254255/*256* MMU EXTENDED OPERATIONS257*258* enum neg_errnoval HYPERVISOR_mmuext_op(mmuext_op_t uops[],259* unsigned int count,260* unsigned int *pdone,261* unsigned int foreigndom)262*/263/* HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.264* A foreigndom (FD) can be specified (or DOMID_SELF for none).265* Where the FD has some effect, it is described below.266*267* cmd: MMUEXT_(UN)PIN_*_TABLE268* mfn: Machine frame number to be (un)pinned as a p.t. page.269* The frame must belong to the FD, if one is specified.270*271* cmd: MMUEXT_NEW_BASEPTR272* mfn: Machine frame number of new page-table base to install in MMU.273*274* cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]275* mfn: Machine frame number of new page-table base to install in MMU276* when in user space.277*278* cmd: MMUEXT_TLB_FLUSH_LOCAL279* No additional arguments. Flushes local TLB.280*281* cmd: MMUEXT_INVLPG_LOCAL282* linear_addr: Linear address to be flushed from the local TLB.283*284* cmd: MMUEXT_TLB_FLUSH_MULTI285* vcpumask: Pointer to bitmap of VCPUs to be flushed.286*287* cmd: MMUEXT_INVLPG_MULTI288* linear_addr: Linear address to be flushed.289* vcpumask: Pointer to bitmap of VCPUs to be flushed.290*291* cmd: MMUEXT_TLB_FLUSH_ALL292* No additional arguments. Flushes all VCPUs' TLBs.293*294* cmd: MMUEXT_INVLPG_ALL295* linear_addr: Linear address to be flushed from all VCPUs' TLBs.296*297* cmd: MMUEXT_FLUSH_CACHE298* No additional arguments. Writes back and flushes cache contents.299*300* cmd: MMUEXT_FLUSH_CACHE_GLOBAL301* No additional arguments. Writes back and flushes cache contents302* on all CPUs in the system.303*304* cmd: MMUEXT_SET_LDT305* linear_addr: Linear address of LDT base (NB. must be page-aligned).306* nr_ents: Number of entries in LDT.307*308* cmd: MMUEXT_CLEAR_PAGE309* mfn: Machine frame number to be cleared.310*311* cmd: MMUEXT_COPY_PAGE312* mfn: Machine frame number of the destination page.313* src_mfn: Machine frame number of the source page.314*315* cmd: MMUEXT_[UN]MARK_SUPER316* mfn: Machine frame number of head of superpage to be [un]marked.317*/318#define MMUEXT_PIN_L1_TABLE 0319#define MMUEXT_PIN_L2_TABLE 1320#define MMUEXT_PIN_L3_TABLE 2321#define MMUEXT_PIN_L4_TABLE 3322#define MMUEXT_UNPIN_TABLE 4323#define MMUEXT_NEW_BASEPTR 5324#define MMUEXT_TLB_FLUSH_LOCAL 6325#define MMUEXT_INVLPG_LOCAL 7326#define MMUEXT_TLB_FLUSH_MULTI 8327#define MMUEXT_INVLPG_MULTI 9328#define MMUEXT_TLB_FLUSH_ALL 10329#define MMUEXT_INVLPG_ALL 11330#define MMUEXT_FLUSH_CACHE 12331#define MMUEXT_SET_LDT 13332#define MMUEXT_NEW_USER_BASEPTR 15333#define MMUEXT_CLEAR_PAGE 16334#define MMUEXT_COPY_PAGE 17335#define MMUEXT_FLUSH_CACHE_GLOBAL 18336#define MMUEXT_MARK_SUPER 19337#define MMUEXT_UNMARK_SUPER 20338339#ifndef __ASSEMBLY__340struct mmuext_op {341unsigned int cmd;342union {343/* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR344* CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */345xen_pfn_t mfn;346/* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */347unsigned long linear_addr;348} arg1;349union {350/* SET_LDT */351unsigned int nr_ents;352/* TLB_FLUSH_MULTI, INVLPG_MULTI */353void *vcpumask;354/* COPY_PAGE */355xen_pfn_t src_mfn;356} arg2;357};358DEFINE_GUEST_HANDLE_STRUCT(mmuext_op);359#endif360361/* These are passed as 'flags' to update_va_mapping. They can be ORed. */362/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */363/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */364#define UVMF_NONE (0UL<<0) /* No flushing at all. */365#define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */366#define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */367#define UVMF_FLUSHTYPE_MASK (3UL<<0)368#define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */369#define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */370#define UVMF_ALL (1UL<<2) /* Flush all TLBs. */371372/*373* Commands to HYPERVISOR_console_io().374*/375#define CONSOLEIO_write 0376#define CONSOLEIO_read 1377378/*379* Commands to HYPERVISOR_vm_assist().380*/381#define VMASST_CMD_enable 0382#define VMASST_CMD_disable 1383384/* x86/32 guests: simulate full 4GB segment limits. */385#define VMASST_TYPE_4gb_segments 0386387/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */388#define VMASST_TYPE_4gb_segments_notify 1389390/*391* x86 guests: support writes to bottom-level PTEs.392* NB1. Page-directory entries cannot be written.393* NB2. Guest must continue to remove all writable mappings of PTEs.394*/395#define VMASST_TYPE_writable_pagetables 2396397/* x86/PAE guests: support PDPTs above 4GB. */398#define VMASST_TYPE_pae_extended_cr3 3399400/*401* x86 guests: Sane behaviour for virtual iopl402* - virtual iopl updated from do_iret() hypercalls.403* - virtual iopl reported in bounce frames.404* - guest kernels assumed to be level 0 for the purpose of iopl checks.405*/406#define VMASST_TYPE_architectural_iopl 4407408/*409* All guests: activate update indicator in vcpu_runstate_info410* Enable setting the XEN_RUNSTATE_UPDATE flag in guest memory mapped411* vcpu_runstate_info during updates of the runstate information.412*/413#define VMASST_TYPE_runstate_update_flag 5414415#define MAX_VMASST_TYPE 5416417#ifndef __ASSEMBLY__418419typedef uint16_t domid_t;420421/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */422#define DOMID_FIRST_RESERVED (0x7FF0U)423424/* DOMID_SELF is used in certain contexts to refer to oneself. */425#define DOMID_SELF (0x7FF0U)426427/*428* DOMID_IO is used to restrict page-table updates to mapping I/O memory.429* Although no Foreign Domain need be specified to map I/O pages, DOMID_IO430* is useful to ensure that no mappings to the OS's own heap are accidentally431* installed. (e.g., in Linux this could cause havoc as reference counts432* aren't adjusted on the I/O-mapping code path).433* This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can434* be specified by any calling domain.435*/436#define DOMID_IO (0x7FF1U)437438/*439* DOMID_XEN is used to allow privileged domains to map restricted parts of440* Xen's heap space (e.g., the machine_to_phys table).441* This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if442* the caller is privileged.443*/444#define DOMID_XEN (0x7FF2U)445446/* DOMID_COW is used as the owner of sharable pages */447#define DOMID_COW (0x7FF3U)448449/* DOMID_INVALID is used to identify pages with unknown owner. */450#define DOMID_INVALID (0x7FF4U)451452/* Idle domain. */453#define DOMID_IDLE (0x7FFFU)454455/*456* Send an array of these to HYPERVISOR_mmu_update().457* NB. The fields are natural pointer/address size for this architecture.458*/459struct mmu_update {460uint64_t ptr; /* Machine address of PTE. */461uint64_t val; /* New contents of PTE. */462};463DEFINE_GUEST_HANDLE_STRUCT(mmu_update);464465/*466* Send an array of these to HYPERVISOR_multicall().467* NB. The fields are logically the natural register size for this468* architecture. In cases where xen_ulong_t is larger than this then469* any unused bits in the upper portion must be zero.470*/471struct multicall_entry {472xen_ulong_t op;473xen_long_t result;474xen_ulong_t args[6];475};476DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);477478struct vcpu_time_info {479/*480* Updates to the following values are preceded and followed481* by an increment of 'version'. The guest can therefore482* detect updates by looking for changes to 'version'. If the483* least-significant bit of the version number is set then an484* update is in progress and the guest must wait to read a485* consistent set of values. The correct way to interact with486* the version number is similar to Linux's seqlock: see the487* implementations of read_seqbegin/read_seqretry.488*/489uint32_t version;490uint32_t pad0;491uint64_t tsc_timestamp; /* TSC at last update of time vals. */492uint64_t system_time; /* Time, in nanosecs, since boot. */493/*494* Current system time:495* system_time + ((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul496* CPU frequency (Hz):497* ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift498*/499uint32_t tsc_to_system_mul;500int8_t tsc_shift;501int8_t pad1[3];502}; /* 32 bytes */503504struct vcpu_info {505/*506* 'evtchn_upcall_pending' is written non-zero by Xen to indicate507* a pending notification for a particular VCPU. It is then cleared508* by the guest OS /before/ checking for pending work, thus avoiding509* a set-and-check race. Note that the mask is only accessed by Xen510* on the CPU that is currently hosting the VCPU. This means that the511* pending and mask flags can be updated by the guest without special512* synchronisation (i.e., no need for the x86 LOCK prefix).513* This may seem suboptimal because if the pending flag is set by514* a different CPU then an IPI may be scheduled even when the mask515* is set. However, note:516* 1. The task of 'interrupt holdoff' is covered by the per-event-517* channel mask bits. A 'noisy' event that is continually being518* triggered can be masked at source at this very precise519* granularity.520* 2. The main purpose of the per-VCPU mask is therefore to restrict521* reentrant execution: whether for concurrency control, or to522* prevent unbounded stack usage. Whatever the purpose, we expect523* that the mask will be asserted only for short periods at a time,524* and so the likelihood of a 'spurious' IPI is suitably small.525* The mask is read before making an event upcall to the guest: a526* non-zero mask therefore guarantees that the VCPU will not receive527* an upcall activation. The mask is cleared when the VCPU requests528* to block: this avoids wakeup-waiting races.529*/530uint8_t evtchn_upcall_pending;531uint8_t evtchn_upcall_mask;532xen_ulong_t evtchn_pending_sel;533struct arch_vcpu_info arch;534struct pvclock_vcpu_time_info time;535}; /* 64 bytes (x86) */536537/*538* Xen/kernel shared data -- pointer provided in start_info.539* NB. We expect that this struct is smaller than a page.540*/541struct shared_info {542struct vcpu_info vcpu_info[MAX_VIRT_CPUS];543544/*545* A domain can create "event channels" on which it can send and receive546* asynchronous event notifications. There are three classes of event that547* are delivered by this mechanism:548* 1. Bi-directional inter- and intra-domain connections. Domains must549* arrange out-of-band to set up a connection (usually by allocating550* an unbound 'listener' port and avertising that via a storage service551* such as xenstore).552* 2. Physical interrupts. A domain with suitable hardware-access553* privileges can bind an event-channel port to a physical interrupt554* source.555* 3. Virtual interrupts ('events'). A domain can bind an event-channel556* port to a virtual interrupt source, such as the virtual-timer557* device or the emergency console.558*559* Event channels are addressed by a "port index". Each channel is560* associated with two bits of information:561* 1. PENDING -- notifies the domain that there is a pending notification562* to be processed. This bit is cleared by the guest.563* 2. MASK -- if this bit is clear then a 0->1 transition of PENDING564* will cause an asynchronous upcall to be scheduled. This bit is only565* updated by the guest. It is read-only within Xen. If a channel566* becomes pending while the channel is masked then the 'edge' is lost567* (i.e., when the channel is unmasked, the guest must manually handle568* pending notifications as no upcall will be scheduled by Xen).569*570* To expedite scanning of pending notifications, any 0->1 pending571* transition on an unmasked channel causes a corresponding bit in a572* per-vcpu selector word to be set. Each bit in the selector covers a573* 'C long' in the PENDING bitfield array.574*/575xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8];576xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];577578/*579* Wallclock time: updated only by control software. Guests should base580* their gettimeofday() syscall on this wallclock-base value.581*/582struct pvclock_wall_clock wc;583#ifndef CONFIG_X86_32584uint32_t wc_sec_hi;585#endif586struct arch_shared_info arch;587588};589590/*591* Start-of-day memory layout592*593* 1. The domain is started within contiguous virtual-memory region.594* 2. The contiguous region begins and ends on an aligned 4MB boundary.595* 3. This the order of bootstrap elements in the initial virtual region:596* a. relocated kernel image597* b. initial ram disk [mod_start, mod_len]598* (may be omitted)599* c. list of allocated page frames [mfn_list, nr_pages]600* (unless relocated due to XEN_ELFNOTE_INIT_P2M)601* d. start_info_t structure [register ESI (x86)]602* in case of dom0 this page contains the console info, too603* e. unless dom0: xenstore ring page604* f. unless dom0: console ring page605* g. bootstrap page tables [pt_base, CR3 (x86)]606* h. bootstrap stack [register ESP (x86)]607* 4. Bootstrap elements are packed together, but each is 4kB-aligned.608* 5. The list of page frames forms a contiguous 'pseudo-physical' memory609* layout for the domain. In particular, the bootstrap virtual-memory610* region is a 1:1 mapping to the first section of the pseudo-physical map.611* 6. All bootstrap elements are mapped read-writable for the guest OS. The612* only exception is the bootstrap page table, which is mapped read-only.613* 7. There is guaranteed to be at least 512kB padding after the final614* bootstrap element. If necessary, the bootstrap virtual region is615* extended by an extra 4MB to ensure this.616*/617618#define MAX_GUEST_CMDLINE 1024619struct start_info {620/* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */621char magic[32]; /* "xen-<version>-<platform>". */622unsigned long nr_pages; /* Total pages allocated to this domain. */623unsigned long shared_info; /* MACHINE address of shared info struct. */624uint32_t flags; /* SIF_xxx flags. */625xen_pfn_t store_mfn; /* MACHINE page number of shared page. */626uint32_t store_evtchn; /* Event channel for store communication. */627union {628struct {629xen_pfn_t mfn; /* MACHINE page number of console page. */630uint32_t evtchn; /* Event channel for console page. */631} domU;632struct {633uint32_t info_off; /* Offset of console_info struct. */634uint32_t info_size; /* Size of console_info struct from start.*/635} dom0;636} console;637/* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */638unsigned long pt_base; /* VIRTUAL address of page directory. */639unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */640unsigned long mfn_list; /* VIRTUAL address of page-frame list. */641unsigned long mod_start; /* VIRTUAL address of pre-loaded module. */642unsigned long mod_len; /* Size (bytes) of pre-loaded module. */643int8_t cmd_line[MAX_GUEST_CMDLINE];644/* The pfn range here covers both page table and p->m table frames. */645unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */646unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */647};648649/* These flags are passed in the 'flags' field of start_info_t. */650#define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */651#define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */652#define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */653#define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */654#define SIF_VIRT_P2M_4TOOLS (1<<4) /* Do Xen tools understand a virt. mapped */655/* P->M making the 3 level tree obsolete? */656#define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */657658/*659* A multiboot module is a package containing modules very similar to a660* multiboot module array. The only differences are:661* - the array of module descriptors is by convention simply at the beginning662* of the multiboot module,663* - addresses in the module descriptors are based on the beginning of the664* multiboot module,665* - the number of modules is determined by a termination descriptor that has666* mod_start == 0.667*668* This permits to both build it statically and reference it in a configuration669* file, and let the PV guest easily rebase the addresses to virtual addresses670* and at the same time count the number of modules.671*/672struct xen_multiboot_mod_list {673/* Address of first byte of the module */674uint32_t mod_start;675/* Address of last byte of the module (inclusive) */676uint32_t mod_end;677/* Address of zero-terminated command line */678uint32_t cmdline;679/* Unused, must be zero */680uint32_t pad;681};682/*683* The console structure in start_info.console.dom0684*685* This structure includes a variety of information required to686* have a working VGA/VESA console.687*/688struct dom0_vga_console_info {689uint8_t video_type;690#define XEN_VGATYPE_TEXT_MODE_3 0x03691#define XEN_VGATYPE_VESA_LFB 0x23692#define XEN_VGATYPE_EFI_LFB 0x70693694union {695struct {696/* Font height, in pixels. */697uint16_t font_height;698/* Cursor location (column, row). */699uint16_t cursor_x, cursor_y;700/* Number of rows and columns (dimensions in characters). */701uint16_t rows, columns;702} text_mode_3;703704struct {705/* Width and height, in pixels. */706uint16_t width, height;707/* Bytes per scan line. */708uint16_t bytes_per_line;709/* Bits per pixel. */710uint16_t bits_per_pixel;711/* LFB physical address, and size (in units of 64kB). */712uint32_t lfb_base;713uint32_t lfb_size;714/* RGB mask offsets and sizes, as defined by VBE 1.2+ */715uint8_t red_pos, red_size;716uint8_t green_pos, green_size;717uint8_t blue_pos, blue_size;718uint8_t rsvd_pos, rsvd_size;719720/* VESA capabilities (offset 0xa, VESA command 0x4f00). */721uint32_t gbl_caps;722/* Mode attributes (offset 0x0, VESA command 0x4f01). */723uint16_t mode_attrs;724uint16_t pad;725/* high 32 bits of lfb_base */726uint32_t ext_lfb_base;727} vesa_lfb;728} u;729};730731typedef uint64_t cpumap_t;732733typedef uint8_t xen_domain_handle_t[16];734735/* Turn a plain number into a C unsigned long constant. */736#define __mk_unsigned_long(x) x ## UL737#define mk_unsigned_long(x) __mk_unsigned_long(x)738739#define TMEM_SPEC_VERSION 1740741struct tmem_op {742uint32_t cmd;743int32_t pool_id;744union {745struct { /* for cmd == TMEM_NEW_POOL */746uint64_t uuid[2];747uint32_t flags;748} new;749struct {750uint64_t oid[3];751uint32_t index;752uint32_t tmem_offset;753uint32_t pfn_offset;754uint32_t len;755GUEST_HANDLE(void) gmfn; /* guest machine page frame */756} gen;757} u;758};759760DEFINE_GUEST_HANDLE(u64);761762#else /* __ASSEMBLY__ */763764/* In assembly code we cannot use C numeric constant suffixes. */765#define mk_unsigned_long(x) x766767#endif /* !__ASSEMBLY__ */768769#endif /* __XEN_PUBLIC_XEN_H__ */770771772