win-pvdrivers

changeset 580:52da65ad3f0c

Fixed EOL in xen.h
Worked around compiler bug^H^H^Hfeature in NTDDK where an empty struct is not allowed
author James Harper <james.harper@bendigoit.com.au>
date Tue Jun 02 21:13:28 2009 +1000 (2009-06-02)
parents c5136ccae1f3
children da7ec4df7dd6
files common/include/public/xen.h
line diff
     1.1 --- a/common/include/public/xen.h	Tue Jun 02 21:12:09 2009 +1000
     1.2 +++ b/common/include/public/xen.h	Tue Jun 02 21:13:28 2009 +1000
     1.3 @@ -1,612 +1,614 @@
     1.4 -/******************************************************************************
     1.5 - * xen.h
     1.6 - * 
     1.7 - * Guest OS interface to Xen.
     1.8 - * 
     1.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.10 - * of this software and associated documentation files (the "Software"), to
    1.11 - * deal in the Software without restriction, including without limitation the
    1.12 - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    1.13 - * sell copies of the Software, and to permit persons to whom the Software is
    1.14 - * furnished to do so, subject to the following conditions:
    1.15 - *
    1.16 - * The above copyright notice and this permission notice shall be included in
    1.17 - * all copies or substantial portions of the Software.
    1.18 - *
    1.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.22 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    1.24 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    1.25 - * DEALINGS IN THE SOFTWARE.
    1.26 - *
    1.27 - * Copyright (c) 2004, K A Fraser
    1.28 - */
    1.29 -
    1.30 -#ifndef __XEN_PUBLIC_XEN_H__
    1.31 -#define __XEN_PUBLIC_XEN_H__
    1.32 -
    1.33 -#include "xen-compat.h"
    1.34 -
    1.35 -#if defined(__i386__) || defined(__x86_64__)
    1.36 -#include "arch-x86/xen.h"
    1.37 -#elif defined(__ia64__)
    1.38 -#include "arch-ia64.h"
    1.39 -#elif defined(__powerpc__)
    1.40 -#include "arch-powerpc.h"
    1.41 -#else
    1.42 -#error "Unsupported architecture"
    1.43 -#endif
    1.44 -
    1.45 -/*
    1.46 - * HYPERCALLS
    1.47 - */
    1.48 -
    1.49 -#define __HYPERVISOR_set_trap_table        0
    1.50 -#define __HYPERVISOR_mmu_update            1
    1.51 -#define __HYPERVISOR_set_gdt               2
    1.52 -#define __HYPERVISOR_stack_switch          3
    1.53 -#define __HYPERVISOR_set_callbacks         4
    1.54 -#define __HYPERVISOR_fpu_taskswitch        5
    1.55 -#define __HYPERVISOR_sched_op_compat       6 /* compat since 0x00030101 */
    1.56 -#define __HYPERVISOR_platform_op           7
    1.57 -#define __HYPERVISOR_set_debugreg          8
    1.58 -#define __HYPERVISOR_get_debugreg          9
    1.59 -#define __HYPERVISOR_update_descriptor    10
    1.60 -#define __HYPERVISOR_memory_op            12
    1.61 -#define __HYPERVISOR_multicall            13
    1.62 -#define __HYPERVISOR_update_va_mapping    14
    1.63 -#define __HYPERVISOR_set_timer_op         15
    1.64 -#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
    1.65 -#define __HYPERVISOR_xen_version          17
    1.66 -#define __HYPERVISOR_console_io           18
    1.67 -#define __HYPERVISOR_physdev_op_compat    19 /* compat since 0x00030202 */
    1.68 -#define __HYPERVISOR_grant_table_op       20
    1.69 -#define __HYPERVISOR_vm_assist            21
    1.70 -#define __HYPERVISOR_update_va_mapping_otherdomain 22
    1.71 -#define __HYPERVISOR_iret                 23 /* x86 only */
    1.72 -#define __HYPERVISOR_vcpu_op              24
    1.73 -#define __HYPERVISOR_set_segment_base     25 /* x86/64 only */
    1.74 -#define __HYPERVISOR_mmuext_op            26
    1.75 -#define __HYPERVISOR_acm_op               27
    1.76 -#define __HYPERVISOR_nmi_op               28
    1.77 -#define __HYPERVISOR_sched_op             29
    1.78 -#define __HYPERVISOR_callback_op          30
    1.79 -#define __HYPERVISOR_xenoprof_op          31
    1.80 -#define __HYPERVISOR_event_channel_op     32
    1.81 -#define __HYPERVISOR_physdev_op           33
    1.82 -#define __HYPERVISOR_hvm_op               34
    1.83 -#define __HYPERVISOR_sysctl               35
    1.84 -#define __HYPERVISOR_domctl               36
    1.85 -#define __HYPERVISOR_kexec_op             37
    1.86 -
    1.87 -/* Architecture-specific hypercall definitions. */
    1.88 -#define __HYPERVISOR_arch_0               48
    1.89 -#define __HYPERVISOR_arch_1               49
    1.90 -#define __HYPERVISOR_arch_2               50
    1.91 -#define __HYPERVISOR_arch_3               51
    1.92 -#define __HYPERVISOR_arch_4               52
    1.93 -#define __HYPERVISOR_arch_5               53
    1.94 -#define __HYPERVISOR_arch_6               54
    1.95 -#define __HYPERVISOR_arch_7               55
    1.96 -
    1.97 -/*
    1.98 - * HYPERCALL COMPATIBILITY.
    1.99 - */
   1.100 -
   1.101 -/* New sched_op hypercall introduced in 0x00030101. */
   1.102 -#if __XEN_INTERFACE_VERSION__ < 0x00030101
   1.103 -#undef __HYPERVISOR_sched_op
   1.104 -#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
   1.105 -#endif
   1.106 -
   1.107 -/* New event-channel and physdev hypercalls introduced in 0x00030202. */
   1.108 -#if __XEN_INTERFACE_VERSION__ < 0x00030202
   1.109 -#undef __HYPERVISOR_event_channel_op
   1.110 -#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
   1.111 -#undef __HYPERVISOR_physdev_op
   1.112 -#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
   1.113 -#endif
   1.114 -
   1.115 -/* New platform_op hypercall introduced in 0x00030204. */
   1.116 -#if __XEN_INTERFACE_VERSION__ < 0x00030204
   1.117 -#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
   1.118 -#endif
   1.119 -
   1.120 -/* 
   1.121 - * VIRTUAL INTERRUPTS
   1.122 - * 
   1.123 - * Virtual interrupts that a guest OS may receive from Xen.
   1.124 - * 
   1.125 - * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
   1.126 - * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
   1.127 - * The latter can be allocated only once per guest: they must initially be
   1.128 - * allocated to VCPU0 but can subsequently be re-bound.
   1.129 - */
   1.130 -#define VIRQ_TIMER      0  /* V. Timebase update, and/or requested timeout.  */
   1.131 -#define VIRQ_DEBUG      1  /* V. Request guest to dump debug info.           */
   1.132 -#define VIRQ_CONSOLE    2  /* G. (DOM0) Bytes received on emergency console. */
   1.133 -#define VIRQ_DOM_EXC    3  /* G. (DOM0) Exceptional event for some domain.   */
   1.134 -#define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
   1.135 -#define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
   1.136 -#define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
   1.137 -#define VIRQ_CON_RING   8  /* G. (DOM0) Bytes received on console            */
   1.138 -
   1.139 -/* Architecture-specific VIRQ definitions. */
   1.140 -#define VIRQ_ARCH_0    16
   1.141 -#define VIRQ_ARCH_1    17
   1.142 -#define VIRQ_ARCH_2    18
   1.143 -#define VIRQ_ARCH_3    19
   1.144 -#define VIRQ_ARCH_4    20
   1.145 -#define VIRQ_ARCH_5    21
   1.146 -#define VIRQ_ARCH_6    22
   1.147 -#define VIRQ_ARCH_7    23
   1.148 -
   1.149 -#define NR_VIRQS       24
   1.150 -
   1.151 -/*
   1.152 - * MMU-UPDATE REQUESTS
   1.153 - * 
   1.154 - * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
   1.155 - * A foreigndom (FD) can be specified (or DOMID_SELF for none).
   1.156 - * Where the FD has some effect, it is described below.
   1.157 - * ptr[1:0] specifies the appropriate MMU_* command.
   1.158 - * 
   1.159 - * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
   1.160 - * Updates an entry in a page table. If updating an L1 table, and the new
   1.161 - * table entry is valid/present, the mapped frame must belong to the FD, if
   1.162 - * an FD has been specified. If attempting to map an I/O page then the
   1.163 - * caller assumes the privilege of the FD.
   1.164 - * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
   1.165 - * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
   1.166 - * ptr[:2]  -- Machine address of the page-table entry to modify.
   1.167 - * val      -- Value to write.
   1.168 - * 
   1.169 - * ptr[1:0] == MMU_MACHPHYS_UPDATE:
   1.170 - * Updates an entry in the machine->pseudo-physical mapping table.
   1.171 - * ptr[:2]  -- Machine address within the frame whose mapping to modify.
   1.172 - *             The frame must belong to the FD, if one is specified.
   1.173 - * val      -- Value to write into the mapping entry.
   1.174 - */
   1.175 -#define MMU_NORMAL_PT_UPDATE     0 /* checked '*ptr = val'. ptr is MA.       */
   1.176 -#define MMU_MACHPHYS_UPDATE      1 /* ptr = MA of frame to modify entry for  */
   1.177 -
   1.178 -/*
   1.179 - * MMU EXTENDED OPERATIONS
   1.180 - * 
   1.181 - * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
   1.182 - * A foreigndom (FD) can be specified (or DOMID_SELF for none).
   1.183 - * Where the FD has some effect, it is described below.
   1.184 - * 
   1.185 - * cmd: MMUEXT_(UN)PIN_*_TABLE
   1.186 - * mfn: Machine frame number to be (un)pinned as a p.t. page.
   1.187 - *      The frame must belong to the FD, if one is specified.
   1.188 - * 
   1.189 - * cmd: MMUEXT_NEW_BASEPTR
   1.190 - * mfn: Machine frame number of new page-table base to install in MMU.
   1.191 - * 
   1.192 - * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
   1.193 - * mfn: Machine frame number of new page-table base to install in MMU
   1.194 - *      when in user space.
   1.195 - * 
   1.196 - * cmd: MMUEXT_TLB_FLUSH_LOCAL
   1.197 - * No additional arguments. Flushes local TLB.
   1.198 - * 
   1.199 - * cmd: MMUEXT_INVLPG_LOCAL
   1.200 - * linear_addr: Linear address to be flushed from the local TLB.
   1.201 - * 
   1.202 - * cmd: MMUEXT_TLB_FLUSH_MULTI
   1.203 - * vcpumask: Pointer to bitmap of VCPUs to be flushed.
   1.204 - * 
   1.205 - * cmd: MMUEXT_INVLPG_MULTI
   1.206 - * linear_addr: Linear address to be flushed.
   1.207 - * vcpumask: Pointer to bitmap of VCPUs to be flushed.
   1.208 - * 
   1.209 - * cmd: MMUEXT_TLB_FLUSH_ALL
   1.210 - * No additional arguments. Flushes all VCPUs' TLBs.
   1.211 - * 
   1.212 - * cmd: MMUEXT_INVLPG_ALL
   1.213 - * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
   1.214 - * 
   1.215 - * cmd: MMUEXT_FLUSH_CACHE
   1.216 - * No additional arguments. Writes back and flushes cache contents.
   1.217 - * 
   1.218 - * cmd: MMUEXT_SET_LDT
   1.219 - * linear_addr: Linear address of LDT base (NB. must be page-aligned).
   1.220 - * nr_ents: Number of entries in LDT.
   1.221 - */
   1.222 -#define MMUEXT_PIN_L1_TABLE      0
   1.223 -#define MMUEXT_PIN_L2_TABLE      1
   1.224 -#define MMUEXT_PIN_L3_TABLE      2
   1.225 -#define MMUEXT_PIN_L4_TABLE      3
   1.226 -#define MMUEXT_UNPIN_TABLE       4
   1.227 -#define MMUEXT_NEW_BASEPTR       5
   1.228 -#define MMUEXT_TLB_FLUSH_LOCAL   6
   1.229 -#define MMUEXT_INVLPG_LOCAL      7
   1.230 -#define MMUEXT_TLB_FLUSH_MULTI   8
   1.231 -#define MMUEXT_INVLPG_MULTI      9
   1.232 -#define MMUEXT_TLB_FLUSH_ALL    10
   1.233 -#define MMUEXT_INVLPG_ALL       11
   1.234 -#define MMUEXT_FLUSH_CACHE      12
   1.235 -#define MMUEXT_SET_LDT          13
   1.236 -#define MMUEXT_NEW_USER_BASEPTR 15
   1.237 -
   1.238 -#ifndef __ASSEMBLY__
   1.239 -struct mmuext_op {
   1.240 -    unsigned int cmd;
   1.241 -    union {
   1.242 -        /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
   1.243 -        xen_pfn_t     mfn;
   1.244 -        /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
   1.245 -        xen_ulong_t linear_addr;
   1.246 -    } arg1;
   1.247 -    union {
   1.248 -        /* SET_LDT */
   1.249 -        unsigned int nr_ents;
   1.250 -        /* TLB_FLUSH_MULTI, INVLPG_MULTI */
   1.251 -        XEN_GUEST_HANDLE_00030205(void) vcpumask;
   1.252 -    } arg2;
   1.253 -};
   1.254 -typedef struct mmuext_op mmuext_op_t;
   1.255 -DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
   1.256 -#endif
   1.257 -
   1.258 -/* These are passed as 'flags' to update_va_mapping. They can be ORed. */
   1.259 -/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap.   */
   1.260 -/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer.         */
   1.261 -#define UVMF_NONE               (0UL<<0) /* No flushing at all.   */
   1.262 -#define UVMF_TLB_FLUSH          (1UL<<0) /* Flush entire TLB(s).  */
   1.263 -#define UVMF_INVLPG             (2UL<<0) /* Flush only one entry. */
   1.264 -#define UVMF_FLUSHTYPE_MASK     (3UL<<0)
   1.265 -#define UVMF_MULTI              (0UL<<2) /* Flush subset of TLBs. */
   1.266 -#define UVMF_LOCAL              (0UL<<2) /* Flush local TLB.      */
   1.267 -#define UVMF_ALL                (1UL<<2) /* Flush all TLBs.       */
   1.268 -
   1.269 -/*
   1.270 - * Commands to HYPERVISOR_console_io().
   1.271 - */
   1.272 -#define CONSOLEIO_write         0
   1.273 -#define CONSOLEIO_read          1
   1.274 -
   1.275 -/*
   1.276 - * Commands to HYPERVISOR_vm_assist().
   1.277 - */
   1.278 -#define VMASST_CMD_enable                0
   1.279 -#define VMASST_CMD_disable               1
   1.280 -
   1.281 -/* x86/32 guests: simulate full 4GB segment limits. */
   1.282 -#define VMASST_TYPE_4gb_segments         0
   1.283 -
   1.284 -/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
   1.285 -#define VMASST_TYPE_4gb_segments_notify  1
   1.286 -
   1.287 -/*
   1.288 - * x86 guests: support writes to bottom-level PTEs.
   1.289 - * NB1. Page-directory entries cannot be written.
   1.290 - * NB2. Guest must continue to remove all writable mappings of PTEs.
   1.291 - */
   1.292 -#define VMASST_TYPE_writable_pagetables  2
   1.293 -
   1.294 -/* x86/PAE guests: support PDPTs above 4GB. */
   1.295 -#define VMASST_TYPE_pae_extended_cr3     3
   1.296 -
   1.297 -#define MAX_VMASST_TYPE                  3
   1.298 -
   1.299 -#ifndef __ASSEMBLY__
   1.300 -
   1.301 -typedef uint16_t domid_t;
   1.302 -
   1.303 -/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
   1.304 -#define DOMID_FIRST_RESERVED (0x7FF0U)
   1.305 -
   1.306 -/* DOMID_SELF is used in certain contexts to refer to oneself. */
   1.307 -#define DOMID_SELF (0x7FF0U)
   1.308 -
   1.309 -/*
   1.310 - * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
   1.311 - * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
   1.312 - * is useful to ensure that no mappings to the OS's own heap are accidentally
   1.313 - * installed. (e.g., in Linux this could cause havoc as reference counts
   1.314 - * aren't adjusted on the I/O-mapping code path).
   1.315 - * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
   1.316 - * be specified by any calling domain.
   1.317 - */
   1.318 -#define DOMID_IO   (0x7FF1U)
   1.319 -
   1.320 -/*
   1.321 - * DOMID_XEN is used to allow privileged domains to map restricted parts of
   1.322 - * Xen's heap space (e.g., the machine_to_phys table).
   1.323 - * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
   1.324 - * the caller is privileged.
   1.325 - */
   1.326 -#define DOMID_XEN  (0x7FF2U)
   1.327 -
   1.328 -/*
   1.329 - * Send an array of these to HYPERVISOR_mmu_update().
   1.330 - * NB. The fields are natural pointer/address size for this architecture.
   1.331 - */
   1.332 -struct mmu_update {
   1.333 -    uint64_t ptr;       /* Machine address of PTE. */
   1.334 -    uint64_t val;       /* New contents of PTE.    */
   1.335 -};
   1.336 -typedef struct mmu_update mmu_update_t;
   1.337 -DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
   1.338 -
   1.339 -/*
   1.340 - * Send an array of these to HYPERVISOR_multicall().
   1.341 - * NB. The fields are natural register size for this architecture.
   1.342 - */
   1.343 -struct multicall_entry {
   1.344 -    xen_ulong_t op, result;
   1.345 -    xen_ulong_t args[6];
   1.346 -};
   1.347 -typedef struct multicall_entry multicall_entry_t;
   1.348 -DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
   1.349 -
   1.350 -/*
   1.351 - * Event channel endpoints per domain:
   1.352 - *  1024 if a long is 32 bits; 4096 if a long is 64 bits.
   1.353 - */
   1.354 -#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
   1.355 -
   1.356 -struct vcpu_time_info {
   1.357 -    /*
   1.358 -     * Updates to the following values are preceded and followed by an
   1.359 -     * increment of 'version'. The guest can therefore detect updates by
   1.360 -     * looking for changes to 'version'. If the least-significant bit of
   1.361 -     * the version number is set then an update is in progress and the guest
   1.362 -     * must wait to read a consistent set of values.
   1.363 -     * The correct way to interact with the version number is similar to
   1.364 -     * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
   1.365 -     */
   1.366 -    uint32_t version;
   1.367 -    uint32_t pad0;
   1.368 -    uint64_t tsc_timestamp;   /* TSC at last update of time vals.  */
   1.369 -    uint64_t system_time;     /* Time, in nanosecs, since boot.    */
   1.370 -    /*
   1.371 -     * Current system time:
   1.372 -     *   system_time +
   1.373 -     *   ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
   1.374 -     * CPU frequency (Hz):
   1.375 -     *   ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
   1.376 -     */
   1.377 -    uint32_t tsc_to_system_mul;
   1.378 -    int8_t   tsc_shift;
   1.379 -    int8_t   pad1[3];
   1.380 -}; /* 32 bytes */
   1.381 -typedef struct vcpu_time_info vcpu_time_info_t;
   1.382 -
   1.383 -struct vcpu_info {
   1.384 -    /*
   1.385 -     * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
   1.386 -     * a pending notification for a particular VCPU. It is then cleared 
   1.387 -     * by the guest OS /before/ checking for pending work, thus avoiding
   1.388 -     * a set-and-check race. Note that the mask is only accessed by Xen
   1.389 -     * on the CPU that is currently hosting the VCPU. This means that the
   1.390 -     * pending and mask flags can be updated by the guest without special
   1.391 -     * synchronisation (i.e., no need for the x86 LOCK prefix).
   1.392 -     * This may seem suboptimal because if the pending flag is set by
   1.393 -     * a different CPU then an IPI may be scheduled even when the mask
   1.394 -     * is set. However, note:
   1.395 -     *  1. The task of 'interrupt holdoff' is covered by the per-event-
   1.396 -     *     channel mask bits. A 'noisy' event that is continually being
   1.397 -     *     triggered can be masked at source at this very precise
   1.398 -     *     granularity.
   1.399 -     *  2. The main purpose of the per-VCPU mask is therefore to restrict
   1.400 -     *     reentrant execution: whether for concurrency control, or to
   1.401 -     *     prevent unbounded stack usage. Whatever the purpose, we expect
   1.402 -     *     that the mask will be asserted only for short periods at a time,
   1.403 -     *     and so the likelihood of a 'spurious' IPI is suitably small.
   1.404 -     * The mask is read before making an event upcall to the guest: a
   1.405 -     * non-zero mask therefore guarantees that the VCPU will not receive
   1.406 -     * an upcall activation. The mask is cleared when the VCPU requests
   1.407 -     * to block: this avoids wakeup-waiting races.
   1.408 -     */
   1.409 -    uint8_t evtchn_upcall_pending;
   1.410 -    uint8_t evtchn_upcall_mask;
   1.411 -    xen_ulong_t evtchn_pending_sel;
   1.412 -    struct arch_vcpu_info arch;
   1.413 -    struct vcpu_time_info time;
   1.414 -}; /* 64 bytes (x86) */
   1.415 -#ifndef __XEN__
   1.416 -typedef struct vcpu_info vcpu_info_t;
   1.417 -#endif
   1.418 -
   1.419 -/*
   1.420 - * Xen/kernel shared data -- pointer provided in start_info.
   1.421 - *
   1.422 - * This structure is defined to be both smaller than a page, and the
   1.423 - * only data on the shared page, but may vary in actual size even within
   1.424 - * compatible Xen versions; guests should not rely on the size
   1.425 - * of this structure remaining constant.
   1.426 - */
   1.427 -struct shared_info {
   1.428 -    struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
   1.429 -
   1.430 -    /*
   1.431 -     * A domain can create "event channels" on which it can send and receive
   1.432 -     * asynchronous event notifications. There are three classes of event that
   1.433 -     * are delivered by this mechanism:
   1.434 -     *  1. Bi-directional inter- and intra-domain connections. Domains must
   1.435 -     *     arrange out-of-band to set up a connection (usually by allocating
   1.436 -     *     an unbound 'listener' port and avertising that via a storage service
   1.437 -     *     such as xenstore).
   1.438 -     *  2. Physical interrupts. A domain with suitable hardware-access
   1.439 -     *     privileges can bind an event-channel port to a physical interrupt
   1.440 -     *     source.
   1.441 -     *  3. Virtual interrupts ('events'). A domain can bind an event-channel
   1.442 -     *     port to a virtual interrupt source, such as the virtual-timer
   1.443 -     *     device or the emergency console.
   1.444 -     * 
   1.445 -     * Event channels are addressed by a "port index". Each channel is
   1.446 -     * associated with two bits of information:
   1.447 -     *  1. PENDING -- notifies the domain that there is a pending notification
   1.448 -     *     to be processed. This bit is cleared by the guest.
   1.449 -     *  2. MASK -- if this bit is clear then a 0->1 transition of PENDING
   1.450 -     *     will cause an asynchronous upcall to be scheduled. This bit is only
   1.451 -     *     updated by the guest. It is read-only within Xen. If a channel
   1.452 -     *     becomes pending while the channel is masked then the 'edge' is lost
   1.453 -     *     (i.e., when the channel is unmasked, the guest must manually handle
   1.454 -     *     pending notifications as no upcall will be scheduled by Xen).
   1.455 -     * 
   1.456 -     * To expedite scanning of pending notifications, any 0->1 pending
   1.457 -     * transition on an unmasked channel causes a corresponding bit in a
   1.458 -     * per-vcpu selector word to be set. Each bit in the selector covers a
   1.459 -     * 'C long' in the PENDING bitfield array.
   1.460 -     */
   1.461 -    xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8];
   1.462 -    xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];
   1.463 -
   1.464 -    /*
   1.465 -     * Wallclock time: updated only by control software. Guests should base
   1.466 -     * their gettimeofday() syscall on this wallclock-base value.
   1.467 -     */
   1.468 -    uint32_t wc_version;      /* Version counter: see vcpu_time_info_t. */
   1.469 -    uint32_t wc_sec;          /* Secs  00:00:00 UTC, Jan 1, 1970.  */
   1.470 -    uint32_t wc_nsec;         /* Nsecs 00:00:00 UTC, Jan 1, 1970.  */
   1.471 -
   1.472 -    struct arch_shared_info arch;
   1.473 -
   1.474 -};
   1.475 -#ifndef __XEN__
   1.476 -typedef struct shared_info shared_info_t;
   1.477 -#endif
   1.478 -
   1.479 -/*
   1.480 - * Start-of-day memory layout:
   1.481 - *  1. The domain is started within contiguous virtual-memory region.
   1.482 - *  2. The contiguous region ends on an aligned 4MB boundary.
   1.483 - *  3. This the order of bootstrap elements in the initial virtual region:
   1.484 - *      a. relocated kernel image
   1.485 - *      b. initial ram disk              [mod_start, mod_len]
   1.486 - *      c. list of allocated page frames [mfn_list, nr_pages]
   1.487 - *      d. start_info_t structure        [register ESI (x86)]
   1.488 - *      e. bootstrap page tables         [pt_base, CR3 (x86)]
   1.489 - *      f. bootstrap stack               [register ESP (x86)]
   1.490 - *  4. Bootstrap elements are packed together, but each is 4kB-aligned.
   1.491 - *  5. The initial ram disk may be omitted.
   1.492 - *  6. The list of page frames forms a contiguous 'pseudo-physical' memory
   1.493 - *     layout for the domain. In particular, the bootstrap virtual-memory
   1.494 - *     region is a 1:1 mapping to the first section of the pseudo-physical map.
   1.495 - *  7. All bootstrap elements are mapped read-writable for the guest OS. The
   1.496 - *     only exception is the bootstrap page table, which is mapped read-only.
   1.497 - *  8. There is guaranteed to be at least 512kB padding after the final
   1.498 - *     bootstrap element. If necessary, the bootstrap virtual region is
   1.499 - *     extended by an extra 4MB to ensure this.
   1.500 - */
   1.501 -
   1.502 -#define MAX_GUEST_CMDLINE 1024
   1.503 -struct start_info {
   1.504 -    /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.    */
   1.505 -    char magic[32];             /* "xen-<version>-<platform>".            */
   1.506 -    xen_ulong_t nr_pages;     /* Total pages allocated to this domain.  */
   1.507 -    xen_ulong_t shared_info;  /* MACHINE address of shared info struct. */
   1.508 -    uint32_t flags;             /* SIF_xxx flags.                         */
   1.509 -    xen_pfn_t store_mfn;        /* MACHINE page number of shared page.    */
   1.510 -    uint32_t store_evtchn;      /* Event channel for store communication. */
   1.511 -    union {
   1.512 -        struct {
   1.513 -            xen_pfn_t mfn;      /* MACHINE page number of console page.   */
   1.514 -            uint32_t  evtchn;   /* Event channel for console page.        */
   1.515 -        } domU;
   1.516 -        struct {
   1.517 -            uint32_t info_off;  /* Offset of console_info struct.         */
   1.518 -            uint32_t info_size; /* Size of console_info struct from start.*/
   1.519 -        } dom0;
   1.520 -    } console;
   1.521 -    /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).     */
   1.522 -    xen_ulong_t pt_base;      /* VIRTUAL address of page directory.     */
   1.523 -    xen_ulong_t nr_pt_frames; /* Number of bootstrap p.t. frames.       */
   1.524 -    xen_ulong_t mfn_list;     /* VIRTUAL address of page-frame list.    */
   1.525 -    xen_ulong_t mod_start;    /* VIRTUAL address of pre-loaded module.  */
   1.526 -    xen_ulong_t mod_len;      /* Size (bytes) of pre-loaded module.     */
   1.527 -    int8_t cmd_line[MAX_GUEST_CMDLINE];
   1.528 -};
   1.529 -typedef struct start_info start_info_t;
   1.530 -
   1.531 -/* New console union for dom0 introduced in 0x00030203. */
   1.532 -#if __XEN_INTERFACE_VERSION__ < 0x00030203
   1.533 -#define console_mfn    console.domU.mfn
   1.534 -#define console_evtchn console.domU.evtchn
   1.535 -#endif
   1.536 -
   1.537 -/* These flags are passed in the 'flags' field of start_info_t. */
   1.538 -#define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
   1.539 -#define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
   1.540 -
   1.541 -typedef struct dom0_vga_console_info {
   1.542 -    uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
   1.543 -#define XEN_VGATYPE_TEXT_MODE_3 0x03
   1.544 -#define XEN_VGATYPE_VESA_LFB    0x23
   1.545 -
   1.546 -    union {
   1.547 -        struct {
   1.548 -            /* Font height, in pixels. */
   1.549 -            uint16_t font_height;
   1.550 -            /* Cursor location (column, row). */
   1.551 -            uint16_t cursor_x, cursor_y;
   1.552 -            /* Number of rows and columns (dimensions in characters). */
   1.553 -            uint16_t rows, columns;
   1.554 -        } text_mode_3;
   1.555 -
   1.556 -        struct {
   1.557 -            /* Width and height, in pixels. */
   1.558 -            uint16_t width, height;
   1.559 -            /* Bytes per scan line. */
   1.560 -            uint16_t bytes_per_line;
   1.561 -            /* Bits per pixel. */
   1.562 -            uint16_t bits_per_pixel;
   1.563 -            /* LFB physical address, and size (in units of 64kB). */
   1.564 -            uint32_t lfb_base;
   1.565 -            uint32_t lfb_size;
   1.566 -            /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
   1.567 -            uint8_t  red_pos, red_size;
   1.568 -            uint8_t  green_pos, green_size;
   1.569 -            uint8_t  blue_pos, blue_size;
   1.570 -            uint8_t  rsvd_pos, rsvd_size;
   1.571 -        } vesa_lfb;
   1.572 -    } u;
   1.573 -} dom0_vga_console_info_t;
   1.574 -#define xen_vga_console_info dom0_vga_console_info
   1.575 -#define xen_vga_console_info_t dom0_vga_console_info_t
   1.576 -
   1.577 -typedef uint8_t xen_domain_handle_t[16];
   1.578 -
   1.579 -/* Turn a plain number into a C xen_ulong_t constant. */
   1.580 -#define __mk_unsigned_long(x) x ## UL
   1.581 -#define mk_unsigned_long(x) __mk_unsigned_long(x)
   1.582 -
   1.583 -DEFINE_XEN_GUEST_HANDLE(uint8_t);
   1.584 -DEFINE_XEN_GUEST_HANDLE(uint16_t);
   1.585 -DEFINE_XEN_GUEST_HANDLE(uint32_t);
   1.586 -DEFINE_XEN_GUEST_HANDLE(uint64_t);
   1.587 -
   1.588 -#else /* __ASSEMBLY__ */
   1.589 -
   1.590 -/* In assembly code we cannot use C numeric constant suffixes. */
   1.591 -#define mk_unsigned_long(x) x
   1.592 -
   1.593 -#endif /* !__ASSEMBLY__ */
   1.594 -
   1.595 -/* Default definitions for macros used by domctl/sysctl. */
   1.596 -#if defined(__XEN__) || defined(__XEN_TOOLS__)
   1.597 -#ifndef uint64_aligned_t
   1.598 -#define uint64_aligned_t uint64_t
   1.599 -#endif
   1.600 -#ifndef XEN_GUEST_HANDLE_64
   1.601 -#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
   1.602 -#endif
   1.603 -#endif
   1.604 -
   1.605 -#endif /* __XEN_PUBLIC_XEN_H__ */
   1.606 -
   1.607 -/*
   1.608 - * Local variables:
   1.609 - * mode: C
   1.610 - * c-set-style: "BSD"
   1.611 - * c-basic-offset: 4
   1.612 - * tab-width: 4
   1.613 - * indent-tabs-mode: nil
   1.614 - * End:
   1.615 - */
   1.616 +/******************************************************************************
   1.617 + * xen.h
   1.618 + * 
   1.619 + * Guest OS interface to Xen.
   1.620 + * 
   1.621 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   1.622 + * of this software and associated documentation files (the "Software"), to
   1.623 + * deal in the Software without restriction, including without limitation the
   1.624 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   1.625 + * sell copies of the Software, and to permit persons to whom the Software is
   1.626 + * furnished to do so, subject to the following conditions:
   1.627 + *
   1.628 + * The above copyright notice and this permission notice shall be included in
   1.629 + * all copies or substantial portions of the Software.
   1.630 + *
   1.631 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   1.632 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   1.633 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   1.634 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   1.635 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   1.636 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   1.637 + * DEALINGS IN THE SOFTWARE.
   1.638 + *
   1.639 + * Copyright (c) 2004, K A Fraser
   1.640 + */
   1.641 +
   1.642 +#ifndef __XEN_PUBLIC_XEN_H__
   1.643 +#define __XEN_PUBLIC_XEN_H__
   1.644 +
   1.645 +#include "xen-compat.h"
   1.646 +
   1.647 +#if defined(__i386__) || defined(__x86_64__)
   1.648 +#include "arch-x86/xen.h"
   1.649 +#elif defined(__ia64__)
   1.650 +#include "arch-ia64.h"
   1.651 +#elif defined(__powerpc__)
   1.652 +#include "arch-powerpc.h"
   1.653 +#else
   1.654 +#error "Unsupported architecture"
   1.655 +#endif
   1.656 +
   1.657 +/*
   1.658 + * HYPERCALLS
   1.659 + */
   1.660 +
   1.661 +#define __HYPERVISOR_set_trap_table        0
   1.662 +#define __HYPERVISOR_mmu_update            1
   1.663 +#define __HYPERVISOR_set_gdt               2
   1.664 +#define __HYPERVISOR_stack_switch          3
   1.665 +#define __HYPERVISOR_set_callbacks         4
   1.666 +#define __HYPERVISOR_fpu_taskswitch        5
   1.667 +#define __HYPERVISOR_sched_op_compat       6 /* compat since 0x00030101 */
   1.668 +#define __HYPERVISOR_platform_op           7
   1.669 +#define __HYPERVISOR_set_debugreg          8
   1.670 +#define __HYPERVISOR_get_debugreg          9
   1.671 +#define __HYPERVISOR_update_descriptor    10
   1.672 +#define __HYPERVISOR_memory_op            12
   1.673 +#define __HYPERVISOR_multicall            13
   1.674 +#define __HYPERVISOR_update_va_mapping    14
   1.675 +#define __HYPERVISOR_set_timer_op         15
   1.676 +#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
   1.677 +#define __HYPERVISOR_xen_version          17
   1.678 +#define __HYPERVISOR_console_io           18
   1.679 +#define __HYPERVISOR_physdev_op_compat    19 /* compat since 0x00030202 */
   1.680 +#define __HYPERVISOR_grant_table_op       20
   1.681 +#define __HYPERVISOR_vm_assist            21
   1.682 +#define __HYPERVISOR_update_va_mapping_otherdomain 22
   1.683 +#define __HYPERVISOR_iret                 23 /* x86 only */
   1.684 +#define __HYPERVISOR_vcpu_op              24
   1.685 +#define __HYPERVISOR_set_segment_base     25 /* x86/64 only */
   1.686 +#define __HYPERVISOR_mmuext_op            26
   1.687 +#define __HYPERVISOR_acm_op               27
   1.688 +#define __HYPERVISOR_nmi_op               28
   1.689 +#define __HYPERVISOR_sched_op             29
   1.690 +#define __HYPERVISOR_callback_op          30
   1.691 +#define __HYPERVISOR_xenoprof_op          31
   1.692 +#define __HYPERVISOR_event_channel_op     32
   1.693 +#define __HYPERVISOR_physdev_op           33
   1.694 +#define __HYPERVISOR_hvm_op               34
   1.695 +#define __HYPERVISOR_sysctl               35
   1.696 +#define __HYPERVISOR_domctl               36
   1.697 +#define __HYPERVISOR_kexec_op             37
   1.698 +
   1.699 +/* Architecture-specific hypercall definitions. */
   1.700 +#define __HYPERVISOR_arch_0               48
   1.701 +#define __HYPERVISOR_arch_1               49
   1.702 +#define __HYPERVISOR_arch_2               50
   1.703 +#define __HYPERVISOR_arch_3               51
   1.704 +#define __HYPERVISOR_arch_4               52
   1.705 +#define __HYPERVISOR_arch_5               53
   1.706 +#define __HYPERVISOR_arch_6               54
   1.707 +#define __HYPERVISOR_arch_7               55
   1.708 +
   1.709 +/*
   1.710 + * HYPERCALL COMPATIBILITY.
   1.711 + */
   1.712 +
   1.713 +/* New sched_op hypercall introduced in 0x00030101. */
   1.714 +#if __XEN_INTERFACE_VERSION__ < 0x00030101
   1.715 +#undef __HYPERVISOR_sched_op
   1.716 +#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
   1.717 +#endif
   1.718 +
   1.719 +/* New event-channel and physdev hypercalls introduced in 0x00030202. */
   1.720 +#if __XEN_INTERFACE_VERSION__ < 0x00030202
   1.721 +#undef __HYPERVISOR_event_channel_op
   1.722 +#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
   1.723 +#undef __HYPERVISOR_physdev_op
   1.724 +#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
   1.725 +#endif
   1.726 +
   1.727 +/* New platform_op hypercall introduced in 0x00030204. */
   1.728 +#if __XEN_INTERFACE_VERSION__ < 0x00030204
   1.729 +#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
   1.730 +#endif
   1.731 +
   1.732 +/* 
   1.733 + * VIRTUAL INTERRUPTS
   1.734 + * 
   1.735 + * Virtual interrupts that a guest OS may receive from Xen.
   1.736 + * 
   1.737 + * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
   1.738 + * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
   1.739 + * The latter can be allocated only once per guest: they must initially be
   1.740 + * allocated to VCPU0 but can subsequently be re-bound.
   1.741 + */
   1.742 +#define VIRQ_TIMER      0  /* V. Timebase update, and/or requested timeout.  */
   1.743 +#define VIRQ_DEBUG      1  /* V. Request guest to dump debug info.           */
   1.744 +#define VIRQ_CONSOLE    2  /* G. (DOM0) Bytes received on emergency console. */
   1.745 +#define VIRQ_DOM_EXC    3  /* G. (DOM0) Exceptional event for some domain.   */
   1.746 +#define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
   1.747 +#define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
   1.748 +#define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
   1.749 +#define VIRQ_CON_RING   8  /* G. (DOM0) Bytes received on console            */
   1.750 +
   1.751 +/* Architecture-specific VIRQ definitions. */
   1.752 +#define VIRQ_ARCH_0    16
   1.753 +#define VIRQ_ARCH_1    17
   1.754 +#define VIRQ_ARCH_2    18
   1.755 +#define VIRQ_ARCH_3    19
   1.756 +#define VIRQ_ARCH_4    20
   1.757 +#define VIRQ_ARCH_5    21
   1.758 +#define VIRQ_ARCH_6    22
   1.759 +#define VIRQ_ARCH_7    23
   1.760 +
   1.761 +#define NR_VIRQS       24
   1.762 +
   1.763 +/*
   1.764 + * MMU-UPDATE REQUESTS
   1.765 + * 
   1.766 + * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
   1.767 + * A foreigndom (FD) can be specified (or DOMID_SELF for none).
   1.768 + * Where the FD has some effect, it is described below.
   1.769 + * ptr[1:0] specifies the appropriate MMU_* command.
   1.770 + * 
   1.771 + * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
   1.772 + * Updates an entry in a page table. If updating an L1 table, and the new
   1.773 + * table entry is valid/present, the mapped frame must belong to the FD, if
   1.774 + * an FD has been specified. If attempting to map an I/O page then the
   1.775 + * caller assumes the privilege of the FD.
   1.776 + * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
   1.777 + * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
   1.778 + * ptr[:2]  -- Machine address of the page-table entry to modify.
   1.779 + * val      -- Value to write.
   1.780 + * 
   1.781 + * ptr[1:0] == MMU_MACHPHYS_UPDATE:
   1.782 + * Updates an entry in the machine->pseudo-physical mapping table.
   1.783 + * ptr[:2]  -- Machine address within the frame whose mapping to modify.
   1.784 + *             The frame must belong to the FD, if one is specified.
   1.785 + * val      -- Value to write into the mapping entry.
   1.786 + */
   1.787 +#define MMU_NORMAL_PT_UPDATE     0 /* checked '*ptr = val'. ptr is MA.       */
   1.788 +#define MMU_MACHPHYS_UPDATE      1 /* ptr = MA of frame to modify entry for  */
   1.789 +
   1.790 +/*
   1.791 + * MMU EXTENDED OPERATIONS
   1.792 + * 
   1.793 + * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
   1.794 + * A foreigndom (FD) can be specified (or DOMID_SELF for none).
   1.795 + * Where the FD has some effect, it is described below.
   1.796 + * 
   1.797 + * cmd: MMUEXT_(UN)PIN_*_TABLE
   1.798 + * mfn: Machine frame number to be (un)pinned as a p.t. page.
   1.799 + *      The frame must belong to the FD, if one is specified.
   1.800 + * 
   1.801 + * cmd: MMUEXT_NEW_BASEPTR
   1.802 + * mfn: Machine frame number of new page-table base to install in MMU.
   1.803 + * 
   1.804 + * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
   1.805 + * mfn: Machine frame number of new page-table base to install in MMU
   1.806 + *      when in user space.
   1.807 + * 
   1.808 + * cmd: MMUEXT_TLB_FLUSH_LOCAL
   1.809 + * No additional arguments. Flushes local TLB.
   1.810 + * 
   1.811 + * cmd: MMUEXT_INVLPG_LOCAL
   1.812 + * linear_addr: Linear address to be flushed from the local TLB.
   1.813 + * 
   1.814 + * cmd: MMUEXT_TLB_FLUSH_MULTI
   1.815 + * vcpumask: Pointer to bitmap of VCPUs to be flushed.
   1.816 + * 
   1.817 + * cmd: MMUEXT_INVLPG_MULTI
   1.818 + * linear_addr: Linear address to be flushed.
   1.819 + * vcpumask: Pointer to bitmap of VCPUs to be flushed.
   1.820 + * 
   1.821 + * cmd: MMUEXT_TLB_FLUSH_ALL
   1.822 + * No additional arguments. Flushes all VCPUs' TLBs.
   1.823 + * 
   1.824 + * cmd: MMUEXT_INVLPG_ALL
   1.825 + * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
   1.826 + * 
   1.827 + * cmd: MMUEXT_FLUSH_CACHE
   1.828 + * No additional arguments. Writes back and flushes cache contents.
   1.829 + * 
   1.830 + * cmd: MMUEXT_SET_LDT
   1.831 + * linear_addr: Linear address of LDT base (NB. must be page-aligned).
   1.832 + * nr_ents: Number of entries in LDT.
   1.833 + */
   1.834 +#define MMUEXT_PIN_L1_TABLE      0
   1.835 +#define MMUEXT_PIN_L2_TABLE      1
   1.836 +#define MMUEXT_PIN_L3_TABLE      2
   1.837 +#define MMUEXT_PIN_L4_TABLE      3
   1.838 +#define MMUEXT_UNPIN_TABLE       4
   1.839 +#define MMUEXT_NEW_BASEPTR       5
   1.840 +#define MMUEXT_TLB_FLUSH_LOCAL   6
   1.841 +#define MMUEXT_INVLPG_LOCAL      7
   1.842 +#define MMUEXT_TLB_FLUSH_MULTI   8
   1.843 +#define MMUEXT_INVLPG_MULTI      9
   1.844 +#define MMUEXT_TLB_FLUSH_ALL    10
   1.845 +#define MMUEXT_INVLPG_ALL       11
   1.846 +#define MMUEXT_FLUSH_CACHE      12
   1.847 +#define MMUEXT_SET_LDT          13
   1.848 +#define MMUEXT_NEW_USER_BASEPTR 15
   1.849 +
   1.850 +#ifndef __ASSEMBLY__
   1.851 +struct mmuext_op {
   1.852 +    unsigned int cmd;
   1.853 +    union {
   1.854 +        /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
   1.855 +        xen_pfn_t     mfn;
   1.856 +        /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
   1.857 +        xen_ulong_t linear_addr;
   1.858 +    } arg1;
   1.859 +    union {
   1.860 +        /* SET_LDT */
   1.861 +        unsigned int nr_ents;
   1.862 +        /* TLB_FLUSH_MULTI, INVLPG_MULTI */
   1.863 +        XEN_GUEST_HANDLE_00030205(void) vcpumask;
   1.864 +    } arg2;
   1.865 +};
   1.866 +typedef struct mmuext_op mmuext_op_t;
   1.867 +DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
   1.868 +#endif
   1.869 +
   1.870 +/* These are passed as 'flags' to update_va_mapping. They can be ORed. */
   1.871 +/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap.   */
   1.872 +/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer.         */
   1.873 +#define UVMF_NONE               (0UL<<0) /* No flushing at all.   */
   1.874 +#define UVMF_TLB_FLUSH          (1UL<<0) /* Flush entire TLB(s).  */
   1.875 +#define UVMF_INVLPG             (2UL<<0) /* Flush only one entry. */
   1.876 +#define UVMF_FLUSHTYPE_MASK     (3UL<<0)
   1.877 +#define UVMF_MULTI              (0UL<<2) /* Flush subset of TLBs. */
   1.878 +#define UVMF_LOCAL              (0UL<<2) /* Flush local TLB.      */
   1.879 +#define UVMF_ALL                (1UL<<2) /* Flush all TLBs.       */
   1.880 +
   1.881 +/*
   1.882 + * Commands to HYPERVISOR_console_io().
   1.883 + */
   1.884 +#define CONSOLEIO_write         0
   1.885 +#define CONSOLEIO_read          1
   1.886 +
   1.887 +/*
   1.888 + * Commands to HYPERVISOR_vm_assist().
   1.889 + */
   1.890 +#define VMASST_CMD_enable                0
   1.891 +#define VMASST_CMD_disable               1
   1.892 +
   1.893 +/* x86/32 guests: simulate full 4GB segment limits. */
   1.894 +#define VMASST_TYPE_4gb_segments         0
   1.895 +
   1.896 +/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
   1.897 +#define VMASST_TYPE_4gb_segments_notify  1
   1.898 +
   1.899 +/*
   1.900 + * x86 guests: support writes to bottom-level PTEs.
   1.901 + * NB1. Page-directory entries cannot be written.
   1.902 + * NB2. Guest must continue to remove all writable mappings of PTEs.
   1.903 + */
   1.904 +#define VMASST_TYPE_writable_pagetables  2
   1.905 +
   1.906 +/* x86/PAE guests: support PDPTs above 4GB. */
   1.907 +#define VMASST_TYPE_pae_extended_cr3     3
   1.908 +
   1.909 +#define MAX_VMASST_TYPE                  3
   1.910 +
   1.911 +#ifndef __ASSEMBLY__
   1.912 +
   1.913 +typedef uint16_t domid_t;
   1.914 +
   1.915 +/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
   1.916 +#define DOMID_FIRST_RESERVED (0x7FF0U)
   1.917 +
   1.918 +/* DOMID_SELF is used in certain contexts to refer to oneself. */
   1.919 +#define DOMID_SELF (0x7FF0U)
   1.920 +
   1.921 +/*
   1.922 + * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
   1.923 + * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
   1.924 + * is useful to ensure that no mappings to the OS's own heap are accidentally
   1.925 + * installed. (e.g., in Linux this could cause havoc as reference counts
   1.926 + * aren't adjusted on the I/O-mapping code path).
   1.927 + * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
   1.928 + * be specified by any calling domain.
   1.929 + */
   1.930 +#define DOMID_IO   (0x7FF1U)
   1.931 +
   1.932 +/*
   1.933 + * DOMID_XEN is used to allow privileged domains to map restricted parts of
   1.934 + * Xen's heap space (e.g., the machine_to_phys table).
   1.935 + * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
   1.936 + * the caller is privileged.
   1.937 + */
   1.938 +#define DOMID_XEN  (0x7FF2U)
   1.939 +
   1.940 +/*
   1.941 + * Send an array of these to HYPERVISOR_mmu_update().
   1.942 + * NB. The fields are natural pointer/address size for this architecture.
   1.943 + */
   1.944 +struct mmu_update {
   1.945 +    uint64_t ptr;       /* Machine address of PTE. */
   1.946 +    uint64_t val;       /* New contents of PTE.    */
   1.947 +};
   1.948 +typedef struct mmu_update mmu_update_t;
   1.949 +DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
   1.950 +
   1.951 +/*
   1.952 + * Send an array of these to HYPERVISOR_multicall().
   1.953 + * NB. The fields are natural register size for this architecture.
   1.954 + */
   1.955 +struct multicall_entry {
   1.956 +    xen_ulong_t op, result;
   1.957 +    xen_ulong_t args[6];
   1.958 +};
   1.959 +typedef struct multicall_entry multicall_entry_t;
   1.960 +DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
   1.961 +
   1.962 +/*
   1.963 + * Event channel endpoints per domain:
   1.964 + *  1024 if a long is 32 bits; 4096 if a long is 64 bits.
   1.965 + */
   1.966 +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
   1.967 +
   1.968 +struct vcpu_time_info {
   1.969 +    /*
   1.970 +     * Updates to the following values are preceded and followed by an
   1.971 +     * increment of 'version'. The guest can therefore detect updates by
   1.972 +     * looking for changes to 'version'. If the least-significant bit of
   1.973 +     * the version number is set then an update is in progress and the guest
   1.974 +     * must wait to read a consistent set of values.
   1.975 +     * The correct way to interact with the version number is similar to
   1.976 +     * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
   1.977 +     */
   1.978 +    uint32_t version;
   1.979 +    uint32_t pad0;
   1.980 +    uint64_t tsc_timestamp;   /* TSC at last update of time vals.  */
   1.981 +    uint64_t system_time;     /* Time, in nanosecs, since boot.    */
   1.982 +    /*
   1.983 +     * Current system time:
   1.984 +     *   system_time +
   1.985 +     *   ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
   1.986 +     * CPU frequency (Hz):
   1.987 +     *   ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
   1.988 +     */
   1.989 +    uint32_t tsc_to_system_mul;
   1.990 +    int8_t   tsc_shift;
   1.991 +    int8_t   pad1[3];
   1.992 +}; /* 32 bytes */
   1.993 +typedef struct vcpu_time_info vcpu_time_info_t;
   1.994 +
   1.995 +struct vcpu_info {
   1.996 +    /*
   1.997 +     * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
   1.998 +     * a pending notification for a particular VCPU. It is then cleared 
   1.999 +     * by the guest OS /before/ checking for pending work, thus avoiding
  1.1000 +     * a set-and-check race. Note that the mask is only accessed by Xen
  1.1001 +     * on the CPU that is currently hosting the VCPU. This means that the
  1.1002 +     * pending and mask flags can be updated by the guest without special
  1.1003 +     * synchronisation (i.e., no need for the x86 LOCK prefix).
  1.1004 +     * This may seem suboptimal because if the pending flag is set by
  1.1005 +     * a different CPU then an IPI may be scheduled even when the mask
  1.1006 +     * is set. However, note:
  1.1007 +     *  1. The task of 'interrupt holdoff' is covered by the per-event-
  1.1008 +     *     channel mask bits. A 'noisy' event that is continually being
  1.1009 +     *     triggered can be masked at source at this very precise
  1.1010 +     *     granularity.
  1.1011 +     *  2. The main purpose of the per-VCPU mask is therefore to restrict
  1.1012 +     *     reentrant execution: whether for concurrency control, or to
  1.1013 +     *     prevent unbounded stack usage. Whatever the purpose, we expect
  1.1014 +     *     that the mask will be asserted only for short periods at a time,
  1.1015 +     *     and so the likelihood of a 'spurious' IPI is suitably small.
  1.1016 +     * The mask is read before making an event upcall to the guest: a
  1.1017 +     * non-zero mask therefore guarantees that the VCPU will not receive
  1.1018 +     * an upcall activation. The mask is cleared when the VCPU requests
  1.1019 +     * to block: this avoids wakeup-waiting races.
  1.1020 +     */
  1.1021 +    uint8_t evtchn_upcall_pending;
  1.1022 +    uint8_t evtchn_upcall_mask;
  1.1023 +    xen_ulong_t evtchn_pending_sel;
  1.1024 +#if !defined(__ia64__)
  1.1025 +    struct arch_vcpu_info arch;
  1.1026 +#endif
  1.1027 +    struct vcpu_time_info time;
  1.1028 +}; /* 64 bytes (x86) */
  1.1029 +#ifndef __XEN__
  1.1030 +typedef struct vcpu_info vcpu_info_t;
  1.1031 +#endif
  1.1032 +
  1.1033 +/*
  1.1034 + * Xen/kernel shared data -- pointer provided in start_info.
  1.1035 + *
  1.1036 + * This structure is defined to be both smaller than a page, and the
  1.1037 + * only data on the shared page, but may vary in actual size even within
  1.1038 + * compatible Xen versions; guests should not rely on the size
  1.1039 + * of this structure remaining constant.
  1.1040 + */
  1.1041 +struct shared_info {
  1.1042 +    struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
  1.1043 +
  1.1044 +    /*
  1.1045 +     * A domain can create "event channels" on which it can send and receive
  1.1046 +     * asynchronous event notifications. There are three classes of event that
  1.1047 +     * are delivered by this mechanism:
  1.1048 +     *  1. Bi-directional inter- and intra-domain connections. Domains must
  1.1049 +     *     arrange out-of-band to set up a connection (usually by allocating
  1.1050 +     *     an unbound 'listener' port and avertising that via a storage service
  1.1051 +     *     such as xenstore).
  1.1052 +     *  2. Physical interrupts. A domain with suitable hardware-access
  1.1053 +     *     privileges can bind an event-channel port to a physical interrupt
  1.1054 +     *     source.
  1.1055 +     *  3. Virtual interrupts ('events'). A domain can bind an event-channel
  1.1056 +     *     port to a virtual interrupt source, such as the virtual-timer
  1.1057 +     *     device or the emergency console.
  1.1058 +     * 
  1.1059 +     * Event channels are addressed by a "port index". Each channel is
  1.1060 +     * associated with two bits of information:
  1.1061 +     *  1. PENDING -- notifies the domain that there is a pending notification
  1.1062 +     *     to be processed. This bit is cleared by the guest.
  1.1063 +     *  2. MASK -- if this bit is clear then a 0->1 transition of PENDING
  1.1064 +     *     will cause an asynchronous upcall to be scheduled. This bit is only
  1.1065 +     *     updated by the guest. It is read-only within Xen. If a channel
  1.1066 +     *     becomes pending while the channel is masked then the 'edge' is lost
  1.1067 +     *     (i.e., when the channel is unmasked, the guest must manually handle
  1.1068 +     *     pending notifications as no upcall will be scheduled by Xen).
  1.1069 +     * 
  1.1070 +     * To expedite scanning of pending notifications, any 0->1 pending
  1.1071 +     * transition on an unmasked channel causes a corresponding bit in a
  1.1072 +     * per-vcpu selector word to be set. Each bit in the selector covers a
  1.1073 +     * 'C long' in the PENDING bitfield array.
  1.1074 +     */
  1.1075 +    xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8];
  1.1076 +    xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];
  1.1077 +
  1.1078 +    /*
  1.1079 +     * Wallclock time: updated only by control software. Guests should base
  1.1080 +     * their gettimeofday() syscall on this wallclock-base value.
  1.1081 +     */
  1.1082 +    uint32_t wc_version;      /* Version counter: see vcpu_time_info_t. */
  1.1083 +    uint32_t wc_sec;          /* Secs  00:00:00 UTC, Jan 1, 1970.  */
  1.1084 +    uint32_t wc_nsec;         /* Nsecs 00:00:00 UTC, Jan 1, 1970.  */
  1.1085 +
  1.1086 +    struct arch_shared_info arch;
  1.1087 +
  1.1088 +};
  1.1089 +#ifndef __XEN__
  1.1090 +typedef struct shared_info shared_info_t;
  1.1091 +#endif
  1.1092 +
  1.1093 +/*
  1.1094 + * Start-of-day memory layout:
  1.1095 + *  1. The domain is started within contiguous virtual-memory region.
  1.1096 + *  2. The contiguous region ends on an aligned 4MB boundary.
  1.1097 + *  3. This the order of bootstrap elements in the initial virtual region:
  1.1098 + *      a. relocated kernel image
  1.1099 + *      b. initial ram disk              [mod_start, mod_len]
  1.1100 + *      c. list of allocated page frames [mfn_list, nr_pages]
  1.1101 + *      d. start_info_t structure        [register ESI (x86)]
  1.1102 + *      e. bootstrap page tables         [pt_base, CR3 (x86)]
  1.1103 + *      f. bootstrap stack               [register ESP (x86)]
  1.1104 + *  4. Bootstrap elements are packed together, but each is 4kB-aligned.
  1.1105 + *  5. The initial ram disk may be omitted.
  1.1106 + *  6. The list of page frames forms a contiguous 'pseudo-physical' memory
  1.1107 + *     layout for the domain. In particular, the bootstrap virtual-memory
  1.1108 + *     region is a 1:1 mapping to the first section of the pseudo-physical map.
  1.1109 + *  7. All bootstrap elements are mapped read-writable for the guest OS. The
  1.1110 + *     only exception is the bootstrap page table, which is mapped read-only.
  1.1111 + *  8. There is guaranteed to be at least 512kB padding after the final
  1.1112 + *     bootstrap element. If necessary, the bootstrap virtual region is
  1.1113 + *     extended by an extra 4MB to ensure this.
  1.1114 + */
  1.1115 +
  1.1116 +#define MAX_GUEST_CMDLINE 1024
  1.1117 +struct start_info {
  1.1118 +    /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.    */
  1.1119 +    char magic[32];             /* "xen-<version>-<platform>".            */
  1.1120 +    xen_ulong_t nr_pages;     /* Total pages allocated to this domain.  */
  1.1121 +    xen_ulong_t shared_info;  /* MACHINE address of shared info struct. */
  1.1122 +    uint32_t flags;             /* SIF_xxx flags.                         */
  1.1123 +    xen_pfn_t store_mfn;        /* MACHINE page number of shared page.    */
  1.1124 +    uint32_t store_evtchn;      /* Event channel for store communication. */
  1.1125 +    union {
  1.1126 +        struct {
  1.1127 +            xen_pfn_t mfn;      /* MACHINE page number of console page.   */
  1.1128 +            uint32_t  evtchn;   /* Event channel for console page.        */
  1.1129 +        } domU;
  1.1130 +        struct {
  1.1131 +            uint32_t info_off;  /* Offset of console_info struct.         */
  1.1132 +            uint32_t info_size; /* Size of console_info struct from start.*/
  1.1133 +        } dom0;
  1.1134 +    } console;
  1.1135 +    /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).     */
  1.1136 +    xen_ulong_t pt_base;      /* VIRTUAL address of page directory.     */
  1.1137 +    xen_ulong_t nr_pt_frames; /* Number of bootstrap p.t. frames.       */
  1.1138 +    xen_ulong_t mfn_list;     /* VIRTUAL address of page-frame list.    */
  1.1139 +    xen_ulong_t mod_start;    /* VIRTUAL address of pre-loaded module.  */
  1.1140 +    xen_ulong_t mod_len;      /* Size (bytes) of pre-loaded module.     */
  1.1141 +    int8_t cmd_line[MAX_GUEST_CMDLINE];
  1.1142 +};
  1.1143 +typedef struct start_info start_info_t;
  1.1144 +
  1.1145 +/* New console union for dom0 introduced in 0x00030203. */
  1.1146 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
  1.1147 +#define console_mfn    console.domU.mfn
  1.1148 +#define console_evtchn console.domU.evtchn
  1.1149 +#endif
  1.1150 +
  1.1151 +/* These flags are passed in the 'flags' field of start_info_t. */
  1.1152 +#define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
  1.1153 +#define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
  1.1154 +
  1.1155 +typedef struct dom0_vga_console_info {
  1.1156 +    uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
  1.1157 +#define XEN_VGATYPE_TEXT_MODE_3 0x03
  1.1158 +#define XEN_VGATYPE_VESA_LFB    0x23
  1.1159 +
  1.1160 +    union {
  1.1161 +        struct {
  1.1162 +            /* Font height, in pixels. */
  1.1163 +            uint16_t font_height;
  1.1164 +            /* Cursor location (column, row). */
  1.1165 +            uint16_t cursor_x, cursor_y;
  1.1166 +            /* Number of rows and columns (dimensions in characters). */
  1.1167 +            uint16_t rows, columns;
  1.1168 +        } text_mode_3;
  1.1169 +
  1.1170 +        struct {
  1.1171 +            /* Width and height, in pixels. */
  1.1172 +            uint16_t width, height;
  1.1173 +            /* Bytes per scan line. */
  1.1174 +            uint16_t bytes_per_line;
  1.1175 +            /* Bits per pixel. */
  1.1176 +            uint16_t bits_per_pixel;
  1.1177 +            /* LFB physical address, and size (in units of 64kB). */
  1.1178 +            uint32_t lfb_base;
  1.1179 +            uint32_t lfb_size;
  1.1180 +            /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
  1.1181 +            uint8_t  red_pos, red_size;
  1.1182 +            uint8_t  green_pos, green_size;
  1.1183 +            uint8_t  blue_pos, blue_size;
  1.1184 +            uint8_t  rsvd_pos, rsvd_size;
  1.1185 +        } vesa_lfb;
  1.1186 +    } u;
  1.1187 +} dom0_vga_console_info_t;
  1.1188 +#define xen_vga_console_info dom0_vga_console_info
  1.1189 +#define xen_vga_console_info_t dom0_vga_console_info_t
  1.1190 +
  1.1191 +typedef uint8_t xen_domain_handle_t[16];
  1.1192 +
  1.1193 +/* Turn a plain number into a C xen_ulong_t constant. */
  1.1194 +#define __mk_unsigned_long(x) x ## UL
  1.1195 +#define mk_unsigned_long(x) __mk_unsigned_long(x)
  1.1196 +
  1.1197 +DEFINE_XEN_GUEST_HANDLE(uint8_t);
  1.1198 +DEFINE_XEN_GUEST_HANDLE(uint16_t);
  1.1199 +DEFINE_XEN_GUEST_HANDLE(uint32_t);
  1.1200 +DEFINE_XEN_GUEST_HANDLE(uint64_t);
  1.1201 +
  1.1202 +#else /* __ASSEMBLY__ */
  1.1203 +
  1.1204 +/* In assembly code we cannot use C numeric constant suffixes. */
  1.1205 +#define mk_unsigned_long(x) x
  1.1206 +
  1.1207 +#endif /* !__ASSEMBLY__ */
  1.1208 +
  1.1209 +/* Default definitions for macros used by domctl/sysctl. */
  1.1210 +#if defined(__XEN__) || defined(__XEN_TOOLS__)
  1.1211 +#ifndef uint64_aligned_t
  1.1212 +#define uint64_aligned_t uint64_t
  1.1213 +#endif
  1.1214 +#ifndef XEN_GUEST_HANDLE_64
  1.1215 +#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
  1.1216 +#endif
  1.1217 +#endif
  1.1218 +
  1.1219 +#endif /* __XEN_PUBLIC_XEN_H__ */
  1.1220 +
  1.1221 +/*
  1.1222 + * Local variables:
  1.1223 + * mode: C
  1.1224 + * c-set-style: "BSD"
  1.1225 + * c-basic-offset: 4
  1.1226 + * tab-width: 4
  1.1227 + * indent-tabs-mode: nil
  1.1228 + * End:
  1.1229 + */