Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Andreas Tanz wrote: Craig Metz wrote: In message 49d396ab.6090...@redhat.com, you write: Via engineers have contacted me and confirmed that this is a problem in the processor. Is there a known-fixed CPU revision? Is there a way to identify working vs. non-working chips, either from IC stamp or from /proc/cpuinfo? (Bonus: is it possible to put a check and an error into the kvm-intel kernel model?) I have no idea. Please contact Via for this information. Hi, I've read an EMail from VIA, telling that the Nano must be at least stepping 3. Prior steppings have a buggy vt implementation... (Damn! I have stepping 2 :-I ) Can you send your /proc/cpuinfo, I'll try to blacklist it. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Craig Metz wrote: In message 49d396ab.6090...@redhat.com, you write: Via engineers have contacted me and confirmed that this is a problem in the processor. Is there a known-fixed CPU revision? Is there a way to identify working vs. non-working chips, either from IC stamp or from /proc/cpuinfo? (Bonus: is it possible to put a check and an error into the kvm-intel kernel model?) I have no idea. Please contact Via for this information. Hi, I've read an EMail from VIA, telling that the Nano must be at least stepping 3. Prior steppings have a buggy vt implementation... (Damn! I have stepping 2 :-I ) -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Avi Kivity wrote: Will talk to the specification and come up with further tests. Please printk() vmcs_readl(GUEST_RFLAGS) (where you printk kvm_rip_read()). vmx.c: 2637 static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2638 { ... 2687 error_code = 0; 2688 rip = kvm_rip_read(vcpu); 2689 unsigned long debug_guest_rflags = vmcs_readl(GUEST_RFLAGS); 2690 printk(KERN_ERR vmx-handle_exception 0a : kvm_rip_read(vcpu) returned 0x%lx ; vmcs_readl(GUEST_RFLAGS) returned 0x%x 2691 if (intr_info INTR_INFO_DELIVER_CODE_MASK) 2692 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); ... # dmesg ... [63930.809295] returning from kvm_handle_exit, cause 3, retval = 0, exit_reason = 30 [63930.809313] vmx-vmx_vcpu_run() 00 : vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) returned 0x0 [63930.809326] returning from kvm_handle_exit, cause 3, retval = 0, exit_reason = 30 [63930.809344] vmx-vmx_vcpu_run() 00 : vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) returned 0x0 [63930.809358] returning from kvm_handle_exit, cause 3, retval = 0, exit_reason = 30 [63930.809376] vmx-vmx_vcpu_run() 00 : vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) returned 0x0 [63930.809388] returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 7 [63930.809399] vmx-vmx_vcpu_run() 00 : vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) returned 0x8408 [63930.809412] vmx-handle_exception 00 : giving some infos [63930.809417] vmx-handle_exception 01 : vect_info: 0x0 [63930.809423] vmx-handle_exception 02 : intr_info: 0x8b0d, is_page_fault()==0 [63930.809429] vmx-handle_exception 03 : irq_chip_in_kernel()==1 [63930.809434] vmx-handle_exception 04 : is_external_interrupt()==0 [63930.809440] vmx-handle_exception 0a : kvm_rip_read(vcpu) returned 0x3154 ; vmcs_readl(GUEST_RFLAGS) returned 0x33202 [63930.809447] vmx-handle_exception 0f : vcpu-arch.rmode.active: 0x1 [63930.809454] vmx-handle_exception 10 : handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code) returned 0x1 [63930.809462] returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 0 [63930.809474] vmx-vmx_vcpu_run() 00 : vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) returned 0x840d -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Andreas Tanz wrote: [ 3732.020033] returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 7 Here, vmx tells us that the guest is ready to accept interrupts (having executed the sti instruction) [ 3732.020044] vmx-vmx_vcpu_run() 00 : vmcs_read32(VM_ENTRY_INTR_INFO_FIELD) returned 0x8408 ... noticing that, kvm injects a timer interrupt that was previously blocked ... [ 3732.020056] vmx-handle_exception 00 : giving some infos [ 3732.020062] vmx-handle_exception 01 : vect_info: 0x0 [ 3732.020067] vmx-handle_exception 02 : intr_info: 0x8b0d, is_page_fault()==0 ... and the Nano rewards us with a General Protection Fault instead of injecting the interrupt. Will talk to the specification and come up with further tests. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Avi Kivity wrote: Will talk to the specification and come up with further tests. Please printk() vmcs_readl(GUEST_RFLAGS) (where you printk kvm_rip_read()). -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Andreas Tanz wrote: Hi! The guest starts up showing the Bochs BIOS POST and stucks giving thousands of lines : [15013.656923] returning from kvm_handle_exit, cause 3, retval = 1 What was the value of exit_reason? kernel/x86/vmx.c: 3211 static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) 3212 { ... 3273 if (exit_reason kvm_vmx_max_exit_handlers 3274 kvm_vmx_exit_handlers[exit_reason]){ 3275 int retval = kvm_vmx_exit_handlers[exit_reason](vcpu, kvm_run); 3276 printk(KERN_WARNING returning from kvm_handle_exit, cause 3, retval = %i 3277 , exit_reason = %i\n 3278 ,retval, exit_reason); 3279 // return kvm_vmx_exit_handlers[exit_reason](vcpu, kvm_run); 3280 return retval; 3281 } 3282 else { 3283 kvm_run-exit_reason = KVM_EXIT_UNKNOWN; 3284 kvm_run-hw.hardware_exit_reason = exit_reason; 3285 } 3286 printk(KERN_WARNING returning from kvm_handle_exit\n 3287 return 0; 3288 } ... -- dmesg : [79116.175571] returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 0 That's an exception or nmi. Next step is to instrument handle_exception() and see what happens there. Please print out vect_info, intr_info, and kvm_rip_read(vcpu) (all as hex). The more you instrument, of course, the better. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
-- dmesg : [79116.175571] returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 0 That's an exception or nmi. Next step is to instrument handle_exception() and see what happens there. Please print out vect_info, intr_info, and kvm_rip_read(vcpu) (all as hex). The more you instrument, of course, the better. for testing i killed the kvm guest 0.4s after starting it - got this: thousands of lines : returning from kvm_handle_exit, cause 3, retval = 0, exit_reason = 30 mixed with single line (every ca. 40th-100th line) : returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 1 ... vmx.c : ... 3244 static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ... 3306 if (exit_reason kvm_vmx_max_exit_handlers 3307 kvm_vmx_exit_handlers[exit_reason]){ 3308 int retval = kvm_vmx_exit_handlers[exit_reason](vcpu, kvm_run); 3309 printk(KERN_WARNING returning from kvm_handle_exit, cause 3, retval = %i 3310 , exit_reason = %i\n 3311 ,retval, exit_reason); 3312 // return kvm_vmx_exit_handlers[exit_reason](vcpu, kvm_run); 3313 return retval; 3314 } 3315 else { ... i modded handle_exception : vmx.c: ... 2637 static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2638 { 2639 struct vcpu_vmx *vmx = to_vmx(vcpu); 2640 u32 intr_info, ex_no, error_code; 2641 unsigned long cr2, rip, dr6; 2642 u32 vect_info; 2643 enum emulation_result er; 2644 2645 vect_info = vmx-idt_vectoring_info; 2646 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); 2647 2648 printk(KERN_ERR vmx-handle_exception 00 : giving some infos\n); 2649 printk(KERN_ERR vmx-handle_exception 01 : vect_info: 0x%x\n,vect_info); 2650 printk(KERN_ERR vmx-handle_exception 02 : intr_info: 0x%x, is_page_fault()==i%i\n,intr_info,is_page_fault(intr_info)); 2651 2652 if ((vect_info VECTORING_INFO_VALID_MASK) 2653 !is_page_fault(intr_info)) 2654 printk(KERN_ERR %s: unexpected, vectoring info 0x%x 2655intr info 0x%x\n, __func__, vect_info, intr_info); 2656 2657 printk(KERN_ERR vmx-handle_exception 03 : irq_chip_in_kernel()==i%i\n,irqchip_in_kernel(vcpu-kvm)); 2658 printk(KERN_ERR vmx-handle_exception 04 : is_external_interrupt()==i%i\n,is_external_interrupt(vect_info)); 2659 if (!irqchip_in_kernel(vcpu-kvm) is_external_interrupt(vect_info)) { 2660 int irq = vect_info VECTORING_INFO_VECTOR_MASK; 2661 printk(KERN_ERR vmx-handle_exception 05 : irq: 0x%x\n,irq); 2662 set_bit(irq, vcpu-arch.irq_pending); 2663 set_bit(irq / BITS_PER_LONG, vcpu-arch.irq_summary); 2664 } 2665 2666 if ((intr_info INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR){ 2667 printk(KERN_ERR vmx-handle_exception 06 : already handled by vmx_vcpu_run()\n); 2668 return 1; /* already handled by vmx_vcpu_run() */ 2669 } 2670 2671 if (is_no_device(intr_info)) { 2672 printk(KERN_ERR vmx-handle_exception 07 : is_no_device(intr_info)\n); 2673 vmx_fpu_activate(vcpu); 2674 return 1; 2675 } 2676 2677 if (is_invalid_opcode(intr_info)) { 2678 printk(KERN_ERR vmx-handle_exception 08 : is_invalid_opcode(intr_info)\n); 2679 er = emulate_instruction(vcpu, kvm_run, 0, 0, EMULTYPE_TRAP_UD); 2680 if (er != EMULATE_DONE) { 2681 printk(KERN_ERR vmx-handle_exception 09 : emulation not done. enqueueing exception\n); 2682 kvm_queue_exception(vcpu, UD_VECTOR); 2683 } 2684 return 1; 2685 } 2686 2687 error_code = 0; 2688 rip = kvm_rip_read(vcpu); 2689 printk(KERN_ERR vmx-handle_exception 0a : kvm_rip_read(vcpu) returned 0x%x\n,rip); 2690 if (intr_info INTR_INFO_DELIVER_CODE_MASK) 2691 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); 2692 if (is_page_fault(intr_info)) { 2693 printk(KERN_ERR vmx-handle_exception 0b : is_page_fault(intr_info) returned 0x%x\n,is_page_fault(intr_info)); 2694 /* EPT won't cause page fault directly */ 2695 if (vm_need_ept()) 2696 BUG(); 2697 cr2 = vmcs_readl(EXIT_QUALIFICATION); 2698 printk(KERN_ERR vmx-handle_exception 0c : vmcs_readl(EXIT_QUALIFICATION) returned 0x%x\n,cr2); 2699 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, 2700 (u32)((u64)cr2 32), handler); 2701 if (vcpu-arch.interrupt.pending ||
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Andreas Tanz wrote: -- dmesg : [79116.175571] returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 0 That's an exception or nmi. Next step is to instrument handle_exception() and see what happens there. Please print out vect_info, intr_info, and kvm_rip_read(vcpu) (all as hex). The more you instrument, of course, the better. for testing i killed the kvm guest 0.4s after starting it - got this: thousands of lines : returning from kvm_handle_exit, cause 3, retval = 0, exit_reason = 30 mixed with single line (every ca. 40th-100th line) : returning from kvm_handle_exit, cause 3, retval = 1, exit_reason = 1 ... This is normal operation. 30 is IO_INSTRUCTION, the guest is probably reading its boot disk. 1 is EXTERNAL_INTERRUPT, normal host interrupts. So the guest hands a little later. Let it reach steady state and see where it hangs. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
i modded handle_exception as you said : vmx.c: ... 2637 static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2638 { 2639 struct vcpu_vmx *vmx = to_vmx(vcpu); 2640 u32 intr_info, ex_no, error_code; 2641 unsigned long cr2, rip, dr6; 2642 u32 vect_info; 2643 enum emulation_result er; 2644 2645 vect_info = vmx-idt_vectoring_info; 2646 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); 2647 2648 printk(KERN_ERR vmx-handle_exception 00 : giving some infos\n); 2649 printk(KERN_ERR vmx-handle_exception 01 : vect_info: 0x%x\n,vect_info); 2650 printk(KERN_ERR vmx-handle_exception 02 : intr_info: 0x%x, is_page_fault()==i%i\n,intr_info,is_page_fault(intr_info)); 2651 2652 if ((vect_info VECTORING_INFO_VALID_MASK) 2653 !is_page_fault(intr_info)) 2654 printk(KERN_ERR %s: unexpected, vectoring info 0x%x 2655intr info 0x%x\n, __func__, vect_info, intr_info); 2656 2657 printk(KERN_ERR vmx-handle_exception 03 : irq_chip_in_kernel()==i%i\n,irqchip_in_kernel(vcpu-kvm)); 2658 printk(KERN_ERR vmx-handle_exception 04 : is_external_interrupt()==i%i\n,is_external_interrupt(vect_info)); 2659 if (!irqchip_in_kernel(vcpu-kvm) is_external_interrupt(vect_info)) { 2660 int irq = vect_info VECTORING_INFO_VECTOR_MASK; 2661 printk(KERN_ERR vmx-handle_exception 05 : irq: 0x%x\n,irq); 2662 set_bit(irq, vcpu-arch.irq_pending); 2663 set_bit(irq / BITS_PER_LONG, vcpu-arch.irq_summary); 2664 } 2665 2666 if ((intr_info INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR){ 2667 printk(KERN_ERR vmx-handle_exception 06 : already handled by vmx_vcpu_run()\n); 2668 return 1; /* already handled by vmx_vcpu_run() */ 2669 } 2670 2671 if (is_no_device(intr_info)) { 2672 printk(KERN_ERR vmx-handle_exception 07 : is_no_device(intr_info)\n); 2673 vmx_fpu_activate(vcpu); 2674 return 1; 2675 } 2676 2677 if (is_invalid_opcode(intr_info)) { 2678 printk(KERN_ERR vmx-handle_exception 08 : is_invalid_opcode(intr_info)\n); 2679 er = emulate_instruction(vcpu, kvm_run, 0, 0, EMULTYPE_TRAP_UD); 2680 if (er != EMULATE_DONE) { 2681 printk(KERN_ERR vmx-handle_exception 09 : emulation not done. enqueueing exception\n); 2682 kvm_queue_exception(vcpu, UD_VECTOR); 2683 } 2684 return 1; 2685 } 2686 2687 error_code = 0; 2688 rip = kvm_rip_read(vcpu); 2689 printk(KERN_ERR vmx-handle_exception 0a : kvm_rip_read(vcpu) returned 0x%x\n,rip); 2690 if (intr_info INTR_INFO_DELIVER_CODE_MASK) 2691 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); 2692 if (is_page_fault(intr_info)) { 2693 printk(KERN_ERR vmx-handle_exception 0b : is_page_fault(intr_info) returned 0x%x\n,is_page_fault(intr_info)); 2694 /* EPT won't cause page fault directly */ 2695 if (vm_need_ept()) 2696 BUG(); 2697 cr2 = vmcs_readl(EXIT_QUALIFICATION); 2698 printk(KERN_ERR vmx-handle_exception 0c : vmcs_readl(EXIT_QUALIFICATION) returned 0x%x\n,cr2); 2699 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, 2700 (u32)((u64)cr2 32), handler); 2701 if (vcpu-arch.interrupt.pending || vcpu-arch.exception.pending){ 2702 printk(KERN_ERR vmx-handle_exception 0d : interrupt.pending or exception.pending\n); 2703 kvm_mmu_unprotect_page_virt(vcpu, cr2); 2704 } 2705 int retval = kvm_mmu_page_fault(vcpu, cr2, error_code); 2706 printk(KERN_ERR vmx-handle_exception 0e : kvm_mmu_page_fault(vcpu, cr2, error_code) returned 0x%x\n,retval); 2707 //return kvm_mmu_page_fault(vcpu, cr2, error_code); 2708 return retval; 2709 } 2710 2711 printk(KERN_ERR vmx-handle_exception 0f : vcpu-arch.rmode.active: 0x%x\n,vcpu-arch.rmode.active); 2712 int debug_handle_rmode_exception = handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code); 2713 printk(KERN_ERR vmx-handle_exception 10 : handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code) returned 0x%x\n, debug_handle_rmode_exception 2714 if (vcpu-arch.rmode.active debug_handle_rmode_exception) { 2715 if (vcpu-arch.halt_request) { 2716 printk(KERN_ERR vmx-handle_exception 11 : vcpu-arch.halt_request: 0x%x, resetting to 0\n,vcpu-arch.halt_request); 2717
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Andreas Tanz wrote: i modded handle_exception as you said : 2711 printk(KERN_ERR vmx-handle_exception 0f : vcpu-arch.rmode.active: 0x%x\n,vcpu-arch.rmode.active); 2712 int debug_handle_rmode_exception = handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code); 2713 printk(KERN_ERR vmx-handle_exception 10 : handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code) returned 0x%x\n, debug_handle_rmode_exception 2714 if (vcpu-arch.rmode.active debug_handle_rmode_exception) { This bit is broken. The original code: if (vcpu-arch.rmode.active handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code)) { Only executes handle_rmode_exception() if rmode.active is true. Your code executes it unconditionally. You can write it as if (vcpu-arch.rmode.active (retval = handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code))) { Please check for other cases as well. As it happens, the guest crashed immediately after entering protected mode (so rmode.active became false, triggering the bug). -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Am 19.03.2009 schrieb Avi Kivity: This bit is broken. The original code: if (vcpu-arch.rmode.active handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code)) { Only executes handle_rmode_exception() if rmode.active is true. Your code executes it unconditionally. You can write it as if (vcpu-arch.rmode.active (retval = handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code))) { Please check for other cases as well. As it happens, the guest crashed immediately after entering protected mode (so rmode.active became false, triggering the bug). ooops - stupid mistake :-I that was it... vmx.c now looks as this : 2637 static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2638 { 2639 struct vcpu_vmx *vmx = to_vmx(vcpu); 2640 u32 intr_info, ex_no, error_code; 2641 unsigned long cr2, rip, dr6; 2642 u32 vect_info; 2643 enum emulation_result er; 2644 2645 vect_info = vmx-idt_vectoring_info; 2646 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); 2647 2648 printk(KERN_ERR vmx-handle_exception 00 : giving some infos\n); 2649 printk(KERN_ERR vmx-handle_exception 01 : vect_info: 0x%x\n,vect_info); 2650 printk(KERN_ERR vmx-handle_exception 02 : intr_info: 0x%x, is_page_fault()==%i\n,intr_info,is_page_fault(intr_info)); 2651 2652 if ((vect_info VECTORING_INFO_VALID_MASK) 2653 !is_page_fault(intr_info)) 2654 printk(KERN_ERR %s: unexpected, vectoring info 0x%x 2655intr info 0x%x\n, __func__, vect_info, intr_info); 2656 2657 printk(KERN_ERR vmx-handle_exception 03 : irq_chip_in_kernel()==%i\n,irqchip_in_kernel(vcpu-kvm)); 2658 printk(KERN_ERR vmx-handle_exception 04 : is_external_interrupt()==%i\n,is_external_interrupt(vect_info)); 2659 if (!irqchip_in_kernel(vcpu-kvm) is_external_interrupt(vect_info)) { 2660 int irq = vect_info VECTORING_INFO_VECTOR_MASK; 2661 printk(KERN_ERR vmx-handle_exception 05 : irq: 0x%x\n,irq); 2662 set_bit(irq, vcpu-arch.irq_pending); 2663 set_bit(irq / BITS_PER_LONG, vcpu-arch.irq_summary); 2664 } 2665 2666 if ((intr_info INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR){ 2667 printk(KERN_ERR vmx-handle_exception 06 : already handled by vmx_vcpu_run()\n); 2668 return 1; /* already handled by vmx_vcpu_run() */ 2669 } 2670 2671 if (is_no_device(intr_info)) { 2672 printk(KERN_ERR vmx-handle_exception 07 : is_no_device(intr_info)\n); 2673 vmx_fpu_activate(vcpu); 2674 return 1; 2675 } 2676 2677 if (is_invalid_opcode(intr_info)) { 2678 printk(KERN_ERR vmx-handle_exception 08 : is_invalid_opcode(intr_info)\n); 2679 er = emulate_instruction(vcpu, kvm_run, 0, 0, EMULTYPE_TRAP_UD); 2680 if (er != EMULATE_DONE) { 2681 printk(KERN_ERR vmx-handle_exception 09 : emulation not done. enqueueing exception\n); 2682 kvm_queue_exception(vcpu, UD_VECTOR); 2683 } 2684 return 1; 2685 } 2686 2687 error_code = 0; 2688 rip = kvm_rip_read(vcpu); 2689 printk(KERN_ERR vmx-handle_exception 0a : kvm_rip_read(vcpu) returned 0x%lx\n,rip); 2690 if (intr_info INTR_INFO_DELIVER_CODE_MASK) 2691 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); 2692 if (is_page_fault(intr_info)) { 2693 printk(KERN_ERR vmx-handle_exception 0b : is_page_fault(intr_info) returned 0x%x\n,is_page_fault(intr_info)); 2694 /* EPT won't cause page fault directly */ 2695 if (vm_need_ept()) 2696 BUG(); 2697 cr2 = vmcs_readl(EXIT_QUALIFICATION); 2698 printk(KERN_ERR vmx-handle_exception 0c : vmcs_readl(EXIT_QUALIFICATION) returned 0x%lx\n,cr2); 2699 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, 2700 (u32)((u64)cr2 32), handler); 2701 if (vcpu-arch.interrupt.pending || vcpu-arch.exception.pending){ 2702 printk(KERN_ERR vmx-handle_exception 0d : interrupt.pending or exception.pending\n); 2703 kvm_mmu_unprotect_page_virt(vcpu, cr2); 2704 } 2705 int retval = kvm_mmu_page_fault(vcpu, cr2, error_code); 2706 printk(KERN_ERR vmx-handle_exception 0e : kvm_mmu_page_fault(vcpu, cr2, error_code) returned 0x%x\n,retval); 2707 //return kvm_mmu_page_fault(vcpu, cr2, error_code); 2708 return retval;
Re: KVM on Via Nano (Isaiah) CPUs? Virus checked
Andreas Tanz wrote: Am 19.03.2009 schrieb Avi Kivity: This bit is broken. The original code: if (vcpu-arch.rmode.active handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code)) { Only executes handle_rmode_exception() if rmode.active is true. Your code executes it unconditionally. You can write it as if (vcpu-arch.rmode.active (retval = handle_rmode_exception(vcpu, intr_info INTR_INFO_VECTOR_MASK, error_code))) { Please check for other cases as well. As it happens, the guest crashed immediately after entering protected mode (so rmode.active became false, triggering the bug). ooops - stupid mistake :-I that was it... vmx.c now looks as this : 2637 static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2638 { 2639 struct vcpu_vmx *vmx = to_vmx(vcpu); 2640 u32 intr_info, ex_no, error_code; 2641 unsigned long cr2, rip, dr6; 2642 u32 vect_info; 2643 enum emulation_result er; 2644 2645 vect_info = vmx-idt_vectoring_info; 2646 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); 2647 2648 printk(KERN_ERR vmx-handle_exception 00 : giving some infos\n); 2649 printk(KERN_ERR vmx-handle_exception 01 : vect_info: 0x%x\n,vect_info); 2650 printk(KERN_ERR vmx-handle_exception 02 : intr_info: 0x%x, is_page_fault()==%i\n,intr_info,is_page_fault(intr_info)); 2651 2652 if ((vect_info VECTORING_INFO_VALID_MASK) 2653 !is_page_fault(intr_info)) 2654 printk(KERN_ERR %s: unexpected, vectoring info 0x%x 2655intr info 0x%x\n, __func__, vect_info, intr_info); 2656 2657 printk(KERN_ERR vmx-handle_exception 03 : irq_chip_in_kernel()==%i\n,irqchip_in_kernel(vcpu-kvm)); 2658 printk(KERN_ERR vmx-handle_exception 04 : is_external_interrupt()==%i\n,is_external_interrupt(vect_info)); 2659 if (!irqchip_in_kernel(vcpu-kvm) is_external_interrupt(vect_info)) { 2660 int irq = vect_info VECTORING_INFO_VECTOR_MASK; 2661 printk(KERN_ERR vmx-handle_exception 05 : irq: 0x%x\n,irq); 2662 set_bit(irq, vcpu-arch.irq_pending); 2663 set_bit(irq / BITS_PER_LONG, vcpu-arch.irq_summary); 2664 } 2665 2666 if ((intr_info INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR){ 2667 printk(KERN_ERR vmx-handle_exception 06 : already handled by vmx_vcpu_run()\n); 2668 return 1; /* already handled by vmx_vcpu_run() */ 2669 } 2670 2671 if (is_no_device(intr_info)) { 2672 printk(KERN_ERR vmx-handle_exception 07 : is_no_device(intr_info)\n); 2673 vmx_fpu_activate(vcpu); 2674 return 1; 2675 } 2676 2677 if (is_invalid_opcode(intr_info)) { 2678 printk(KERN_ERR vmx-handle_exception 08 : is_invalid_opcode(intr_info)\n); 2679 er = emulate_instruction(vcpu, kvm_run, 0, 0, EMULTYPE_TRAP_UD); 2680 if (er != EMULATE_DONE) { 2681 printk(KERN_ERR vmx-handle_exception 09 : emulation not done. enqueueing exception\n); 2682 kvm_queue_exception(vcpu, UD_VECTOR); 2683 } 2684 return 1; 2685 } 2686 2687 error_code = 0; 2688 rip = kvm_rip_read(vcpu); 2689 printk(KERN_ERR vmx-handle_exception 0a : kvm_rip_read(vcpu) returned 0x%lx\n,rip); 2690 if (intr_info INTR_INFO_DELIVER_CODE_MASK) 2691 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); 2692 if (is_page_fault(intr_info)) { 2693 printk(KERN_ERR vmx-handle_exception 0b : is_page_fault(intr_info) returned 0x%x\n,is_page_fault(intr_info)); 2694 /* EPT won't cause page fault directly */ 2695 if (vm_need_ept()) 2696 BUG(); 2697 cr2 = vmcs_readl(EXIT_QUALIFICATION); 2698 printk(KERN_ERR vmx-handle_exception 0c : vmcs_readl(EXIT_QUALIFICATION) returned 0x%lx\n,cr2); 2699 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, 2700 (u32)((u64)cr2 32), handler); 2701 if (vcpu-arch.interrupt.pending || vcpu-arch.exception.pending){ 2702 printk(KERN_ERR vmx-handle_exception 0d : interrupt.pending or exception.pending\n); 2703 kvm_mmu_unprotect_page_virt(vcpu, cr2); 2704 } 2705 int retval = kvm_mmu_page_fault(vcpu, cr2, error_code); 2706 printk(KERN_ERR vmx-handle_exception 0e : kvm_mmu_page_fault(vcpu, cr2, error_code) returned 0x%x\n,retval); 2707 //return kvm_mmu_page_fault(vcpu, cr2, error_code); 2708