Lines Matching refs:vcpu

113 GETREG(struct vcpu *vcpu, int reg)  in GETREG()  argument
118 error = vm_get_register(vcpu, reg, &val); in GETREG()
124 SETREG(struct vcpu *vcpu, int reg, uint64_t val) in SETREG() argument
128 error = vm_set_register(vcpu, reg, val); in SETREG()
164 sel_exception(struct vcpu *vcpu, int vector, uint16_t sel, int ext) in sel_exception() argument
178 vm_inject_fault(vcpu, vector, 1, sel); in sel_exception()
186 desc_table_limit_check(struct vcpu *vcpu, uint16_t sel) in desc_table_limit_check() argument
193 error = vm_get_desc(vcpu, reg, &base, &limit, &access); in desc_table_limit_check()
216 desc_table_rw(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_rw() argument
226 error = vm_get_desc(vcpu, reg, &base, &limit, &access); in desc_table_rw()
230 error = vm_copy_setup(vcpu, paging, base + SEL_START(sel), in desc_table_rw()
244 desc_table_read(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_read() argument
247 return (desc_table_rw(vcpu, paging, sel, desc, true, faultptr)); in desc_table_read()
251 desc_table_write(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_write() argument
254 return (desc_table_rw(vcpu, paging, sel, desc, false, faultptr)); in desc_table_write()
265 read_tss_descriptor(struct vcpu *vcpu, struct vm_task_switch *ts, in read_tss_descriptor() argument
275 if (desc_table_limit_check(vcpu, sel)) { in read_tss_descriptor()
277 sel_exception(vcpu, IDT_TS, sel, ts->ext); in read_tss_descriptor()
279 sel_exception(vcpu, IDT_GP, sel, ts->ext); in read_tss_descriptor()
285 error = desc_table_read(vcpu, &sup_paging, sel, desc, faultptr); in read_tss_descriptor()
321 validate_seg_desc(struct vcpu *vcpu, struct vm_task_switch *ts, in validate_seg_desc() argument
353 sel = GETREG(vcpu, segment); in validate_seg_desc()
357 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
362 if (desc_table_limit_check(vcpu, sel)) { in validate_seg_desc()
363 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
371 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
383 error = desc_table_read(vcpu, &sup_paging, sel, &usd, faultptr); in validate_seg_desc()
392 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
404 sel_exception(vcpu, idtvec, sel, ts->ext); in validate_seg_desc()
408 cs = GETREG(vcpu, VM_REG_GUEST_CS); in validate_seg_desc()
414 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
422 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
438 sel_exception(vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
447 tss32_save(struct vcpu *vcpu, struct vm_task_switch *task_switch, in tss32_save() argument
452 tss->tss_eax = GETREG(vcpu, VM_REG_GUEST_RAX); in tss32_save()
453 tss->tss_ecx = GETREG(vcpu, VM_REG_GUEST_RCX); in tss32_save()
454 tss->tss_edx = GETREG(vcpu, VM_REG_GUEST_RDX); in tss32_save()
455 tss->tss_ebx = GETREG(vcpu, VM_REG_GUEST_RBX); in tss32_save()
456 tss->tss_esp = GETREG(vcpu, VM_REG_GUEST_RSP); in tss32_save()
457 tss->tss_ebp = GETREG(vcpu, VM_REG_GUEST_RBP); in tss32_save()
458 tss->tss_esi = GETREG(vcpu, VM_REG_GUEST_RSI); in tss32_save()
459 tss->tss_edi = GETREG(vcpu, VM_REG_GUEST_RDI); in tss32_save()
462 tss->tss_es = GETREG(vcpu, VM_REG_GUEST_ES); in tss32_save()
463 tss->tss_cs = GETREG(vcpu, VM_REG_GUEST_CS); in tss32_save()
464 tss->tss_ss = GETREG(vcpu, VM_REG_GUEST_SS); in tss32_save()
465 tss->tss_ds = GETREG(vcpu, VM_REG_GUEST_DS); in tss32_save()
466 tss->tss_fs = GETREG(vcpu, VM_REG_GUEST_FS); in tss32_save()
467 tss->tss_gs = GETREG(vcpu, VM_REG_GUEST_GS); in tss32_save()
470 tss->tss_eflags = GETREG(vcpu, VM_REG_GUEST_RFLAGS); in tss32_save()
480 update_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *sd) in update_seg_desc() argument
484 error = vm_set_desc(vcpu, reg, sd->base, sd->limit, sd->access); in update_seg_desc()
492 tss32_restore(struct vmctx *ctx, struct vcpu *vcpu, struct vm_task_switch *ts, in tss32_restore() argument
512 SETREG(vcpu, VM_REG_GUEST_LDTR, tss->tss_ldt); in tss32_restore()
532 vm_inject_gp(vcpu); in tss32_restore()
536 SETREG(vcpu, VM_REG_GUEST_PDPTE0, pdpte[0]); in tss32_restore()
537 SETREG(vcpu, VM_REG_GUEST_PDPTE1, pdpte[1]); in tss32_restore()
538 SETREG(vcpu, VM_REG_GUEST_PDPTE2, pdpte[2]); in tss32_restore()
539 SETREG(vcpu, VM_REG_GUEST_PDPTE3, pdpte[3]); in tss32_restore()
541 SETREG(vcpu, VM_REG_GUEST_CR3, tss->tss_cr3); in tss32_restore()
546 SETREG(vcpu, VM_REG_GUEST_RFLAGS, eflags); in tss32_restore()
547 SETREG(vcpu, VM_REG_GUEST_RIP, tss->tss_eip); in tss32_restore()
550 SETREG(vcpu, VM_REG_GUEST_RAX, tss->tss_eax); in tss32_restore()
551 SETREG(vcpu, VM_REG_GUEST_RCX, tss->tss_ecx); in tss32_restore()
552 SETREG(vcpu, VM_REG_GUEST_RDX, tss->tss_edx); in tss32_restore()
553 SETREG(vcpu, VM_REG_GUEST_RBX, tss->tss_ebx); in tss32_restore()
554 SETREG(vcpu, VM_REG_GUEST_RSP, tss->tss_esp); in tss32_restore()
555 SETREG(vcpu, VM_REG_GUEST_RBP, tss->tss_ebp); in tss32_restore()
556 SETREG(vcpu, VM_REG_GUEST_RSI, tss->tss_esi); in tss32_restore()
557 SETREG(vcpu, VM_REG_GUEST_RDI, tss->tss_edi); in tss32_restore()
560 SETREG(vcpu, VM_REG_GUEST_ES, tss->tss_es); in tss32_restore()
561 SETREG(vcpu, VM_REG_GUEST_CS, tss->tss_cs); in tss32_restore()
562 SETREG(vcpu, VM_REG_GUEST_SS, tss->tss_ss); in tss32_restore()
563 SETREG(vcpu, VM_REG_GUEST_DS, tss->tss_ds); in tss32_restore()
564 SETREG(vcpu, VM_REG_GUEST_FS, tss->tss_fs); in tss32_restore()
565 SETREG(vcpu, VM_REG_GUEST_GS, tss->tss_gs); in tss32_restore()
575 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc, in tss32_restore()
579 update_seg_desc(vcpu, VM_REG_GUEST_LDTR, &seg_desc); in tss32_restore()
590 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_CS, &seg_desc, in tss32_restore()
595 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_SS, &seg_desc2, in tss32_restore()
599 update_seg_desc(vcpu, VM_REG_GUEST_CS, &seg_desc); in tss32_restore()
600 update_seg_desc(vcpu, VM_REG_GUEST_SS, &seg_desc2); in tss32_restore()
603 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_DS, &seg_desc, in tss32_restore()
607 update_seg_desc(vcpu, VM_REG_GUEST_DS, &seg_desc); in tss32_restore()
609 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_ES, &seg_desc, in tss32_restore()
613 update_seg_desc(vcpu, VM_REG_GUEST_ES, &seg_desc); in tss32_restore()
615 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_FS, &seg_desc, in tss32_restore()
619 update_seg_desc(vcpu, VM_REG_GUEST_FS, &seg_desc); in tss32_restore()
621 error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_GS, &seg_desc, in tss32_restore()
625 update_seg_desc(vcpu, VM_REG_GUEST_GS, &seg_desc); in tss32_restore()
780 push_errcode(struct vcpu *vcpu, struct vm_guest_paging *paging, in push_errcode() argument
792 cr0 = GETREG(vcpu, VM_REG_GUEST_CR0); in push_errcode()
793 rflags = GETREG(vcpu, VM_REG_GUEST_RFLAGS); in push_errcode()
794 stacksel = GETREG(vcpu, VM_REG_GUEST_SS); in push_errcode()
796 error = vm_get_desc(vcpu, VM_REG_GUEST_SS, &seg_desc.base, in push_errcode()
820 esp = GETREG(vcpu, VM_REG_GUEST_RSP); in push_errcode()
825 sel_exception(vcpu, IDT_SS, stacksel, 1); in push_errcode()
831 vm_inject_ac(vcpu, 1); in push_errcode()
836 error = vm_copy_setup(vcpu, paging, gla, bytes, PROT_WRITE, in push_errcode()
842 SETREG(vcpu, VM_REG_GUEST_RSP, esp); in push_errcode()
860 vmexit_task_switch(struct vmctx *ctx, struct vcpu *vcpu, struct vm_exit *vmexit) in vmexit_task_switch() argument
897 error = read_tss_descriptor(vcpu, task_switch, nt_sel, &nt_desc, in vmexit_task_switch()
907 sel_exception(vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
913 sel_exception(vcpu, IDT_NP, nt_sel, ext); in vmexit_task_switch()
930 sel_exception(vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
936 sel_exception(vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
945 sel_exception(vcpu, IDT_GP, nt_sel, ext); in vmexit_task_switch()
950 error = vm_copy_setup(vcpu, &sup_paging, nt.base, minlimit + 1, in vmexit_task_switch()
956 ot_sel = GETREG(vcpu, VM_REG_GUEST_TR); in vmexit_task_switch()
964 sel_exception(vcpu, IDT_TS, ot_sel, task_switch->ext); in vmexit_task_switch()
969 error = vm_get_desc(vcpu, VM_REG_GUEST_TR, &ot_base, &ot_lim, in vmexit_task_switch()
977 error = read_tss_descriptor(vcpu, task_switch, ot_sel, &ot_desc, in vmexit_task_switch()
982 error = vm_copy_setup(vcpu, &sup_paging, ot_base, minlimit + 1, in vmexit_task_switch()
993 error = desc_table_write(vcpu, &sup_paging, ot_sel, in vmexit_task_switch()
1004 tss32_save(vcpu, task_switch, eip, &oldtss, ot_iov); in vmexit_task_switch()
1012 error = desc_table_write(vcpu, &sup_paging, nt_sel, in vmexit_task_switch()
1018 SETREG(vcpu, VM_REG_GUEST_TR, nt_sel); in vmexit_task_switch()
1022 update_seg_desc(vcpu, VM_REG_GUEST_TR, &nt); in vmexit_task_switch()
1025 cr0 = GETREG(vcpu, VM_REG_GUEST_CR0); in vmexit_task_switch()
1026 SETREG(vcpu, VM_REG_GUEST_CR0, cr0 | CR0_TS); in vmexit_task_switch()
1033 error = vm_set_register(vcpu, VM_REG_GUEST_RIP, newtss.tss_eip); in vmexit_task_switch()
1037 error = tss32_restore(ctx, vcpu, task_switch, ot_sel, &newtss, nt_iov, in vmexit_task_switch()
1049 error = push_errcode(vcpu, &task_switch->paging, nt_type, in vmexit_task_switch()
1085 error = vm_set_intinfo(vcpu, 0); in vmexit_task_switch()