~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/public/arch-x86/hvm/save.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Structure definitions for HVM state that is held by Xen and must
 
3
 * be saved along with the domain's memory and device-model state.
 
4
 * 
 
5
 * Copyright (c) 2007 XenSource Ltd.
 
6
 *
 
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
8
 * of this software and associated documentation files (the "Software"), to
 
9
 * deal in the Software without restriction, including without limitation the
 
10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 
11
 * sell copies of the Software, and to permit persons to whom the Software is
 
12
 * furnished to do so, subject to the following conditions:
 
13
 *
 
14
 * The above copyright notice and this permission notice shall be included in
 
15
 * all copies or substantial portions of the Software.
 
16
 *
 
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
23
 * DEALINGS IN THE SOFTWARE.
 
24
 */
 
25
 
 
26
#ifndef __XEN_PUBLIC_HVM_SAVE_X86_H__
 
27
#define __XEN_PUBLIC_HVM_SAVE_X86_H__
 
28
 
 
29
/* 
 
30
 * Save/restore header: general info about the save file. 
 
31
 */
 
32
 
 
33
#define HVM_FILE_MAGIC   0x54381286
 
34
#define HVM_FILE_VERSION 0x00000001
 
35
 
 
36
struct hvm_save_header {
 
37
    uint32_t magic;             /* Must be HVM_FILE_MAGIC */
 
38
    uint32_t version;           /* File format version */
 
39
    uint64_t changeset;         /* Version of Xen that saved this file */
 
40
    uint32_t cpuid;             /* CPUID[0x01][%eax] on the saving machine */
 
41
    uint32_t gtsc_khz;        /* Guest's TSC frequency in kHz */
 
42
};
 
43
 
 
44
DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);
 
45
 
 
46
 
 
47
/*
 
48
 * Processor
 
49
 */
 
50
 
 
51
struct hvm_hw_cpu {
 
52
    uint8_t  fpu_regs[512];
 
53
 
 
54
    uint64_t rax;
 
55
    uint64_t rbx;
 
56
    uint64_t rcx;
 
57
    uint64_t rdx;
 
58
    uint64_t rbp;
 
59
    uint64_t rsi;
 
60
    uint64_t rdi;
 
61
    uint64_t rsp;
 
62
    uint64_t r8;
 
63
    uint64_t r9;
 
64
    uint64_t r10;
 
65
    uint64_t r11;
 
66
    uint64_t r12;
 
67
    uint64_t r13;
 
68
    uint64_t r14;
 
69
    uint64_t r15;
 
70
 
 
71
    uint64_t rip;
 
72
    uint64_t rflags;
 
73
 
 
74
    uint64_t cr0;
 
75
    uint64_t cr2;
 
76
    uint64_t cr3;
 
77
    uint64_t cr4;
 
78
 
 
79
    uint64_t dr0;
 
80
    uint64_t dr1;
 
81
    uint64_t dr2;
 
82
    uint64_t dr3;
 
83
    uint64_t dr6;
 
84
    uint64_t dr7;    
 
85
 
 
86
    uint32_t cs_sel;
 
87
    uint32_t ds_sel;
 
88
    uint32_t es_sel;
 
89
    uint32_t fs_sel;
 
90
    uint32_t gs_sel;
 
91
    uint32_t ss_sel;
 
92
    uint32_t tr_sel;
 
93
    uint32_t ldtr_sel;
 
94
 
 
95
    uint32_t cs_limit;
 
96
    uint32_t ds_limit;
 
97
    uint32_t es_limit;
 
98
    uint32_t fs_limit;
 
99
    uint32_t gs_limit;
 
100
    uint32_t ss_limit;
 
101
    uint32_t tr_limit;
 
102
    uint32_t ldtr_limit;
 
103
    uint32_t idtr_limit;
 
104
    uint32_t gdtr_limit;
 
105
 
 
106
    uint64_t cs_base;
 
107
    uint64_t ds_base;
 
108
    uint64_t es_base;
 
109
    uint64_t fs_base;
 
110
    uint64_t gs_base;
 
111
    uint64_t ss_base;
 
112
    uint64_t tr_base;
 
113
    uint64_t ldtr_base;
 
114
    uint64_t idtr_base;
 
115
    uint64_t gdtr_base;
 
116
 
 
117
    uint32_t cs_arbytes;
 
118
    uint32_t ds_arbytes;
 
119
    uint32_t es_arbytes;
 
120
    uint32_t fs_arbytes;
 
121
    uint32_t gs_arbytes;
 
122
    uint32_t ss_arbytes;
 
123
    uint32_t tr_arbytes;
 
124
    uint32_t ldtr_arbytes;
 
125
 
 
126
    uint64_t sysenter_cs;
 
127
    uint64_t sysenter_esp;
 
128
    uint64_t sysenter_eip;
 
129
 
 
130
    /* msr for em64t */
 
131
    uint64_t shadow_gs;
 
132
 
 
133
    /* msr content saved/restored. */
 
134
    uint64_t msr_flags;
 
135
    uint64_t msr_lstar;
 
136
    uint64_t msr_star;
 
137
    uint64_t msr_cstar;
 
138
    uint64_t msr_syscall_mask;
 
139
    uint64_t msr_efer;
 
140
    uint64_t msr_tsc_aux;
 
141
 
 
142
    /* guest's idea of what rdtsc() would return */
 
143
    uint64_t tsc;
 
144
 
 
145
    /* pending event, if any */
 
146
    union {
 
147
        uint32_t pending_event;
 
148
        struct {
 
149
            uint8_t  pending_vector:8;
 
150
            uint8_t  pending_type:3;
 
151
            uint8_t  pending_error_valid:1;
 
152
            uint32_t pending_reserved:19;
 
153
            uint8_t  pending_valid:1;
 
154
        };
 
155
    };
 
156
    /* error code for pending event */
 
157
    uint32_t error_code;
 
158
};
 
