qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803
@ 2016-08-03  5:25 David Gibson
  2016-08-03  5:25 ` [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines David Gibson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: David Gibson @ 2016-08-03  5:25 UTC (permalink / raw)
  To: peter.maydell; +Cc: agraf, pbonzini, qemu-ppc, qemu-devel, David Gibson

The following changes since commit 8b54a6a6c63dc84f2744f6b125c1a6c5a16ee10b:

  Merge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging (2016-08-02 12:55:12 +0100)

are available in the git repository at:

  git://github.com/dgibson/qemu.git tags/ppc-for-2.7-20160803

for you to fetch changes up to 7005f7f81cef31bda895d3274c13854c143d3d8d:

  kvm-irqchip: only commit route when irqchip is used (2016-08-03 13:25:44 +1000)

----------------------------------------------------------------
qemu-2.7: ppc patch queue 2016-08-03

Here's the current set of patches (only 2) for spapr, ppc and related
things.  These are important bugfixes for the stabilizing 2.7 tree.

One is for a regression where confusion between x86 only and generic
KVM irq handling resulted in breakage on KVM/Power.  The other is
fixing (yet another) problem in the vcpu hotplug code: older pseries
machine types which don't support vcpu hotplug weren't correctly
advertising that, potentially leading to crashes or other problems.

----------------------------------------------------------------
Bharata B Rao (1):
      spapr: Error out when CPU hotplug is attempted on older pseries machines

Peter Xu (1):
      kvm-irqchip: only commit route when irqchip is used

NOTE: The KVM irq fix is technically in generic, not ppc, code, but
Paolo suggested pulling it through this tree, since ppc is the main
affected platform.

 hw/ppc/spapr.c          |  7 ++++++-
 hw/ppc/spapr_cpu_core.c | 19 ++++++-------------
 kvm-all.c               |  8 ++++++++
 3 files changed, 20 insertions(+), 14 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines
  2016-08-03  5:25 [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 David Gibson
@ 2016-08-03  5:25 ` David Gibson
  2016-08-04 10:44   ` Bharata B Rao
  2016-08-03  5:25 ` [Qemu-devel] [PULL 2/2] kvm-irqchip: only commit route when irqchip is used David Gibson
  2016-08-03 12:40 ` [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 Peter Maydell
  2 siblings, 1 reply; 6+ messages in thread
From: David Gibson @ 2016-08-03  5:25 UTC (permalink / raw)
  To: peter.maydell
  Cc: agraf, pbonzini, qemu-ppc, qemu-devel, Bharata B Rao,
	David Gibson

From: Bharata B Rao <bharata@linux.vnet.ibm.com>

CPU hotplug and coldplug aren't supported prior to pseries-2.7.  Further,
earlier machine types don't use CPU core objects at all.  These mean that
query-hotpluggable-cpus and coldplug on older pseries machines will crash
QEMU.  It also means that hotpluggable_cpus flag in query-machines will
be incorrectly set to true for pseries < 2.7, since it is based on the
presence of the query_hotpluggable_cpus hook.

- Don't assign the query_hotpluggable_cpus hook for pseries < 2.7
- query_hotpluggable_cpus should therefore never be called on pseries <
  2.7, so add an assert
- spapr_core_pre_plug() should fail hot/cold plug attempts for pseries <
  2.7, since core objects are never used there
- spapr_core_plug() should therefore never be called for pseries < 2.7, so
  add an assert.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
[dwg: Change from query_hotpluggable_cpus returning NULL for pseries < 2.7
 to not being called at all, reword commit message for accuracy]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c          |  7 ++++++-
 hw/ppc/spapr_cpu_core.c | 19 ++++++-------------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index fbbd051..bce2371 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2376,8 +2376,11 @@ static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *machine)
     int i;
     HotpluggableCPUList *head = NULL;
     sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
+    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
     int spapr_max_cores = max_cpus / smp_threads;
 
+    g_assert(smc->dr_cpu_enabled);
+
     for (i = 0; i < spapr_max_cores; i++) {
         HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1);
         HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1);
@@ -2432,7 +2435,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     hc->plug = spapr_machine_device_plug;
     hc->unplug = spapr_machine_device_unplug;
     mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
-    mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
+    if (smc->dr_cpu_enabled) {
+        mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
+    }
 
     smc->dr_lmb_enabled = true;
     smc->dr_cpu_enabled = true;
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index ec81ee6..170ed15 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -166,18 +166,11 @@ void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     int index = cc->core_id / smp_threads;
     int smt = kvmppc_smt_threads();
 
+    g_assert(smc->dr_cpu_enabled);
+
     drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt);
     spapr->cores[index] = OBJECT(dev);
 
-    if (!smc->dr_cpu_enabled) {
-        /*
-         * This is a cold plugged CPU core but the machine doesn't support
-         * DR. So skip the hotplug path ensuring that the core is brought
-         * up online with out an associated DR connector.
-         */
-        return;
-    }
-
     g_assert(drc);
 
     /*
@@ -225,13 +218,13 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
     const char *type = object_get_typename(OBJECT(dev));
 
-    if (strcmp(base_core_type, type)) {
-        error_setg(&local_err, "CPU core type should be %s", base_core_type);
+    if (!smc->dr_cpu_enabled) {
+        error_setg(&local_err, "CPU hotplug not supported for this machine");
         goto out;
     }
 
-    if (!smc->dr_cpu_enabled && dev->hotplugged) {
-        error_setg(&local_err, "CPU hotplug not supported for this machine");
+    if (strcmp(base_core_type, type)) {
+        error_setg(&local_err, "CPU core type should be %s", base_core_type);
         goto out;
     }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 2/2] kvm-irqchip: only commit route when irqchip is used
  2016-08-03  5:25 [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 David Gibson
  2016-08-03  5:25 ` [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines David Gibson
@ 2016-08-03  5:25 ` David Gibson
  2016-08-03 12:40 ` [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 Peter Maydell
  2 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2016-08-03  5:25 UTC (permalink / raw)
  To: peter.maydell
  Cc: agraf, pbonzini, qemu-ppc, qemu-devel, Peter Xu, David Gibson

From: Peter Xu <peterx@redhat.com>

Reported from Alexey Kardashevskiy:

3f1fea0fb5bf "kvm-irqchip: do explicit commit when update irq" produces
a crash on pseries guest running with VFIO on POWER8 machine as it does
not support KVM_CAP_IRQCHIP (KVM_CAP_IRQ_XICS is there instead). At the
result, KVMState::irq_routes is NULL when VFIO calls
kvm_irqchip_commit_routes.

This makes the routing update conditional.

Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 kvm-all.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kvm-all.c b/kvm-all.c
index ef81ca5..65608de 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1047,6 +1047,14 @@ void kvm_irqchip_commit_routes(KVMState *s)
 {
     int ret;
 
+    if (kvm_gsi_direct_mapping()) {
+        return;
+    }
+
+    if (!kvm_gsi_routing_enabled()) {
+        return;
+    }
+
     s->irq_routes->flags = 0;
     trace_kvm_irqchip_commit_routes();
     ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803
  2016-08-03  5:25 [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 David Gibson
  2016-08-03  5:25 ` [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines David Gibson
  2016-08-03  5:25 ` [Qemu-devel] [PULL 2/2] kvm-irqchip: only commit route when irqchip is used David Gibson
@ 2016-08-03 12:40 ` Peter Maydell
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-08-03 12:40 UTC (permalink / raw)
  To: David Gibson
  Cc: Alexander Graf, Paolo Bonzini, qemu-ppc@nongnu.org,
	QEMU Developers

On 3 August 2016 at 06:25, David Gibson <david@gibson.dropbear.id.au> wrote:
> The following changes since commit 8b54a6a6c63dc84f2744f6b125c1a6c5a16ee10b:
>
>   Merge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging (2016-08-02 12:55:12 +0100)
>
> are available in the git repository at:
>
>   git://github.com/dgibson/qemu.git tags/ppc-for-2.7-20160803
>
> for you to fetch changes up to 7005f7f81cef31bda895d3274c13854c143d3d8d:
>
>   kvm-irqchip: only commit route when irqchip is used (2016-08-03 13:25:44 +1000)
>
> ----------------------------------------------------------------
> qemu-2.7: ppc patch queue 2016-08-03
>
> Here's the current set of patches (only 2) for spapr, ppc and related
> things.  These are important bugfixes for the stabilizing 2.7 tree.
>
> One is for a regression where confusion between x86 only and generic
> KVM irq handling resulted in breakage on KVM/Power.  The other is
> fixing (yet another) problem in the vcpu hotplug code: older pseries
> machine types which don't support vcpu hotplug weren't correctly
> advertising that, potentially leading to crashes or other problems.
>
> ----------------------------------------------------------------
> Bharata B Rao (1):
>       spapr: Error out when CPU hotplug is attempted on older pseries machines
>
> Peter Xu (1):
>       kvm-irqchip: only commit route when irqchip is used

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines
  2016-08-03  5:25 ` [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines David Gibson
@ 2016-08-04 10:44   ` Bharata B Rao
  2016-08-05  2:16     ` David Gibson
  0 siblings, 1 reply; 6+ messages in thread
From: Bharata B Rao @ 2016-08-04 10:44 UTC (permalink / raw)
  To: David Gibson; +Cc: peter.maydell, agraf, pbonzini, qemu-ppc, qemu-devel

On Wed, Aug 03, 2016 at 03:25:50PM +1000, David Gibson wrote:
> From: Bharata B Rao <bharata@linux.vnet.ibm.com>
> 
> CPU hotplug and coldplug aren't supported prior to pseries-2.7.  Further,
> earlier machine types don't use CPU core objects at all.  These mean that
> query-hotpluggable-cpus and coldplug on older pseries machines will crash
> QEMU.  It also means that hotpluggable_cpus flag in query-machines will
> be incorrectly set to true for pseries < 2.7, since it is based on the
> presence of the query_hotpluggable_cpus hook.
> 
> - Don't assign the query_hotpluggable_cpus hook for pseries < 2.7
> - query_hotpluggable_cpus should therefore never be called on pseries <
>   2.7, so add an assert
> - spapr_core_pre_plug() should fail hot/cold plug attempts for pseries <
>   2.7, since core objects are never used there
> - spapr_core_plug() should therefore never be called for pseries < 2.7, so
>   add an assert.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> [dwg: Change from query_hotpluggable_cpus returning NULL for pseries < 2.7
>  to not being called at all, reword commit message for accuracy]
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/ppc/spapr.c          |  7 ++++++-
>  hw/ppc/spapr_cpu_core.c | 19 ++++++-------------
>  2 files changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index fbbd051..bce2371 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2376,8 +2376,11 @@ static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *machine)
>      int i;
>      HotpluggableCPUList *head = NULL;
>      sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
> +    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
>      int spapr_max_cores = max_cpus / smp_threads;
> 
> +    g_assert(smc->dr_cpu_enabled);
> +
>      for (i = 0; i < spapr_max_cores; i++) {
>          HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1);
>          HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1);
> @@ -2432,7 +2435,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
>      hc->plug = spapr_machine_device_plug;
>      hc->unplug = spapr_machine_device_unplug;
>      mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
> -    mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
> +    if (smc->dr_cpu_enabled) {
> +        mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
> +    }
> 
>      smc->dr_lmb_enabled = true;
>      smc->dr_cpu_enabled = true;

Unfortunately smc->dr_cpu_enabled is always false when you set
mc->query_hotpluggable_cpus and will be set to true immediately
afterwards as seen in above hunk.

This leads to query-hotpluggable-cpus being unavailable for all
machine type versions. Your first version of setting
mc->query_hotpluggable_cpus to NULL explicitly for 2.6 and downwards
was correct.

Regards,
Bharata.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines
  2016-08-04 10:44   ` Bharata B Rao
@ 2016-08-05  2:16     ` David Gibson
  0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2016-08-05  2:16 UTC (permalink / raw)
  To: Bharata B Rao; +Cc: peter.maydell, agraf, pbonzini, qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3564 bytes --]

On Thu, Aug 04, 2016 at 04:14:53PM +0530, Bharata B Rao wrote:
> On Wed, Aug 03, 2016 at 03:25:50PM +1000, David Gibson wrote:
> > From: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > 
> > CPU hotplug and coldplug aren't supported prior to pseries-2.7.  Further,
> > earlier machine types don't use CPU core objects at all.  These mean that
> > query-hotpluggable-cpus and coldplug on older pseries machines will crash
> > QEMU.  It also means that hotpluggable_cpus flag in query-machines will
> > be incorrectly set to true for pseries < 2.7, since it is based on the
> > presence of the query_hotpluggable_cpus hook.
> > 
> > - Don't assign the query_hotpluggable_cpus hook for pseries < 2.7
> > - query_hotpluggable_cpus should therefore never be called on pseries <
> >   2.7, so add an assert
> > - spapr_core_pre_plug() should fail hot/cold plug attempts for pseries <
> >   2.7, since core objects are never used there
> > - spapr_core_plug() should therefore never be called for pseries < 2.7, so
> >   add an assert.
> > 
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > [dwg: Change from query_hotpluggable_cpus returning NULL for pseries < 2.7
> >  to not being called at all, reword commit message for accuracy]
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  hw/ppc/spapr.c          |  7 ++++++-
> >  hw/ppc/spapr_cpu_core.c | 19 ++++++-------------
> >  2 files changed, 12 insertions(+), 14 deletions(-)
> > 
> > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > index fbbd051..bce2371 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -2376,8 +2376,11 @@ static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *machine)
> >      int i;
> >      HotpluggableCPUList *head = NULL;
> >      sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
> > +    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
> >      int spapr_max_cores = max_cpus / smp_threads;
> > 
> > +    g_assert(smc->dr_cpu_enabled);
> > +
> >      for (i = 0; i < spapr_max_cores; i++) {
> >          HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1);
> >          HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1);
> > @@ -2432,7 +2435,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
> >      hc->plug = spapr_machine_device_plug;
> >      hc->unplug = spapr_machine_device_unplug;
> >      mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
> > -    mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
> > +    if (smc->dr_cpu_enabled) {
> > +        mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
> > +    }
> > 
> >      smc->dr_lmb_enabled = true;
> >      smc->dr_cpu_enabled = true;
> 
> Unfortunately smc->dr_cpu_enabled is always false when you set
> mc->query_hotpluggable_cpus and will be set to true immediately
> afterwards as seen in above hunk.
> 
> This leads to query-hotpluggable-cpus being unavailable for all
> machine type versions. Your first version of setting
> mc->query_hotpluggable_cpus to NULL explicitly for 2.6 and downwards
> was correct.

*facepalm* I can't believe I forgot to check that.


In fact.. we could just replace dr_lmb_enabled with the NULL or
not-NULL status of query_hotpluggable_cpus.

I'll send a fix shortly.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-05  6:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03  5:25 [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 David Gibson
2016-08-03  5:25 ` [Qemu-devel] [PULL 1/2] spapr: Error out when CPU hotplug is attempted on older pseries machines David Gibson
2016-08-04 10:44   ` Bharata B Rao
2016-08-05  2:16     ` David Gibson
2016-08-03  5:25 ` [Qemu-devel] [PULL 2/2] kvm-irqchip: only commit route when irqchip is used David Gibson
2016-08-03 12:40 ` [Qemu-devel] [PULL 0/2] ppc-for-2.7 queue 20160803 Peter Maydell

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).