aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/kvm/kvm.h109
-rw-r--r--drivers/kvm/x86.h110
2 files changed, 110 insertions, 109 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 1c4de50ac06a..41f6ee2134de 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -577,115 +577,6 @@ static inline int memslot_id(struct kvm *kvm, struct kvm_memory_slot *slot)
577 return slot - kvm->memslots; 577 return slot - kvm->memslots;
578} 578}
579 579
580static inline struct kvm_mmu_page *page_header(hpa_t shadow_page)
581{
582 struct page *page = pfn_to_page(shadow_page >> PAGE_SHIFT);
583
584 return (struct kvm_mmu_page *)page_private(page);
585}
586
587static inline u16 read_fs(void)
588{
589 u16 seg;
590 asm("mov %%fs, %0" : "=g"(seg));
591 return seg;
592}
593
594static inline u16 read_gs(void)
595{
596 u16 seg;
597 asm("mov %%gs, %0" : "=g"(seg));
598 return seg;
599}
600
601static inline u16 read_ldt(void)
602{
603 u16 ldt;
604 asm("sldt %0" : "=g"(ldt));
605 return ldt;
606}
607
608static inline void load_fs(u16 sel)
609{
610 asm("mov %0, %%fs" : : "rm"(sel));
611}
612
613static inline void load_gs(u16 sel)
614{
615 asm("mov %0, %%gs" : : "rm"(sel));
616}
617
618#ifndef load_ldt
619static inline void load_ldt(u16 sel)
620{
621 asm("lldt %0" : : "rm"(sel));
622}
623#endif
624
625static inline void get_idt(struct descriptor_table *table)
626{
627 asm("sidt %0" : "=m"(*table));
628}
629
630static inline void get_gdt(struct descriptor_table *table)
631{
632 asm("sgdt %0" : "=m"(*table));
633}
634
635static inline unsigned long read_tr_base(void)
636{
637 u16 tr;
638 asm("str %0" : "=g"(tr));
639 return segment_base(tr);
640}
641
642#ifdef CONFIG_X86_64
643static inline unsigned long read_msr(unsigned long msr)
644{
645 u64 value;
646
647 rdmsrl(msr, value);
648 return value;
649}
650#endif
651
652static inline void fx_save(struct i387_fxsave_struct *image)
653{
654 asm("fxsave (%0)":: "r" (image));
655}
656
657static inline void fx_restore(struct i387_fxsave_struct *image)
658{
659 asm("fxrstor (%0)":: "r" (image));
660}
661
662static inline void fpu_init(void)
663{
664 asm("finit");
665}
666
667static inline u32 get_rdx_init_val(void)
668{
669 return 0x600; /* P6 family */
670}
671
672#define ASM_VMX_VMCLEAR_RAX ".byte 0x66, 0x0f, 0xc7, 0x30"
673#define ASM_VMX_VMLAUNCH ".byte 0x0f, 0x01, 0xc2"
674#define ASM_VMX_VMRESUME ".byte 0x0f, 0x01, 0xc3"
675#define ASM_VMX_VMPTRLD_RAX ".byte 0x0f, 0xc7, 0x30"
676#define ASM_VMX_VMREAD_RDX_RAX ".byte 0x0f, 0x78, 0xd0"
677#define ASM_VMX_VMWRITE_RAX_RDX ".byte 0x0f, 0x79, 0xd0"
678#define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4"
679#define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4"
680#define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30"
681
682#define MSR_IA32_TIME_STAMP_COUNTER 0x010
683
684#define TSS_IOPB_BASE_OFFSET 0x66
685#define TSS_BASE_SIZE 0x68
686#define TSS_IOPB_SIZE (65536 / 8)
687#define TSS_REDIRECTION_SIZE (256 / 8)
688#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
689 580
690enum kvm_stat_kind { 581enum kvm_stat_kind {
691 KVM_STAT_VM, 582 KVM_STAT_VM,
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