aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/public/dom0_ops.h
blob: 3ff82b43aca5164c8ab3e08273ad91f01def9e17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/******************************************************************************
 * dom0_ops.h
 * 
 * Process command requests from domain-0 guest OS.
 * 
 * Copyright (c) 2002-2003, B Dragovic
 * Copyright (c) 2002-2004, K Fraser
 */


#ifndef __XEN_PUBLIC_DOM0_OPS_H__
#define __XEN_PUBLIC_DOM0_OPS_H__

#include "xen.h"
#include "sched_ctl.h"

/*
 * Make sure you increment the interface version whenever you modify this file!
 * This makes sure that old versions of dom0 tools will stop working in a
 * well-defined way (rather than crashing the machine, for instance).
 */
#define DOM0_INTERFACE_VERSION   0xAAAA1006

/************************************************************************/

#define DOM0_GETMEMLIST        2
typedef struct {
    /* IN variables. */
    domid_t       domain;
    memory_t      max_pfns;
    void         *buffer;
    /* OUT variables. */
    memory_t      num_pfns;
} dom0_getmemlist_t;

#define DOM0_SCHEDCTL          6
 /* struct sched_ctl_cmd is from sched-ctl.h   */
typedef struct sched_ctl_cmd dom0_schedctl_t;

#define DOM0_ADJUSTDOM         7
/* struct sched_adjdom_cmd is from sched-ctl.h */
typedef struct sched_adjdom_cmd dom0_adjustdom_t;

#define DOM0_CREATEDOMAIN      8
typedef struct {
    /* IN parameters */
    u32 ssidref;
    /* IN/OUT parameters. */
    /* Identifier for new domain (auto-allocate if zero is specified). */
    domid_t domain;
} dom0_createdomain_t;

#define DOM0_DESTROYDOMAIN     9
typedef struct {
    /* IN variables. */
    domid_t      domain;
} dom0_destroydomain_t;

#define DOM0_PAUSEDOMAIN      10
typedef struct {
    /* IN parameters. */
    domid_t domain;
} dom0_pausedomain_t;

#define DOM0_UNPAUSEDOMAIN    11
typedef struct {
    /* IN parameters. */
    domid_t domain;
} dom0_unpausedomain_t;

#define DOM0_GETDOMAININFO    12
typedef struct {
    /* IN variables. */
    domid_t  domain;                  /* NB. IN/OUT variable. */
    /* OUT variables. */
#define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
#define DOMFLAGS_SHUTDOWN  (1<<2) /* The guest OS has shut down.             */
#define DOMFLAGS_PAUSED    (1<<3) /* Currently paused by control software.   */
#define DOMFLAGS_BLOCKED   (1<<4) /* Currently blocked pending an event.     */
#define DOMFLAGS_RUNNING   (1<<5) /* Domain is currently running.            */
#define DOMFLAGS_CPUMASK      255 /* CPU to which this domain is bound.      */
#define DOMFLAGS_CPUSHIFT       8
#define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code.  */
#define DOMFLAGS_SHUTDOWNSHIFT 16
    u32      flags;
    memory_t tot_pages;
    memory_t max_pages;
    memory_t shared_info_frame;       /* MFN of shared_info struct */
    u64      cpu_time;
    u32      n_vcpu;
    s32      vcpu_to_cpu[MAX_VIRT_CPUS];  /* current mapping   */
    cpumap_t cpumap[MAX_VIRT_CPUS];       /* allowable mapping */
    u32	     ssidref;
} dom0_getdomaininfo_t;

#define DOM0_SETDOMAININFO      13
typedef struct {
    /* IN variables. */
    domid_t                   domain;
    u16                       vcpu;
    /* IN/OUT parameters */
    vcpu_guest_context_t *ctxt;
} dom0_setdomaininfo_t;

#define DOM0_MSR              15
typedef struct {
    /* IN variables. */
    u32 write;
    u32 cpu_mask;
    u32 msr;
    u32 in1;
    u32 in2;
    /* OUT variables. */
    u32 out1;
    u32 out2;
} dom0_msr_t;

#define DOM0_DEBUG            16
typedef struct {
    /* IN variables. */
    domid_t domain;
    u8  opcode;
    u32 in1;
    u32 in2;
    u32 in3;
    u32 in4;
    /* OUT variables. */
    u32 status;
    u32 out1;
    u32 out2;
} dom0_debug_t;

/*
 * Set clock such that it would read <secs,usecs> after 00:00:00 UTC,
 * 1 January, 1970 if the current system time was <system_time>.
 */
