Lines Matching refs:vcpu

104 GETREG(struct vmctx *ctx, int vcpu, int reg)  in GETREG()  argument
109 error = vm_get_register(ctx, vcpu, reg, &val); in GETREG()
115 SETREG(struct vmctx *ctx, int vcpu, int reg, uint64_t val) in SETREG() argument
119 error = vm_set_register(ctx, vcpu, reg, val); in SETREG()
155 sel_exception(struct vmctx *ctx, int vcpu, int vector, uint16_t sel, int ext) in sel_exception() argument
169 vm_inject_fault(ctx, vcpu, vector, 1, sel); in sel_exception()
177 desc_table_limit_check(struct vmctx *ctx, int vcpu, uint16_t sel) in desc_table_limit_check() argument
184 error = vm_get_desc(ctx, vcpu, reg, &base, &limit, &access); in desc_table_limit_check()
207 desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in desc_table_rw() argument
217 error = vm_get_desc(ctx, vcpu, reg, &base, &limit, &access); in desc_table_rw()
221 error = vm_copy_setup(ctx, vcpu, paging, base + SEL_START(sel), in desc_table_rw()
228 vm_copyin(ctx, vcpu, iov, desc, sizeof(*desc)); in desc_table_rw()
230 vm_copyout(ctx, vcpu, desc, iov, sizeof(*desc)); in desc_table_rw()
235 desc_table_read(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in desc_table_read() argument
238 return (desc_table_rw(ctx, vcpu, paging, sel, desc, true, faultptr)); in desc_table_read()
242 desc_table_write(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in desc_table_write() argument
245 return (desc_table_rw(ctx, vcpu, paging, sel, desc, false, faultptr)); in desc_table_write()
256 read_tss_descriptor(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, in read_tss_descriptor() argument
266 if (desc_table_limit_check(ctx, vcpu, sel)) { in read_tss_descriptor()
268 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in read_tss_descriptor()
270 sel_exception(ctx, vcpu, IDT_GP, sel, ts->ext); in read_tss_descriptor()
276 error = desc_table_read(ctx, vcpu, &sup_paging, sel, desc, faultptr); in read_tss_descriptor()
312 validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, in validate_seg_desc() argument
344 sel = GETREG(ctx, vcpu, segment); in validate_seg_desc()
348 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
353 if (desc_table_limit_check(ctx, vcpu, sel)) { in validate_seg_desc()
354 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
362 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
374 error = desc_table_read(ctx, vcpu, &sup_paging, sel, &usd, faultptr); in validate_seg_desc()
383 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
395 sel_exception(ctx, vcpu, idtvec, sel, ts->ext); in validate_seg_desc()
399 cs = GETREG(ctx, vcpu, VM_REG_GUEST_CS); in validate_seg_desc()
405 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
413 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
429 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
438 tss32_save(struct vmctx *ctx, int vcpu, struct vm_task_switch *task_switch, in tss32_save() argument
443 tss->tss_eax = GETREG(ctx, vcpu, VM_REG_GUEST_RAX); in tss32_save()
444 tss->tss_ecx = GETREG(ctx, vcpu, VM_REG_GUEST_RCX); in tss32_save()
445 tss->tss_edx = GETREG(ctx, vcpu, VM_REG_GUEST_RDX); in tss32_save()
446 tss->tss_ebx = GETREG(ctx, vcpu, VM_REG_GUEST_RBX); in tss32_save()
447 tss->tss_esp = GETREG(ctx, vcpu, VM_REG_GUEST_RSP); in tss32_save()
448 tss->tss_ebp = GETREG(ctx, vcpu, VM_REG_GUEST_RBP); in tss32_save()
449 tss->tss_esi = GETREG(ctx, vcpu, VM_REG_GUEST_RSI); in tss32_save()
450 tss->tss_edi = GETREG(ctx, vcpu, VM_REG_GUEST_RDI); in tss32_save()
453 tss->tss_es = GETREG(ctx, vcpu, VM_REG_GUEST_ES); in tss32_save()
454 tss->tss_cs = GETREG(ctx, vcpu, VM_REG_GUEST_CS); in tss32_save()
455 tss->tss_ss = GETREG(ctx, vcpu, VM_REG_GUEST_SS); in tss32_save()
456 tss->tss_ds = GETREG(ctx, vcpu, VM_REG_GUEST_DS); in tss32_save()
457 tss->tss_fs = GETREG(ctx, vcpu, VM_REG_GUEST_FS); in tss32_save()
458 tss->tss_gs = GETREG(ctx, vcpu, VM_REG_GUEST_GS); in tss32_save()
461 tss->tss_eflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS); in tss32_save()
467 vm_copyout(ctx, vcpu, tss, iov, sizeof(struct tss32)); in tss32_save()
471 update_seg_desc(struct vmctx *ctx, int vcpu, int reg, struct seg_desc *sd) in update_seg_desc() argument
475 error = vm_set_desc(ctx, vcpu, reg, sd->base, sd->limit, sd->access); in update_seg_desc()
483 tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, in tss32_restore() argument
503 SETREG(ctx, vcpu, VM_REG_GUEST_LDTR, tss->tss_ldt); in tss32_restore()
523 vm_inject_gp(ctx, vcpu); in tss32_restore()
527 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE0, pdpte[0]); in tss32_restore()
528 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE1, pdpte[1]); in tss32_restore()
529 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE2, pdpte[2]); in tss32_restore()
530 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE3, pdpte[3]); in tss32_restore()
532 SETREG(ctx, vcpu, VM_REG_GUEST_CR3, tss->tss_cr3); in tss32_restore()
537 SETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS, eflags); in tss32_restore()
538 SETREG(ctx, vcpu, VM_REG_GUEST_RIP, tss->tss_eip); in tss32_restore()
541 SETREG(ctx, vcpu, VM_REG_GUEST_RAX, tss->tss_eax); in tss32_restore()
542 SETREG(ctx, vcpu, VM_REG_GUEST_RCX, tss->tss_ecx); in tss32_restore()
543 SETREG(ctx, vcpu, VM_REG_GUEST_RDX, tss->tss_edx); in tss32_restore()
544 SETREG(ctx, vcpu, VM_REG_GUEST_RBX, tss->tss_ebx); in tss32_restore()
545 SETREG(ctx, vcpu, VM_REG_GUEST_RSP, tss->tss_esp); in tss32_restore()
546 SETREG(ctx, vcpu, VM_REG_GUEST_RBP, tss->tss_ebp); in tss32_restore()
547 SETREG(ctx, vcpu, VM_REG_GUEST_RSI, tss->tss_esi); in tss32_restore()
548 SETREG(ctx, vcpu, VM_REG_GUEST_RDI, tss->tss_edi); in tss32_restore()
551 SETREG(ctx, vcpu, VM_REG_GUEST_ES, tss->tss_es); in tss32_restore()
552 SETREG(ctx, vcpu, VM_REG_GUEST_CS, tss->tss_cs); in tss32_restore()
553 SETREG(ctx, vcpu, VM_REG_GUEST_SS, tss->tss_ss); in tss32_restore()
554 SETREG(ctx, vcpu, VM_REG_GUEST_DS, tss->tss_ds); in tss32_restore()
555 SETREG(ctx, vcpu, VM_REG_GUEST_FS, tss->tss_fs); in tss32_restore()
556 SETREG(ctx, vcpu, VM_REG_GUEST_GS, tss->tss_gs); in tss32_restore()
563 vm_copyout(ctx, vcpu, tss, iov, sizeof(*tss)); in tss32_restore()
566 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc, in tss32_restore()
570 update_seg_desc(ctx, vcpu, VM_REG_GUEST_LDTR, &seg_desc); in tss32_restore()
581 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_CS, &seg_desc, in tss32_restore()
586 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_SS, &seg_desc2, in tss32_restore()
590 update_seg_desc(ctx, vcpu, VM_REG_GUEST_CS, &seg_desc); in tss32_restore()
591 update_seg_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc2); in tss32_restore()
594 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_DS, &seg_desc, in tss32_restore()
598 update_seg_desc(ctx, vcpu, VM_REG_GUEST_DS, &seg_desc); in tss32_restore()
600 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_ES, &seg_desc, in tss32_restore()
604 update_seg_desc(ctx, vcpu, VM_REG_GUEST_ES, &seg_desc); in tss32_restore()
606 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_FS, &seg_desc, in tss32_restore()
610 update_seg_desc(ctx, vcpu, VM_REG_GUEST_FS, &seg_desc); in tss32_restore()
612 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_GS, &seg_desc, in tss32_restore()
616 update_seg_desc(ctx, vcpu, VM_REG_GUEST_GS, &seg_desc); in tss32_restore()
627 push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in push_errcode() argument
639 cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0); in push_errcode()
640 rflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS); in push_errcode()
641 stacksel = GETREG(ctx, vcpu, VM_REG_GUEST_SS); in push_errcode()
643 error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc.base, in push_errcode()
667 esp = GETREG(ctx, vcpu, VM_REG_GUEST_RSP); in push_errcode()
672 sel_exception(ctx, vcpu, IDT_SS, stacksel, 1); in push_errcode()
678 vm_inject_ac(ctx, vcpu, 1); in push_errcode()
683 error = vm_copy_setup(ctx, vcpu, paging, gla, bytes, PROT_WRITE, in push_errcode()
688 vm_copyout(ctx, vcpu, &errcode, iov, bytes); in push_errcode()
689 SETREG(ctx, vcpu, VM_REG_GUEST_RSP, esp); in push_errcode()
717 int error, ext, fault, minlimit, nt_type, ot_type, vcpu; in vmexit_task_switch() local
726 vcpu = *pvcpu; in vmexit_task_switch()
745 error = read_tss_descriptor(ctx, vcpu, task_switch, nt_sel, &nt_desc, in vmexit_task_switch()
755 sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
761 sel_exception(ctx, vcpu, IDT_NP, nt_sel, ext); in vmexit_task_switch()
778 sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
784 sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
793 sel_exception(ctx, vcpu, IDT_GP, nt_sel, ext); in vmexit_task_switch()
798 error = vm_copy_setup(ctx, vcpu, &sup_paging, nt.base, minlimit + 1, in vmexit_task_switch()
801 vm_copyin(ctx, vcpu, nt_iov, &newtss, minlimit + 1); in vmexit_task_switch()
804 ot_sel = GETREG(ctx, vcpu, VM_REG_GUEST_TR); in vmexit_task_switch()
812 sel_exception(ctx, vcpu, IDT_TS, ot_sel, task_switch->ext); in vmexit_task_switch()
817 error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_TR, &ot_base, &ot_lim, in vmexit_task_switch()
825 error = read_tss_descriptor(ctx, vcpu, task_switch, ot_sel, &ot_desc, in vmexit_task_switch()
830 error = vm_copy_setup(ctx, vcpu, &sup_paging, ot_base, minlimit + 1, in vmexit_task_switch()
833 vm_copyin(ctx, vcpu, ot_iov, &oldtss, minlimit + 1); in vmexit_task_switch()
841 error = desc_table_write(ctx, vcpu, &sup_paging, ot_sel, in vmexit_task_switch()
852 tss32_save(ctx, vcpu, task_switch, eip, &oldtss, ot_iov); in vmexit_task_switch()
860 error = desc_table_write(ctx, vcpu, &sup_paging, nt_sel, in vmexit_task_switch()
866 SETREG(ctx, vcpu, VM_REG_GUEST_TR, nt_sel); in vmexit_task_switch()
870 update_seg_desc(ctx, vcpu, VM_REG_GUEST_TR, &nt); in vmexit_task_switch()
873 cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0); in vmexit_task_switch()
874 SETREG(ctx, vcpu, VM_REG_GUEST_CR0, cr0 | CR0_TS); in vmexit_task_switch()
881 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, newtss.tss_eip); in vmexit_task_switch()
885 error = tss32_restore(ctx, vcpu, task_switch, ot_sel, &newtss, nt_iov, in vmexit_task_switch()
897 error = push_errcode(ctx, vcpu, &task_switch->paging, nt_type, in vmexit_task_switch()
933 error = vm_set_intinfo(ctx, vcpu, 0); in vmexit_task_switch()