Lines Matching refs:vcpu

103 GETREG(struct vmctx *ctx, int vcpu, int reg)  in GETREG()  argument
108 error = vm_get_register(ctx, vcpu, reg, &val); in GETREG()
114 SETREG(struct vmctx *ctx, int vcpu, int reg, uint64_t val) in SETREG() argument
118 error = vm_set_register(ctx, vcpu, reg, val); in SETREG()
154 sel_exception(struct vmctx *ctx, int vcpu, int vector, uint16_t sel, int ext) in sel_exception() argument
168 vm_inject_fault(ctx, vcpu, vector, 1, sel); in sel_exception()
176 desc_table_limit_check(struct vmctx *ctx, int vcpu, uint16_t sel) in desc_table_limit_check() argument
183 error = vm_get_desc(ctx, vcpu, reg, &base, &limit, &access); in desc_table_limit_check()
206 desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in desc_table_rw() argument
216 error = vm_get_desc(ctx, vcpu, reg, &base, &limit, &access); in desc_table_rw()
220 error = vm_copy_setup(ctx, vcpu, paging, base + SEL_START(sel), in desc_table_rw()
227 vm_copyin(ctx, vcpu, iov, desc, sizeof(*desc)); in desc_table_rw()
229 vm_copyout(ctx, vcpu, desc, iov, sizeof(*desc)); in desc_table_rw()
234 desc_table_read(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in desc_table_read() argument
237 return (desc_table_rw(ctx, vcpu, paging, sel, desc, true, faultptr)); in desc_table_read()
241 desc_table_write(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in desc_table_write() argument
244 return (desc_table_rw(ctx, vcpu, paging, sel, desc, false, faultptr)); in desc_table_write()
255 read_tss_descriptor(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, in read_tss_descriptor() argument
265 if (desc_table_limit_check(ctx, vcpu, sel)) { in read_tss_descriptor()
267 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in read_tss_descriptor()
269 sel_exception(ctx, vcpu, IDT_GP, sel, ts->ext); in read_tss_descriptor()
275 error = desc_table_read(ctx, vcpu, &sup_paging, sel, desc, faultptr); in read_tss_descriptor()
311 validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, in validate_seg_desc() argument
343 sel = GETREG(ctx, vcpu, segment); in validate_seg_desc()
347 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
352 if (desc_table_limit_check(ctx, vcpu, sel)) { in validate_seg_desc()
353 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
361 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
373 error = desc_table_read(ctx, vcpu, &sup_paging, sel, &usd, faultptr); in validate_seg_desc()
382 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
394 sel_exception(ctx, vcpu, idtvec, sel, ts->ext); in validate_seg_desc()
398 cs = GETREG(ctx, vcpu, VM_REG_GUEST_CS); in validate_seg_desc()
404 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
412 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
428 sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext); in validate_seg_desc()
437 tss32_save(struct vmctx *ctx, int vcpu, struct vm_task_switch *task_switch, in tss32_save() argument
442 tss->tss_eax = GETREG(ctx, vcpu, VM_REG_GUEST_RAX); in tss32_save()
443 tss->tss_ecx = GETREG(ctx, vcpu, VM_REG_GUEST_RCX); in tss32_save()
444 tss->tss_edx = GETREG(ctx, vcpu, VM_REG_GUEST_RDX); in tss32_save()
445 tss->tss_ebx = GETREG(ctx, vcpu, VM_REG_GUEST_RBX); in tss32_save()
446 tss->tss_esp = GETREG(ctx, vcpu, VM_REG_GUEST_RSP); in tss32_save()
447 tss->tss_ebp = GETREG(ctx, vcpu, VM_REG_GUEST_RBP); in tss32_save()
448 tss->tss_esi = GETREG(ctx, vcpu, VM_REG_GUEST_RSI); in tss32_save()
449 tss->tss_edi = GETREG(ctx, vcpu, VM_REG_GUEST_RDI); in tss32_save()
452 tss->tss_es = GETREG(ctx, vcpu, VM_REG_GUEST_ES); in tss32_save()
453 tss->tss_cs = GETREG(ctx, vcpu, VM_REG_GUEST_CS); in tss32_save()
454 tss->tss_ss = GETREG(ctx, vcpu, VM_REG_GUEST_SS); in tss32_save()
455 tss->tss_ds = GETREG(ctx, vcpu, VM_REG_GUEST_DS); in tss32_save()
456 tss->tss_fs = GETREG(ctx, vcpu, VM_REG_GUEST_FS); in tss32_save()
457 tss->tss_gs = GETREG(ctx, vcpu, VM_REG_GUEST_GS); in tss32_save()
460 tss->tss_eflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS); in tss32_save()
466 vm_copyout(ctx, vcpu, tss, iov, sizeof(struct tss32)); in tss32_save()
470 update_seg_desc(struct vmctx *ctx, int vcpu, int reg, struct seg_desc *sd) in update_seg_desc() argument
474 error = vm_set_desc(ctx, vcpu, reg, sd->base, sd->limit, sd->access); in update_seg_desc()
482 tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, in tss32_restore() argument
502 SETREG(ctx, vcpu, VM_REG_GUEST_LDTR, tss->tss_ldt); in tss32_restore()
522 vm_inject_gp(ctx, vcpu); in tss32_restore()
526 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE0, pdpte[0]); in tss32_restore()
527 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE1, pdpte[1]); in tss32_restore()
528 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE2, pdpte[2]); in tss32_restore()
529 SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE3, pdpte[3]); in tss32_restore()
531 SETREG(ctx, vcpu, VM_REG_GUEST_CR3, tss->tss_cr3); in tss32_restore()
536 SETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS, eflags); in tss32_restore()
537 SETREG(ctx, vcpu, VM_REG_GUEST_RIP, tss->tss_eip); in tss32_restore()
540 SETREG(ctx, vcpu, VM_REG_GUEST_RAX, tss->tss_eax); in tss32_restore()
541 SETREG(ctx, vcpu, VM_REG_GUEST_RCX, tss->tss_ecx); in tss32_restore()
542 SETREG(ctx, vcpu, VM_REG_GUEST_RDX, tss->tss_edx); in tss32_restore()
543 SETREG(ctx, vcpu, VM_REG_GUEST_RBX, tss->tss_ebx); in tss32_restore()
544 SETREG(ctx, vcpu, VM_REG_GUEST_RSP, tss->tss_esp); in tss32_restore()
545 SETREG(ctx, vcpu, VM_REG_GUEST_RBP, tss->tss_ebp); in tss32_restore()
546 SETREG(ctx, vcpu, VM_REG_GUEST_RSI, tss->tss_esi); in tss32_restore()
547 SETREG(ctx, vcpu, VM_REG_GUEST_RDI, tss->tss_edi); in tss32_restore()
550 SETREG(ctx, vcpu, VM_REG_GUEST_ES, tss->tss_es); in tss32_restore()
551 SETREG(ctx, vcpu, VM_REG_GUEST_CS, tss->tss_cs); in tss32_restore()
552 SETREG(ctx, vcpu, VM_REG_GUEST_SS, tss->tss_ss); in tss32_restore()
553 SETREG(ctx, vcpu, VM_REG_GUEST_DS, tss->tss_ds); in tss32_restore()
554 SETREG(ctx, vcpu, VM_REG_GUEST_FS, tss->tss_fs); in tss32_restore()
555 SETREG(ctx, vcpu, VM_REG_GUEST_GS, tss->tss_gs); in tss32_restore()
562 vm_copyout(ctx, vcpu, tss, iov, sizeof(*tss)); in tss32_restore()
565 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc, in tss32_restore()
569 update_seg_desc(ctx, vcpu, VM_REG_GUEST_LDTR, &seg_desc); in tss32_restore()
580 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_CS, &seg_desc, in tss32_restore()
585 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_SS, &seg_desc2, in tss32_restore()
589 update_seg_desc(ctx, vcpu, VM_REG_GUEST_CS, &seg_desc); in tss32_restore()
590 update_seg_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc2); in tss32_restore()
593 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_DS, &seg_desc, in tss32_restore()
597 update_seg_desc(ctx, vcpu, VM_REG_GUEST_DS, &seg_desc); in tss32_restore()
599 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_ES, &seg_desc, in tss32_restore()
603 update_seg_desc(ctx, vcpu, VM_REG_GUEST_ES, &seg_desc); in tss32_restore()
605 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_FS, &seg_desc, in tss32_restore()
609 update_seg_desc(ctx, vcpu, VM_REG_GUEST_FS, &seg_desc); in tss32_restore()
611 error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_GS, &seg_desc, in tss32_restore()
615 update_seg_desc(ctx, vcpu, VM_REG_GUEST_GS, &seg_desc); in tss32_restore()
626 push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, in push_errcode() argument
638 cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0); in push_errcode()
639 rflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS); in push_errcode()
640 stacksel = GETREG(ctx, vcpu, VM_REG_GUEST_SS); in push_errcode()
642 error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc.base, in push_errcode()
666 esp = GETREG(ctx, vcpu, VM_REG_GUEST_RSP); in push_errcode()
671 sel_exception(ctx, vcpu, IDT_SS, stacksel, 1); in push_errcode()
677 vm_inject_ac(ctx, vcpu, 1); in push_errcode()
682 error = vm_copy_setup(ctx, vcpu, paging, gla, bytes, PROT_WRITE, in push_errcode()
687 vm_copyout(ctx, vcpu, &errcode, iov, bytes); in push_errcode()
688 SETREG(ctx, vcpu, VM_REG_GUEST_RSP, esp); in push_errcode()
716 int error, ext, fault, minlimit, nt_type, ot_type, vcpu; in vmexit_task_switch() local
725 vcpu = *pvcpu; in vmexit_task_switch()
744 error = read_tss_descriptor(ctx, vcpu, task_switch, nt_sel, &nt_desc, in vmexit_task_switch()
754 sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
760 sel_exception(ctx, vcpu, IDT_NP, nt_sel, ext); in vmexit_task_switch()
777 sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
783 sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); in vmexit_task_switch()
792 sel_exception(ctx, vcpu, IDT_GP, nt_sel, ext); in vmexit_task_switch()
797 error = vm_copy_setup(ctx, vcpu, &sup_paging, nt.base, minlimit + 1, in vmexit_task_switch()
800 vm_copyin(ctx, vcpu, nt_iov, &newtss, minlimit + 1); in vmexit_task_switch()
803 ot_sel = GETREG(ctx, vcpu, VM_REG_GUEST_TR); in vmexit_task_switch()
811 sel_exception(ctx, vcpu, IDT_TS, ot_sel, task_switch->ext); in vmexit_task_switch()
816 error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_TR, &ot_base, &ot_lim, in vmexit_task_switch()
824 error = read_tss_descriptor(ctx, vcpu, task_switch, ot_sel, &ot_desc, in vmexit_task_switch()
829 error = vm_copy_setup(ctx, vcpu, &sup_paging, ot_base, minlimit + 1, in vmexit_task_switch()
832 vm_copyin(ctx, vcpu, ot_iov, &oldtss, minlimit + 1); in vmexit_task_switch()
840 error = desc_table_write(ctx, vcpu, &sup_paging, ot_sel, in vmexit_task_switch()
851 tss32_save(ctx, vcpu, task_switch, eip, &oldtss, ot_iov); in vmexit_task_switch()
859 error = desc_table_write(ctx, vcpu, &sup_paging, nt_sel, in vmexit_task_switch()
865 SETREG(ctx, vcpu, VM_REG_GUEST_TR, nt_sel); in vmexit_task_switch()
869 update_seg_desc(ctx, vcpu, VM_REG_GUEST_TR, &nt); in vmexit_task_switch()
872 cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0); in vmexit_task_switch()
873 SETREG(ctx, vcpu, VM_REG_GUEST_CR0, cr0 | CR0_TS); in vmexit_task_switch()
880 error = vm_set_register(ctx, 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(ctx, vcpu, &task_switch->paging, nt_type, in vmexit_task_switch()
932 error = vm_set_intinfo(ctx, vcpu, 0); in vmexit_task_switch()