1 /*
2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
19 *
20 * Copyright (c) 2015, Roger Pau Monne <roger.pau@citrix.com>
21 */
22
23 #ifndef __XEN_PUBLIC_HVM_HVM_VCPU_H__
24 #define __XEN_PUBLIC_HVM_HVM_VCPU_H__
25
26 #include "../xen.h"
27
28 struct vcpu_hvm_x86_32 {
29 uint32_t eax;
30 uint32_t ecx;
31 uint32_t edx;
32 uint32_t ebx;
33 uint32_t esp;
34 uint32_t ebp;
35 uint32_t esi;
36 uint32_t edi;
37 uint32_t eip;
38 uint32_t eflags;
39
40 uint32_t cr0;
41 uint32_t cr3;
42 uint32_t cr4;
43
44 uint32_t pad1;
45
46 /*
47 * EFER should only be used to set the NXE bit (if required)
48 * when starting a vCPU in 32bit mode with paging enabled or
49 * to set the LME/LMA bits in order to start the vCPU in
50 * compatibility mode.
51 */
52 uint64_t efer;
53
54 uint32_t cs_base;
55 uint32_t ds_base;
56 uint32_t ss_base;
57 uint32_t es_base;
58 uint32_t tr_base;
59 uint32_t cs_limit;
60 uint32_t ds_limit;
61 uint32_t ss_limit;
62 uint32_t es_limit;
63 uint32_t tr_limit;
64 uint16_t cs_ar;
65 uint16_t ds_ar;
66 uint16_t ss_ar;
67 uint16_t es_ar;
68 uint16_t tr_ar;
69
70 uint16_t pad2[3];
71 };
72 typedef struct vcpu_hvm_x86_32 xen_vcpu_hvm_x86_32_t;
73
74 /*
75 * The layout of the _ar fields of the segment registers is the
76 * following:
77 *
78 * Bits [0,3]: type (bits 40-43).
79 * Bit 4: s (descriptor type, bit 44).
80 * Bit [5,6]: dpl (descriptor privilege level, bits 45-46).
81 * Bit 7: p (segment-present, bit 47).
82 * Bit 8: avl (available for system software, bit 52).
83 * Bit 9: l (64-bit code segment, bit 53).
84 * Bit 10: db (meaning depends on the segment, bit 54).
85 * Bit 11: g (granularity, bit 55)
86 * Bits [12,15]: unused, must be blank.
87 *
88 * A more complete description of the meaning of this fields can be
89 * obtained from the Intel SDM, Volume 3, section 3.4.5.
90 */
91
92 struct vcpu_hvm_x86_64 {
93 uint64_t rax;
94 uint64_t rcx;
95 uint64_t rdx;
96 uint64_t rbx;
97 uint64_t rsp;
98 uint64_t rbp;
99 uint64_t rsi;
100 uint64_t rdi;
101 uint64_t rip;
102 uint64_t rflags;
103
104 uint64_t cr0;
105 uint64_t cr3;
106 uint64_t cr4;
107 uint64_t efer;
108
109 /*
110 * Using VCPU_HVM_MODE_64B implies that the vCPU is launched
111 * directly in long mode, so the cached parts of the segment
112 * registers get set to match that environment.
113 *
114 * If the user wants to launch the vCPU in compatibility mode
115 * the 32-bit structure should be used instead.
116 */
117 };
118 typedef struct vcpu_hvm_x86_64 xen_vcpu_hvm_x86_64_t;
119
120 struct vcpu_hvm_context {
121 #define VCPU_HVM_MODE_32B 0 /* 32bit fields of the structure will be used. */
122 #define VCPU_HVM_MODE_64B 1 /* 64bit fields of the structure will be used. */
123 uint32_t mode;
124
125 uint32_t pad;
126
127 /* CPU registers. */
128 union {
129 xen_vcpu_hvm_x86_32_t x86_32;
130 xen_vcpu_hvm_x86_64_t x86_64;
131 } cpu_regs;
132 };
133 typedef struct vcpu_hvm_context vcpu_hvm_context_t;
134 DEFINE_XEN_GUEST_HANDLE(vcpu_hvm_context_t);
135
136 #endif /* __XEN_PUBLIC_HVM_HVM_VCPU_H__ */
137
138 /*
139 * Local variables:
140 * mode: C
141 * c-file-style: "BSD"
142 * c-basic-offset: 4
143 * tab-width: 4
144 * indent-tabs-mode: nil
145 * End:
146 */
Cache object: c81d09124a56320521848cbdc3929a19
|