162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 262306a36Sopenharmony_ci/****************************************************************************** 362306a36Sopenharmony_ci * xen.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Guest OS interface to Xen. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 2004, K A Fraser 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef __XEN_PUBLIC_XEN_H__ 1162306a36Sopenharmony_ci#define __XEN_PUBLIC_XEN_H__ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <asm/xen/interface.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* 1662306a36Sopenharmony_ci * XEN "SYSTEM CALLS" (a.k.a. HYPERCALLS). 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/* 2062306a36Sopenharmony_ci * x86_32: EAX = vector; EBX, ECX, EDX, ESI, EDI = args 1, 2, 3, 4, 5. 2162306a36Sopenharmony_ci * EAX = return value 2262306a36Sopenharmony_ci * (argument registers may be clobbered on return) 2362306a36Sopenharmony_ci * x86_64: RAX = vector; RDI, RSI, RDX, R10, R8, R9 = args 1, 2, 3, 4, 5, 6. 2462306a36Sopenharmony_ci * RAX = return value 2562306a36Sopenharmony_ci * (argument registers not clobbered on return; RCX, R11 are) 2662306a36Sopenharmony_ci */ 2762306a36Sopenharmony_ci#define __HYPERVISOR_set_trap_table 0 2862306a36Sopenharmony_ci#define __HYPERVISOR_mmu_update 1 2962306a36Sopenharmony_ci#define __HYPERVISOR_set_gdt 2 3062306a36Sopenharmony_ci#define __HYPERVISOR_stack_switch 3 3162306a36Sopenharmony_ci#define __HYPERVISOR_set_callbacks 4 3262306a36Sopenharmony_ci#define __HYPERVISOR_fpu_taskswitch 5 3362306a36Sopenharmony_ci#define __HYPERVISOR_sched_op_compat 6 3462306a36Sopenharmony_ci#define __HYPERVISOR_platform_op 7 3562306a36Sopenharmony_ci#define __HYPERVISOR_set_debugreg 8 3662306a36Sopenharmony_ci#define __HYPERVISOR_get_debugreg 9 3762306a36Sopenharmony_ci#define __HYPERVISOR_update_descriptor 10 3862306a36Sopenharmony_ci#define __HYPERVISOR_memory_op 12 3962306a36Sopenharmony_ci#define __HYPERVISOR_multicall 13 4062306a36Sopenharmony_ci#define __HYPERVISOR_update_va_mapping 14 4162306a36Sopenharmony_ci#define __HYPERVISOR_set_timer_op 15 4262306a36Sopenharmony_ci#define __HYPERVISOR_event_channel_op_compat 16 4362306a36Sopenharmony_ci#define __HYPERVISOR_xen_version 17 4462306a36Sopenharmony_ci#define __HYPERVISOR_console_io 18 4562306a36Sopenharmony_ci#define __HYPERVISOR_physdev_op_compat 19 4662306a36Sopenharmony_ci#define __HYPERVISOR_grant_table_op 20 4762306a36Sopenharmony_ci#define __HYPERVISOR_vm_assist 21 4862306a36Sopenharmony_ci#define __HYPERVISOR_update_va_mapping_otherdomain 22 4962306a36Sopenharmony_ci#define __HYPERVISOR_iret 23 /* x86 only */ 5062306a36Sopenharmony_ci#define __HYPERVISOR_vcpu_op 24 5162306a36Sopenharmony_ci#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */ 5262306a36Sopenharmony_ci#define __HYPERVISOR_mmuext_op 26 5362306a36Sopenharmony_ci#define __HYPERVISOR_xsm_op 27 5462306a36Sopenharmony_ci#define __HYPERVISOR_nmi_op 28 5562306a36Sopenharmony_ci#define __HYPERVISOR_sched_op 29 5662306a36Sopenharmony_ci#define __HYPERVISOR_callback_op 30 5762306a36Sopenharmony_ci#define __HYPERVISOR_xenoprof_op 31 5862306a36Sopenharmony_ci#define __HYPERVISOR_event_channel_op 32 5962306a36Sopenharmony_ci#define __HYPERVISOR_physdev_op 33 6062306a36Sopenharmony_ci#define __HYPERVISOR_hvm_op 34 6162306a36Sopenharmony_ci#define __HYPERVISOR_sysctl 35 6262306a36Sopenharmony_ci#define __HYPERVISOR_domctl 36 6362306a36Sopenharmony_ci#define __HYPERVISOR_kexec_op 37 6462306a36Sopenharmony_ci#define __HYPERVISOR_tmem_op 38 6562306a36Sopenharmony_ci#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ 6662306a36Sopenharmony_ci#define __HYPERVISOR_xenpmu_op 40 6762306a36Sopenharmony_ci#define __HYPERVISOR_dm_op 41 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* Architecture-specific hypercall definitions. */ 7062306a36Sopenharmony_ci#define __HYPERVISOR_arch_0 48 7162306a36Sopenharmony_ci#define __HYPERVISOR_arch_1 49 7262306a36Sopenharmony_ci#define __HYPERVISOR_arch_2 50 7362306a36Sopenharmony_ci#define __HYPERVISOR_arch_3 51 7462306a36Sopenharmony_ci#define __HYPERVISOR_arch_4 52 7562306a36Sopenharmony_ci#define __HYPERVISOR_arch_5 53 7662306a36Sopenharmony_ci#define __HYPERVISOR_arch_6 54 7762306a36Sopenharmony_ci#define __HYPERVISOR_arch_7 55 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci/* 8062306a36Sopenharmony_ci * VIRTUAL INTERRUPTS 8162306a36Sopenharmony_ci * 8262306a36Sopenharmony_ci * Virtual interrupts that a guest OS may receive from Xen. 8362306a36Sopenharmony_ci * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a 8462306a36Sopenharmony_ci * global VIRQ. The former can be bound once per VCPU and cannot be re-bound. 8562306a36Sopenharmony_ci * The latter can be allocated only once per guest: they must initially be 8662306a36Sopenharmony_ci * allocated to VCPU0 but can subsequently be re-bound. 8762306a36Sopenharmony_ci */ 8862306a36Sopenharmony_ci#define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */ 8962306a36Sopenharmony_ci#define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */ 9062306a36Sopenharmony_ci#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */ 9162306a36Sopenharmony_ci#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */ 9262306a36Sopenharmony_ci#define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */ 9362306a36Sopenharmony_ci#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */ 9462306a36Sopenharmony_ci#define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */ 9562306a36Sopenharmony_ci#define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */ 9662306a36Sopenharmony_ci#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */ 9762306a36Sopenharmony_ci#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */ 9862306a36Sopenharmony_ci#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */ 9962306a36Sopenharmony_ci#define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */ 10062306a36Sopenharmony_ci#define VIRQ_XENPMU 13 /* PMC interrupt */ 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci/* Architecture-specific VIRQ definitions. */ 10362306a36Sopenharmony_ci#define VIRQ_ARCH_0 16 10462306a36Sopenharmony_ci#define VIRQ_ARCH_1 17 10562306a36Sopenharmony_ci#define VIRQ_ARCH_2 18 10662306a36Sopenharmony_ci#define VIRQ_ARCH_3 19 10762306a36Sopenharmony_ci#define VIRQ_ARCH_4 20 10862306a36Sopenharmony_ci#define VIRQ_ARCH_5 21 10962306a36Sopenharmony_ci#define VIRQ_ARCH_6 22 11062306a36Sopenharmony_ci#define VIRQ_ARCH_7 23 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#define NR_VIRQS 24 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* 11562306a36Sopenharmony_ci * enum neg_errnoval HYPERVISOR_mmu_update(const struct mmu_update reqs[], 11662306a36Sopenharmony_ci * unsigned count, unsigned *done_out, 11762306a36Sopenharmony_ci * unsigned foreigndom) 11862306a36Sopenharmony_ci * @reqs is an array of mmu_update_t structures ((ptr, val) pairs). 11962306a36Sopenharmony_ci * @count is the length of the above array. 12062306a36Sopenharmony_ci * @pdone is an output parameter indicating number of completed operations 12162306a36Sopenharmony_ci * @foreigndom[15:0]: FD, the expected owner of data pages referenced in this 12262306a36Sopenharmony_ci * hypercall invocation. Can be DOMID_SELF. 12362306a36Sopenharmony_ci * @foreigndom[31:16]: PFD, the expected owner of pagetable pages referenced 12462306a36Sopenharmony_ci * in this hypercall invocation. The value of this field 12562306a36Sopenharmony_ci * (x) encodes the PFD as follows: 12662306a36Sopenharmony_ci * x == 0 => PFD == DOMID_SELF 12762306a36Sopenharmony_ci * x != 0 => PFD == x - 1 12862306a36Sopenharmony_ci * 12962306a36Sopenharmony_ci * Sub-commands: ptr[1:0] specifies the appropriate MMU_* command. 13062306a36Sopenharmony_ci * ------------- 13162306a36Sopenharmony_ci * ptr[1:0] == MMU_NORMAL_PT_UPDATE: 13262306a36Sopenharmony_ci * Updates an entry in a page table belonging to PFD. If updating an L1 table, 13362306a36Sopenharmony_ci * and the new table entry is valid/present, the mapped frame must belong to 13462306a36Sopenharmony_ci * FD. If attempting to map an I/O page then the caller assumes the privilege 13562306a36Sopenharmony_ci * of the FD. 13662306a36Sopenharmony_ci * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller. 13762306a36Sopenharmony_ci * FD == DOMID_XEN: Map restricted areas of Xen's heap space. 13862306a36Sopenharmony_ci * ptr[:2] -- Machine address of the page-table entry to modify. 13962306a36Sopenharmony_ci * val -- Value to write. 14062306a36Sopenharmony_ci * 14162306a36Sopenharmony_ci * There also certain implicit requirements when using this hypercall. The 14262306a36Sopenharmony_ci * pages that make up a pagetable must be mapped read-only in the guest. 14362306a36Sopenharmony_ci * This prevents uncontrolled guest updates to the pagetable. Xen strictly 14462306a36Sopenharmony_ci * enforces this, and will disallow any pagetable update which will end up 14562306a36Sopenharmony_ci * mapping pagetable page RW, and will disallow using any writable page as a 14662306a36Sopenharmony_ci * pagetable. In practice it means that when constructing a page table for a 14762306a36Sopenharmony_ci * process, thread, etc, we MUST be very dilligient in following these rules: 14862306a36Sopenharmony_ci * 1). Start with top-level page (PGD or in Xen language: L4). Fill out 14962306a36Sopenharmony_ci * the entries. 15062306a36Sopenharmony_ci * 2). Keep on going, filling out the upper (PUD or L3), and middle (PMD 15162306a36Sopenharmony_ci * or L2). 15262306a36Sopenharmony_ci * 3). Start filling out the PTE table (L1) with the PTE entries. Once 15362306a36Sopenharmony_ci * done, make sure to set each of those entries to RO (so writeable bit 15462306a36Sopenharmony_ci * is unset). Once that has been completed, set the PMD (L2) for this 15562306a36Sopenharmony_ci * PTE table as RO. 15662306a36Sopenharmony_ci * 4). When completed with all of the PMD (L2) entries, and all of them have 15762306a36Sopenharmony_ci * been set to RO, make sure to set RO the PUD (L3). Do the same 15862306a36Sopenharmony_ci * operation on PGD (L4) pagetable entries that have a PUD (L3) entry. 15962306a36Sopenharmony_ci * 5). Now before you can use those pages (so setting the cr3), you MUST also 16062306a36Sopenharmony_ci * pin them so that the hypervisor can verify the entries. This is done 16162306a36Sopenharmony_ci * via the HYPERVISOR_mmuext_op(MMUEXT_PIN_L4_TABLE, guest physical frame 16262306a36Sopenharmony_ci * number of the PGD (L4)). And this point the HYPERVISOR_mmuext_op( 16362306a36Sopenharmony_ci * MMUEXT_NEW_BASEPTR, guest physical frame number of the PGD (L4)) can be 16462306a36Sopenharmony_ci * issued. 16562306a36Sopenharmony_ci * For 32-bit guests, the L4 is not used (as there is less pagetables), so 16662306a36Sopenharmony_ci * instead use L3. 16762306a36Sopenharmony_ci * At this point the pagetables can be modified using the MMU_NORMAL_PT_UPDATE 16862306a36Sopenharmony_ci * hypercall. Also if so desired the OS can also try to write to the PTE 16962306a36Sopenharmony_ci * and be trapped by the hypervisor (as the PTE entry is RO). 17062306a36Sopenharmony_ci * 17162306a36Sopenharmony_ci * To deallocate the pages, the operations are the reverse of the steps 17262306a36Sopenharmony_ci * mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the 17362306a36Sopenharmony_ci * pagetable MUST not be in use (meaning that the cr3 is not set to it). 17462306a36Sopenharmony_ci * 17562306a36Sopenharmony_ci * ptr[1:0] == MMU_MACHPHYS_UPDATE: 17662306a36Sopenharmony_ci * Updates an entry in the machine->pseudo-physical mapping table. 17762306a36Sopenharmony_ci * ptr[:2] -- Machine address within the frame whose mapping to modify. 17862306a36Sopenharmony_ci * The frame must belong to the FD, if one is specified. 17962306a36Sopenharmony_ci * val -- Value to write into the mapping entry. 18062306a36Sopenharmony_ci * 18162306a36Sopenharmony_ci * ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD: 18262306a36Sopenharmony_ci * As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed 18362306a36Sopenharmony_ci * with those in @val. 18462306a36Sopenharmony_ci * 18562306a36Sopenharmony_ci * @val is usually the machine frame number along with some attributes. 18662306a36Sopenharmony_ci * The attributes by default follow the architecture defined bits. Meaning that 18762306a36Sopenharmony_ci * if this is a X86_64 machine and four page table layout is used, the layout 18862306a36Sopenharmony_ci * of val is: 18962306a36Sopenharmony_ci * - 63 if set means No execute (NX) 19062306a36Sopenharmony_ci * - 46-13 the machine frame number 19162306a36Sopenharmony_ci * - 12 available for guest 19262306a36Sopenharmony_ci * - 11 available for guest 19362306a36Sopenharmony_ci * - 10 available for guest 19462306a36Sopenharmony_ci * - 9 available for guest 19562306a36Sopenharmony_ci * - 8 global 19662306a36Sopenharmony_ci * - 7 PAT (PSE is disabled, must use hypercall to make 4MB or 2MB pages) 19762306a36Sopenharmony_ci * - 6 dirty 19862306a36Sopenharmony_ci * - 5 accessed 19962306a36Sopenharmony_ci * - 4 page cached disabled 20062306a36Sopenharmony_ci * - 3 page write through 20162306a36Sopenharmony_ci * - 2 userspace accessible 20262306a36Sopenharmony_ci * - 1 writeable 20362306a36Sopenharmony_ci * - 0 present 20462306a36Sopenharmony_ci * 20562306a36Sopenharmony_ci * The one bits that does not fit with the default layout is the PAGE_PSE 20662306a36Sopenharmony_ci * also called PAGE_PAT). The MMUEXT_[UN]MARK_SUPER arguments to the 20762306a36Sopenharmony_ci * HYPERVISOR_mmuext_op serve as mechanism to set a pagetable to be 4MB 20862306a36Sopenharmony_ci * (or 2MB) instead of using the PAGE_PSE bit. 20962306a36Sopenharmony_ci * 21062306a36Sopenharmony_ci * The reason that the PAGE_PSE (bit 7) is not being utilized is due to Xen 21162306a36Sopenharmony_ci * using it as the Page Attribute Table (PAT) bit - for details on it please 21262306a36Sopenharmony_ci * refer to Intel SDM 10.12. The PAT allows to set the caching attributes of 21362306a36Sopenharmony_ci * pages instead of using MTRRs. 21462306a36Sopenharmony_ci * 21562306a36Sopenharmony_ci * The PAT MSR is as follows (it is a 64-bit value, each entry is 8 bits): 21662306a36Sopenharmony_ci * PAT4 PAT0 21762306a36Sopenharmony_ci * +-----+-----+----+----+----+-----+----+----+ 21862306a36Sopenharmony_ci * | UC | UC- | WC | WB | UC | UC- | WC | WB | <= Linux 21962306a36Sopenharmony_ci * +-----+-----+----+----+----+-----+----+----+ 22062306a36Sopenharmony_ci * | UC | UC- | WT | WB | UC | UC- | WT | WB | <= BIOS (default when machine boots) 22162306a36Sopenharmony_ci * +-----+-----+----+----+----+-----+----+----+ 22262306a36Sopenharmony_ci * | rsv | rsv | WP | WC | UC | UC- | WT | WB | <= Xen 22362306a36Sopenharmony_ci * +-----+-----+----+----+----+-----+----+----+ 22462306a36Sopenharmony_ci * 22562306a36Sopenharmony_ci * The lookup of this index table translates to looking up 22662306a36Sopenharmony_ci * Bit 7, Bit 4, and Bit 3 of val entry: 22762306a36Sopenharmony_ci * 22862306a36Sopenharmony_ci * PAT/PSE (bit 7) ... PCD (bit 4) .. PWT (bit 3). 22962306a36Sopenharmony_ci * 23062306a36Sopenharmony_ci * If all bits are off, then we are using PAT0. If bit 3 turned on, 23162306a36Sopenharmony_ci * then we are using PAT1, if bit 3 and bit 4, then PAT2.. 23262306a36Sopenharmony_ci * 23362306a36Sopenharmony_ci * As you can see, the Linux PAT1 translates to PAT4 under Xen. Which means 23462306a36Sopenharmony_ci * that if a guest that follows Linux's PAT setup and would like to set Write 23562306a36Sopenharmony_ci * Combined on pages it MUST use PAT4 entry. Meaning that Bit 7 (PAGE_PAT) is 23662306a36Sopenharmony_ci * set. For example, under Linux it only uses PAT0, PAT1, and PAT2 for the 23762306a36Sopenharmony_ci * caching as: 23862306a36Sopenharmony_ci * 23962306a36Sopenharmony_ci * WB = none (so PAT0) 24062306a36Sopenharmony_ci * WC = PWT (bit 3 on) 24162306a36Sopenharmony_ci * UC = PWT | PCD (bit 3 and 4 are on). 24262306a36Sopenharmony_ci * 24362306a36Sopenharmony_ci * To make it work with Xen, it needs to translate the WC bit as so: 24462306a36Sopenharmony_ci * 24562306a36Sopenharmony_ci * PWT (so bit 3 on) --> PAT (so bit 7 is on) and clear bit 3 24662306a36Sopenharmony_ci * 24762306a36Sopenharmony_ci * And to translate back it would: 24862306a36Sopenharmony_ci * 24962306a36Sopenharmony_ci * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7. 25062306a36Sopenharmony_ci */ 25162306a36Sopenharmony_ci#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */ 25262306a36Sopenharmony_ci#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */ 25362306a36Sopenharmony_ci#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */ 25462306a36Sopenharmony_ci#define MMU_PT_UPDATE_NO_TRANSLATE 3 /* checked '*ptr = val'. ptr is MA. */ 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci/* 25762306a36Sopenharmony_ci * MMU EXTENDED OPERATIONS 25862306a36Sopenharmony_ci * 25962306a36Sopenharmony_ci * enum neg_errnoval HYPERVISOR_mmuext_op(mmuext_op_t uops[], 26062306a36Sopenharmony_ci * unsigned int count, 26162306a36Sopenharmony_ci * unsigned int *pdone, 26262306a36Sopenharmony_ci * unsigned int foreigndom) 26362306a36Sopenharmony_ci */ 26462306a36Sopenharmony_ci/* HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures. 26562306a36Sopenharmony_ci * A foreigndom (FD) can be specified (or DOMID_SELF for none). 26662306a36Sopenharmony_ci * Where the FD has some effect, it is described below. 26762306a36Sopenharmony_ci * 26862306a36Sopenharmony_ci * cmd: MMUEXT_(UN)PIN_*_TABLE 26962306a36Sopenharmony_ci * mfn: Machine frame number to be (un)pinned as a p.t. page. 27062306a36Sopenharmony_ci * The frame must belong to the FD, if one is specified. 27162306a36Sopenharmony_ci * 27262306a36Sopenharmony_ci * cmd: MMUEXT_NEW_BASEPTR 27362306a36Sopenharmony_ci * mfn: Machine frame number of new page-table base to install in MMU. 27462306a36Sopenharmony_ci * 27562306a36Sopenharmony_ci * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only] 27662306a36Sopenharmony_ci * mfn: Machine frame number of new page-table base to install in MMU 27762306a36Sopenharmony_ci * when in user space. 27862306a36Sopenharmony_ci * 27962306a36Sopenharmony_ci * cmd: MMUEXT_TLB_FLUSH_LOCAL 28062306a36Sopenharmony_ci * No additional arguments. Flushes local TLB. 28162306a36Sopenharmony_ci * 28262306a36Sopenharmony_ci * cmd: MMUEXT_INVLPG_LOCAL 28362306a36Sopenharmony_ci * linear_addr: Linear address to be flushed from the local TLB. 28462306a36Sopenharmony_ci * 28562306a36Sopenharmony_ci * cmd: MMUEXT_TLB_FLUSH_MULTI 28662306a36Sopenharmony_ci * vcpumask: Pointer to bitmap of VCPUs to be flushed. 28762306a36Sopenharmony_ci * 28862306a36Sopenharmony_ci * cmd: MMUEXT_INVLPG_MULTI 28962306a36Sopenharmony_ci * linear_addr: Linear address to be flushed. 29062306a36Sopenharmony_ci * vcpumask: Pointer to bitmap of VCPUs to be flushed. 29162306a36Sopenharmony_ci * 29262306a36Sopenharmony_ci * cmd: MMUEXT_TLB_FLUSH_ALL 29362306a36Sopenharmony_ci * No additional arguments. Flushes all VCPUs' TLBs. 29462306a36Sopenharmony_ci * 29562306a36Sopenharmony_ci * cmd: MMUEXT_INVLPG_ALL 29662306a36Sopenharmony_ci * linear_addr: Linear address to be flushed from all VCPUs' TLBs. 29762306a36Sopenharmony_ci * 29862306a36Sopenharmony_ci * cmd: MMUEXT_FLUSH_CACHE 29962306a36Sopenharmony_ci * No additional arguments. Writes back and flushes cache contents. 30062306a36Sopenharmony_ci * 30162306a36Sopenharmony_ci * cmd: MMUEXT_FLUSH_CACHE_GLOBAL 30262306a36Sopenharmony_ci * No additional arguments. Writes back and flushes cache contents 30362306a36Sopenharmony_ci * on all CPUs in the system. 30462306a36Sopenharmony_ci * 30562306a36Sopenharmony_ci * cmd: MMUEXT_SET_LDT 30662306a36Sopenharmony_ci * linear_addr: Linear address of LDT base (NB. must be page-aligned). 30762306a36Sopenharmony_ci * nr_ents: Number of entries in LDT. 30862306a36Sopenharmony_ci * 30962306a36Sopenharmony_ci * cmd: MMUEXT_CLEAR_PAGE 31062306a36Sopenharmony_ci * mfn: Machine frame number to be cleared. 31162306a36Sopenharmony_ci * 31262306a36Sopenharmony_ci * cmd: MMUEXT_COPY_PAGE 31362306a36Sopenharmony_ci * mfn: Machine frame number of the destination page. 31462306a36Sopenharmony_ci * src_mfn: Machine frame number of the source page. 31562306a36Sopenharmony_ci * 31662306a36Sopenharmony_ci * cmd: MMUEXT_[UN]MARK_SUPER 31762306a36Sopenharmony_ci * mfn: Machine frame number of head of superpage to be [un]marked. 31862306a36Sopenharmony_ci */ 31962306a36Sopenharmony_ci#define MMUEXT_PIN_L1_TABLE 0 32062306a36Sopenharmony_ci#define MMUEXT_PIN_L2_TABLE 1 32162306a36Sopenharmony_ci#define MMUEXT_PIN_L3_TABLE 2 32262306a36Sopenharmony_ci#define MMUEXT_PIN_L4_TABLE 3 32362306a36Sopenharmony_ci#define MMUEXT_UNPIN_TABLE 4 32462306a36Sopenharmony_ci#define MMUEXT_NEW_BASEPTR 5 32562306a36Sopenharmony_ci#define MMUEXT_TLB_FLUSH_LOCAL 6 32662306a36Sopenharmony_ci#define MMUEXT_INVLPG_LOCAL 7 32762306a36Sopenharmony_ci#define MMUEXT_TLB_FLUSH_MULTI 8 32862306a36Sopenharmony_ci#define MMUEXT_INVLPG_MULTI 9 32962306a36Sopenharmony_ci#define MMUEXT_TLB_FLUSH_ALL 10 33062306a36Sopenharmony_ci#define MMUEXT_INVLPG_ALL 11 33162306a36Sopenharmony_ci#define MMUEXT_FLUSH_CACHE 12 33262306a36Sopenharmony_ci#define MMUEXT_SET_LDT 13 33362306a36Sopenharmony_ci#define MMUEXT_NEW_USER_BASEPTR 15 33462306a36Sopenharmony_ci#define MMUEXT_CLEAR_PAGE 16 33562306a36Sopenharmony_ci#define MMUEXT_COPY_PAGE 17 33662306a36Sopenharmony_ci#define MMUEXT_FLUSH_CACHE_GLOBAL 18 33762306a36Sopenharmony_ci#define MMUEXT_MARK_SUPER 19 33862306a36Sopenharmony_ci#define MMUEXT_UNMARK_SUPER 20 33962306a36Sopenharmony_ci 34062306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 34162306a36Sopenharmony_cistruct mmuext_op { 34262306a36Sopenharmony_ci unsigned int cmd; 34362306a36Sopenharmony_ci union { 34462306a36Sopenharmony_ci /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR 34562306a36Sopenharmony_ci * CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */ 34662306a36Sopenharmony_ci xen_pfn_t mfn; 34762306a36Sopenharmony_ci /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */ 34862306a36Sopenharmony_ci unsigned long linear_addr; 34962306a36Sopenharmony_ci } arg1; 35062306a36Sopenharmony_ci union { 35162306a36Sopenharmony_ci /* SET_LDT */ 35262306a36Sopenharmony_ci unsigned int nr_ents; 35362306a36Sopenharmony_ci /* TLB_FLUSH_MULTI, INVLPG_MULTI */ 35462306a36Sopenharmony_ci void *vcpumask; 35562306a36Sopenharmony_ci /* COPY_PAGE */ 35662306a36Sopenharmony_ci xen_pfn_t src_mfn; 35762306a36Sopenharmony_ci } arg2; 35862306a36Sopenharmony_ci}; 35962306a36Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(mmuext_op); 36062306a36Sopenharmony_ci#endif 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci/* These are passed as 'flags' to update_va_mapping. They can be ORed. */ 36362306a36Sopenharmony_ci/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */ 36462306a36Sopenharmony_ci/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */ 36562306a36Sopenharmony_ci#define UVMF_NONE (0UL<<0) /* No flushing at all. */ 36662306a36Sopenharmony_ci#define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */ 36762306a36Sopenharmony_ci#define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */ 36862306a36Sopenharmony_ci#define UVMF_FLUSHTYPE_MASK (3UL<<0) 36962306a36Sopenharmony_ci#define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */ 37062306a36Sopenharmony_ci#define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */ 37162306a36Sopenharmony_ci#define UVMF_ALL (1UL<<2) /* Flush all TLBs. */ 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci/* 37462306a36Sopenharmony_ci * Commands to HYPERVISOR_console_io(). 37562306a36Sopenharmony_ci */ 37662306a36Sopenharmony_ci#define CONSOLEIO_write 0 37762306a36Sopenharmony_ci#define CONSOLEIO_read 1 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci/* 38062306a36Sopenharmony_ci * Commands to HYPERVISOR_vm_assist(). 38162306a36Sopenharmony_ci */ 38262306a36Sopenharmony_ci#define VMASST_CMD_enable 0 38362306a36Sopenharmony_ci#define VMASST_CMD_disable 1 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ci/* x86/32 guests: simulate full 4GB segment limits. */ 38662306a36Sopenharmony_ci#define VMASST_TYPE_4gb_segments 0 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */ 38962306a36Sopenharmony_ci#define VMASST_TYPE_4gb_segments_notify 1 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_ci/* 39262306a36Sopenharmony_ci * x86 guests: support writes to bottom-level PTEs. 39362306a36Sopenharmony_ci * NB1. Page-directory entries cannot be written. 39462306a36Sopenharmony_ci * NB2. Guest must continue to remove all writable mappings of PTEs. 39562306a36Sopenharmony_ci */ 39662306a36Sopenharmony_ci#define VMASST_TYPE_writable_pagetables 2 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci/* x86/PAE guests: support PDPTs above 4GB. */ 39962306a36Sopenharmony_ci#define VMASST_TYPE_pae_extended_cr3 3 40062306a36Sopenharmony_ci 40162306a36Sopenharmony_ci/* 40262306a36Sopenharmony_ci * x86 guests: Sane behaviour for virtual iopl 40362306a36Sopenharmony_ci * - virtual iopl updated from do_iret() hypercalls. 40462306a36Sopenharmony_ci * - virtual iopl reported in bounce frames. 40562306a36Sopenharmony_ci * - guest kernels assumed to be level 0 for the purpose of iopl checks. 40662306a36Sopenharmony_ci */ 40762306a36Sopenharmony_ci#define VMASST_TYPE_architectural_iopl 4 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ci/* 41062306a36Sopenharmony_ci * All guests: activate update indicator in vcpu_runstate_info 41162306a36Sopenharmony_ci * Enable setting the XEN_RUNSTATE_UPDATE flag in guest memory mapped 41262306a36Sopenharmony_ci * vcpu_runstate_info during updates of the runstate information. 41362306a36Sopenharmony_ci */ 41462306a36Sopenharmony_ci#define VMASST_TYPE_runstate_update_flag 5 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci#define MAX_VMASST_TYPE 5 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_citypedef uint16_t domid_t; 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_ci/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */ 42362306a36Sopenharmony_ci#define DOMID_FIRST_RESERVED (0x7FF0U) 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci/* DOMID_SELF is used in certain contexts to refer to oneself. */ 42662306a36Sopenharmony_ci#define DOMID_SELF (0x7FF0U) 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci/* 42962306a36Sopenharmony_ci * DOMID_IO is used to restrict page-table updates to mapping I/O memory. 43062306a36Sopenharmony_ci * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO 43162306a36Sopenharmony_ci * is useful to ensure that no mappings to the OS's own heap are accidentally 43262306a36Sopenharmony_ci * installed. (e.g., in Linux this could cause havoc as reference counts 43362306a36Sopenharmony_ci * aren't adjusted on the I/O-mapping code path). 43462306a36Sopenharmony_ci * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can 43562306a36Sopenharmony_ci * be specified by any calling domain. 43662306a36Sopenharmony_ci */ 43762306a36Sopenharmony_ci#define DOMID_IO (0x7FF1U) 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_ci/* 44062306a36Sopenharmony_ci * DOMID_XEN is used to allow privileged domains to map restricted parts of 44162306a36Sopenharmony_ci * Xen's heap space (e.g., the machine_to_phys table). 44262306a36Sopenharmony_ci * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if 44362306a36Sopenharmony_ci * the caller is privileged. 44462306a36Sopenharmony_ci */ 44562306a36Sopenharmony_ci#define DOMID_XEN (0x7FF2U) 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_ci/* DOMID_COW is used as the owner of sharable pages */ 44862306a36Sopenharmony_ci#define DOMID_COW (0x7FF3U) 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_ci/* DOMID_INVALID is used to identify pages with unknown owner. */ 45162306a36Sopenharmony_ci#define DOMID_INVALID (0x7FF4U) 45262306a36Sopenharmony_ci 45362306a36Sopenharmony_ci/* Idle domain. */ 45462306a36Sopenharmony_ci#define DOMID_IDLE (0x7FFFU) 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_ci/* 45762306a36Sopenharmony_ci * Send an array of these to HYPERVISOR_mmu_update(). 45862306a36Sopenharmony_ci * NB. The fields are natural pointer/address size for this architecture. 45962306a36Sopenharmony_ci */ 46062306a36Sopenharmony_cistruct mmu_update { 46162306a36Sopenharmony_ci uint64_t ptr; /* Machine address of PTE. */ 46262306a36Sopenharmony_ci uint64_t val; /* New contents of PTE. */ 46362306a36Sopenharmony_ci}; 46462306a36Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(mmu_update); 46562306a36Sopenharmony_ci 46662306a36Sopenharmony_ci/* 46762306a36Sopenharmony_ci * Send an array of these to HYPERVISOR_multicall(). 46862306a36Sopenharmony_ci * NB. The fields are logically the natural register size for this 46962306a36Sopenharmony_ci * architecture. In cases where xen_ulong_t is larger than this then 47062306a36Sopenharmony_ci * any unused bits in the upper portion must be zero. 47162306a36Sopenharmony_ci */ 47262306a36Sopenharmony_cistruct multicall_entry { 47362306a36Sopenharmony_ci xen_ulong_t op; 47462306a36Sopenharmony_ci xen_long_t result; 47562306a36Sopenharmony_ci xen_ulong_t args[6]; 47662306a36Sopenharmony_ci}; 47762306a36Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(multicall_entry); 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_cistruct vcpu_time_info { 48062306a36Sopenharmony_ci /* 48162306a36Sopenharmony_ci * Updates to the following values are preceded and followed 48262306a36Sopenharmony_ci * by an increment of 'version'. The guest can therefore 48362306a36Sopenharmony_ci * detect updates by looking for changes to 'version'. If the 48462306a36Sopenharmony_ci * least-significant bit of the version number is set then an 48562306a36Sopenharmony_ci * update is in progress and the guest must wait to read a 48662306a36Sopenharmony_ci * consistent set of values. The correct way to interact with 48762306a36Sopenharmony_ci * the version number is similar to Linux's seqlock: see the 48862306a36Sopenharmony_ci * implementations of read_seqbegin/read_seqretry. 48962306a36Sopenharmony_ci */ 49062306a36Sopenharmony_ci uint32_t version; 49162306a36Sopenharmony_ci uint32_t pad0; 49262306a36Sopenharmony_ci uint64_t tsc_timestamp; /* TSC at last update of time vals. */ 49362306a36Sopenharmony_ci uint64_t system_time; /* Time, in nanosecs, since boot. */ 49462306a36Sopenharmony_ci /* 49562306a36Sopenharmony_ci * Current system time: 49662306a36Sopenharmony_ci * system_time + ((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul 49762306a36Sopenharmony_ci * CPU frequency (Hz): 49862306a36Sopenharmony_ci * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift 49962306a36Sopenharmony_ci */ 50062306a36Sopenharmony_ci uint32_t tsc_to_system_mul; 50162306a36Sopenharmony_ci int8_t tsc_shift; 50262306a36Sopenharmony_ci int8_t pad1[3]; 50362306a36Sopenharmony_ci}; /* 32 bytes */ 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_cistruct vcpu_info { 50662306a36Sopenharmony_ci /* 50762306a36Sopenharmony_ci * 'evtchn_upcall_pending' is written non-zero by Xen to indicate 50862306a36Sopenharmony_ci * a pending notification for a particular VCPU. It is then cleared 50962306a36Sopenharmony_ci * by the guest OS /before/ checking for pending work, thus avoiding 51062306a36Sopenharmony_ci * a set-and-check race. Note that the mask is only accessed by Xen 51162306a36Sopenharmony_ci * on the CPU that is currently hosting the VCPU. This means that the 51262306a36Sopenharmony_ci * pending and mask flags can be updated by the guest without special 51362306a36Sopenharmony_ci * synchronisation (i.e., no need for the x86 LOCK prefix). 51462306a36Sopenharmony_ci * This may seem suboptimal because if the pending flag is set by 51562306a36Sopenharmony_ci * a different CPU then an IPI may be scheduled even when the mask 51662306a36Sopenharmony_ci * is set. However, note: 51762306a36Sopenharmony_ci * 1. The task of 'interrupt holdoff' is covered by the per-event- 51862306a36Sopenharmony_ci * channel mask bits. A 'noisy' event that is continually being 51962306a36Sopenharmony_ci * triggered can be masked at source at this very precise 52062306a36Sopenharmony_ci * granularity. 52162306a36Sopenharmony_ci * 2. The main purpose of the per-VCPU mask is therefore to restrict 52262306a36Sopenharmony_ci * reentrant execution: whether for concurrency control, or to 52362306a36Sopenharmony_ci * prevent unbounded stack usage. Whatever the purpose, we expect 52462306a36Sopenharmony_ci * that the mask will be asserted only for short periods at a time, 52562306a36Sopenharmony_ci * and so the likelihood of a 'spurious' IPI is suitably small. 52662306a36Sopenharmony_ci * The mask is read before making an event upcall to the guest: a 52762306a36Sopenharmony_ci * non-zero mask therefore guarantees that the VCPU will not receive 52862306a36Sopenharmony_ci * an upcall activation. The mask is cleared when the VCPU requests 52962306a36Sopenharmony_ci * to block: this avoids wakeup-waiting races. 53062306a36Sopenharmony_ci */ 53162306a36Sopenharmony_ci uint8_t evtchn_upcall_pending; 53262306a36Sopenharmony_ci uint8_t evtchn_upcall_mask; 53362306a36Sopenharmony_ci xen_ulong_t evtchn_pending_sel; 53462306a36Sopenharmony_ci struct arch_vcpu_info arch; 53562306a36Sopenharmony_ci struct pvclock_vcpu_time_info time; 53662306a36Sopenharmony_ci}; /* 64 bytes (x86) */ 53762306a36Sopenharmony_ci 53862306a36Sopenharmony_ci/* 53962306a36Sopenharmony_ci * Xen/kernel shared data -- pointer provided in start_info. 54062306a36Sopenharmony_ci * NB. We expect that this struct is smaller than a page. 54162306a36Sopenharmony_ci */ 54262306a36Sopenharmony_cistruct shared_info { 54362306a36Sopenharmony_ci struct vcpu_info vcpu_info[MAX_VIRT_CPUS]; 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ci /* 54662306a36Sopenharmony_ci * A domain can create "event channels" on which it can send and receive 54762306a36Sopenharmony_ci * asynchronous event notifications. There are three classes of event that 54862306a36Sopenharmony_ci * are delivered by this mechanism: 54962306a36Sopenharmony_ci * 1. Bi-directional inter- and intra-domain connections. Domains must 55062306a36Sopenharmony_ci * arrange out-of-band to set up a connection (usually by allocating 55162306a36Sopenharmony_ci * an unbound 'listener' port and avertising that via a storage service 55262306a36Sopenharmony_ci * such as xenstore). 55362306a36Sopenharmony_ci * 2. Physical interrupts. A domain with suitable hardware-access 55462306a36Sopenharmony_ci * privileges can bind an event-channel port to a physical interrupt 55562306a36Sopenharmony_ci * source. 55662306a36Sopenharmony_ci * 3. Virtual interrupts ('events'). A domain can bind an event-channel 55762306a36Sopenharmony_ci * port to a virtual interrupt source, such as the virtual-timer 55862306a36Sopenharmony_ci * device or the emergency console. 55962306a36Sopenharmony_ci * 56062306a36Sopenharmony_ci * Event channels are addressed by a "port index". Each channel is 56162306a36Sopenharmony_ci * associated with two bits of information: 56262306a36Sopenharmony_ci * 1. PENDING -- notifies the domain that there is a pending notification 56362306a36Sopenharmony_ci * to be processed. This bit is cleared by the guest. 56462306a36Sopenharmony_ci * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING 56562306a36Sopenharmony_ci * will cause an asynchronous upcall to be scheduled. This bit is only 56662306a36Sopenharmony_ci * updated by the guest. It is read-only within Xen. If a channel 56762306a36Sopenharmony_ci * becomes pending while the channel is masked then the 'edge' is lost 56862306a36Sopenharmony_ci * (i.e., when the channel is unmasked, the guest must manually handle 56962306a36Sopenharmony_ci * pending notifications as no upcall will be scheduled by Xen). 57062306a36Sopenharmony_ci * 57162306a36Sopenharmony_ci * To expedite scanning of pending notifications, any 0->1 pending 57262306a36Sopenharmony_ci * transition on an unmasked channel causes a corresponding bit in a 57362306a36Sopenharmony_ci * per-vcpu selector word to be set. Each bit in the selector covers a 57462306a36Sopenharmony_ci * 'C long' in the PENDING bitfield array. 57562306a36Sopenharmony_ci */ 57662306a36Sopenharmony_ci xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8]; 57762306a36Sopenharmony_ci xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8]; 57862306a36Sopenharmony_ci 57962306a36Sopenharmony_ci /* 58062306a36Sopenharmony_ci * Wallclock time: updated only by control software. Guests should base 58162306a36Sopenharmony_ci * their gettimeofday() syscall on this wallclock-base value. 58262306a36Sopenharmony_ci */ 58362306a36Sopenharmony_ci struct pvclock_wall_clock wc; 58462306a36Sopenharmony_ci#ifndef CONFIG_X86_32 58562306a36Sopenharmony_ci uint32_t wc_sec_hi; 58662306a36Sopenharmony_ci#endif 58762306a36Sopenharmony_ci struct arch_shared_info arch; 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_ci}; 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_ci/* 59262306a36Sopenharmony_ci * Start-of-day memory layout 59362306a36Sopenharmony_ci * 59462306a36Sopenharmony_ci * 1. The domain is started within contiguous virtual-memory region. 59562306a36Sopenharmony_ci * 2. The contiguous region begins and ends on an aligned 4MB boundary. 59662306a36Sopenharmony_ci * 3. This the order of bootstrap elements in the initial virtual region: 59762306a36Sopenharmony_ci * a. relocated kernel image 59862306a36Sopenharmony_ci * b. initial ram disk [mod_start, mod_len] 59962306a36Sopenharmony_ci * (may be omitted) 60062306a36Sopenharmony_ci * c. list of allocated page frames [mfn_list, nr_pages] 60162306a36Sopenharmony_ci * (unless relocated due to XEN_ELFNOTE_INIT_P2M) 60262306a36Sopenharmony_ci * d. start_info_t structure [register ESI (x86)] 60362306a36Sopenharmony_ci * in case of dom0 this page contains the console info, too 60462306a36Sopenharmony_ci * e. unless dom0: xenstore ring page 60562306a36Sopenharmony_ci * f. unless dom0: console ring page 60662306a36Sopenharmony_ci * g. bootstrap page tables [pt_base, CR3 (x86)] 60762306a36Sopenharmony_ci * h. bootstrap stack [register ESP (x86)] 60862306a36Sopenharmony_ci * 4. Bootstrap elements are packed together, but each is 4kB-aligned. 60962306a36Sopenharmony_ci * 5. The list of page frames forms a contiguous 'pseudo-physical' memory 61062306a36Sopenharmony_ci * layout for the domain. In particular, the bootstrap virtual-memory 61162306a36Sopenharmony_ci * region is a 1:1 mapping to the first section of the pseudo-physical map. 61262306a36Sopenharmony_ci * 6. All bootstrap elements are mapped read-writable for the guest OS. The 61362306a36Sopenharmony_ci * only exception is the bootstrap page table, which is mapped read-only. 61462306a36Sopenharmony_ci * 7. There is guaranteed to be at least 512kB padding after the final 61562306a36Sopenharmony_ci * bootstrap element. If necessary, the bootstrap virtual region is 61662306a36Sopenharmony_ci * extended by an extra 4MB to ensure this. 61762306a36Sopenharmony_ci */ 61862306a36Sopenharmony_ci 61962306a36Sopenharmony_ci#define MAX_GUEST_CMDLINE 1024 62062306a36Sopenharmony_cistruct start_info { 62162306a36Sopenharmony_ci /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */ 62262306a36Sopenharmony_ci char magic[32]; /* "xen-<version>-<platform>". */ 62362306a36Sopenharmony_ci unsigned long nr_pages; /* Total pages allocated to this domain. */ 62462306a36Sopenharmony_ci unsigned long shared_info; /* MACHINE address of shared info struct. */ 62562306a36Sopenharmony_ci uint32_t flags; /* SIF_xxx flags. */ 62662306a36Sopenharmony_ci xen_pfn_t store_mfn; /* MACHINE page number of shared page. */ 62762306a36Sopenharmony_ci uint32_t store_evtchn; /* Event channel for store communication. */ 62862306a36Sopenharmony_ci union { 62962306a36Sopenharmony_ci struct { 63062306a36Sopenharmony_ci xen_pfn_t mfn; /* MACHINE page number of console page. */ 63162306a36Sopenharmony_ci uint32_t evtchn; /* Event channel for console page. */ 63262306a36Sopenharmony_ci } domU; 63362306a36Sopenharmony_ci struct { 63462306a36Sopenharmony_ci uint32_t info_off; /* Offset of console_info struct. */ 63562306a36Sopenharmony_ci uint32_t info_size; /* Size of console_info struct from start.*/ 63662306a36Sopenharmony_ci } dom0; 63762306a36Sopenharmony_ci } console; 63862306a36Sopenharmony_ci /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */ 63962306a36Sopenharmony_ci unsigned long pt_base; /* VIRTUAL address of page directory. */ 64062306a36Sopenharmony_ci unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */ 64162306a36Sopenharmony_ci unsigned long mfn_list; /* VIRTUAL address of page-frame list. */ 64262306a36Sopenharmony_ci unsigned long mod_start; /* VIRTUAL address of pre-loaded module. */ 64362306a36Sopenharmony_ci unsigned long mod_len; /* Size (bytes) of pre-loaded module. */ 64462306a36Sopenharmony_ci int8_t cmd_line[MAX_GUEST_CMDLINE]; 64562306a36Sopenharmony_ci /* The pfn range here covers both page table and p->m table frames. */ 64662306a36Sopenharmony_ci unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */ 64762306a36Sopenharmony_ci unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */ 64862306a36Sopenharmony_ci}; 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_ci/* These flags are passed in the 'flags' field of start_info_t. */ 65162306a36Sopenharmony_ci#define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */ 65262306a36Sopenharmony_ci#define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */ 65362306a36Sopenharmony_ci#define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */ 65462306a36Sopenharmony_ci#define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */ 65562306a36Sopenharmony_ci#define SIF_VIRT_P2M_4TOOLS (1<<4) /* Do Xen tools understand a virt. mapped */ 65662306a36Sopenharmony_ci /* P->M making the 3 level tree obsolete? */ 65762306a36Sopenharmony_ci#define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */ 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_ci/* 66062306a36Sopenharmony_ci * A multiboot module is a package containing modules very similar to a 66162306a36Sopenharmony_ci * multiboot module array. The only differences are: 66262306a36Sopenharmony_ci * - the array of module descriptors is by convention simply at the beginning 66362306a36Sopenharmony_ci * of the multiboot module, 66462306a36Sopenharmony_ci * - addresses in the module descriptors are based on the beginning of the 66562306a36Sopenharmony_ci * multiboot module, 66662306a36Sopenharmony_ci * - the number of modules is determined by a termination descriptor that has 66762306a36Sopenharmony_ci * mod_start == 0. 66862306a36Sopenharmony_ci * 66962306a36Sopenharmony_ci * This permits to both build it statically and reference it in a configuration 67062306a36Sopenharmony_ci * file, and let the PV guest easily rebase the addresses to virtual addresses 67162306a36Sopenharmony_ci * and at the same time count the number of modules. 67262306a36Sopenharmony_ci */ 67362306a36Sopenharmony_cistruct xen_multiboot_mod_list { 67462306a36Sopenharmony_ci /* Address of first byte of the module */ 67562306a36Sopenharmony_ci uint32_t mod_start; 67662306a36Sopenharmony_ci /* Address of last byte of the module (inclusive) */ 67762306a36Sopenharmony_ci uint32_t mod_end; 67862306a36Sopenharmony_ci /* Address of zero-terminated command line */ 67962306a36Sopenharmony_ci uint32_t cmdline; 68062306a36Sopenharmony_ci /* Unused, must be zero */ 68162306a36Sopenharmony_ci uint32_t pad; 68262306a36Sopenharmony_ci}; 68362306a36Sopenharmony_ci/* 68462306a36Sopenharmony_ci * The console structure in start_info.console.dom0 68562306a36Sopenharmony_ci * 68662306a36Sopenharmony_ci * This structure includes a variety of information required to 68762306a36Sopenharmony_ci * have a working VGA/VESA console. 68862306a36Sopenharmony_ci */ 68962306a36Sopenharmony_cistruct dom0_vga_console_info { 69062306a36Sopenharmony_ci uint8_t video_type; 69162306a36Sopenharmony_ci#define XEN_VGATYPE_TEXT_MODE_3 0x03 69262306a36Sopenharmony_ci#define XEN_VGATYPE_VESA_LFB 0x23 69362306a36Sopenharmony_ci#define XEN_VGATYPE_EFI_LFB 0x70 69462306a36Sopenharmony_ci 69562306a36Sopenharmony_ci union { 69662306a36Sopenharmony_ci struct { 69762306a36Sopenharmony_ci /* Font height, in pixels. */ 69862306a36Sopenharmony_ci uint16_t font_height; 69962306a36Sopenharmony_ci /* Cursor location (column, row). */ 70062306a36Sopenharmony_ci uint16_t cursor_x, cursor_y; 70162306a36Sopenharmony_ci /* Number of rows and columns (dimensions in characters). */ 70262306a36Sopenharmony_ci uint16_t rows, columns; 70362306a36Sopenharmony_ci } text_mode_3; 70462306a36Sopenharmony_ci 70562306a36Sopenharmony_ci struct { 70662306a36Sopenharmony_ci /* Width and height, in pixels. */ 70762306a36Sopenharmony_ci uint16_t width, height; 70862306a36Sopenharmony_ci /* Bytes per scan line. */ 70962306a36Sopenharmony_ci uint16_t bytes_per_line; 71062306a36Sopenharmony_ci /* Bits per pixel. */ 71162306a36Sopenharmony_ci uint16_t bits_per_pixel; 71262306a36Sopenharmony_ci /* LFB physical address, and size (in units of 64kB). */ 71362306a36Sopenharmony_ci uint32_t lfb_base; 71462306a36Sopenharmony_ci uint32_t lfb_size; 71562306a36Sopenharmony_ci /* RGB mask offsets and sizes, as defined by VBE 1.2+ */ 71662306a36Sopenharmony_ci uint8_t red_pos, red_size; 71762306a36Sopenharmony_ci uint8_t green_pos, green_size; 71862306a36Sopenharmony_ci uint8_t blue_pos, blue_size; 71962306a36Sopenharmony_ci uint8_t rsvd_pos, rsvd_size; 72062306a36Sopenharmony_ci 72162306a36Sopenharmony_ci /* VESA capabilities (offset 0xa, VESA command 0x4f00). */ 72262306a36Sopenharmony_ci uint32_t gbl_caps; 72362306a36Sopenharmony_ci /* Mode attributes (offset 0x0, VESA command 0x4f01). */ 72462306a36Sopenharmony_ci uint16_t mode_attrs; 72562306a36Sopenharmony_ci uint16_t pad; 72662306a36Sopenharmony_ci /* high 32 bits of lfb_base */ 72762306a36Sopenharmony_ci uint32_t ext_lfb_base; 72862306a36Sopenharmony_ci } vesa_lfb; 72962306a36Sopenharmony_ci } u; 73062306a36Sopenharmony_ci}; 73162306a36Sopenharmony_ci 73262306a36Sopenharmony_citypedef uint64_t cpumap_t; 73362306a36Sopenharmony_ci 73462306a36Sopenharmony_citypedef uint8_t xen_domain_handle_t[16]; 73562306a36Sopenharmony_ci 73662306a36Sopenharmony_ci/* Turn a plain number into a C unsigned long constant. */ 73762306a36Sopenharmony_ci#define __mk_unsigned_long(x) x ## UL 73862306a36Sopenharmony_ci#define mk_unsigned_long(x) __mk_unsigned_long(x) 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_ci#define TMEM_SPEC_VERSION 1 74162306a36Sopenharmony_ci 74262306a36Sopenharmony_cistruct tmem_op { 74362306a36Sopenharmony_ci uint32_t cmd; 74462306a36Sopenharmony_ci int32_t pool_id; 74562306a36Sopenharmony_ci union { 74662306a36Sopenharmony_ci struct { /* for cmd == TMEM_NEW_POOL */ 74762306a36Sopenharmony_ci uint64_t uuid[2]; 74862306a36Sopenharmony_ci uint32_t flags; 74962306a36Sopenharmony_ci } new; 75062306a36Sopenharmony_ci struct { 75162306a36Sopenharmony_ci uint64_t oid[3]; 75262306a36Sopenharmony_ci uint32_t index; 75362306a36Sopenharmony_ci uint32_t tmem_offset; 75462306a36Sopenharmony_ci uint32_t pfn_offset; 75562306a36Sopenharmony_ci uint32_t len; 75662306a36Sopenharmony_ci GUEST_HANDLE(void) gmfn; /* guest machine page frame */ 75762306a36Sopenharmony_ci } gen; 75862306a36Sopenharmony_ci } u; 75962306a36Sopenharmony_ci}; 76062306a36Sopenharmony_ci 76162306a36Sopenharmony_ciDEFINE_GUEST_HANDLE(u64); 76262306a36Sopenharmony_ci 76362306a36Sopenharmony_ci#else /* __ASSEMBLY__ */ 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci/* In assembly code we cannot use C numeric constant suffixes. */ 76662306a36Sopenharmony_ci#define mk_unsigned_long(x) x 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_ci#endif /* __XEN_PUBLIC_XEN_H__ */ 771