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