Il Sun, Aug 19, 2007 at 10:36:06AM +0300, Avi Kivity ha scritto: 
> Luca wrote:
>> On 8/13/07, Avi Kivity <[EMAIL PROTECTED]> wrote:
>>   
>>> Luca Tettamanti wrote:
>>>     
>>>> The patch stops the "unhandled wrmsr", but reboot is still not working
>>>> (guest is stuck using 100% of the CPU). The last working userspace is
>>>> KVM-28, and I tested it with recent kernel modules. Any idea on this
>>>> one?
>>>>
>>>>       
>>> That's around the time kvm moved to its own main loop (for smp), so it's
>>> not surprising there's breakage there.  I tested erboot at the time, but
>>> not with all guests.
>>>     
>>
>> Here I can't reboot anything... the only thing that works is GRUB, but
>> I guess that it just goes through the BIOS.
>>
>> I debugged a bit the problem, but I'm not sure about the solution.
>> This is what's happening:
>> - guest requests the reboot, the corresponding branch
>> kvm_main_loop_cpu() is executed.
>> - qemu_system_reset() is called; among the other stuff the APIC is
>> re-initialized.
>> - kvm_apic_init (called via reset notifier: qemu_system_reset ->
>> apic_reset -> apic_init_ipi ->
>> kvm_apic_init) set the ->init flag of the vcpu to 1
>> - in next loop  if (info->init) is executed. Forever ;-)
>>
>> The only thing that clears ->init is kvm_update_after_sipi which in
>> turn is only called by apic_startup; (I'm following the execution with
>> gdb and that function is never called, btw). Anyway, as long as ->init
>> is set, guest code won't be executed, so qemu/kvm spins forever in the
>> main loop, executing update_regs_for_init().
>>   
>
> Hmm. INIT processing should be different for the boot processor 
> (->cpu_index == 0), in that it should resume execution after INIT, whereas 
> non-boot processors enter a halt state waiting for a SIPI.  Maybe that's 
> the issue.

Yes, the CPU is halted. I don't see any special treatment for BP vs. APs
in the code...
I tried the most obvious fix:

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 709e714..1d83d26 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -702,6 +702,9 @@ static void update_regs_for_init(CPUState *env)
 {
     cpu_reset(env);
     load_regs(env);
+    /* BP */
+    if (env->cpu_index == 0)
+        vcpu_info[env->cpu_index].init = 0;
 }
 
 static void setup_kernel_sigmask(CPUState *env)

In order to reactivate the CPU after the reset. When the guest reboots I
get an unhandled vm exit:

unhandled vm exit:  0x80000021
rax 0000000000000000 rbx 0000000000000000 rcx 0000000000000000 rdx 
0000000000000600
rsi 0000000000000000 rdi 0000000000000000 rsp 0000000000000000 rbp 
0000000000000000
r8  0000000000000000 r9  0000000000000000 r10 0000000000000000 r11 
0000000000000000
r12 0000000000000000 r13 0000000000000000 r14 0000000000000000 r15 
0000000000000000
rip 000000000000fff2 rflags 00000002
cs f000 (000f0000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ds 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
es 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ss 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
fs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
gs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
tr 0080 (10850000/00002088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
ldt 0000 (00000000/0000ffff p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
gdt 0/ffff
idt 0/ffff
cr0 60000010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0

which is a vm entry failure due to invalid guest state (RIP looks good
though :P)

Luca
-- 
Al termine di un pranzo di nozze mi hanno dato un
amaro alle erbe cosi' schifoso che perfino sull'etichetta
c'era un frate che vomitava.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to