#define DOM0_SETTIME          17
typedef struct {
    /* IN variables. */
    u32 secs;
    u32 usecs;
    u64 system_time;
} dom0_settime_t;

#define DOM0_GETPAGEFRAMEINFO 18
#define NOTAB 0         /* normal page */
#define L1TAB (1<<28)
#define L2TAB (2<<28)
#define L3TAB (3<<28)
#define L4TAB (4<<28)
#define LPINTAB  (1<<31)
#define XTAB  (0xf<<28) /* invalid page */
#define LTAB_MASK XTAB
#define LTABTYPE_MASK (0x7<<28)

typedef struct {
    /* IN variables. */
    memory_t pfn;          /* Machine page frame number to query.       */
    domid_t domain;        /* To which domain does the frame belong?    */
    /* OUT variables. */
    /* Is the page PINNED to a type? */
    u32 type;              /* see above type defs */
} dom0_getpageframeinfo_t;

/*
 * Read console content from Xen buffer ring.
 */
#define DOM0_READCONSOLE      19
typedef struct {
    /* IN variables. */
    u32      clear;        /* Non-zero -> clear after reading. */
    /* IN/OUT variables. */
    char    *buffer;       /* In: Buffer start; Out: Used buffer start */
    u32      count;        /* In: Buffer size;  Out: Used buffer size  */
} dom0_readconsole_t;

/* 
 * Set which physical cpus a vcpu can execute on.
 */
#define DOM0_PINCPUDOMAIN     20
typedef struct {
    /* IN variables. */
    domid_t      domain;
    u16          vcpu;
    cpumap_t     *cpumap;
} dom0_pincpudomain_t;

/* Get trace buffers machine base address */
#define DOM0_TBUFCONTROL       21
typedef struct {
    /* IN variables */
#define DOM0_TBUF_GET_INFO     0
#define DOM0_TBUF_SET_CPU_MASK 1
#define DOM0_TBUF_SET_EVT_MASK 2
    u8 op;
    /* IN/OUT variables */
    unsigned long cpu_mask;
    u32           evt_mask;
    /* OUT variables */
    memory_t mach_addr;
    u32      size;
} dom0_tbufcontrol_t;

/*
 * Get physical information about the host machine
 */
#define DOM0_PHYSINFO         22
typedef struct {
    u32      ht_per_core;
    u32      cores;
    u32      cpu_khz;
    memory_t total_pages;
    memory_t free_pages;
} dom0_physinfo_t;

/*
 * Get the ID of the current scheduler.
 */
#define DOM0_SCHED_ID        24
typedef struct {
    /* OUT variable */
    u32 sched_id;
} dom0_sched_id_t;

/* 
 * Control shadow pagetables operation
 */
#define DOM0_SHADOW_CONTROL  25

#define DOM0_SHADOW_CONTROL_OP_OFF         0
#define DOM0_SHADOW_CONTROL_OP_ENABLE_TEST 1
#define DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY 2
#define DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE 3

#define DOM0_SHADOW_CONTROL_OP_FLUSH       10     /* table ops */
#define DOM0_SHADOW_CONTROL_OP_CLEAN       11
#define DOM0_SHADOW_CONTROL_OP_PEEK        12

typedef struct dom0_shadow_control
{
    u32 fault_count;
    u32 dirty_count;
    u32 dirty_net_count;     
    u32 dirty_block_count;     
} dom0_shadow_control_stats_t;

typedef struct {
    /* IN variables. */
    domid_t        domain;
    u32            op;
    unsigned long *dirty_bitmap; /* pointer to locked buffer */
    /* IN/OUT variables. */
    memory_t       pages;        /* size of buffer, updated with actual size */
    /* OUT variables. */
    dom0_shadow_control_stats_t stats;
} dom0_shadow_control_t;

#define DOM0_SETDOMAINMAXMEM   28
typedef struct {
    /* IN variables. */
    domid_t     domain;
    memory_t    max_memkb;
} dom0_setdomainmaxmem_t;

#define DOM0_GETPAGEFRAMEINFO2 29   /* batched interface */
typedef struct {
    /* IN variables. */
    domid_t  domain;
    memory_t num;
    /* IN/OUT variables. */
    unsigned long *array;
} dom0_getpageframeinfo2_t;

/*
 * Request memory range (@pfn, @pfn+@nr_pfns-1) to have type @type.
 * On x86, @type is an architecture-defined MTRR memory type.
 * On success, returns the MTRR that was used (@reg) and a handle that can
 * be passed to DOM0_DEL_MEMTYPE to accurately tear down the new setting.
 * (x86-specific).
 */
