From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Riku Voipio" <riku.voipio@iki.fi>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
philmd@redhat.com
Subject: Re: [PATCH v4 17/19] spapr: Remove last pieces of SpaprIrq
Date: Fri, 11 Oct 2019 10:33:15 +0200 [thread overview]
Message-ID: <20191011103315.3b790ea1@bahia.lan> (raw)
In-Reply-To: <20191011081333.7e483b95@bahia.lan>
[-- Attachment #1: Type: text/plain, Size: 9657 bytes --]
On Fri, 11 Oct 2019 08:13:33 +0200
Greg Kurz <groug@kaod.org> wrote:
> On Fri, 11 Oct 2019 16:07:58 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > On Thu, Oct 10, 2019 at 10:33:04PM +0200, Greg Kurz wrote:
> > > On Thu, 10 Oct 2019 08:29:58 +0200
> > > Greg Kurz <groug@kaod.org> wrote:
> > >
> > > > On Thu, 10 Oct 2019 13:02:09 +1100
> > > > David Gibson <david@gibson.dropbear.id.au> wrote:
> > > >
> > > > > On Wed, Oct 09, 2019 at 07:02:15PM +0200, Greg Kurz wrote:
> > > > > > On Wed, 9 Oct 2019 17:08:16 +1100
> > > > > > David Gibson <david@gibson.dropbear.id.au> wrote:
> > > > > >
> > > > > > > The only thing remaining in this structure are the flags to allow either
> > > > > > > XICS or XIVE to be present. These actually make more sense as spapr
> > > > > > > capabilities - that way they can take advantage of the existing
> > > > > > > infrastructure to sanity check capability states across migration and so
> > > > > > > forth.
> > > > > > >
> > > > > >
> > > > > > The user can now choose the interrupt controller mode either through
> > > > > > ic-mode or through cap-xics/cap-xive. I guess it doesn't break anything
> > > > > > to expose another API to do the same thing but it raises some questions.
> > > > > >
> > > > > > We should at least document somewhere that ic-mode is an alias to these
> > > > > > caps, and maybe state which is the preferred method (I personally vote
> > > > > > for the caps).
> > > > > >
> > > > > > Also, we must keep ic-mode for the moment to stay compatible with the
> > > > > > existing pseries-4.0 and pseries-4.1 machine types, but will we
> > > > > > keep ic-mode forever ? If no, maybe start by not allowing it for
> > > > > > pseries-4.2 ?
> > > > >
> > > > > I'm actually inclined to keep it for now, maybe even leave it as the
> > > > > suggested way to configure this. The caps are nice from an internal
> > > > > organization point of view, but ic-mode is arguably a more user
> > > > > friendly way of configuring it. The conversion of one to the other is
> > > > > straightforward, isolated ans small, so I'm not especially bothered by
> > > > > keeping it around.
> > > > >
> > > >
> > > > Fair enough.
> > > >
> > > > Reviewed-by: Greg Kurz <groug@kaod.org>
> > > >
> > >
> > > But unfortunately this still requires care :-\
> > >
> > > qemu-system-ppc64: cap-xive higher level (1) in incoming stream than on destination (0)
> > > qemu-system-ppc64: error while loading state for instance 0x0 of device 'spapr'
> > > qemu-system-ppc64: load of migration failed: Invalid argument
> > >
> > > or
> > >
> > > qemu-system-ppc64: cap-xics higher level (1) in incoming stream than on destination (0)
> > > qemu-system-ppc64: error while loading state for instance 0x0 of device 'spapr'
> > > qemu-system-ppc64: load of migration failed: Invalid argument
> > >
> > > when migrating from QEMU 4.1 with ic-mode=xics and ic-mode=xive respectively.
> > >
> > > This happens because the existing pseries-4.1 machine type doesn't send the
> > > new caps and the logic in spapr_caps_post_migration() wrongly assumes that
> > > the source has both caps set:
> > >
> > > srccaps = default_caps_with_cpu(spapr, MACHINE(spapr)->cpu_type);
> > > for (i = 0; i < SPAPR_CAP_NUM; i++) {
> > > /* If not default value then assume came in with the migration */
> > > if (spapr->mig.caps[i] != spapr->def.caps[i]) {
> > >
> > > spapr->mig.caps[SPAPR_CAP_XICS] = 0
> > > spapr->mig.caps[SPAPR_CAP_XIVE] = 0
> > >
> > > srccaps.caps[i] = spapr->mig.caps[i];
> > >
> > > srcaps.caps[SPAPR_CAP_XICS] = 1
> > > srcaps.caps[SPAPR_CAP_XIVE] = 1
> > >
> > > }
> > > }
> > >
> > > and breaks
> > >
> > > for (i = 0; i < SPAPR_CAP_NUM; i++) {
> > > SpaprCapabilityInfo *info = &capability_table[i];
> > >
> > > if (srccaps.caps[i] > dstcaps.caps[i]) {
> > >
> > > srcaps.caps[SPAPR_CAP_XICS] = 0 when ic-mode=xive
> > > srcaps.caps[SPAPR_CAP_XIVE] = 0 when ic-mode=xics
> > >
> > > error_report("cap-%s higher level (%d) in incoming stream than on destination (%d)",
> > > info->name, srccaps.caps[i], dstcaps.caps[i]);
> > > ok = false;
> > > }
> >
> > Ah.. right. I thought there would be problems with backwards
> > migration, but I didn't think of this problem even with forward
> > migration.
> >
> > > Maybe we shouldn't check capabilities that we know the source
> > > isn't supposed to send, eg. by having a smc->max_cap ?
> >
> > Uh.. I'm not really sure what exactly you're suggesting here.
> >
>
> I'm suggesting to have a per-machine version smc->max_cap that
> contains the highest supported cap index, to be used instead of
> SPAPR_CAP_NUM in this functions, ie.
>
> for (i = 0; i <= smc->max_cap; i++) {
> ...
> }
>
> where we would have
>
> smc->max_cap = SPAPR_CAP_CCF_ASSIST for pseries-4.1
>
> and
>
> smc->max_cap = SPAPR_CAP_XIVE for psereis-4.2
>
> > I think what we need here is a custom migrate_needed function, like we
> > already have for cap_hpt_maxpagesize, to exclude it from the migration
> > stream for machine versions before 4.2.
> >
>
> No, VMState needed() hooks are for outgoing migration only.
>
Well we actually do need a needed() function to fix backward
migration, but it doesn't solve anything with forward migration.
I'm thinking about something like this to address both:
=======================================================================
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 66b68fdd5ef5..1342058c1aae 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -83,7 +83,12 @@ typedef enum {
#define SPAPR_CAP_XICS 0x0a
/* XIVE interrupt controller */
#define SPAPR_CAP_XIVE 0x0b
-/* Num Caps */
+/*
+ * Num Caps.
+ *
+ * CAUTION: when new caps are being added, older machine types should
+ * set smc->mig_cap_num to the previous value of SPAPR_CAP_NUM.
+ */
#define SPAPR_CAP_NUM (SPAPR_CAP_XIVE + 1)
/*
@@ -135,6 +140,7 @@ struct SpaprMachineClass {
hwaddr *nv2atsd, Error **errp);
SpaprResizeHpt resize_hpt_default;
SpaprCapabilities default_caps;
+ int mig_cap_num; /* don't migrate newer capabilities */
};
/**
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index bf9fdb169303..fa81cedfbcc5 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4453,6 +4453,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
smc->dr_phb_enabled = true;
smc->linux_pci_probe = true;
smc->nr_xirqs = SPAPR_NR_XIRQS;
+ smc->mig_cap_num = SPAPR_CAP_NUM;
}
static const TypeInfo spapr_machine_info = {
@@ -4520,6 +4521,7 @@ static void spapr_machine_4_1_class_options(MachineClass *mc)
spapr_machine_4_2_class_options(mc);
smc->linux_pci_probe = false;
+ smc->mig_cap_num = SPAPR_CAP_CCF_ASSIST + 1;
compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
}
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index e06fd386f6ac..ba079f46e084 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -532,6 +532,13 @@ static void cap_xive_apply(SpaprMachineState *spapr, uint8_t val, Error **errp)
}
}
+static bool cap_xics_xive_migrate_needed(void *opaque)
+{
+ int mig_cap_num = SPAPR_MACHINE_GET_CLASS(opaque)->mig_cap_num;
+
+ return mig_cap_num > SPAPR_CAP_XIVE && mig_cap_num > SPAPR_CAP_XICS;
+}
+
SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
[SPAPR_CAP_HTM] = {
.name = "htm",
@@ -639,6 +646,7 @@ SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
.set = spapr_cap_set_bool,
.type = "bool",
.apply = cap_xics_apply,
+ .migrate_needed = cap_xics_xive_migrate_needed,
},
[SPAPR_CAP_XIVE] = {
.name = "xive",
@@ -648,6 +656,7 @@ SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
.set = spapr_cap_set_bool,
.type = "bool",
.apply = cap_xive_apply,
+ .migrate_needed = cap_xics_xive_migrate_needed,
},
};
@@ -729,20 +738,21 @@ int spapr_caps_pre_save(void *opaque)
* caps on the destination */
int spapr_caps_post_migration(SpaprMachineState *spapr)
{
+ SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
int i;
bool ok = true;
SpaprCapabilities dstcaps = spapr->eff;
SpaprCapabilities srccaps;
srccaps = default_caps_with_cpu(spapr, MACHINE(spapr)->cpu_type);
- for (i = 0; i < SPAPR_CAP_NUM; i++) {
+ for (i = 0; i < smc->mig_cap_num; i++) {
/* If not default value then assume came in with the migration */
if (spapr->mig.caps[i] != spapr->def.caps[i]) {
srccaps.caps[i] = spapr->mig.caps[i];
}
}
- for (i = 0; i < SPAPR_CAP_NUM; i++) {
+ for (i = 0; i < smc->mig_cap_num; i++) {
SpaprCapabilityInfo *info = &capability_table[i];
if (srccaps.caps[i] > dstcaps.caps[i]) {
=======================================================================
> bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque)
> {
> if (vmsd->needed && !vmsd->needed(opaque)) {
> /* optional section not needed */
> return false;
> }
> return true;
> }
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-10-11 8:36 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 6:07 [PATCH v4 00/19] spapr: IRQ subsystem cleanup David Gibson
2019-10-09 6:08 ` [PATCH v4 01/19] xive: Make some device types not user creatable David Gibson
2019-10-09 6:08 ` [PATCH v4 02/19] xics: " David Gibson
2019-10-09 6:08 ` [PATCH v4 03/19] target/ppc: Fix for optimized vsl/vsr instructions David Gibson
2019-10-09 6:08 ` [PATCH v4 04/19] spapr, xics, xive: Introduce SpaprInterruptController QOM interface David Gibson
2019-10-09 6:08 ` [PATCH v4 05/19] spapr, xics, xive: Move cpu_intc_create from SpaprIrq to SpaprInterruptController David Gibson
2019-10-09 6:08 ` [PATCH v4 06/19] spapr, xics, xive: Move irq claim and free " David Gibson
2019-10-09 6:08 ` [PATCH v4 07/19] spapr: Formalize notion of active interrupt controller David Gibson
2019-10-09 9:16 ` Cédric Le Goater
2019-10-09 9:19 ` Cédric Le Goater
2019-10-09 11:38 ` David Gibson
2019-10-09 6:08 ` [PATCH v4 08/19] spapr, xics, xive: Move set_irq from SpaprIrq to SpaprInterruptController David Gibson
2019-10-09 9:18 ` Cédric Le Goater
2019-10-09 6:08 ` [PATCH v4 09/19] spapr, xics, xive: Move print_info " David Gibson
2019-10-09 9:19 ` Cédric Le Goater
2019-10-09 6:08 ` [PATCH v4 10/19] spapr, xics, xive: Move dt_populate " David Gibson
2019-10-09 9:20 ` Cédric Le Goater
2019-10-09 6:08 ` [PATCH v4 11/19] spapr, xics, xive: Match signatures for XICS and XIVE KVM connect routines David Gibson
2019-10-09 6:08 ` [PATCH v4 12/19] spapr: Remove SpaprIrq::init_kvm hook David Gibson
2019-10-09 6:08 ` [PATCH v4 13/19] spapr, xics, xive: Move SpaprIrq::reset hook logic into activate/deactivate David Gibson
2019-10-09 14:25 ` Greg Kurz
2019-10-09 15:56 ` Cédric Le Goater
2019-10-09 15:56 ` Cédric Le Goater
2019-10-09 6:08 ` [PATCH v4 14/19] spapr, xics, xive: Move SpaprIrq::post_load hook to backends David Gibson
2019-10-09 15:57 ` Cédric Le Goater
2019-10-09 6:08 ` [PATCH v4 15/19] spapr: Remove SpaprIrq::nr_msis David Gibson
2019-10-09 15:59 ` Cédric Le Goater
2019-10-10 1:56 ` David Gibson
2019-10-09 6:08 ` [PATCH v4 16/19] spapr: Move SpaprIrq::nr_xirqs to SpaprMachineClass David Gibson
2019-10-09 16:01 ` Cédric Le Goater
2019-10-09 6:08 ` [PATCH v4 17/19] spapr: Remove last pieces of SpaprIrq David Gibson
2019-10-09 16:44 ` Cédric Le Goater
2019-10-10 1:59 ` David Gibson
2019-10-09 17:02 ` Greg Kurz
2019-10-10 2:02 ` David Gibson
2019-10-10 6:29 ` Greg Kurz
2019-10-10 20:33 ` Greg Kurz
2019-10-11 5:07 ` David Gibson
2019-10-11 6:13 ` Greg Kurz
2019-10-11 8:33 ` Greg Kurz [this message]
2019-10-12 0:00 ` David Gibson
2019-10-14 9:15 ` Greg Kurz
2019-11-20 5:38 ` David Gibson
2019-11-20 8:36 ` Greg Kurz
2019-10-09 6:08 ` [PATCH v4 18/19] spapr: Handle irq backend changes with VFIO PCI devices David Gibson
2019-10-09 8:57 ` David Gibson
2019-10-09 6:08 ` [PATCH v4 19/19] spapr: Work around spurious warnings from vfio INTx initialization David Gibson
2019-10-09 8:37 ` Greg Kurz
2019-10-09 8:52 ` David Gibson
2019-10-09 17:16 ` Greg Kurz
2019-10-10 2:02 ` David Gibson
2019-10-09 9:02 ` [PATCH v4 00/19] spapr: IRQ subsystem cleanup David Gibson
2019-10-16 16:04 ` Greg Kurz
2019-10-17 0:26 ` David Gibson
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=20191011103315.3b790ea1@bahia.lan \
--to=groug@kaod.org \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=riku.voipio@iki.fi \
/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).