1 /* $NetBSD: vcpu.h,v 1.5 2007/10/17 19:58:31 garbled Exp $ */
2 /******************************************************************************
5 * VCPU initialisation, query, and hotplug.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
28 #ifndef __XEN_PUBLIC_VCPU_H__
29 #define __XEN_PUBLIC_VCPU_H__
32 * Prototype for this hypercall is:
33 * int vcpu_op(int cmd, int vcpuid, void *extra_args)
34 * @cmd == VCPUOP_??? (VCPU operation).
35 * @vcpuid == VCPU to operate on.
36 * @extra_args == Operation-specific extra arguments (NULL if none).
40 * Initialise a VCPU. Each VCPU can be initialised only once. A
41 * newly-initialised VCPU will not run until it is brought up by VCPUOP_up.
43 * @extra_arg == pointer to vcpu_guest_context structure containing initial
46 #define VCPUOP_initialise 0
49 * Bring up a VCPU. This makes the VCPU runnable. This operation will fail
50 * if the VCPU has not been initialised (VCPUOP_initialise).
55 * Bring down a VCPU (i.e., make it non-runnable).
56 * There are a few caveats that callers should observe:
57 * 1. This operation may return, and VCPU_is_up may return false, before the
58 * VCPU stops running (i.e., the command is asynchronous). It is a good
59 * idea to ensure that the VCPU has entered a non-critical loop before
60 * bringing it down. Alternatively, this operation is guaranteed
61 * synchronous if invoked by the VCPU itself.
62 * 2. After a VCPU is initialised, there is currently no way to drop all its
63 * references to domain memory. Even a VCPU that is down still holds
64 * memory references via its pagetable base pointer and GDT. It is good
65 * practise to move a VCPU onto an 'idle' or default page table, LDT and
66 * GDT before bringing it down.
70 /* Returns 1 if the given VCPU is up. */
71 #define VCPUOP_is_up 3
74 * Return information about the state and running time of a VCPU.
75 * @extra_arg == pointer to vcpu_runstate_info structure.
77 #define VCPUOP_get_runstate_info 4
78 struct vcpu_runstate_info
{
79 /* VCPU's current state (RUNSTATE_*). */
81 /* When was current state entered (system time, ns)? */
82 uint64_t state_entry_time
;
84 * Time spent in each RUNSTATE_* (ns). The sum of these times is
85 * guaranteed not to drift from system time.
89 typedef struct vcpu_runstate_info vcpu_runstate_info_t
;
90 DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_t
);
92 /* VCPU is currently running on a physical CPU. */
93 #define RUNSTATE_running 0
95 /* VCPU is runnable, but not currently scheduled on any physical CPU. */
96 #define RUNSTATE_runnable 1
98 /* VCPU is blocked (a.k.a. idle). It is therefore not runnable. */
99 #define RUNSTATE_blocked 2
102 * VCPU is not runnable, but it is not blocked.
103 * This is a 'catch all' state for things like hotplug and pauses by the
104 * system administrator (or for critical sections in the hypervisor).
105 * RUNSTATE_blocked dominates this state (it is the preferred state).
107 #define RUNSTATE_offline 3
110 * Register a shared memory area from which the guest may obtain its own
111 * runstate information without needing to execute a hypercall.
113 * 1. The registered address may be virtual or physical or guest handle,
114 * depending on the platform. Virtual address or guest handle should be
115 * registered on x86 systems.
116 * 2. Only one shared area may be registered per VCPU. The shared area is
117 * updated by the hypervisor each time the VCPU is scheduled. Thus
118 * runstate.state will always be RUNSTATE_running and
119 * runstate.state_entry_time will indicate the system time at which the
120 * VCPU was last scheduled to run.
121 * @extra_arg == pointer to vcpu_register_runstate_memory_area structure.
123 #define VCPUOP_register_runstate_memory_area 5
124 struct vcpu_register_runstate_memory_area
{
126 XEN_GUEST_HANDLE(vcpu_runstate_info_t
) h
;
127 struct vcpu_runstate_info
*v
;
131 typedef struct vcpu_register_runstate_memory_area vcpu_register_runstate_memory_area_t
;
132 DEFINE_XEN_GUEST_HANDLE(vcpu_register_runstate_memory_area_t
);
135 * Set or stop a VCPU's periodic timer. Every VCPU has one periodic timer
136 * which can be set via these commands. Periods smaller than one millisecond
137 * may not be supported.
139 #define VCPUOP_set_periodic_timer 6 /* arg == vcpu_set_periodic_timer_t */
140 #define VCPUOP_stop_periodic_timer 7 /* arg == NULL */
141 struct vcpu_set_periodic_timer
{
144 typedef struct vcpu_set_periodic_timer vcpu_set_periodic_timer_t
;
145 DEFINE_XEN_GUEST_HANDLE(vcpu_set_periodic_timer_t
);
148 * Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot
149 * timer which can be set via these commands.
151 #define VCPUOP_set_singleshot_timer 8 /* arg == vcpu_set_singleshot_timer_t */
152 #define VCPUOP_stop_singleshot_timer 9 /* arg == NULL */
153 struct vcpu_set_singleshot_timer
{
154 uint64_t timeout_abs_ns
; /* Absolute system time value in nanoseconds. */
155 uint32_t flags
; /* VCPU_SSHOTTMR_??? */
157 typedef struct vcpu_set_singleshot_timer vcpu_set_singleshot_timer_t
;
158 DEFINE_XEN_GUEST_HANDLE(vcpu_set_singleshot_timer_t
);
160 /* Flags to VCPUOP_set_singleshot_timer. */
161 /* Require the timeout to be in the future (return -ETIME if it's passed). */
162 #define _VCPU_SSHOTTMR_future (0)
163 #define VCPU_SSHOTTMR_future (1U << _VCPU_SSHOTTMR_future)
166 * Register a memory location in the guest address space for the
167 * vcpu_info structure. This allows the guest to place the vcpu_info
168 * structure in a convenient place, such as in a per-cpu data area.
169 * The pointer need not be page aligned, but the structure must not
170 * cross a page boundary.
172 * This may be called only once per vcpu.
174 #define VCPUOP_register_vcpu_info 10 /* arg == vcpu_register_vcpu_info_t */
175 struct vcpu_register_vcpu_info
{
176 uint64_t mfn
; /* mfn of page to place vcpu_info */
177 uint32_t offset
; /* offset within page */
178 uint32_t rsvd
; /* unused */
180 typedef struct vcpu_register_vcpu_info vcpu_register_vcpu_info_t
;
181 DEFINE_XEN_GUEST_HANDLE(vcpu_register_vcpu_info_t
);
183 /* Send an NMI to the specified VCPU. @extra_arg == NULL. */
184 #define VCPUOP_send_nmi 11
187 * Get the physical ID information for a pinned vcpu's underlying physical
188 * processor. The physical ID informmation is architecture-specific.
189 * On x86: id[31:0]=apic_id, id[63:32]=acpi_id, and all values 0xff and
190 * greater are reserved.
191 * This command returns -EINVAL if it is not a valid operation for this VCPU.
193 #define VCPUOP_get_physid 12 /* arg == vcpu_get_physid_t */
194 struct vcpu_get_physid
{
197 typedef struct vcpu_get_physid vcpu_get_physid_t
;
198 DEFINE_XEN_GUEST_HANDLE(vcpu_get_physid_t
);
199 #define xen_vcpu_physid_to_x86_apicid(physid) \
200 ((((uint32_t)(physid)) >= 0xff) ? 0xff : ((uint8_t)(physid)))
201 #define xen_vcpu_physid_to_x86_acpiid(physid) \
202 ((((uint32_t)((physid)>>32)) >= 0xff) ? 0xff : ((uint8_t)((physid)>>32)))
204 #endif /* __XEN_PUBLIC_VCPU_H__ */
212 * indent-tabs-mode: nil