1 /******************************************************************************
4 * VCPU initialisation, query, and hotplug.
6 * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
9 #ifndef __XEN_PUBLIC_VCPU_H__
10 #define __XEN_PUBLIC_VCPU_H__
13 * Prototype for this hypercall is:
14 * int vcpu_op(int cmd, int vcpuid, void *extra_args)
15 * @cmd == VCPUOP_??? (VCPU operation).
16 * @vcpuid == VCPU to operate on.
17 * @extra_args == Operation-specific extra arguments (NULL if none).
21 * Initialise a VCPU. Each VCPU can be initialised only once. A
22 * newly-initialised VCPU will not run until it is brought up by VCPUOP_up.
24 * @extra_arg == pointer to vcpu_guest_context structure containing initial
27 #define VCPUOP_initialise 0
30 * Bring up a VCPU. This makes the VCPU runnable. This operation will fail
31 * if the VCPU has not been initialised (VCPUOP_initialise).
36 * Bring down a VCPU (i.e., make it non-runnable).
37 * There are a few caveats that callers should observe:
38 * 1. This operation may return, and VCPU_is_up may return false, before the
39 * VCPU stops running (i.e., the command is asynchronous). It is a good
40 * idea to ensure that the VCPU has entered a non-critical loop before
41 * bringing it down. Alternatively, this operation is guaranteed
42 * synchronous if invoked by the VCPU itself.
43 * 2. After a VCPU is initialised, there is currently no way to drop all its
44 * references to domain memory. Even a VCPU that is down still holds
45 * memory references via its pagetable base pointer and GDT. It is good
46 * practise to move a VCPU onto an 'idle' or default page table, LDT and
47 * GDT before bringing it down.
51 /* Returns 1 if the given VCPU is up. */
52 #define VCPUOP_is_up 3
55 * Return information about the state and running time of a VCPU.
56 * @extra_arg == pointer to vcpu_runstate_info structure.
58 #define VCPUOP_get_runstate_info 4
59 struct vcpu_runstate_info {
60 /* VCPU's current state (RUNSTATE_*). */
62 /* When was current state entered (system time, ns)? */
63 uint64_t state_entry_time;
65 * Time spent in each RUNSTATE_* (ns). The sum of these times is
66 * guaranteed not to drift from system time.
70 typedef struct vcpu_runstate_info vcpu_runstate_info_t;
72 /* VCPU is currently running on a physical CPU. */
73 #define RUNSTATE_running 0
75 /* VCPU is runnable, but not currently scheduled on any physical CPU. */
76 #define RUNSTATE_runnable 1
78 /* VCPU is blocked (a.k.a. idle). It is therefore not runnable. */
79 #define RUNSTATE_blocked 2
82 * VCPU is not runnable, but it is not blocked.
83 * This is a 'catch all' state for things like hotplug and pauses by the
84 * system administrator (or for critical sections in the hypervisor).
85 * RUNSTATE_blocked dominates this state (it is the preferred state).
87 #define RUNSTATE_offline 3
90 * Register a shared memory area from which the guest may obtain its own
91 * runstate information without needing to execute a hypercall.
93 * 1. The registered address may be virtual or physical, depending on the
94 * platform. The virtual address should be registered on x86 systems.
95 * 2. Only one shared area may be registered per VCPU. The shared area is
96 * updated by the hypervisor each time the VCPU is scheduled. Thus
97 * runstate.state will always be RUNSTATE_running and
98 * runstate.state_entry_time will indicate the system time at which the
99 * VCPU was last scheduled to run.
100 * @extra_arg == pointer to vcpu_register_runstate_memory_area structure.
102 #define VCPUOP_register_runstate_memory_area 5
103 struct vcpu_register_runstate_memory_area {
105 struct vcpu_runstate_info *v;
109 typedef struct vcpu_register_runstate_memory_area vcpu_register_runstate_memory_area_t;
111 #endif /* __XEN_PUBLIC_VCPU_H__ */
119 * indent-tabs-mode: nil