From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Wangjing (Hogan,
Cloud Infrastructure Service Product Dept.)"
<king.wang@huawei.com>
Cc: "Huangweidong \(C\)" <weidong.huang@huawei.com>,
"Wangxin \(Alexander\)" <wangxinxin.wang@huawei.com>,
"jusual@redhat.com" <jusual@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [PATCH v1] hw/pci-host: save/restore pci host config register
Date: Fri, 24 Jul 2020 08:58:08 -0400 [thread overview]
Message-ID: <20200724085630-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <ec09235475524a94b8aeb5dc73cd0e74@huawei.com>
On Fri, Jul 24, 2020 at 03:21:58AM +0000, Wangjing (Hogan, Cloud Infrastructure Service Product Dept.) wrote:
> On Sat, Jul 25, 2020 at 10:53:03AM Hogan Wang wrote:
> > * Michael S. Tsirkin (mst@redhat.com) wrote:
> > > On Thu, Jul 23, 2020 at 02:12:54PM +0100, Dr. David Alan Gilbert wrote:
> > > > * Michael S. Tsirkin (mst@redhat.com) wrote:
> > > > > On Thu, Jul 23, 2020 at 08:53:03PM +0800, Hogan Wang wrote:
> > > > > > From: Hogan Wang <king.wang@huawei.com>
> > > > > >
> > > > > > The pci host config register is used to save PCI address for
> > > > > > read/write config data. If guest write a value to config
> > > > > > register, and then pause the vcpu to migrate, After the
> > > > > > migration, the guest continue to write pci config data, and the
> > > > > > write data will be ignored because of new qemu process lost the config register state.
> > > > > >
> > > > > > Reproduction steps are:
> > > > > > 1. guest booting in seabios.
> > > > > > 2. guest enable the SMRAM in seabios:piix4_apmc_smm_setup, and then
> > > > > > expect to disable the SMRAM by pci_config_writeb.
> > > > > > 3. after guest write the pci host config register, and then pasued vcpu
> > > > > > to finish migration.
> > > > > > 4. guest write config data(0x0A) fail to disable the SMRAM becasue of
> > > > > > config register state lost.
> > > > > > 5. guest continue to boot and crash in ipxe option ROM due to SMRAM in
> > > > > > enabled state.
> > > > > >
> > > > > > Signed-off-by: Hogan Wang <king.wang@huawei.com>
> > > > >
> > > > > I guess this is like v3 right?
> > > > >
> > > > > thanks a lot for the patch!
> > > > >
> > > > > My question stands : does anyone see a way to pass this info
> > > > > around without breaking migration for all existing machine types?
> > > >
> > > > You need a .needed clause in the vmstate_i440fx_pcihost and
> > > > vmstate_q35_pcihost which is a pointer to a function which enables
> > > > it on new machine types and ignores it on old ones.
> > > >
> > > > Or, if it always crashes if the SMRAM is enabled, then the migration
> > > > is dead anyway; so you could make the .needed only save the config
> > > > if the SMRAM is opened, so you'd get a unknown section error, which
> > > > is nasty but it would only happen in the case it would crash anyway.
> > > >
> > > > Dave
> > >
> > > Problem is we never know whether it's needed.
> > >
> > > For example: guest programs cf8, then cfc.
> > > Guest on destination can crash if migrated after writing cf8 before
> > > writing cfc.
> > > But in theory it can also crash if guest assumes
> > > cf8 is unchanged and just writes cfc.
> > >
> > > So what I'd prefer to do is put it in some data that old qemu ignores.
> > > Then once qemu on destination is updated, it will start interpreting
> > > it.
> >
> > We don't have a way to do that; the choice is:
> > a) Not sending it for old versions, so you only get the
> > fix for new machine types
> >
> > b) Trying to second guess when it will crash
> >
> > I recommend (a) generally - but the format has no way to ignore unknown data.
> >
> > Dave
> >
>
> The i440fx and q35 machines integrate i440FX or ICH9-LPC PCI device by
> default. Refer to i440FX and ICH9-LPC spcifications, there are some reserved
> configuration registers can used to save/restore PCIHostState.config_reg,
> like i440FX.config[0x57] used for Older coreboot to get RAM size from QEMU.
>
> whitch is nasty but it friendly to old ones.
Right. So what I propose is a series of two patches:
1. a patch to add it in a clean way to new machine types only.
2. a patch on top for old machine types to stick it in some
reserved register.
Then people can review both approaches and we can decide.
> > >
> > > > >
> > > > > > ---
> > > > > > hw/pci-host/i440fx.c | 11 +++++++++++
> > > > > > hw/pci-host/q35.c | 11 +++++++++++
> > > > > > hw/pci/pci_host.c | 11 +++++++++++
> > > > > > hw/pci/pcie_host.c | 11 +++++++++++
> > > > > > include/hw/pci/pci_host.h | 10 ++++++++++
> > > > > > include/hw/pci/pcie_host.h | 10 ++++++++++
> > > > > > 6 files changed, 64 insertions(+)
> > > > > >
> > > > >
> > > > --
> > > > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> > >
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2020-07-24 12:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 3:21 [PATCH v1] hw/pci-host: save/restore pci host config register Wangjing (Hogan, Cloud Infrastructure Service Product Dept.)
2020-07-24 12:58 ` Michael S. Tsirkin [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-07-23 12:53 Wang King
2020-07-23 12:56 ` Michael S. Tsirkin
2020-07-23 13:12 ` Dr. David Alan Gilbert
2020-07-23 15:50 ` Michael S. Tsirkin
2020-07-23 16:04 ` Dr. David Alan Gilbert
2020-07-24 12:58 ` Michael S. Tsirkin
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=20200724085630-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=dgilbert@redhat.com \
--cc=jusual@redhat.com \
--cc=king.wang@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
--cc=weidong.huang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.