um_timetravel.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Permission to use, copy, modify, and/or distribute this software for any
  3. * purpose with or without fee is hereby granted, provided that the above
  4. * copyright notice and this permission notice appear in all copies.
  5. *
  6. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. *
  14. * Copyright (C) 2019 Intel Corporation
  15. */
  16. #ifndef _LINUX_UM_TIMETRAVEL_H
  17. #define _LINUX_UM_TIMETRAVEL_H
  18. #include <linux/types.h>
  19. /**
  20. * struct um_timetravel_msg - UM time travel message
  21. *
  22. * This is the basic message type, going in both directions.
  23. *
  24. * This is the message passed between the host (user-mode Linux instance)
  25. * and the calendar (the application on the other side of the socket) in
  26. * order to implement common scheduling.
  27. *
  28. * Whenever UML has an event it will request runtime for it from the
  29. * calendar, and then wait for its turn until it can run, etc. Note
  30. * that it will only ever request the single next runtime, i.e. multiple
  31. * REQUEST messages override each other.
  32. */
  33. struct um_timetravel_msg {
  34. /**
  35. * @op: operation value from &enum um_timetravel_ops
  36. */
  37. __u32 op;
  38. /**
  39. * @seq: sequence number for the message - shall be reflected in
  40. * the ACK response, and should be checked while processing
  41. * the response to see if it matches
  42. */
  43. __u32 seq;
  44. /**
  45. * @time: time in nanoseconds
  46. */
  47. __u64 time;
  48. };
  49. /**
  50. * enum um_timetravel_ops - Operation codes
  51. */
  52. enum um_timetravel_ops {
  53. /**
  54. * @UM_TIMETRAVEL_ACK: response (ACK) to any previous message,
  55. * this usually doesn't carry any data in the 'time' field
  56. * unless otherwise specified below
  57. */
  58. UM_TIMETRAVEL_ACK = 0,
  59. /**
  60. * @UM_TIMETRAVEL_START: initialize the connection, the time
  61. * field contains an (arbitrary) ID to possibly be able
  62. * to distinguish the connections.
  63. */
  64. UM_TIMETRAVEL_START = 1,
  65. /**
  66. * @UM_TIMETRAVEL_REQUEST: request to run at the given time
  67. * (host -> calendar)
  68. */
  69. UM_TIMETRAVEL_REQUEST = 2,
  70. /**
  71. * @UM_TIMETRAVEL_WAIT: Indicate waiting for the previously requested
  72. * runtime, new requests may be made while waiting (e.g. due to
  73. * interrupts); the time field is ignored. The calendar must process
  74. * this message and later send a %UM_TIMETRAVEL_RUN message when
  75. * the host can run again.
  76. * (host -> calendar)
  77. */
  78. UM_TIMETRAVEL_WAIT = 3,
  79. /**
  80. * @UM_TIMETRAVEL_GET: return the current time from the calendar in the
  81. * ACK message, the time in the request message is ignored
  82. * (host -> calendar)
  83. */
  84. UM_TIMETRAVEL_GET = 4,
  85. /**
  86. * @UM_TIMETRAVEL_UPDATE: time update to the calendar, must be sent e.g.
  87. * before kicking an interrupt to another calendar
  88. * (host -> calendar)
  89. */
  90. UM_TIMETRAVEL_UPDATE = 5,
  91. /**
  92. * @UM_TIMETRAVEL_RUN: run time request granted, current time is in
  93. * the time field
  94. * (calendar -> host)
  95. */
  96. UM_TIMETRAVEL_RUN = 6,
  97. /**
  98. * @UM_TIMETRAVEL_FREE_UNTIL: Enable free-running until the given time,
  99. * this is a message from the calendar telling the host that it can
  100. * freely do its own scheduling for anything before the indicated
  101. * time.
  102. * Note that if a calendar sends this message once, the host may
  103. * assume that it will also do so in the future, if it implements
  104. * wraparound semantics for the time field.
  105. * (calendar -> host)
  106. */
  107. UM_TIMETRAVEL_FREE_UNTIL = 7,
  108. /**
  109. * @UM_TIMETRAVEL_GET_TOD: Return time of day, typically used once at
  110. * boot by the virtual machines to get a synchronized time from
  111. * the simulation.
  112. */
  113. UM_TIMETRAVEL_GET_TOD = 8,
  114. };
  115. #endif /* _LINUX_UM_TIMETRAVEL_H */