159
 
 
160
DECLARE_HVM_SAVE_TYPE(CPU, 2, struct hvm_hw_cpu);
 
161
 
 
162
 
 
163
/*
 
164
 * PIC
 
165
 */
 
166
 
 
167
struct hvm_hw_vpic {
 
168
    /* IR line bitmasks. */
 
169
    uint8_t irr;
 
170
    uint8_t imr;
 
171
    uint8_t isr;
 
172
 
 
173
    /* Line IRx maps to IRQ irq_base+x */
 
174
    uint8_t irq_base;
 
175
 
 
176
    /*
 
177
     * Where are we in ICW2-4 initialisation (0 means no init in progress)?
 
178
     * Bits 0-1 (=x): Next write at A=1 sets ICW(x+1).
 
179
     * Bit 2: ICW1.IC4  (1 == ICW4 included in init sequence)
 
180
     * Bit 3: ICW1.SNGL (0 == ICW3 included in init sequence)
 
181
     */
 
182
    uint8_t init_state:4;
 
183
 
 
184
    /* IR line with highest priority. */
 
185
    uint8_t priority_add:4;
 
186
 
 
187
    /* Reads from A=0 obtain ISR or IRR? */
 
188
    uint8_t readsel_isr:1;
 
189
 
 
190
    /* Reads perform a polling read? */
 
191
    uint8_t poll:1;
 
192
 
 
193
    /* Automatically clear IRQs from the ISR during INTA? */
 
194
    uint8_t auto_eoi:1;
 
195
 
 
196
    /* Automatically rotate IRQ priorities during AEOI? */
 
197
    uint8_t rotate_on_auto_eoi:1;
 
198
 
 
199
    /* Exclude slave inputs when considering in-service IRQs? */
 
200
    uint8_t special_fully_nested_mode:1;
 
201
 
 
202
    /* Special mask mode excludes masked IRs from AEOI and priority checks. */
 
203
    uint8_t special_mask_mode:1;
 
204
 
 
205
    /* Is this a master PIC or slave PIC? (NB. This is not programmable.) */
 
206
    uint8_t is_master:1;
 
207
 
 
208
    /* Edge/trigger selection. */
 
209
    uint8_t elcr;
 
210
 
 
211
    /* Virtual INT output. */
 
212
    uint8_t int_output;
 
213
};
 
214
 
 
215
DECLARE_HVM_SAVE_TYPE(PIC, 3, struct hvm_hw_vpic);
 
216
 
 
217
 
 
218
/*
 
219
 * IO-APIC
 
220
 */
 
221
 
 
222
#ifdef __ia64__
 
223
#define VIOAPIC_IS_IOSAPIC 1
 
224
#define VIOAPIC_NUM_PINS  24
 
225
#else
 
226
#define VIOAPIC_NUM_PINS  48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */
 
227
#endif
 
