1 /* 2 * Copyright (C) 2019 - 2020 Intel Corporation 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #ifndef _UAPI_LINUX_UM_TIMETRAVEL_H 7 #define _UAPI_LINUX_UM_TIMETRAVEL_H 8 #include <linux/types.h> 9 10 /** 11 * struct um_timetravel_msg - UM time travel message 12 * 13 * This is the basic message type, going in both directions. 14 * 15 * This is the message passed between the host (user-mode Linux instance) 16 * and the calendar (the application on the other side of the socket) in 17 * order to implement common scheduling. 18 * 19 * Whenever UML has an event it will request runtime for it from the 20 * calendar, and then wait for its turn until it can run, etc. Note 21 * that it will only ever request the single next runtime, i.e. multiple 22 * REQUEST messages override each other. 23 */ 24 struct um_timetravel_msg { 25 /** 26 * @op: operation value from &enum um_timetravel_ops 27 */ 28 __u32 op; 29 30 /** 31 * @seq: sequence number for the message - shall be reflected in 32 * the ACK response, and should be checked while processing 33 * the response to see if it matches 34 */ 35 __u32 seq; 36 37 /** 38 * @time: time in nanoseconds 39 */ 40 __u64 time; 41 }; 42 43 /** 44 * enum um_timetravel_ops - Operation codes 45 */ 46 enum um_timetravel_ops { 47 /** 48 * @UM_TIMETRAVEL_ACK: response (ACK) to any previous message, 49 * this usually doesn't carry any data in the 'time' field 50 * unless otherwise specified below 51 */ 52 UM_TIMETRAVEL_ACK = 0, 53 54 /** 55 * @UM_TIMETRAVEL_START: initialize the connection, the time 56 * field contains an (arbitrary) ID to possibly be able 57 * to distinguish the connections. 58 */ 59 UM_TIMETRAVEL_START = 1, 60 61 /** 62 * @UM_TIMETRAVEL_REQUEST: request to run at the given time 63 * (host -> calendar) 64 */ 65 UM_TIMETRAVEL_REQUEST = 2, 66 67 /** 68 * @UM_TIMETRAVEL_WAIT: Indicate waiting for the previously requested 69 * runtime, new requests may be made while waiting (e.g. due to 70 * interrupts); the time field is ignored. The calendar must process 71 * this message and later send a %UM_TIMETRAVEL_RUN message when 72 * the host can run again. 73 * (host -> calendar) 74 */ 75 UM_TIMETRAVEL_WAIT = 3, 76 77 /** 78 * @UM_TIMETRAVEL_GET: return the current time from the calendar in the 79 * ACK message, the time in the request message is ignored 80 * (host -> calendar) 81 */ 82 UM_TIMETRAVEL_GET = 4, 83 84 /** 85 * @UM_TIMETRAVEL_UPDATE: time update to the calendar, must be sent e.g. 86 * before kicking an interrupt to another calendar 87 * (host -> calendar) 88 */ 89 UM_TIMETRAVEL_UPDATE = 5, 90 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 /** 99 * @UM_TIMETRAVEL_FREE_UNTIL: Enable free-running until the given time, 100 * this is a message from the calendar telling the host that it can 101 * freely do its own scheduling for anything before the indicated 102 * time. 103 * Note that if a calendar sends this message once, the host may 104 * assume that it will also do so in the future, if it implements 105 * wraparound semantics for the time field. 106 * (calendar -> host) 107 */ 108 UM_TIMETRAVEL_FREE_UNTIL = 7, 109 110 /** 111 * @UM_TIMETRAVEL_GET_TOD: Return time of day, typically used once at 112 * boot by the virtual machines to get a synchronized time from 113 * the simulation. 114 */ 115 UM_TIMETRAVEL_GET_TOD = 8, 116 }; 117 118 #endif /* _UAPI_LINUX_UM_TIMETRAVEL_H */ 119