/* SPDX-License-Identifier: MIT */1/******************************************************************************2* sched.h3*4* Scheduler state interactions5*6* Copyright (c) 2005, Keir Fraser <[email protected]>7*/89#ifndef __XEN_PUBLIC_SCHED_H__10#define __XEN_PUBLIC_SCHED_H__1112#include <xen/interface/event_channel.h>1314/*15* Guest Scheduler Operations16*17* The SCHEDOP interface provides mechanisms for a guest to interact18* with the scheduler, including yield, blocking and shutting itself19* down.20*/2122/*23* The prototype for this hypercall is:24* long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...)25*26* @cmd == SCHEDOP_??? (scheduler operation).27* @arg == Operation-specific extra argument(s), as described below.28* ... == Additional Operation-specific extra arguments, described below.29*30* Versions of Xen prior to 3.0.2 provided only the following legacy version31* of this hypercall, supporting only the commands yield, block and shutdown:32* long sched_op(int cmd, unsigned long arg)33* @cmd == SCHEDOP_??? (scheduler operation).34* @arg == 0 (SCHEDOP_yield and SCHEDOP_block)35* == SHUTDOWN_* code (SCHEDOP_shutdown)36*37* This legacy version is available to new guests as:38* long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg)39*/4041/*42* Voluntarily yield the CPU.43* @arg == NULL.44*/45#define SCHEDOP_yield 04647/*48* Block execution of this VCPU until an event is received for processing.49* If called with event upcalls masked, this operation will atomically50* reenable event delivery and check for pending events before blocking the51* VCPU. This avoids a "wakeup waiting" race.52* @arg == NULL.53*/54#define SCHEDOP_block 15556/*57* Halt execution of this domain (all VCPUs) and notify the system controller.58* @arg == pointer to sched_shutdown structure.59*60* If the sched_shutdown_t reason is SHUTDOWN_suspend then61* x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN62* of the guest's start info page. RDX/EDX is the third hypercall63* argument.64*65* In addition, which reason is SHUTDOWN_suspend this hypercall66* returns 1 if suspend was cancelled or the domain was merely67* checkpointed, and 0 if it is resuming in a new domain.68*/69#define SCHEDOP_shutdown 27071/*72* Poll a set of event-channel ports. Return when one or more are pending. An73* optional timeout may be specified.74* @arg == pointer to sched_poll structure.75*/76#define SCHEDOP_poll 37778/*79* Declare a shutdown for another domain. The main use of this function is80* in interpreting shutdown requests and reasons for fully-virtualized81* domains. A para-virtualized domain may use SCHEDOP_shutdown directly.82* @arg == pointer to sched_remote_shutdown structure.83*/84#define SCHEDOP_remote_shutdown 48586/*87* Latch a shutdown code, so that when the domain later shuts down it88* reports this code to the control tools.89* @arg == sched_shutdown, as for SCHEDOP_shutdown.90*/91#define SCHEDOP_shutdown_code 59293/*94* Setup, poke and destroy a domain watchdog timer.95* @arg == pointer to sched_watchdog structure.96* With id == 0, setup a domain watchdog timer to cause domain shutdown97* after timeout, returns watchdog id.98* With id != 0 and timeout == 0, destroy domain watchdog timer.99* With id != 0 and timeout != 0, poke watchdog timer and set new timeout.100*/101#define SCHEDOP_watchdog 6102103/*104* Override the current vcpu affinity by pinning it to one physical cpu or105* undo this override restoring the previous affinity.106* @arg == pointer to sched_pin_override structure.107*108* A negative pcpu value will undo a previous pin override and restore the109* previous cpu affinity.110* This call is allowed for the hardware domain only and requires the cpu111* to be part of the domain's cpupool.112*/113#define SCHEDOP_pin_override 7114115struct sched_shutdown {116unsigned int reason; /* SHUTDOWN_* => shutdown reason */117};118DEFINE_GUEST_HANDLE_STRUCT(sched_shutdown);119120struct sched_poll {121GUEST_HANDLE(evtchn_port_t) ports;122unsigned int nr_ports;123uint64_t timeout;124};125DEFINE_GUEST_HANDLE_STRUCT(sched_poll);126127struct sched_remote_shutdown {128domid_t domain_id; /* Remote domain ID */129unsigned int reason; /* SHUTDOWN_* => shutdown reason */130};131DEFINE_GUEST_HANDLE_STRUCT(sched_remote_shutdown);132133struct sched_watchdog {134uint32_t id; /* watchdog ID */135uint32_t timeout; /* timeout */136};137DEFINE_GUEST_HANDLE_STRUCT(sched_watchdog);138139struct sched_pin_override {140int32_t pcpu;141};142DEFINE_GUEST_HANDLE_STRUCT(sched_pin_override);143144/*145* Reason codes for SCHEDOP_shutdown. These may be interpreted by control146* software to determine the appropriate action. For the most part, Xen does147* not care about the shutdown code.148*/149#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */150#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */151#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */152#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */153#define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */154155/*156* Domain asked to perform 'soft reset' for it. The expected behavior is to157* reset internal Xen state for the domain returning it to the point where it158* was created but leaving the domain's memory contents and vCPU contexts159* intact. This will allow the domain to start over and set up all Xen specific160* interfaces again.161*/162#define SHUTDOWN_soft_reset 5163#define SHUTDOWN_MAX 5 /* Maximum valid shutdown reason. */164165#endif /* __XEN_PUBLIC_SCHED_H__ */166167168