228
 
 
229
struct hvm_hw_vioapic {
 
230
    uint64_t base_address;
 
231
    uint32_t ioregsel;
 
232
    uint32_t id;
 
233
    union vioapic_redir_entry
 
234
    {
 
235
        uint64_t bits;
 
236
        struct {
 
237
            uint8_t vector;
 
238
            uint8_t delivery_mode:3;
 
239
            uint8_t dest_mode:1;
 
240
            uint8_t delivery_status:1;
 
241
            uint8_t polarity:1;
 
242
            uint8_t remote_irr:1;
 
243
            uint8_t trig_mode:1;
 
244
            uint8_t mask:1;
 
245
            uint8_t reserve:7;
 
246
#if !VIOAPIC_IS_IOSAPIC
 
247
            uint8_t reserved[4];
 
248
            uint8_t dest_id;
 
249
#else
 
250
            uint8_t reserved[3];
 
251
            uint16_t dest_id;
 
252
#endif
 
253
        } fields;
 
254
    } redirtbl[VIOAPIC_NUM_PINS];
 
255
};
 
256
 
 
257
DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct hvm_hw_vioapic);
 
258
 
 
259
 
 
260
/*
 
261
 * LAPIC
 
262
 */
 
263
 
 
264
struct hvm_hw_lapic {
 
265
    uint64_t             apic_base_msr;
 
266
    uint32_t             disabled; /* VLAPIC_xx_DISABLED */
 
267
    uint32_t             timer_divisor;
 
268
};
 
269
 
 
270
DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic);
 
271
 
 
272
struct hvm_hw_lapic_regs {
 
273
    uint8_t data[1024];
 
274
};
 
275
 
 
276
DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs);
 
277
 
 
278
 
 
279
/*
 
280
 * IRQs
 
281
 */
 
282
 
 
283
struct hvm_hw_pci_irqs {
 
284
    /*
 
285
     * Virtual interrupt wires for a single PCI bus.
 
286
     * Indexed by: device*4 + INTx#.
 
287
     */
 
288
    union {
 
289
        unsigned long i[16 / sizeof (unsigned long)]; /* DECLARE_BITMAP(i, 32*4); */
 
290
        uint64_t pad[2];
 
291
    };
 
292
};
 
293
 
 
294
DECLARE_HVM_SAVE_TYPE(PCI_IRQ, 7, struct hvm_hw_pci_irqs);
 
295
 
 
296
struct hvm_hw_isa_irqs {
 
297
    /*
 
298
     * Virtual interrupt wires for ISA devices.
 
299
     * Indexed by ISA IRQ (assumes no ISA-device IRQ sharing).
 
300
     */
 
301
    union {
 
302
        unsigned long i[1];  /* DECLARE_BITMAP(i, 16); */
 
303
        uint64_t pad[1];
 
304
    };
 
305
};
 
306
 
 
307
DECLARE_HVM_SAVE_TYPE(ISA_IRQ, 8, struct hvm_hw_isa_irqs);
 
308
 
 
309
struct hvm_hw_pci_link {
 
310
    /*
 
311
     * PCI-ISA interrupt router.
 
312
     * Each PCI <device:INTx#> is 'wire-ORed' into one of four links using
 
313
     * the traditional 'barber's pole' mapping ((device + INTx#) & 3).
 
314
     * The router provides a programmable mapping from each link to a GSI.
 
315
     */
 
316
    uint8_t route[4];
 
317
    uint8_t pad0[4];
 
318
};
 
319
 
 
320
DECLARE_HVM_SAVE_TYPE(PCI_LINK, 9, struct hvm_hw_pci_link);
 
321
 
 
322
/* 
 
323
 *  PIT
 
324
 */
 
325
 
 
326
struct hvm_hw_pit {
 
327
    struct hvm_hw_pit_channel {
 
328
        uint32_t count; /* can be 65536 */
 
329
        uint16_t latched_count;
 
330
        uint8_t count_latched;
 
331
        uint8_t status_latched;
 
332
        uint8_t status;
 
333
        uint8_t read_state;
 
334
        uint8_t write_state;
 
335
        uint8_t write_latch;
 
336
        uint8_t rw_mode;
 
337
        uint8_t mode;
 
338
        uint8_t bcd; /* not supported */
 
339
        uint8_t gate; /* timer start */
 
340
    } channels[3];  /* 3 x 16 bytes */
 
341
    uint32_t speaker_data_on;
 
342
    uint32_t pad0;
 
343
};
 
