qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: amit.shah@redhat.com, quintela@redhat.com, dgilbert@redhat.com,
	Pavel.Dovgaluk@ispras.ru, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 09/10] piix: do not raise irq while loading vmstate
Date: Wed, 10 Sep 2014 10:38:46 +0200	[thread overview]
Message-ID: <54100E16.1040306@redhat.com> (raw)
In-Reply-To: <20140909205122.GB15637@redhat.com>

Il 09/09/2014 22:51, Michael S. Tsirkin ha scritto:
> > i440FX/PIIX3 state is loaded before i8259, so the interrupt will never
> > be in the i8259 ISR.  I am not sure why it is a problem for
> > record/replay, but I think it's plausible to consider this a bug.  i8259
> > state should not be affected by the load of PIIX3 state, since i8259 is
> > migrated separately.
> 
> Sorry I still don't understand. Why do stuff from vmstate callback then?
> How is it different?

Reconstructing internal state from post_load is okay.

What is not okay (and I think it should be a rule) is to touch other
devices from post_load, unless you know that they are deserialized
first.  For example it's okay for a PCI device to talk to the parent
bridge in its post_load function.

In the case of PIIX3 vs. i8259, however, you know that i8259 is
deserialized _last_ because i8259 is an ISA device and PIIX3 provides
the ISA bus.  So it's incorrect, even though it's currently harmless, to
touch the i8259 before it's deserialized.

> I'd like to see a description of a scenario where this patch makes
> a difference.

Of course it would be nice to have testcases for this, but I guess one
case could be:

- LAPIC configured in ExtINT mode

- interrupts are masked in the i8259, but the i8259 doesn't know that
yet because it's not been loaded yet

- the PIIX3 loads the state and the interrupt is set.  pic_set_irq is
called, calls pic_update_irq

- pic_update_irq calls pic_get_irq, which uses IMR=0 and thus raises LINT0

- the APIC has been loaded already, so LINT0 is injected incorrectly


Another case could be:

- i8259 is processing IRQ0.  The lower-priority interrupt from PIIX3 is
in IRR.  Machine is migrated.

- the PIIX3 loads the state and sets the interrupt in the i8259.
pic_set_irq is called, calls pic_update_irq, calls pic_get_irq

- because i8259 has not been loaded yet, pic_get_irq sees ISR=0 and the
interrupt is injected even though IRQ0 (higher priority) is being serviced.


In both cases, the saved i8259 state will have the PIIX3 interrupt in
IRR, so the interrupt is not lost, just held (as it would have been on
the source machine).

Paolo

  reply	other threads:[~2014-09-10  8:39 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 12:29 [Qemu-devel] [PATCH 00/10] x86: migrate more data Paolo Bonzini
2014-09-09 12:30 ` [Qemu-devel] [PATCH 01/10] vl: use QLIST_FOREACH_SAFE to visit change state handlers Paolo Bonzini
2014-09-09 13:09   ` Juan Quintela
2014-09-09 12:30 ` [Qemu-devel] [PATCH 02/10] apic_common: vapic_paddr synchronization fix Paolo Bonzini
2014-09-09 13:10   ` Juan Quintela
2014-09-09 14:00   ` Michael S. Tsirkin
2014-09-09 14:26     ` Paolo Bonzini
2014-09-10  6:55   ` Pavel Dovgaluk
2014-09-09 12:30 ` [Qemu-devel] [PATCH 03/10] cpu: init vmstate for ticks and clock offset Paolo Bonzini
2014-09-09 13:25   ` Juan Quintela
2014-09-09 13:26     ` Paolo Bonzini
2014-09-09 12:30 ` [Qemu-devel] [PATCH 04/10] pcspk: adding vmstate for save/restore Paolo Bonzini
2014-09-09 13:26   ` Juan Quintela
2014-09-09 13:28     ` Paolo Bonzini
2014-09-10 12:02       ` Michael S. Tsirkin
2014-09-10 10:59         ` Paolo Bonzini
2014-09-10 12:20           ` Michael S. Tsirkin
2014-09-10 11:24             ` Paolo Bonzini
2014-09-09 12:30 ` [Qemu-devel] [PATCH 05/10] fdc: " Paolo Bonzini
2014-09-09 13:29   ` Juan Quintela
2014-09-09 12:30 ` [Qemu-devel] [PATCH 06/10] parallel: " Paolo Bonzini
2014-09-09 13:32   ` Juan Quintela
2014-09-09 13:40     ` Paolo Bonzini
2014-09-10 12:09       ` Michael S. Tsirkin
2014-09-10 11:16         ` Paolo Bonzini
2014-09-09 12:30 ` [Qemu-devel] [PATCH 07/10] serial: fixing " Paolo Bonzini
2014-09-09 13:59   ` Juan Quintela
2014-09-09 16:24     ` Paolo Bonzini
2014-09-10 11:24       ` Pavel Dovgaluk
2014-09-10 10:41   ` Paolo Bonzini
2014-09-09 12:30 ` [Qemu-devel] [PATCH 08/10] pckbd: adding new fields to vmstate Paolo Bonzini
2014-09-09 13:07   ` Juan Quintela
2014-09-10 10:14     ` Paolo Bonzini
2014-09-09 12:30 ` [Qemu-devel] [PATCH 09/10] piix: do not raise irq while loading vmstate Paolo Bonzini
2014-09-09 13:37   ` Juan Quintela
2014-09-09 13:54   ` Michael S. Tsirkin
2014-09-09 17:16     ` Paolo Bonzini
2014-09-09 20:51       ` Michael S. Tsirkin
2014-09-10  8:38         ` Paolo Bonzini [this message]
2014-09-10  8:51           ` Peter Maydell
2014-09-10  9:05             ` Paolo Bonzini
2014-09-10 10:20               ` Michael S. Tsirkin
2014-09-10 10:50           ` Michael S. Tsirkin
2014-09-10  9:58             ` Paolo Bonzini
2014-09-10 11:04               ` Michael S. Tsirkin
2014-09-10 10:07                 ` Paolo Bonzini
2014-09-10 11:26                   ` Michael S. Tsirkin
2014-09-09 12:30 ` [Qemu-devel] [PATCH 10/10] mc146818rtc: add missed field to vmstate Paolo Bonzini
2014-09-09 12:58   ` Juan Quintela
2014-09-10 10:50 ` [Qemu-devel] [PATCH 00/10] x86: migrate more data Paolo Bonzini
2014-09-10 11:56   ` Michael S. Tsirkin
2014-09-10 10:58     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54100E16.1040306@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=Pavel.Dovgaluk@ispras.ru \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).