#define DOM0_ADD_MEMTYPE         31
typedef struct {
    /* IN variables. */
    memory_t pfn;
    memory_t nr_pfns;
    u32      type;
    /* OUT variables. */
    u32      handle;
    u32      reg;
} dom0_add_memtype_t;

/*
 * Tear down an existing memory-range type. If @handle is remembered then it
 * should be passed in to accurately tear down the correct setting (in case
 * of overlapping memory regions with differing types). If it is not known
 * then @handle should be set to zero. In all cases @reg must be set.
 * (x86-specific).
 */
#define DOM0_DEL_MEMTYPE         32
typedef struct {
    /* IN variables. */
    u32      handle;
    u32      reg;
} dom0_del_memtype_t;

/* Read current type of an MTRR (x86-specific). */
#define DOM0_READ_MEMTYPE        33
typedef struct {
    /* IN variables. */
    u32      reg;
    /* OUT variables. */
    memory_t pfn;
    memory_t nr_pfns;
    u32      type;
} dom0_read_memtype_t;

/* Interface for controlling Xen software performance counters. */
#define DOM0_PERFCCONTROL        34
/* Sub-operations: */
#define DOM0_PERFCCONTROL_OP_RESET 1   /* Reset all counters to zero. */
#define DOM0_PERFCCONTROL_OP_QUERY 2   /* Get perfctr information. */
typedef struct {
    u8      name[80];               /*  name of perf counter */
    u32     nr_vals;                /* number of values for this counter */
    u32     vals[64];               /* array of values */
} dom0_perfc_desc_t;
typedef struct {
    /* IN variables. */
    u32            op;                /*  DOM0_PERFCCONTROL_OP_??? */
    /* OUT variables. */
    u32            nr_counters;       /*  number of counters */
    dom0_perfc_desc_t *desc;          /*  counter information (or NULL) */
} dom0_perfccontrol_t;

#define DOM0_MICROCODE           35
typedef struct {
    /* IN variables. */
    void   *data;                     /* Pointer to microcode data */
    u32     length;                   /* Length of microcode data. */
} dom0_microcode_t;

#define DOM0_IOPORT_PERMISSION   36
typedef struct {
    domid_t domain;                   /* domain to be affected */
    u16     first_port;               /* first port int range */
    u16     nr_ports;                 /* size of port range */
    u16     allow_access;             /* allow or deny access to range? */
} dom0_ioport_permission_t;

#define DOM0_GETVCPUCONTEXT      37
typedef struct {
    domid_t domain;                   /* domain to be affected */
    u16     vcpu;                     /* vcpu # */
    vcpu_guest_context_t *ctxt;       /* NB. IN/OUT variable. */
    u64     cpu_time;                 
} dom0_getvcpucontext_t;

typedef struct {
    u32 cmd;
    u32 interface_version; /* DOM0_INTERFACE_VERSION */
    union {
        dom0_createdomain_t      createdomain;
        dom0_pausedomain_t       pausedomain;
        dom0_unpausedomain_t     unpausedomain;
        dom0_destroydomain_t     destroydomain;
        dom0_getmemlist_t        getmemlist;
        dom0_schedctl_t          schedctl;
        dom0_adjustdom_t         adjustdom;
        dom0_setdomaininfo_t     setdomaininfo;
        dom0_getdomaininfo_t     getdomaininfo;
        dom0_getpageframeinfo_t  getpageframeinfo;
        dom0_msr_t               msr;
        dom0_debug_t             debug;
        dom0_settime_t           settime;
        dom0_readconsole_t       readconsole;
        dom0_pincpudomain_t      pincpudomain;
        dom0_tbufcontrol_t       tbufcontrol;
        dom0_physinfo_t          physinfo;
        dom0_sched_id_t          sched_id;
        dom0_shadow_control_t    shadow_control;
        dom0_setdomainmaxmem_t   setdomainmaxmem;
        dom0_getpageframeinfo2_t getpageframeinfo2;
        dom0_add_memtype_t       add_memtype;
        dom0_del_memtype_t       del_memtype;
        dom0_read_memtype_t      read_memtype;
        dom0_perfccontrol_t      perfccontrol;
        dom0_microcode_t         microcode;
        dom0_ioport_permission_t ioport_permission;
        dom0_getvcpucontext_t    getvcpucontext;
    } u;
} dom0_op_t;

#endif /* __XEN_PUBLIC_DOM0_OPS_H__ */