⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vmx_virt.c

📁 xen虚拟机源代码安装包
💻 C
📖 第 1 页 / 共 3 页
字号:
    int fault=IA64_NO_FAULT;    visr.val=0;    if(check_target_register(vcpu, inst.M46.r1)){        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    vpsr.val=vmx_vcpu_get_psr(vcpu);    if(vpsr.cpl!=0){        vcpu_set_isr(vcpu, visr.val);        return IA64_FAULT;    }#endif    if(vcpu_get_gr_nat(vcpu, inst.M46.r3, &r3)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,1);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif    }    r1 = vmx_vcpu_tak(vcpu, r3);    vcpu_set_gr(vcpu, inst.M46.r1, r1, 0);    return(IA64_NO_FAULT);}/************************************ * Insert translation register/cache************************************/static IA64FAULT vmx_emul_itr_d(VCPU *vcpu, INST64 inst){    u64 itir, ifa, pte, slot;    ISR isr;#ifdef  VMAL_NO_FAULT_CHECK    IA64_PSR  vpsr;    vpsr.val = vmx_vcpu_get_psr(vcpu);    if (vpsr.ic) {        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr(vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    if (vcpu_get_gr_nat(vcpu, inst.M45.r3, &slot)        || vcpu_get_gr_nat(vcpu, inst.M45.r2, &pte)) {#ifdef  VMAL_NO_FAULT_CHECK        set_isr_reg_nat_consumption(vcpu, 0, 0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif // VMAL_NO_FAULT_CHECK    }#ifdef  VMAL_NO_FAULT_CHECK    if (is_reserved_rr_register(vcpu, slot)) {        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    if (vcpu_get_itir(vcpu ,&itir)) {        return(IA64_FAULT);    }    if (vcpu_get_ifa(vcpu, &ifa)) {        return(IA64_FAULT);    }#ifdef  VMAL_NO_FAULT_CHECK    if (is_reserved_itir_field(vcpu, itir)) {    	// TODO    	return IA64_FAULT;    }    if (unimplemented_gva(vcpu, ifa)) {        unimpl_daddr(vcpu);        return IA64_FAULT;   }#endif // VMAL_NO_FAULT_CHECK    if (slot >= NDTRS) {        isr.val = set_isr_ei_ni(vcpu);        isr.code = IA64_RESERVED_REG_FAULT;        vcpu_set_isr(vcpu, isr.val);        rsv_reg_field(vcpu);        return IA64_FAULT;    }    debugger_event(XEN_IA64_DEBUG_ON_TR);    return (vmx_vcpu_itr_d(vcpu, slot, pte, itir, ifa));}static IA64FAULT vmx_emul_itr_i(VCPU *vcpu, INST64 inst){    u64 itir, ifa, pte, slot;    ISR isr;#ifdef  VMAL_NO_FAULT_CHECK    IA64_PSR  vpsr;    vpsr.val = vmx_vcpu_get_psr(vcpu);    if (vpsr.ic) {        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr(vcpu, 0);        privilege_op(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    if (vcpu_get_gr_nat(vcpu, inst.M45.r3, &slot)        || vcpu_get_gr_nat(vcpu, inst.M45.r2, &pte)) {#ifdef  VMAL_NO_FAULT_CHECK        set_isr_reg_nat_consumption(vcpu, 0, 0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif // VMAL_NO_FAULT_CHECK    }#ifdef  VMAL_NO_FAULT_CHECK    if (is_reserved_rr_register(vcpu, slot)) {        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    if (vcpu_get_itir(vcpu, &itir)) {        return IA64_FAULT;    }    if (vcpu_get_ifa(vcpu, &ifa)) {        return IA64_FAULT;    }#ifdef  VMAL_NO_FAULT_CHECK    if (is_reserved_itir_field(vcpu, itir)) {    	// TODO    	return IA64_FAULT;    }    if (unimplemented_gva(vcpu, ifa)) {        unimpl_daddr(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    if (slot >= NITRS) {        isr.val = set_isr_ei_ni(vcpu);        isr.code = IA64_RESERVED_REG_FAULT;        vcpu_set_isr(vcpu, isr.val);        rsv_reg_field(vcpu);        return IA64_FAULT;    }    debugger_event(XEN_IA64_DEBUG_ON_TR);    return vmx_vcpu_itr_i(vcpu, slot, pte, itir, ifa);}static IA64FAULT itc_fault_check(VCPU *vcpu, INST64 inst,                                 u64 *itir, u64 *ifa, u64 *pte){    IA64FAULT	ret1;#ifdef  VMAL_NO_FAULT_CHECK    IA64_PSR  vpsr;    vpsr.val = vmx_vcpu_get_psr(vcpu);    if (vpsr.ic) {        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    u64 fault;    ISR isr;    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr(vcpu, 0);        privilege_op(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    ret1 = vcpu_get_gr_nat(vcpu, inst.M45.r2,pte);#ifdef  VMAL_NO_FAULT_CHECK    if (ret1 != IA64_NO_FAULT) {        set_isr_reg_nat_consumption(vcpu, 0, 0);        rnat_comsumption(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    if (vcpu_get_itir(vcpu, itir)) {        return IA64_FAULT;    }    if (vcpu_get_ifa(vcpu, ifa)) {        return IA64_FAULT;    }#ifdef  VMAL_NO_FAULT_CHECK    if (unimplemented_gva(vcpu,ifa) ) {        unimpl_daddr(vcpu);        return IA64_FAULT;    }#endif // VMAL_NO_FAULT_CHECK    return IA64_NO_FAULT;}static IA64FAULT vmx_emul_itc_d(VCPU *vcpu, INST64 inst){    u64 itir, ifa, pte;    if ( itc_fault_check(vcpu, inst, &itir, &ifa, &pte) == IA64_FAULT ) {    	return IA64_FAULT;    }    debugger_event(XEN_IA64_DEBUG_ON_TC);        return vmx_vcpu_itc_d(vcpu, pte, itir, ifa);}static IA64FAULT vmx_emul_itc_i(VCPU *vcpu, INST64 inst){    u64 itir, ifa, pte;    if ( itc_fault_check(vcpu, inst, &itir, &ifa, &pte) == IA64_FAULT ) {    	return IA64_FAULT;    }    debugger_event(XEN_IA64_DEBUG_ON_TC);    return vmx_vcpu_itc_i(vcpu, pte, itir, ifa);}/************************************* * Moves to semi-privileged registers*************************************/static IA64FAULT vmx_emul_mov_to_ar_imm(VCPU *vcpu, INST64 inst){    // I27 and M30 are identical for these fields    u64 imm;    if(inst.M30.ar3!=44){        panic_domain(vcpu_regs(vcpu),"Can't support ar register other than itc");    }#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if ( vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(inst.M30.s){        imm = -inst.M30.imm;    }else{        imm = inst.M30.imm;    }    return (vmx_vcpu_set_itc(vcpu, imm));}static IA64FAULT vmx_emul_mov_to_ar_reg(VCPU *vcpu, INST64 inst){    // I26 and M29 are identical for these fields    u64 r2;    if(inst.M29.ar3!=44){        panic_domain(vcpu_regs(vcpu),"Can't support ar register other than itc");    }    if(vcpu_get_gr_nat(vcpu,inst.M29.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if ( vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    return (vmx_vcpu_set_itc(vcpu, r2));}static IA64FAULT vmx_emul_mov_from_ar_reg(VCPU *vcpu, INST64 inst){    // I27 and M30 are identical for these fields    u64 r1;    if(inst.M31.ar3!=44){        panic_domain(vcpu_regs(vcpu),"Can't support ar register other than itc");    }#ifdef  CHECK_FAULT    if(check_target_register(vcpu,inst.M31.r1)){        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.si&& vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    r1 = vmx_vcpu_get_itc(vcpu);    vcpu_set_gr(vcpu,inst.M31.r1,r1,0);    return IA64_NO_FAULT;}/******************************** * Moves to privileged registers********************************/static IA64FAULT vmx_emul_mov_to_pkr(VCPU *vcpu, INST64 inst){    u64 r3,r2;#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(vcpu_get_gr_nat(vcpu,inst.M42.r3,&r3)||vcpu_get_gr_nat(vcpu,inst.M42.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }    return (vmx_vcpu_set_pkr(vcpu,r3,r2));}static IA64FAULT vmx_emul_mov_to_rr(VCPU *vcpu, INST64 inst){    u64 r3,r2;#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(vcpu_get_gr_nat(vcpu,inst.M42.r3,&r3)||vcpu_get_gr_nat(vcpu,inst.M42.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }    return (vmx_vcpu_set_rr(vcpu,r3,r2));}static IA64FAULT vmx_emul_mov_to_dbr(VCPU *vcpu, INST64 inst){    u64 r3,r2;#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(vcpu_get_gr_nat(vcpu,inst.M42.r3,&r3)||vcpu_get_gr_nat(vcpu,inst.M42.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }    return (vmx_vcpu_set_dbr(vcpu,r3,r2));}static IA64FAULT vmx_emul_mov_to_ibr(VCPU *vcpu, INST64 inst){    u64 r3,r2;#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(vcpu_get_gr_nat(vcpu,inst.M42.r3,&r3)||vcpu_get_gr_nat(vcpu,inst.M42.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }    return vmx_vcpu_set_ibr(vcpu,r3,r2);}static IA64FAULT vmx_emul_mov_to_pmc(VCPU *vcpu, INST64 inst){    u64 r3,r2;#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(vcpu_get_gr_nat(vcpu,inst.M42.r3,&r3)||vcpu_get_gr_nat(vcpu,inst.M42.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }    return (vmx_vcpu_set_pmc(vcpu,r3,r2));}static IA64FAULT vmx_emul_mov_to_pmd(VCPU *vcpu, INST64 inst){    u64 r3,r2;#ifdef  CHECK_FAULT    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif // CHECK_FAULT    if(vcpu_get_gr_nat(vcpu,inst.M42.r3,&r3)||vcpu_get_gr_nat(vcpu,inst.M42.r2,&r2)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }    return (vmx_vcpu_set_pmd(vcpu,r3,r2));}/********************************** * Moves from privileged registers **********************************/static IA64FAULT vmx_emul_mov_from_rr(VCPU *vcpu, INST64 inst){    u64 r3,r1;#ifdef  CHECK_FAULT    if(check_target_register(vcpu, inst.M43.r1)){        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif //CHECK_FAULT     if(vcpu_get_gr_nat(vcpu,inst.M43.r3,&r3)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }#ifdef  CHECK_FAULT    if(is_reserved_rr_register(vcpu,r3>>VRN_SHIFT)){        set_rsv_reg_field_isr(vcpu);        rsv_reg_field(vcpu);    }#endif  //CHECK_FAULT    vcpu_get_rr(vcpu,r3,&r1);    return vcpu_set_gr(vcpu, inst.M43.r1, r1,0);}static IA64FAULT vmx_emul_mov_from_pkr(VCPU *vcpu, INST64 inst){    u64 r3,r1;#ifdef  CHECK_FAULT    if(check_target_register(vcpu, inst.M43.r1)){        set_illegal_op_isr(vcpu);        illegal_op(vcpu);        return IA64_FAULT;    }    IA64_PSR vpsr;    vpsr.val=vmx_vcpu_get_psr(vcpu);    if (vpsr.cpl != 0) {        /* Inject Privileged Operation fault into guest */        set_privileged_operation_isr (vcpu, 0);        privilege_op (vcpu);        return IA64_FAULT;    }#endif //CHECK_FAULT     if(vcpu_get_gr_nat(vcpu,inst.M43.r3,&r3)){#ifdef  CHECK_FAULT        set_isr_reg_nat_consumption(vcpu,0,0);        rnat_comsumption(vcpu);        return IA64_FAULT;#endif  //CHECK_FAULT    }#ifdef  CHECK_FAULT    if(is_reserved_indirect_register(vcpu,r3)){        set_rsv_reg_field_isr(vcpu);        rsv_reg_field(vcpu);        return IA64_FAULT;    }#endif  //CHECK_FAULT    r1 = vmx_vcpu_get_pkr(vcpu, r3);    return vcpu_set_gr(vcpu, inst.M43.r1, r1,0);}static IA64FAULT vmx_emul_mov_from_dbr(VCPU *vcpu, INST64 inst){    u64 r3,r1;    IA64FAULT res;#ifdef  CHECK_FAULT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -