sched.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* SPDX-License-Identifier: MIT
  2. *
  3. * sched.h
  4. *
  5. * Scheduler state interactions
  6. *
  7. * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
  8. */
  9. #ifndef __XEN_PUBLIC_SCHED_H__
  10. #define __XEN_PUBLIC_SCHED_H__
  11. #include <xen/interface/event_channel.h>
  12. /*
  13. * Guest Scheduler Operations
  14. *
  15. * The SCHEDOP interface provides mechanisms for a guest to interact
  16. * with the scheduler, including yield, blocking and shutting itself
  17. * down.
  18. */
  19. /*
  20. * The prototype for this hypercall is:
  21. * long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...)
  22. *
  23. * @cmd == SCHEDOP_??? (scheduler operation).
  24. * @arg == Operation-specific extra argument(s), as described below.
  25. * ... == Additional Operation-specific extra arguments, described below.
  26. *
  27. * Versions of Xen prior to 3.0.2 provided only the following legacy version
  28. * of this hypercall, supporting only the commands yield, block and shutdown:
  29. * long sched_op(int cmd, unsigned long arg)
  30. * @cmd == SCHEDOP_??? (scheduler operation).
  31. * @arg == 0 (SCHEDOP_yield and SCHEDOP_block)
  32. * == SHUTDOWN_* code (SCHEDOP_shutdown)
  33. *
  34. * This legacy version is available to new guests as:
  35. * long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg)
  36. */
  37. /*
  38. * Voluntarily yield the CPU.
  39. * @arg == NULL.
  40. */
  41. #define SCHEDOP_yield 0
  42. /*
  43. * Block execution of this VCPU until an event is received for processing.
  44. * If called with event upcalls masked, this operation will atomically
  45. * reenable event delivery and check for pending events before blocking the
  46. * VCPU. This avoids a "wakeup waiting" race.
  47. * @arg == NULL.
  48. */
  49. #define SCHEDOP_block 1
  50. /*
  51. * Halt execution of this domain (all VCPUs) and notify the system controller.
  52. * @arg == pointer to sched_shutdown structure.
  53. *
  54. * If the sched_shutdown_t reason is SHUTDOWN_suspend then
  55. * x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN
  56. * of the guest's start info page. RDX/EDX is the third hypercall
  57. * argument.
  58. *
  59. * In addition, which reason is SHUTDOWN_suspend this hypercall
  60. * returns 1 if suspend was cancelled or the domain was merely
  61. * checkpointed, and 0 if it is resuming in a new domain.
  62. */
  63. #define SCHEDOP_shutdown 2
  64. /*
  65. * Poll a set of event-channel ports. Return when one or more are pending. An
  66. * optional timeout may be specified.
  67. * @arg == pointer to sched_poll structure.
  68. */
  69. #define SCHEDOP_poll 3
  70. /*
  71. * Declare a shutdown for another domain. The main use of this function is
  72. * in interpreting shutdown requests and reasons for fully-virtualized
  73. * domains. A para-virtualized domain may use SCHEDOP_shutdown directly.
  74. * @arg == pointer to sched_remote_shutdown structure.
  75. */
  76. #define SCHEDOP_remote_shutdown 4
  77. /*
  78. * Latch a shutdown code, so that when the domain later shuts down it
  79. * reports this code to the control tools.
  80. * @arg == sched_shutdown, as for SCHEDOP_shutdown.
  81. */
  82. #define SCHEDOP_shutdown_code 5
  83. /*
  84. * Setup, poke and destroy a domain watchdog timer.
  85. * @arg == pointer to sched_watchdog structure.
  86. * With id == 0, setup a domain watchdog timer to cause domain shutdown
  87. * after timeout, returns watchdog id.
  88. * With id != 0 and timeout == 0, destroy domain watchdog timer.
  89. * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
  90. */
  91. #define SCHEDOP_watchdog 6
  92. /*
  93. * Override the current vcpu affinity by pinning it to one physical cpu or
  94. * undo this override restoring the previous affinity.
  95. * @arg == pointer to sched_pin_override structure.
  96. *
  97. * A negative pcpu value will undo a previous pin override and restore the
  98. * previous cpu affinity.
  99. * This call is allowed for the hardware domain only and requires the cpu
  100. * to be part of the domain's cpupool.
  101. */
  102. #define SCHEDOP_pin_override 7
  103. struct sched_shutdown {
  104. unsigned int reason; /* SHUTDOWN_* => shutdown reason */
  105. };
  106. DEFINE_GUEST_HANDLE_STRUCT(sched_shutdown);
  107. struct sched_poll {
  108. GUEST_HANDLE(evtchn_port_t)ports;
  109. unsigned int nr_ports;
  110. u64 timeout;
  111. };
  112. DEFINE_GUEST_HANDLE_STRUCT(sched_poll);
  113. struct sched_remote_shutdown {
  114. domid_t domain_id; /* Remote domain ID */
  115. unsigned int reason; /* SHUTDOWN_* => shutdown reason */
  116. };
  117. DEFINE_GUEST_HANDLE_STRUCT(sched_remote_shutdown);
  118. struct sched_watchdog {
  119. u32 id; /* watchdog ID */
  120. u32 timeout; /* timeout */
  121. };
  122. DEFINE_GUEST_HANDLE_STRUCT(sched_watchdog);
  123. struct sched_pin_override {
  124. s32 pcpu;
  125. };
  126. DEFINE_GUEST_HANDLE_STRUCT(sched_pin_override);
  127. /*
  128. * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
  129. * software to determine the appropriate action. For the most part, Xen does
  130. * not care about the shutdown code.
  131. */
  132. #define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
  133. #define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
  134. #define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
  135. #define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
  136. #define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */
  137. /*
  138. * Domain asked to perform 'soft reset' for it. The expected behavior is to
  139. * reset internal Xen state for the domain returning it to the point where it
  140. * was created but leaving the domain's memory contents and vCPU contexts
  141. * intact. This will allow the domain to start over and set up all Xen specific
  142. * interfaces again.
  143. */
  144. #define SHUTDOWN_soft_reset 5
  145. #define SHUTDOWN_MAX 5 /* Maximum valid shutdown reason. */
  146. #endif /* __XEN_PUBLIC_SCHED_H__ */