2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #ifndef __VMM_CTRL_REGS_H
21 #define __VMM_CTRL_REGS_H
26 #include <palacios/vm_guest.h>
28 #define EFER_MSR 0xc0000080
35 } __attribute__((packed));
53 } __attribute__((packed));
73 } __attribute__((packed));
78 } __attribute__((packed));
82 } __attribute__((packed));
90 uint_t pdt_base_addr : 20;
91 } __attribute__((packed));
98 uint_t pdpt_base_addr : 27;
99 } __attribute__((packed));
107 ullong_t pml4t_base_addr : 40;
109 } __attribute__((packed));
123 uint_t osxmmexcpt : 1;
129 } __attribute__((packed));
142 uint_t osxmmexcpt : 1;
149 } __attribute__((packed));
155 uint_t rsvd1 : 7; // RAZ
157 uint_t rsvd2 : 1; // MBZ
161 uint_t rsvd3 : 1; // MBZ
163 uint_t rsvd4 : 12; // MBZ
164 uint_t rsvd5 : 32; // MBZ
165 } __attribute__((packed));
169 uint_t cf : 1; // carry flag
170 uint_t rsvd1 : 1; // Must be 1
171 uint_t pf : 1; // parity flag
172 uint_t rsvd2 : 1; // Read as 0
173 uint_t af : 1; // Auxillary flag
174 uint_t rsvd3 : 1; // Read as 0
175 uint_t zf : 1; // zero flag
176 uint_t sf : 1; // sign flag
177 uint_t tf : 1; // trap flag
178 uint_t intr : 1; // interrupt flag
179 uint_t df : 1; // direction flag
180 uint_t of : 1; // overflow flag
181 uint_t iopl : 2; // IO privilege level
182 uint_t nt : 1; // nested task
183 uint_t rsvd4 : 1; // read as 0
184 uint_t rf : 1; // resume flag
185 uint_t vm : 1; // Virtual-8086 mode
186 uint_t ac : 1; // alignment check
187 uint_t vif : 1; // virtual interrupt flag
188 uint_t vip : 1; // virtual interrupt pending
189 uint_t id : 1; // ID flag
190 uint_t rsvd5 : 10; // Read as 0
191 uint_t rsvd6 : 32; // Read as 0
192 } __attribute__((packed));
199 static const uchar_t cr_access_byte = 0x0f;
201 // Second opcode byte
202 static const uchar_t lmsw_byte = 0x01;
203 static const uchar_t lmsw_reg_byte = 0x6;
204 static const uchar_t smsw_byte = 0x01;
205 static const uchar_t smsw_reg_byte = 0x4;
206 static const uchar_t clts_byte = 0x06;
207 static const uchar_t mov_to_cr_byte = 0x22;
208 static const uchar_t mov_from_cr_byte = 0x20;
212 int v3_handle_cr0_write(struct guest_info * info);
213 int v3_handle_cr0_read(struct guest_info * info);
215 int v3_handle_cr3_write(struct guest_info * info);
216 int v3_handle_cr3_read(struct guest_info * info);
218 int v3_handle_cr4_write(struct guest_info * info);
219 int v3_handle_cr4_read(struct guest_info * info);
221 int v3_handle_cr8_write(struct guest_info * info);
222 int v3_handle_cr8_read(struct guest_info * info);
225 int v3_handle_efer_write(struct guest_info * core, uint_t msr, struct v3_msr src, void * priv_data);
226 int v3_handle_efer_read(struct guest_info * core, uint_t msr, struct v3_msr * dst, void * priv_data);
228 int v3_handle_vm_cr_write(struct guest_info * core, uint_t msr, struct v3_msr src, void * priv_data);
229 int v3_handle_vm_cr_read(struct guest_info * core, uint_t msr, struct v3_msr * dst, void * priv_data);
232 #endif // ! __V3VEE__