Lines Matching refs:vcpu

100 GETREG(struct vcpu *vcpu, int reg)  in GETREG()  argument
105 error = vm_get_register(vcpu, reg, &val); in GETREG()
111 SETREG(struct vcpu *vcpu, int reg, uint64_t val) in SETREG() argument
115 error = vm_set_register(vcpu, reg, val); in SETREG()
151 sel_exception(struct vcpu *vcpu, int vector, uint16_t sel, int ext) in sel_exception() argument
165 vm_inject_fault(vcpu, vector, 1, sel); in sel_exception()
173 desc_table_limit_check(struct vcpu *vcpu, uint16_t sel) in desc_table_limit_check() argument
180 error = vm_get_desc(vcpu, reg, &base, &limit, &access); in desc_table_limit_check()
203 desc_table_rw(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_rw() argument
213 error = vm_get_desc(vcpu, reg, &base, &limit, &access); in desc_table_rw()
217 error = vm_copy_setup(vcpu, paging, base + SEL_START(sel), in desc_table_rw()
231 desc_table_read(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_read() argument
234 return (desc_table_rw(vcpu, paging, sel, desc, true, faultptr)); in desc_table_read()
238 desc_table_write(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_write() argument
241 return (desc_table_rw(vcpu, paging, sel, desc, false, faultptr)); in desc_table_write()
252 read_tss_descriptor(struct vcpu *vcpu, struct vm_task_switch *ts, in read_tss_descriptor() argument
262 if (desc_table_limit_check(vcpu, sel)) { in read_tss_descriptor()
264 sel_exception(vcpu, IDT_TS, sel, ts->ext); in read_tss_descriptor()
266 sel_exception(vcpu, IDT_GP, sel, ts->ext); in read_tss_descriptor()
272 error = desc_table_read(vcpu, &sup_paging, sel, desc, faultptr); in read_tss_descriptor()
308 validate_seg_desc(struct vcpu *vcpu, struct vm_task_switch *ts, in validate_seg_desc() argument
340 sel = GETREG(vcpu, segment); in validate_seg_desc()
344 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
349 if (desc_table_limit_check(vcpu, sel)) { in validate_seg_desc()
350 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
358 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
370 error = desc_table_read(vcpu, &sup_paging, sel, &usd, faultptr); in validate_seg_desc()
379 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
391 sel_exception(vcpu, idtvec, sel, ts->ext); in validate_seg_desc()
395 cs = GETREG(vcpu, VM_REG_GUEST_CS); in validate_seg_desc()
401 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
409 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
425 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
434 tss32_save(struct vcpu *vcpu, struct vm_task_switch *task_switch, in tss32_save() argument
439 tss->tss_eax = GETREG(vcpu, VM_REG_GUEST_RAX); in tss32_save()
440 tss->tss_ecx = GETREG(vcpu, VM_REG_GUEST_RCX); in tss32_save()
441 tss->tss_edx = GETREG(vcpu, VM_REG_GUEST_RDX); in tss32_save()
442 tss->tss_ebx = GETREG(vcpu, VM_REG_GUEST_RBX); in tss32_save()
443 tss->tss_esp = GETREG(vcpu, VM_REG_GUEST_RSP); in tss32_save()
444 tss->tss_ebp = GETREG(vcpu, VM_REG_GUEST_RBP); in tss32_save()
445 tss->tss_esi = GETREG(vcpu, VM_REG_GUEST_RSI); in tss32_save()
446 tss->tss_edi = GETREG(vcpu, VM_REG_GUEST_RDI); in tss32_save()
449 tss->tss_es = GETREG(vcpu, VM_REG_GUEST_ES); in tss32_save()
450 tss->tss_cs = GETREG(vcpu, VM_REG_GUEST_CS); in tss32_save()
451 tss->tss_ss = GETREG(vcpu, VM_REG_GUEST_SS); in tss32_save()
452 tss->tss_ds = GETREG(vcpu, VM_REG_GUEST_DS); in tss32_save()
453 tss->tss_fs = GETREG(vcpu, VM_REG_GUEST_FS); in tss32_save()
454 tss->tss_gs = GETREG(vcpu, VM_REG_GUEST_GS); in tss32_save()
457 tss->tss_eflags = GETREG(vcpu, VM_REG_GUEST_RFLAGS); in tss32_save()
467 update_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *sd) in update_seg_desc() argument
471 error = vm_set_desc(vcpu, reg, sd->base, sd->limit, sd->access); in update_seg_desc()
479 tss32_restore(struct vmctx *ctx, struct vcpu *vcpu, struct vm_task_switch *ts, in tss32_restore() argument
499 SETREG(vcpu, VM_REG_GUEST_LDTR, tss->tss_ldt); in tss32_restore()
519 vm_inject_gp(vcpu); in tss32_restore()
523 SETREG(vcpu, VM_REG_GUEST_PDPTE0, pdpte[0]); in tss32_restore()
524 SETREG(vcpu, VM_REG_GUEST_PDPTE1, pdpte[1]); in tss32_restore()
525 SETREG(vcpu, VM_REG_GUEST_PDPTE2, pdpte[2]); in tss32_restore()
526 SETREG(vcpu, VM_REG_GUEST_PDPTE3, pdpte[3]); in tss32_restore()
528 SETREG(vcpu, VM_REG_GUEST_CR3, tss->tss_cr3); in tss32_restore()
533 SETREG(vcpu, VM_REG_GUEST_RFLAGS, eflags); in tss32_restore()
534 SETREG(vcpu, VM_REG_GUEST_RIP, tss->tss_eip); in tss32_restore()
537 SETREG(vcpu, VM_REG_GUEST_RAX, tss->tss_eax); in tss32_restore()
538 SETREG(vcpu, VM_REG_GUEST_RCX, tss->tss_ecx); in tss32_restore()
539 SETREG(vcpu, VM_REG_GUEST_RDX, tss->tss_edx); in tss32_restore()
540 SETREG(vcpu, VM_REG_GUEST_RBX, tss->tss_ebx); in tss32_restore()
541 SETREG(vcpu, VM_REG_GUEST_RSP, tss->tss_esp); in tss32_restore()
542 SETREG(vcpu, VM_REG_GUEST_RBP, tss->tss_ebp); in tss32_restore()
543 SETREG(vcpu, VM_REG_GUEST_RSI, tss->tss_esi); in tss32_restore()
544 SETREG(vcpu, VM_REG_GUEST_RDI, tss->tss_edi); in tss32_restore()
547 SETREG(vcpu, VM_REG_GUEST_ES, tss->tss_es); in tss32_restore()
548 SETREG(vcpu, VM_REG_GUEST_CS, tss->tss_cs); in tss32_restore()
549 SETREG(vcpu, VM_REG_GUEST_SS, tss->tss_ss); in tss32_restore()
550 SETREG(vcpu, VM_REG_GUEST_DS, tss->tss_ds); in tss32_restore()
551 SETREG(vcpu, VM_REG_GUEST_FS, tss->tss_fs); in tss32_restore()
552 SETREG(vcpu, VM_REG_GUEST_GS, tss->tss_gs); in tss32_restore()
562 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc, in tss32_restore()
566 update_seg_desc(vcpu, VM_REG_GUEST_LDTR, &seg_desc); in tss32_restore()
577 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_CS, &seg_desc, in tss32_restore()
582 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_SS, &seg_desc2, in tss32_restore()
586 update_seg_desc(vcpu, VM_REG_GUEST_CS, &seg_desc); in tss32_restore()
587 update_seg_desc(vcpu, VM_REG_GUEST_SS, &seg_desc2); in tss32_restore()
590 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_DS, &seg_desc, in tss32_restore()
594 update_seg_desc(vcpu, VM_REG_GUEST_DS, &seg_desc); in tss32_restore()
596 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_ES, &seg_desc, in tss32_restore()
600 update_seg_desc(vcpu, VM_REG_GUEST_ES, &seg_desc); in tss32_restore()
602 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_FS, &seg_desc, in tss32_restore()
606 update_seg_desc(vcpu, VM_REG_GUEST_FS, &seg_desc); in tss32_restore()
608 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_GS, &seg_desc, in tss32_restore()
612 update_seg_desc(vcpu, VM_REG_GUEST_GS, &seg_desc); in tss32_restore()
623 push_errcode(struct vcpu *vcpu, struct vm_guest_paging *paging, in push_errcode() argument
635 cr0 = GETREG(vcpu, VM_REG_GUEST_CR0); in push_errcode()
636 rflags = GETREG(vcpu, VM_REG_GUEST_RFLAGS); in push_errcode()
637 stacksel = GETREG(vcpu, VM_REG_GUEST_SS); in push_errcode()
639 error = vm_get_desc(vcpu, VM_REG_GUEST_SS, &seg_desc.base, in push_errcode()
663 esp = GETREG(vcpu, VM_REG_GUEST_RSP); in push_errcode()
668 sel_exception(vcpu, IDT_SS, stacksel, 1); in push_errcode()
674 vm_inject_ac(vcpu, 1); in push_errcode()
679 error = vm_copy_setup(vcpu, paging, gla, bytes, PROT_WRITE, in push_errcode()
685 SETREG(vcpu, VM_REG_GUEST_RSP, esp); in push_errcode()
702 int vmexit_task_switch(struct vmctx *, struct vcpu *, struct vm_run *);
705 vmexit_task_switch(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun) in vmexit_task_switch() argument
744 error = read_tss_descriptor(vcpu, task_switch, nt_sel, &nt_desc, in vmexit_task_switch()
754 sel_exception(vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
760 sel_exception(vcpu, IDT_NP, nt_sel, ext); in vmexit_task_switch()
777 sel_exception(vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
783 sel_exception(vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
792 sel_exception(vcpu, IDT_GP, nt_sel, ext); in vmexit_task_switch()
797 error = vm_copy_setup(vcpu, &sup_paging, nt.base, minlimit + 1, in vmexit_task_switch()
803 ot_sel = GETREG(vcpu, VM_REG_GUEST_TR); in vmexit_task_switch()
811 sel_exception(vcpu, IDT_TS, ot_sel, task_switch->ext); in vmexit_task_switch()
816 error = vm_get_desc(vcpu, VM_REG_GUEST_TR, &ot_base, &ot_lim, in vmexit_task_switch()
824 error = read_tss_descriptor(vcpu, task_switch, ot_sel, &ot_desc, in vmexit_task_switch()
829 error = vm_copy_setup(vcpu, &sup_paging, ot_base, minlimit + 1, in vmexit_task_switch()
840 error = desc_table_write(vcpu, &sup_paging, ot_sel, in vmexit_task_switch()
851 tss32_save(vcpu, task_switch, eip, &oldtss, ot_iov); in vmexit_task_switch()
859 error = desc_table_write(vcpu, &sup_paging, nt_sel, in vmexit_task_switch()
865 SETREG(vcpu, VM_REG_GUEST_TR, nt_sel); in vmexit_task_switch()
869 update_seg_desc(vcpu, VM_REG_GUEST_TR, &nt); in vmexit_task_switch()
872 cr0 = GETREG(vcpu, VM_REG_GUEST_CR0); in vmexit_task_switch()
873 SETREG(vcpu, VM_REG_GUEST_CR0, cr0 | CR0_TS); in vmexit_task_switch()
880 error = vm_set_register(vcpu, VM_REG_GUEST_RIP, newtss.tss_eip); in vmexit_task_switch()
884 error = tss32_restore(ctx, vcpu, task_switch, ot_sel, &newtss, nt_iov, in vmexit_task_switch()
896 error = push_errcode(vcpu, &task_switch->paging, nt_type, in vmexit_task_switch()
932 error = vm_set_intinfo(vcpu, 0); in vmexit_task_switch()