13a9fd824SRoger Pau Monné /****************************************************************************** 23a9fd824SRoger Pau Monné * sched.h 33a9fd824SRoger Pau Monné * 43a9fd824SRoger Pau Monné * Scheduler state interactions 53a9fd824SRoger Pau Monné * 63a9fd824SRoger Pau Monné * Permission is hereby granted, free of charge, to any person obtaining a copy 73a9fd824SRoger Pau Monné * of this software and associated documentation files (the "Software"), to 83a9fd824SRoger Pau Monné * deal in the Software without restriction, including without limitation the 93a9fd824SRoger Pau Monné * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 103a9fd824SRoger Pau Monné * sell copies of the Software, and to permit persons to whom the Software is 113a9fd824SRoger Pau Monné * furnished to do so, subject to the following conditions: 123a9fd824SRoger Pau Monné * 133a9fd824SRoger Pau Monné * The above copyright notice and this permission notice shall be included in 143a9fd824SRoger Pau Monné * all copies or substantial portions of the Software. 153a9fd824SRoger Pau Monné * 163a9fd824SRoger Pau Monné * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 173a9fd824SRoger Pau Monné * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 183a9fd824SRoger Pau Monné * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 193a9fd824SRoger Pau Monné * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 203a9fd824SRoger Pau Monné * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 213a9fd824SRoger Pau Monné * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 223a9fd824SRoger Pau Monné * DEALINGS IN THE SOFTWARE. 233a9fd824SRoger Pau Monné * 243a9fd824SRoger Pau Monné * Copyright (c) 2005, Keir Fraser <keir@xensource.com> 253a9fd824SRoger Pau Monné */ 263a9fd824SRoger Pau Monné 273a9fd824SRoger Pau Monné #ifndef __XEN_PUBLIC_SCHED_H__ 283a9fd824SRoger Pau Monné #define __XEN_PUBLIC_SCHED_H__ 293a9fd824SRoger Pau Monné 303a9fd824SRoger Pau Monné #include "event_channel.h" 313a9fd824SRoger Pau Monné 323a9fd824SRoger Pau Monné /* 333a9fd824SRoger Pau Monné * `incontents 150 sched Guest Scheduler Operations 343a9fd824SRoger Pau Monné * 353a9fd824SRoger Pau Monné * The SCHEDOP interface provides mechanisms for a guest to interact 363a9fd824SRoger Pau Monné * with the scheduler, including yield, blocking and shutting itself 373a9fd824SRoger Pau Monné * down. 383a9fd824SRoger Pau Monné */ 393a9fd824SRoger Pau Monné 403a9fd824SRoger Pau Monné /* 413a9fd824SRoger Pau Monné * The prototype for this hypercall is: 423a9fd824SRoger Pau Monné * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...) 433a9fd824SRoger Pau Monné * 443a9fd824SRoger Pau Monné * @cmd == SCHEDOP_??? (scheduler operation). 453a9fd824SRoger Pau Monné * @arg == Operation-specific extra argument(s), as described below. 463a9fd824SRoger Pau Monné * ... == Additional Operation-specific extra arguments, described below. 473a9fd824SRoger Pau Monné * 483a9fd824SRoger Pau Monné * Versions of Xen prior to 3.0.2 provided only the following legacy version 493a9fd824SRoger Pau Monné * of this hypercall, supporting only the commands yield, block and shutdown: 503a9fd824SRoger Pau Monné * long sched_op(int cmd, unsigned long arg) 513a9fd824SRoger Pau Monné * @cmd == SCHEDOP_??? (scheduler operation). 523a9fd824SRoger Pau Monné * @arg == 0 (SCHEDOP_yield and SCHEDOP_block) 533a9fd824SRoger Pau Monné * == SHUTDOWN_* code (SCHEDOP_shutdown) 543a9fd824SRoger Pau Monné * 553a9fd824SRoger Pau Monné * This legacy version is available to new guests as: 563a9fd824SRoger Pau Monné * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg) 573a9fd824SRoger Pau Monné */ 583a9fd824SRoger Pau Monné 593a9fd824SRoger Pau Monné /* ` enum sched_op { // SCHEDOP_* => struct sched_* */ 603a9fd824SRoger Pau Monné /* 613a9fd824SRoger Pau Monné * Voluntarily yield the CPU. 623a9fd824SRoger Pau Monné * @arg == NULL. 633a9fd824SRoger Pau Monné */ 643a9fd824SRoger Pau Monné #define SCHEDOP_yield 0 653a9fd824SRoger Pau Monné 663a9fd824SRoger Pau Monné /* 673a9fd824SRoger Pau Monné * Block execution of this VCPU until an event is received for processing. 683a9fd824SRoger Pau Monné * If called with event upcalls masked, this operation will atomically 693a9fd824SRoger Pau Monné * reenable event delivery and check for pending events before blocking the 703a9fd824SRoger Pau Monné * VCPU. This avoids a "wakeup waiting" race. 713a9fd824SRoger Pau Monné * @arg == NULL. 723a9fd824SRoger Pau Monné */ 733a9fd824SRoger Pau Monné #define SCHEDOP_block 1 743a9fd824SRoger Pau Monné 753a9fd824SRoger Pau Monné /* 763a9fd824SRoger Pau Monné * Halt execution of this domain (all VCPUs) and notify the system controller. 773a9fd824SRoger Pau Monné * @arg == pointer to sched_shutdown_t structure. 783a9fd824SRoger Pau Monné * 793a9fd824SRoger Pau Monné * If the sched_shutdown_t reason is SHUTDOWN_suspend then 803a9fd824SRoger Pau Monné * x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN 813a9fd824SRoger Pau Monné * of the guest's start info page. RDX/EDX is the third hypercall 823a9fd824SRoger Pau Monné * argument. 833a9fd824SRoger Pau Monné * 843a9fd824SRoger Pau Monné * In addition, which reason is SHUTDOWN_suspend this hypercall 853a9fd824SRoger Pau Monné * returns 1 if suspend was cancelled or the domain was merely 863a9fd824SRoger Pau Monné * checkpointed, and 0 if it is resuming in a new domain. 873a9fd824SRoger Pau Monné */ 883a9fd824SRoger Pau Monné #define SCHEDOP_shutdown 2 893a9fd824SRoger Pau Monné 903a9fd824SRoger Pau Monné /* 913a9fd824SRoger Pau Monné * Poll a set of event-channel ports. Return when one or more are pending. An 923a9fd824SRoger Pau Monné * optional timeout may be specified. 933a9fd824SRoger Pau Monné * @arg == pointer to sched_poll_t structure. 943a9fd824SRoger Pau Monné */ 953a9fd824SRoger Pau Monné #define SCHEDOP_poll 3 963a9fd824SRoger Pau Monné 973a9fd824SRoger Pau Monné /* 983a9fd824SRoger Pau Monné * Declare a shutdown for another domain. The main use of this function is 993a9fd824SRoger Pau Monné * in interpreting shutdown requests and reasons for fully-virtualized 1003a9fd824SRoger Pau Monné * domains. A para-virtualized domain may use SCHEDOP_shutdown directly. 1013a9fd824SRoger Pau Monné * @arg == pointer to sched_remote_shutdown_t structure. 1023a9fd824SRoger Pau Monné */ 1033a9fd824SRoger Pau Monné #define SCHEDOP_remote_shutdown 4 1043a9fd824SRoger Pau Monné 1053a9fd824SRoger Pau Monné /* 1063a9fd824SRoger Pau Monné * Latch a shutdown code, so that when the domain later shuts down it 1073a9fd824SRoger Pau Monné * reports this code to the control tools. 1083a9fd824SRoger Pau Monné * @arg == sched_shutdown_t, as for SCHEDOP_shutdown. 1093a9fd824SRoger Pau Monné */ 1103a9fd824SRoger Pau Monné #define SCHEDOP_shutdown_code 5 1113a9fd824SRoger Pau Monné 1123a9fd824SRoger Pau Monné /* 1133a9fd824SRoger Pau Monné * Setup, poke and destroy a domain watchdog timer. 1143a9fd824SRoger Pau Monné * @arg == pointer to sched_watchdog_t structure. 1153a9fd824SRoger Pau Monné * With id == 0, setup a domain watchdog timer to cause domain shutdown 1163a9fd824SRoger Pau Monné * after timeout, returns watchdog id. 1173a9fd824SRoger Pau Monné * With id != 0 and timeout == 0, destroy domain watchdog timer. 1183a9fd824SRoger Pau Monné * With id != 0 and timeout != 0, poke watchdog timer and set new timeout. 1193a9fd824SRoger Pau Monné */ 1203a9fd824SRoger Pau Monné #define SCHEDOP_watchdog 6 1213a9fd824SRoger Pau Monné 1223a9fd824SRoger Pau Monné /* 1233a9fd824SRoger Pau Monné * Override the current vcpu affinity by pinning it to one physical cpu or 1243a9fd824SRoger Pau Monné * undo this override restoring the previous affinity. 1253a9fd824SRoger Pau Monné * @arg == pointer to sched_pin_override_t structure. 1263a9fd824SRoger Pau Monné * 1273a9fd824SRoger Pau Monné * A negative pcpu value will undo a previous pin override and restore the 1283a9fd824SRoger Pau Monné * previous cpu affinity. 1293a9fd824SRoger Pau Monné * This call is allowed for the hardware domain only and requires the cpu 1303a9fd824SRoger Pau Monné * to be part of the domain's cpupool. 1313a9fd824SRoger Pau Monné */ 1323a9fd824SRoger Pau Monné #define SCHEDOP_pin_override 7 1333a9fd824SRoger Pau Monné /* ` } */ 1343a9fd824SRoger Pau Monné 1353a9fd824SRoger Pau Monné struct sched_shutdown { 1363a9fd824SRoger Pau Monné unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ 1373a9fd824SRoger Pau Monné }; 1383a9fd824SRoger Pau Monné typedef struct sched_shutdown sched_shutdown_t; 1393a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t); 1403a9fd824SRoger Pau Monné 1413a9fd824SRoger Pau Monné struct sched_poll { 1423a9fd824SRoger Pau Monné XEN_GUEST_HANDLE(evtchn_port_t) ports; 1433a9fd824SRoger Pau Monné unsigned int nr_ports; 1443a9fd824SRoger Pau Monné uint64_t timeout; 1453a9fd824SRoger Pau Monné }; 1463a9fd824SRoger Pau Monné typedef struct sched_poll sched_poll_t; 1473a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(sched_poll_t); 1483a9fd824SRoger Pau Monné 1493a9fd824SRoger Pau Monné struct sched_remote_shutdown { 1503a9fd824SRoger Pau Monné domid_t domain_id; /* Remote domain ID */ 1513a9fd824SRoger Pau Monné unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ 1523a9fd824SRoger Pau Monné }; 1533a9fd824SRoger Pau Monné typedef struct sched_remote_shutdown sched_remote_shutdown_t; 1543a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t); 1553a9fd824SRoger Pau Monné 1563a9fd824SRoger Pau Monné struct sched_watchdog { 1573a9fd824SRoger Pau Monné uint32_t id; /* watchdog ID */ 1583a9fd824SRoger Pau Monné uint32_t timeout; /* timeout */ 1593a9fd824SRoger Pau Monné }; 1603a9fd824SRoger Pau Monné typedef struct sched_watchdog sched_watchdog_t; 1613a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t); 1623a9fd824SRoger Pau Monné 1633a9fd824SRoger Pau Monné struct sched_pin_override { 1643a9fd824SRoger Pau Monné int32_t pcpu; 1653a9fd824SRoger Pau Monné }; 1663a9fd824SRoger Pau Monné typedef struct sched_pin_override sched_pin_override_t; 1673a9fd824SRoger Pau Monné DEFINE_XEN_GUEST_HANDLE(sched_pin_override_t); 1683a9fd824SRoger Pau Monné 1693a9fd824SRoger Pau Monné /* 1703a9fd824SRoger Pau Monné * Reason codes for SCHEDOP_shutdown. These may be interpreted by control 1713a9fd824SRoger Pau Monné * software to determine the appropriate action. For the most part, Xen does 1723a9fd824SRoger Pau Monné * not care about the shutdown code. 1733a9fd824SRoger Pau Monné */ 1743a9fd824SRoger Pau Monné /* ` enum sched_shutdown_reason { */ 1753a9fd824SRoger Pau Monné #define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */ 1763a9fd824SRoger Pau Monné #define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */ 1773a9fd824SRoger Pau Monné #define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */ 1783a9fd824SRoger Pau Monné #define SHUTDOWN_crash 3 /* Tell controller we've crashed. */ 1793a9fd824SRoger Pau Monné #define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */ 1803a9fd824SRoger Pau Monné 1813a9fd824SRoger Pau Monné /* 1823a9fd824SRoger Pau Monné * Domain asked to perform 'soft reset' for it. The expected behavior is to 1833a9fd824SRoger Pau Monné * reset internal Xen state for the domain returning it to the point where it 1843a9fd824SRoger Pau Monné * was created but leaving the domain's memory contents and vCPU contexts 1853a9fd824SRoger Pau Monné * intact. This will allow the domain to start over and set up all Xen specific 1863a9fd824SRoger Pau Monné * interfaces again. 1873a9fd824SRoger Pau Monné */ 1883a9fd824SRoger Pau Monné #define SHUTDOWN_soft_reset 5 1893a9fd824SRoger Pau Monné #define SHUTDOWN_MAX 5 /* Maximum valid shutdown reason. */ 1903a9fd824SRoger Pau Monné /* ` } */ 1913a9fd824SRoger Pau Monné 1923a9fd824SRoger Pau Monné #endif /* __XEN_PUBLIC_SCHED_H__ */ 1933a9fd824SRoger Pau Monné 1943a9fd824SRoger Pau Monné /* 1953a9fd824SRoger Pau Monné * Local variables: 1963a9fd824SRoger Pau Monné * mode: C 1973a9fd824SRoger Pau Monné * c-file-style: "BSD" 1983a9fd824SRoger Pau Monné * c-basic-offset: 4 1993a9fd824SRoger Pau Monné * tab-width: 4 2003a9fd824SRoger Pau Monné * indent-tabs-mode: nil 2013a9fd824SRoger Pau Monné * End: 2023a9fd824SRoger Pau Monné */ 203