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.


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