Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


1c61613c697ebe6faf4f7f708acb57fb1b44228a
[palacios.git] / palacios / include / palacios / vmm_ctrl_regs.h
1 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
2 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
3
4 #ifndef __VMM_CTRL_REGS_H
5 #define __VMM_CTRL_REGS_H
6
7 #ifdef __V3VEE__
8
9
10 #include <palacios/vm_guest.h>
11
12 struct cr0_real {
13   uint_t pe    : 1;
14   uint_t mp    : 1;
15   uint_t em    : 1;
16   uint_t ts    : 1;
17 };
18
19
20 struct cr0_32 {
21   uint_t pe    : 1;
22   uint_t mp    : 1;
23   uint_t em    : 1;
24   uint_t ts    : 1;
25   uint_t et    : 1;
26   uint_t ne    : 1;
27   uint_t rsvd1 : 10;
28   uint_t wp    : 1;
29   uint_t rsvd2 : 1;
30   uint_t am    : 1;
31   uint_t rsvd3 : 10;
32   uint_t nw    : 1;
33   uint_t cd    : 1;
34   uint_t pg    : 1;
35 };
36
37
38 struct cr0_64 {
39   uint_t pe    : 1;
40   uint_t mp    : 1;
41   uint_t em    : 1;
42   uint_t ts    : 1;
43   uint_t et    : 1;
44   uint_t ne    : 1;
45   uint_t rsvd1 : 10;
46   uint_t wp    : 1;
47   uint_t rsvd2 : 1;
48   uint_t am    : 1;
49   uint_t rsvd3 : 10;
50   uint_t nw    : 1;
51   uint_t cd    : 1;
52   uint_t pg    : 1;
53
54   uint_t  rsvd4;  // MBZ
55 };
56
57
58 struct cr2_32 {
59   uint_t pf_vaddr;
60 };
61
62 struct cr2_64 {
63   ullong_t pf_vaddr;
64 };
65
66
67 struct cr3_32 {
68   uint_t rsvd1             : 3;
69   uint_t pwt               : 1;
70   uint_t pcd               : 1;
71   uint_t rsvd2             : 7;
72   uint_t pdt_base_addr    : 20;
73 };
74
75
76 struct cr3_32_PAE {
77   uint_t rsvd1             : 3;
78   uint_t pwt               : 1;
79   uint_t pcd               : 1;
80   uint_t pdpt_base_addr    : 27;
81 };
82
83
84 struct cr3_64 {
85   uint_t rsvd1             : 3;
86   uint_t pwt               : 1;
87   uint_t pcd               : 1;
88   uint_t rsvd2             : 7;
89   ullong_t pml4t_base_addr : 40;
90   uint_t rsvd3             : 12; 
91 };
92
93
94 struct cr4_32 {
95   uint_t vme               : 1;
96   uint_t pvi               : 1;
97   uint_t tsd               : 1;
98   uint_t de                : 1;
99   uint_t pse               : 1;
100   uint_t pae               : 1;
101   uint_t mce               : 1;
102   uint_t pge               : 1;
103   uint_t pce               : 1;
104   uint_t osf_xsr           : 1;
105   uint_t osx               : 1;
106   uint_t rsvd1             : 21;
107 };
108
109 struct cr4_64 {
110   uint_t vme               : 1;
111   uint_t pvi               : 1;
112   uint_t tsd               : 1;
113   uint_t de                : 1;
114   uint_t pse               : 1;
115   uint_t pae               : 1;
116   uint_t mce               : 1;
117   uint_t pge               : 1;
118   uint_t pce               : 1;
119   uint_t osf_xsr           : 1;
120   uint_t osx               : 1;
121   uint_t rsvd1             : 21;
122   uint_t rsvd2             : 32;
123 };
124
125
126
127 struct efer_64 {
128   uint_t sce              : 1;
129   uint_t rsvd1            : 7; // RAZ
130   uint_t lme              : 1;
131   uint_t rsvd2            : 1; // MBZ
132   uint_t lma              : 1;
133   uint_t nxe              : 1;
134   uint_t svme             : 1;
135   uint_t rsvd3            : 1; // MBZ
136   uint_t ffxsr            : 1;
137   uint_t rsvd4            : 12; // MBZ
138   uint_t rsvd5            : 32; // MBZ
139 };
140
141
142 struct rflags {
143   uint_t cf                : 1;  // carry flag
144   uint_t rsvd1             : 1;  // Must be 1
145   uint_t pf                : 1;  // parity flag
146   uint_t rsvd2             : 1;  // Read as 0
147   uint_t af                : 1;  // Auxillary flag
148   uint_t rsvd3             : 1;  // Read as 0
149   uint_t zf                : 1;  // zero flag
150   uint_t sf                : 1;  // sign flag
151   uint_t tf                : 1;  // trap flag
152   uint_t intr              : 1;  // interrupt flag
153   uint_t df                : 1;  // direction flag
154   uint_t of                : 1;  // overflow flag
155   uint_t iopl              : 2;  // IO privilege level
156   uint_t nt                : 1;  // nested task
157   uint_t rsvd4             : 1;  // read as 0
158   uint_t rf                : 1;  // resume flag
159   uint_t vm                : 1;  // Virtual-8086 mode
160   uint_t ac                : 1;  // alignment check
161   uint_t vif               : 1;  // virtual interrupt flag
162   uint_t vip               : 1;  // virtual interrupt pending
163   uint_t id                : 1;  // ID flag
164   uint_t rsvd5             : 10; // Read as 0
165   uint_t rsvd6             : 32; // Read as 0
166 };
167
168
169
170
171
172 /*
173 // First opcode byte
174 static const uchar_t cr_access_byte = 0x0f;
175
176 // Second opcode byte
177 static const uchar_t lmsw_byte = 0x01;
178 static const uchar_t lmsw_reg_byte = 0x6;
179 static const uchar_t smsw_byte = 0x01;
180 static const uchar_t smsw_reg_byte = 0x4;
181 static const uchar_t clts_byte = 0x06;
182 static const uchar_t mov_to_cr_byte = 0x22;
183 static const uchar_t mov_from_cr_byte = 0x20;
184 */
185
186
187 int handle_cr0_write(struct guest_info * info);
188 int handle_cr0_read(struct guest_info * info);
189
190 int handle_cr3_write(struct guest_info * info);
191 int handle_cr3_read(struct guest_info * info);
192
193
194 #endif // ! __V3VEE__
195
196
197 #endif