loadvm and APIC
Here's the scenario:
1. Start QEMU and boot Linux capable of using APIC
2. Save the VM state
3. Exit QEMU
4. Start QEMU and loadvm
Kernel instantly panics. Here's why:
Upon starting eventually following happens:
... -> pc_init -> ... -> pit_irq_timer_update
-> qemu_set_irq -> ...
-> apic_local_deliver -> cpu_interrupt(CPU_INTERRUPT_HARD)
Then qemu_loadvm_state begins executing load handlers eventually coming to apic_load which loads the state from the storage overriding all the effects of apic_local_deliver, in the meantime env->interrupt_request stays the same.
Then cpu_exec is entered and it arrives at line 399 where cpu_get_pic_interrupt calls apic_get_interrupt which returns -1, this bogus interrupt number is then passed to do_interrupt and here it is finally caught by a IDT limit check at line 649, general protection fault is generated and kernel inside the VM panics.
Hence:
vl.c +1 -0
@@ -6296,6 +6296,7 @@ void do_loadvm(const char *name) goto the_end; } ret =qemu_loadvm_state (f); + first_cpu->interrupt_request =0 ;qemu_fclose (f);if (ret <0 ) {term_printf ("Error %d while loading VM state\n" , ret);
Okay to commit?
Signature · 1 line
mailto:[email protected]
Quoted 40 lines · malc
Here's the scenario:
1. Start QEMU and boot Linux capable of using APIC
2. Save the VM state
3. Exit QEMU
4. Start QEMU and loadvmKernel instantly panics. Here's why:
Upon starting eventually following happens:
... ->pc_init-> ... ->pit_irq_timer_update
->qemu_set_irq-> ...-> apic_local_deliver -> cpu_interrupt(CPU_INTERRUPT_HARD)Then
qemu_loadvm_statebegins executing load handlers eventually coming toapic_loadwhich loads the state from the storage overriding all the effects ofapic_local_deliver, in the meantimeenv->interrupt_requeststays the same.Then
cpu_execis entered and it arrives at line 399 wherecpu_get_pic_interruptcallsapic_get_interruptwhich returns -1, this bogus interrupt number is then passed todo_interruptand here it is finally caught by a IDT limit check at line 649, general protection fault is generated and kernel inside the VM panics.Hence:
vl.c +1
-0@@ -6296,6 +6296,7 @@ void do_loadvm(const char *name) goto the_end; } ret =qemu_loadvm_state (f); + first_cpu->interrupt_request =0 ;qemu_fclose (f);if (ret <0 ) {term_printf ("Error %d while loading VM state\n" , ret);
Quoted 1 line
Okay to commit?
That is basically
http://permalink.gmane.org/gmane.comp.emulators.qemu/26215, which I would prefer.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 3 lines · Jan Kiszka
Quoted 2 lines · malc
Here's the scenario:
[..snip..]
Quoted 4 lines
That is basically
http://permalink.gmane.org/gmane.comp.emulators.qemu/26215, which I would prefer.
Yes, i never paid enough attention to that patch, and it does indeed look better.
Signature · 1 line
mailto:[email protected]
Quoted 9 lines · malc
Quoted 3 lines · Jan Kiszka
Quoted 2 lines · malc
Here's the scenario:
[..snip..]
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
That is basically
http://permalink.gmane.org/gmane.comp.emulators.qemu/26215, which I would prefer.Yes, i never paid enough attention to that patch, and it does indeed look better.
No. This is a hack which does not fix the real problem. At least saving and restoring "interrupt_pending" would bring us closer to a better solution.
Fabrice.
Quoted 11 lines · Fabrice Bellard
Quoted 10 lines · malc
Quoted 3 lines · Jan Kiszka
Quoted 2 lines · malc
Here's the scenario:
[..snip..]
Quoted 3 lines
That is basically
http://permalink.gmane.org/gmane.comp.emulators.qemu/26215, which I would prefer.
Quoted 6 lines
Quoted 2 lines
Yes, i never paid enough attention to that patch, and it does indeed look better.
No. This is a hack which does not fix the real problem. At least saving and restoring "
interrupt_pending" would bring us closer to a better solution.
No problem, patch for archs that care about cpu state saving is on the way. I would just have appreciated receiving some indication how you'd like to see that bug being addressed earlier.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 14 lines · Fabrice Bellard
Quoted 13 lines · malc
Quoted 3 lines · Jan Kiszka
Quoted 2 lines · malc
Here's the scenario:
[..snip..]
Quoted 4 lines
That is basically
http://permalink.gmane.org/gmane.comp.emulators.qemu/26215, which I would prefer.
Quoted 6 lines
Quoted 2 lines
Yes, i never paid enough attention to that patch, and it does indeed look better.
No. This is a hack which does not fix the real problem. At least saving and restoring "
interrupt_pending" would bring us closer to a better solution.
Have you read my mail? It's pit/serlial vs [a]pic init/loadvm interaction which is broken, real fix would involve fixing this and i don't see clean way of doing that. When using plain i8259 guest doesn't panic only because i8259 emits a spurious IRQ (and APIC does not).
Signature · 1 line
mailto:[email protected]