344
 
 
345
DECLARE_HVM_SAVE_TYPE(PIT, 10, struct hvm_hw_pit);
 
346
 
 
347
 
 
348
/* 
 
349
 * RTC
 
350
 */ 
 
351
 
 
352
#define RTC_CMOS_SIZE 14
 
353
struct hvm_hw_rtc {
 
354
    /* CMOS bytes */
 
355
    uint8_t cmos_data[RTC_CMOS_SIZE];
 
356
    /* Index register for 2-part operations */
 
357
    uint8_t cmos_index;
 
358
    uint8_t pad0;
 
359
};
 
360
 
 
361
DECLARE_HVM_SAVE_TYPE(RTC, 11, struct hvm_hw_rtc);
 
362
 
 
363
 
 
364
/*
 
365
 * HPET
 
366
 */
 
367
 
 
368
#define HPET_TIMER_NUM     3    /* 3 timers supported now */
 
369
struct hvm_hw_hpet {
 
370
    /* Memory-mapped, software visible registers */
 
371
    uint64_t capability;        /* capabilities */
 
372
    uint64_t res0;              /* reserved */
 
373
    uint64_t config;            /* configuration */
 
374
    uint64_t res1;              /* reserved */
 
375
    uint64_t isr;               /* interrupt status reg */
 
376
    uint64_t res2[25];          /* reserved */
 
377
    uint64_t mc64;              /* main counter */
 
378
    uint64_t res3;              /* reserved */
 
379
    struct {                    /* timers */
 
380
        uint64_t config;        /* configuration/cap */
 
381
        uint64_t cmp;           /* comparator */
 
382
        uint64_t fsb;           /* FSB route, not supported now */
 
383
        uint64_t res4;          /* reserved */
 
384
    } timers[HPET_TIMER_NUM];
 
385
    uint64_t res5[4*(24-HPET_TIMER_NUM)];  /* reserved, up to 0x3ff */
 
386
 
 
387
    /* Hidden register state */
 
388
    uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
 
389
};
 
390
 
 
391
DECLARE_HVM_SAVE_TYPE(HPET, 12, struct hvm_hw_hpet);
 
392
 
 
393
 
 
394
/*
 
395
 * PM timer
 
396
 */
 
397
 
 
398
struct hvm_hw_pmtimer {
 
399
    uint32_t tmr_val;   /* PM_TMR_BLK.TMR_VAL: 32bit free-running counter */
 
400
    uint16_t pm1a_sts;  /* PM1a_EVT_BLK.PM1a_STS: status register */
 
401
    uint16_t pm1a_en;   /* PM1a_EVT_BLK.PM1a_EN: enable register */
 
402
};
 
403
 
 
404
DECLARE_HVM_SAVE_TYPE(PMTIMER, 13, struct hvm_hw_pmtimer);
 
405
 
 
406
/*
 
407
 * MTRR MSRs
 
408
 */
 
409
 
 
410
struct hvm_hw_mtrr {
 
411
#define MTRR_VCNT 8
 
412
#define NUM_FIXED_MSR 11
 
413
    uint64_t msr_pat_cr;
 
414
    /* mtrr physbase & physmask msr pair*/
 
415
    uint64_t msr_mtrr_var[MTRR_VCNT*2];
 
416
    uint64_t msr_mtrr_fixed[NUM_FIXED_MSR];
 
417
    uint64_t msr_mtrr_cap;
 
418
    uint64_t msr_mtrr_def_type;
 
419
};
 
420
 
 
421
DECLARE_HVM_SAVE_TYPE(MTRR, 14, struct hvm_hw_mtrr);
 
422
 
 
423
/*
 
424
 * Viridian hypervisor context.
 
425
 */
 
426
 
 
427
struct hvm_viridian_context {
 
428
    uint64_t hypercall_gpa;
 
429
    uint64_t guest_os_id;
 
430
};
 
431
 
 
432
DECLARE_HVM_SAVE_TYPE(VIRIDIAN, 15, struct hvm_viridian_context);
 
433
 
 
434
/* 
 
435
 * Largest type-code in use
 
436
 */
 
437
#define HVM_SAVE_CODE_MAX 15
 
438
 
 
439
#endif /* __XEN_PUBLIC_HVM_SAVE_X86_H__ */