/******************************************************************************1* vcpu.h2*3* VCPU initialisation, query, and hotplug.4*5* Permission is hereby granted, free of charge, to any person obtaining a copy6* of this software and associated documentation files (the "Software"), to7* deal in the Software without restriction, including without limitation the8* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or9* sell copies of the Software, and to permit persons to whom the Software is10* furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice shall be included in13* all copies or substantial portions of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE18* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER21* DEALINGS IN THE SOFTWARE.22*23* Copyright (c) 2005, Keir Fraser <[email protected]>24*/2526#ifndef __XEN_PUBLIC_VCPU_H__27#define __XEN_PUBLIC_VCPU_H__2829/*30* Prototype for this hypercall is:31* int vcpu_op(int cmd, int vcpuid, void *extra_args)32* @cmd == VCPUOP_??? (VCPU operation).33* @vcpuid == VCPU to operate on.34* @extra_args == Operation-specific extra arguments (NULL if none).35*/3637/*38* Initialise a VCPU. Each VCPU can be initialised only once. A39* newly-initialised VCPU will not run until it is brought up by VCPUOP_up.40*41* @extra_arg == pointer to vcpu_guest_context structure containing initial42* state for the VCPU.43*/44#define VCPUOP_initialise 04546/*47* Bring up a VCPU. This makes the VCPU runnable. This operation will fail48* if the VCPU has not been initialised (VCPUOP_initialise).49*/50#define VCPUOP_up 15152/*53* Bring down a VCPU (i.e., make it non-runnable).54* There are a few caveats that callers should observe:55* 1. This operation may return, and VCPU_is_up may return false, before the56* VCPU stops running (i.e., the command is asynchronous). It is a good57* idea to ensure that the VCPU has entered a non-critical loop before58* bringing it down. Alternatively, this operation is guaranteed59* synchronous if invoked by the VCPU itself.60* 2. After a VCPU is initialised, there is currently no way to drop all its61* references to domain memory. Even a VCPU that is down still holds62* memory references via its pagetable base pointer and GDT. It is good63* practise to move a VCPU onto an 'idle' or default page table, LDT and64* GDT before bringing it down.65*/66#define VCPUOP_down 26768/* Returns 1 if the given VCPU is up. */69#define VCPUOP_is_up 37071/*72* Return information about the state and running time of a VCPU.73* @extra_arg == pointer to vcpu_runstate_info structure.74*/75#define VCPUOP_get_runstate_info 476struct vcpu_runstate_info {77/* VCPU's current state (RUNSTATE_*). */78int state;79/* When was current state entered (system time, ns)? */80uint64_t state_entry_time;81/*82* Time spent in each RUNSTATE_* (ns). The sum of these times is83* guaranteed not to drift from system time.84*/85uint64_t time[4];86};87DEFINE_GUEST_HANDLE_STRUCT(vcpu_runstate_info);8889/* VCPU is currently running on a physical CPU. */90#define RUNSTATE_running 09192/* VCPU is runnable, but not currently scheduled on any physical CPU. */93#define RUNSTATE_runnable 19495/* VCPU is blocked (a.k.a. idle). It is therefore not runnable. */96#define RUNSTATE_blocked 29798/*99* VCPU is not runnable, but it is not blocked.100* This is a 'catch all' state for things like hotplug and pauses by the101* system administrator (or for critical sections in the hypervisor).102* RUNSTATE_blocked dominates this state (it is the preferred state).103*/104#define RUNSTATE_offline 3105106/*107* Register a shared memory area from which the guest may obtain its own108* runstate information without needing to execute a hypercall.109* Notes:110* 1. The registered address may be virtual or physical, depending on the111* platform. The virtual address should be registered on x86 systems.112* 2. Only one shared area may be registered per VCPU. The shared area is113* updated by the hypervisor each time the VCPU is scheduled. Thus114* runstate.state will always be RUNSTATE_running and115* runstate.state_entry_time will indicate the system time at which the116* VCPU was last scheduled to run.117* @extra_arg == pointer to vcpu_register_runstate_memory_area structure.118*/119#define VCPUOP_register_runstate_memory_area 5120struct vcpu_register_runstate_memory_area {121union {122GUEST_HANDLE(vcpu_runstate_info) h;123struct vcpu_runstate_info *v;124uint64_t p;125} addr;126};127128/*129* Set or stop a VCPU's periodic timer. Every VCPU has one periodic timer130* which can be set via these commands. Periods smaller than one millisecond131* may not be supported.132*/133#define VCPUOP_set_periodic_timer 6 /* arg == vcpu_set_periodic_timer_t */134#define VCPUOP_stop_periodic_timer 7 /* arg == NULL */135struct vcpu_set_periodic_timer {136uint64_t period_ns;137};138DEFINE_GUEST_HANDLE_STRUCT(vcpu_set_periodic_timer);139140/*141* Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot142* timer which can be set via these commands.143*/144#define VCPUOP_set_singleshot_timer 8 /* arg == vcpu_set_singleshot_timer_t */145#define VCPUOP_stop_singleshot_timer 9 /* arg == NULL */146struct vcpu_set_singleshot_timer {147uint64_t timeout_abs_ns;148uint32_t flags; /* VCPU_SSHOTTMR_??? */149};150DEFINE_GUEST_HANDLE_STRUCT(vcpu_set_singleshot_timer);151152/* Flags to VCPUOP_set_singleshot_timer. */153/* Require the timeout to be in the future (return -ETIME if it's passed). */154#define _VCPU_SSHOTTMR_future (0)155#define VCPU_SSHOTTMR_future (1U << _VCPU_SSHOTTMR_future)156157/*158* Register a memory location in the guest address space for the159* vcpu_info structure. This allows the guest to place the vcpu_info160* structure in a convenient place, such as in a per-cpu data area.161* The pointer need not be page aligned, but the structure must not162* cross a page boundary.163*/164#define VCPUOP_register_vcpu_info 10 /* arg == struct vcpu_info */165struct vcpu_register_vcpu_info {166uint64_t mfn; /* mfn of page to place vcpu_info */167uint32_t offset; /* offset within page */168uint32_t rsvd; /* unused */169};170DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_vcpu_info);171172#endif /* __XEN_PUBLIC_VCPU_H__ */173174175