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