aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/x86.h
diff options
context:
space:
mode:
authorZhang Xiantao <xiantao.zhang@intel.com>2007-11-19 02:08:31 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:06 -0500
commitec6d273deb56b1607e2acaad3df4bca42f135cd7 (patch)
treebaf98bb322414d814f14c25e529c48c68d489b69 /drivers/kvm/x86.h
parent2b3ccfa0c5c7738a08f473b5d00b78f87935de72 (diff)
KVM: Move some static inline functions out from kvm.h into x86.h
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.h')
-rw-r--r--drivers/kvm/x86.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index 77a4a4ab9391..f1c43cafb0ca 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -267,4 +267,114 @@ static inline int is_paging(struct kvm_vcpu *vcpu)
267 267
268int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 268int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
269int complete_pio(struct kvm_vcpu *vcpu); 269int complete_pio(struct kvm_vcpu *vcpu);
270
271static inline struct kvm_mmu_page *page_header(hpa_t shadow_page)
272{
273 struct page *page = pfn_to_page(shadow_page >> PAGE_SHIFT);
274
275 return (struct kvm_mmu_page *)page_private(page);
276}
277
278static inline u16 read_fs(void)
279{
280 u16 seg;
281 asm("mov %%fs, %0" : "=g"(seg));
282 return seg;
283}
284
285static inline u16 read_gs(void)
286{
287 u16 seg;
288 asm("mov %%gs, %0" : "=g"(seg));
289 return seg;
290}
291
292static inline u16 read_ldt(void)
293{
294 u16 ldt;
295 asm("sldt %0" : "=g"(ldt));
296 return ldt;
297}
298
299static inline void load_fs(u16 sel)
300{
301 asm("mov %0, %%fs" : : "rm"(sel));
302}
303
304static inline void load_gs(u16 sel)
305{
306 asm("mov %0, %%gs" : : "rm"(sel));
307}
308
309#ifndef load_ldt
310static inline void load_ldt(u16 sel)
311{
312 asm("lldt %0" : : "rm"(sel));
313}
314#endif
315
316static inline void get_idt(struct descriptor_table *table)
317{
318 asm("sidt %0" : "=m"(*table));
319}
320
321static inline void get_gdt(struct descriptor_table *table)
322{
323 asm("sgdt %0" : "=m"(*table));
324}
325
326static inline unsigned long read_tr_base(void)
327{
328 u16 tr;
329 asm("str %0" : "=g"(tr));
330 return segment_base(tr);
331}
332
333#ifdef CONFIG_X86_64
334static inline unsigned long read_msr(unsigned long msr)
335{
336 u64 value;
337
338 rdmsrl(msr, value);
339 return value;
340}
341#endif
342
343static inline void fx_save(struct i387_fxsave_struct *image)
344{
345 asm("fxsave (%0)":: "r" (image));
346}
347
348static inline void fx_restore(struct i387_fxsave_struct *image)
349{
350 asm("fxrstor (%0)":: "r" (image));
351}
352
353static inline void fpu_init(void)
354{
355 asm("finit");
356}
357
358static inline u32 get_rdx_init_val(void)
359{
360 return 0x600; /* P6 family */
361}
362
363#define ASM_VMX_VMCLEAR_RAX ".byte 0x66, 0x0f, 0xc7, 0x30"
364#define ASM_VMX_VMLAUNCH ".byte 0x0f, 0x01, 0xc2"
365#define ASM_VMX_VMRESUME ".byte 0x0f, 0x01, 0xc3"
366#define ASM_VMX_VMPTRLD_RAX ".byte 0x0f, 0xc7, 0x30"
367#define ASM_VMX_VMREAD_RDX_RAX ".byte 0x0f, 0x78, 0xd0"
368#define ASM_VMX_VMWRITE_RAX_RDX ".byte 0x0f, 0x79, 0xd0"
369#define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4"
370#define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4"
371#define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30"
372
373#define MSR_IA32_TIME_STAMP_COUNTER 0x010
374
375#define TSS_IOPB_BASE_OFFSET 0x66
376#define TSS_BASE_SIZE 0x68
377#define TSS_IOPB_SIZE (65536 / 8)
378#define TSS_REDIRECTION_SIZE (256 / 8)
379#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
270#endif 380#endif