Introduce SPAPR_IRQ_NR_IPIS and fix max-cpus
v3 cover Introduce SPAPR_IRQ_NR_IPIS and fix max-cpus
On spapr, the max number of CPU IPIs are 4096 which is accounted during spapr_irq_init but currently existing macro SPAPR_XIRQ_BASE is being used to refer to that. Introducing SPAPR_IRQ_NR_IPIS to refer to the range of CPU IPIS which is being further used to initialize mc->max_cpus during spapr_machine_class_init().
v3:
- addressed further review comments from Cedric
v2:
- addressed review comments from Cedric
Harsh Prateek Bora (2):
ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU
IPIs.
ppc/spapr: Initialize max_cpus limit to SPAPR_IRQ_NR_IPIS.
include/hw/ppc/spapr_irq.h | 14 +++++++++++++- hw/ppc/spapr.c | 9 +++------ hw/ppc/spapr_irq.c | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-)
Signature · 1 line
2.39.3
PATCH v3 2/2 ppc/spapr: Initialize max_cpus limit to SPAPR_IRQ_NR_IPIS.
Initialize the machine specific max_cpus limit as per the maximum range of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not free error due to XIVE/XICS limitation and keeping beyond 8192 will hit assert in tcg_region_init or spapr_xive_claim_irq.
Logs:
Without patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: IRQ 4096 is not free
[root@host build]#
On LPAR:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193 **
ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size >= 2 * page_size)
Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size >= 2 * page_size)
Aborted (core dumped)
[root@host build]#
On x86:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
qemu-system-ppc64: ../hw/intc/spapr_xive.c:596: spapr_xive_claim_irq:
Assertion `lisn < xive->nr_irqs' failed.
Aborted (core dumped)
[root@host build]#
With patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by machine 'pseries-8.2' is 4096
[root@host build]#
--- hw/ppc/spapr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
hw/ppc/spapr.c +3 -6
@@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->block_default_type =IF_SCSI ;/* -* Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values -* should be limited by the host capability instead of hardcoded. -* max_cpus for KVM guests will be checked in kvm_init(), and TCG -* guests are welcome to have as many CPUs as the host are capable -* of emulate. +* While KVM determines max cpus in kvm_init() using kvm_max_vcpus(), +* In TCG the limit is restricted by the range of CPU IPIs available. */ - mc->max_cpus =INT32_MAX ; + mc->max_cpus =SPAPR_IRQ_NR_IPIS ; mc->no_parallel =1 ; mc->default_boot_order ="" ;
Signature · 1 line
2.39.3
PATCH v3 1/2 ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
In reply to Harsh Prateek Boraspapr_irq_init currently uses existing macro SPAPR_XIRQ_BASE to refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.
--- include/hw/ppc/spapr_irq.h | 14 +++++++++++++- hw/ppc/spapr_irq.c | 6 ++++-- 2 files changed, 17 insertions(+), 3 deletions(-)
include/hw/ppc/spapr_irq.h +13 -1
@@ -14,9 +14,21 @@#include "qom/object.h" /* -* IRQ range offsets per device type +* The XIVE IRQ backend uses the same layout as the XICS backend but +* covers the full range of the IRQ number space. The IRQ numbers for +* the CPU IPIs are allocated at the bottom of this space, below 4K, +* to preserve compatibility with XICS which does not use that range. +*/ + +/* +* CPU IPI range (XIVE only) */ #define SPAPR_IRQ_IPI 0x0 +#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE XICS_IRQ_BASE/* 0x1000 */ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)
hw/ppc/spapr_irq.c +4 -2
@@ -23,6 +23,8 @@#include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +static const TypeInfo spapr_intc_info = { .name =TYPE_SPAPR_INTC , .parent =TYPE_INTERFACE ,
@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)int i; dev =qdev_new (TYPE_SPAPR_XIVE ); -qdev_prop_set_uint32 (dev,"nr-irqs" , smc->nr_xirqs +SPAPR_XIRQ_BASE ); +qdev_prop_set_uint32 (dev,"nr-irqs" , smc->nr_xirqs +SPAPR_IRQ_NR_IPIS );/* * 8 XIVE END structures per CPU. One for each available * priority
@@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs =qemu_allocate_irqs (spapr_set_irq, spapr, - smc->nr_xirqs +SPAPR_XIRQ_BASE ); + smc->nr_xirqs +SPAPR_IRQ_NR_IPIS );/* * Mostly we don't actually need this until reset, except that not
Signature · 1 line
2.39.3
Re: [PATCH v3 1/2] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
Quoted 7 lines · Harsh Prateek Bora
spapr_irq_initcurrently uses existing macroSPAPR_XIRQ_BASEto refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.Signed-off-by Harsh Prateek Bora <[email protected]>Suggested-by Cedric Le Goater <[email protected]>
One comment below
Quoted 37 lines
--- include/hw/ppc/spapr_irq.h | 14 +++++++++++++- hw/ppc/spapr_irq.c | 6 ++++-- 2 files changed, 17 insertions(+), 3 deletions(-)include/hw/ppc/spapr_irq.h +13
-1@@ -14,9 +14,21 @@#include "qom/object.h" /* -* IRQ range offsets per device type +* The XIVE IRQ backend uses the same layout as the XICS backend but +* covers the full range of the IRQ number space. The IRQ numbers for +* the CPU IPIs are allocated at the bottom of this space, below 4K, +* to preserve compatibility with XICS which does not use that range. +*/ + +/* +* CPU IPI range (XIVE only) */ #define SPAPR_IRQ_IPI 0x0 +#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE XICS_IRQ_BASE/* 0x1000 */ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)hw/ppc/spapr_irq.c +0
-0
hw/ppc/spapr_irq.c line 27
Quoted 5 lines
hw/ppc/spapr_irq.c +2
-0@@ -23,6 +23,8 @@#include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +
I would have put the check in include/hw/ppc/spapr_irq.h but since SPAPR_XIRQ_BASE is only used in hw/ppc/spapr_irq.c which is always compiled, this is fine. You might want to change that in case a respin is asked for.
Thanks,
C.
Quoted 21 lines
hw/ppc/spapr_irq.c +2
-2static const TypeInfo spapr_intc_info = { .name =TYPE_SPAPR_INTC , .parent =TYPE_INTERFACE ,@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)int i; dev =qdev_new (TYPE_SPAPR_XIVE ); -qdev_prop_set_uint32 (dev,"nr-irqs" , smc->nr_xirqs +SPAPR_XIRQ_BASE ); +qdev_prop_set_uint32 (dev,"nr-irqs" , smc->nr_xirqs +SPAPR_IRQ_NR_IPIS );/* * 8 XIVE END structures per CPU. One for each available * priority @@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs =qemu_allocate_irqs (spapr_set_irq, spapr, - smc->nr_xirqs +SPAPR_XIRQ_BASE ); + smc->nr_xirqs +SPAPR_IRQ_NR_IPIS );/* * Mostly we don't actually need this until reset, except that not
Re: [PATCH v3 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_IRQ_NR_IPIS.
In reply to Harsh Prateek BoraQuoted 30 lines · Harsh Prateek Bora
Initialize the machine specific
max_cpuslimit as per the maximum range of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not free error due to XIVE/XICS limitation and keeping beyond 8192 will hit assert intcg_region_initorspapr_xive_claim_irq.Logs:
Without patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: IRQ 4096 is not free
[root@host build]#On LPAR:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193 **
ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size>= 2 *page_size)
Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size>= 2 *page_size)
Aborted (core dumped)
[root@host build]#On x86:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
qemu-system-ppc64:../hw/intc/spapr_xive.c:596:spapr_xive_claim_irq:
Assertion `lisn <xive->nr_irqs' failed.
Aborted (core dumped)
[root@host build]#
Quoted 7 lines
With patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by machine 'pseries-8.2' is 4096
[root@host build]#Signed-off-by Harsh Prateek Bora <[email protected]>
Thanks,
C.
Quoted 25 lines
--- hw/ppc/spapr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)hw/ppc/spapr.c +3
-6@@ -4647,13 +4647,10 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->block_default_type =IF_SCSI ;/* -* Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values -* should be limited by the host capability instead of hardcoded. -* max_cpus for KVM guests will be checked in kvm_init(), and TCG -* guests are welcome to have as many CPUs as the host are capable -* of emulate. +* While KVM determines max cpus in kvm_init() using kvm_max_vcpus(), +* In TCG the limit is restricted by the range of CPU IPIs available. */ - mc->max_cpus =INT32_MAX ; + mc->max_cpus =SPAPR_IRQ_NR_IPIS ; mc->no_parallel =1 ; mc->default_boot_order ="" ;
Re: [PATCH v3 1/2] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
In reply to Cédric Le GoaterQuoted 6 lines · Cédric Le Goater
Quoted 5 lines · Harsh Prateek Bora
spapr_irq_initcurrently uses existing macroSPAPR_XIRQ_BASEto refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Harsh Prateek Bora <[email protected]>Suggested-by Cedric Le Goater <[email protected]>One comment below
Reviewed-by Cédric Le Goater <[email protected]>
Thanks, responding below ..
Quoted 35 lines
Quoted 35 lines
---
include/hw/ppc/spapr_irq.h| 14 +++++++++++++-
hw/ppc/spapr_irq.c | 6 ++++--2 files changed, 17 insertions(+), 3 deletions(-)include/hw/ppc/spapr_irq.h +13
-1@@ -14,9 +14,21 @@ #include "qom/object.h" /* - * IRQ range offsets per device type + * The XIVE IRQ backend uses the same layout as the XICS backend but + * covers the full range of the IRQ number space. The IRQ numbers for + * the CPU IPIs are allocated at the bottom of this space, below 4K, + * to preserve compatibility with XICS which does not use that range. + */ + +/* + * CPU IPI range (XIVE only) */ #define SPAPR_IRQ_IPI 0x0 +#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE XICS_IRQ_BASE /* 0x1000 */ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)hw/ppc/spapr_irq.c +0
-0@@ -23,6 +23,8 @@
Quoted 9 lines
hw/ppc/spapr_irq.c line 27
Quoted 3 lines
hw/ppc/spapr_irq.c +2
-0#include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +I would have put the check in
include/hw/ppc/spapr_irq.hbut sinceSPAPR_XIRQ_BASEis only used inhw/ppc/spapr_irq.cwhich is always compiled, this is fine. You might want to change that in case a respin is asked for.
I had initially tried keeping it in spapr_irq.h , but that would give a build break for XICS_IRQ_BASE not defined since that gets defined in spapr_xics.h and is included later in some files, however, the QEMU_BUILD_BUG_ON expects it to be defined before it reaches here.
regards,
Harsh
Quoted 29 lines
Thanks,
C.
Quoted 23 lines
hw/ppc/spapr_irq.c +1
-1static const TypeInfo spapr_intc_info = { .name = TYPE_SPAPR_INTC, .parent = TYPE_INTERFACE,@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) int i; dev = qdev_new(TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_XIRQ_BASE); + qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs +SPAPR_IRQ_NR_IPIS ); /** 8 XIVE END structures per CPU. One for each available
* priorityhw/ppc/spapr_irq.c +1
-1@@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs = qemu_allocate_irqs(spapr_set_irq, spapr, - smc->nr_xirqs + SPAPR_XIRQ_BASE); + smc->nr_xirqs +SPAPR_IRQ_NR_IPIS ); /** Mostly we don't actually need this until reset, except that not
Re: [PATCH v3 1/2] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
Quoted 64 lines · Harsh Prateek Bora
Quoted 6 lines · Cédric Le Goater
Quoted 5 lines · Harsh Prateek Bora
spapr_irq_initcurrently uses existing macroSPAPR_XIRQ_BASEto refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.Quoted 7 lines
Quoted 2 lines
Signed-off-by Harsh Prateek Bora <[email protected]>Suggested-by Cedric Le Goater <[email protected]>One comment below
Reviewed-by Cédric Le Goater <[email protected]>Thanks, responding below ..
Quoted 35 lines
Quoted 35 lines
---
include/hw/ppc/spapr_irq.h| 14 +++++++++++++-
hw/ppc/spapr_irq.c | 6 ++++--2 files changed, 17 insertions(+), 3 deletions(-)include/hw/ppc/spapr_irq.h +13
-1@@ -14,9 +14,21 @@ #include "qom/object.h" /* - * IRQ range offsets per device type + * The XIVE IRQ backend uses the same layout as the XICS backend but + * covers the full range of the IRQ number space. The IRQ numbers for + * the CPU IPIs are allocated at the bottom of this space, below 4K, + * to preserve compatibility with XICS which does not use that range. + */ + +/* + * CPU IPI range (XIVE only) */ #define SPAPR_IRQ_IPI 0x0 +#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE XICS_IRQ_BASE /* 0x1000 */ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)hw/ppc/spapr_irq.c +0
-0@@ -23,6 +23,8 @@Quoted 9 lines
hw/ppc/spapr_irq.c line 27
Quoted 3 lines
hw/ppc/spapr_irq.c +2
-0#include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +I would have put the check in
include/hw/ppc/spapr_irq.hbut sinceSPAPR_XIRQ_BASEis only used inhw/ppc/spapr_irq.cwhich is always compiled, this is fine. You might want to change that in case a respin is asked for.
Quoted 1 line
I had initially tried keeping it in
spapr_irq.h, but that would give a build break forXICS_IRQ_BASEnot defined since that gets defined inspapr_xics.hand is included later in some files, however, theQEMU_BUILD_BUG_ONexpects it to be defined before it reaches here.
ah. good catch. this went unnoticed and is a bit ugly. We should fix in some ways. May with a define SPAPR_XIRQ_BASE to 0x1000 simply ?
Also, we could probably define the ICS offset to SPAPR_XIRQ_BASE directly under spapr_irq_init() and get rid of ics_instance_init(). The HW IRQ Number offset in the PNV ICS instances is assigned dynamically by the OS (see pnv_phb3). So it should befine to do the same for spapr. In which case we can get rid of XICS_IRQ_BASE.
Thanks,
C.
Quoted 28 lines
regards,
HarshQuoted 24 lines
Thanks,
C.
Quoted 18 lines
hw/ppc/spapr_irq.c +2
-2static const TypeInfo spapr_intc_info = { .name = TYPE_SPAPR_INTC, .parent = TYPE_INTERFACE,@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) int i; dev = qdev_new(TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_XIRQ_BASE); + qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_IRQ_NR_IPIS); /** 8 XIVE END structures per CPU. One for each available * priority @@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs = qemu_allocate_irqs(spapr_set_irq, spapr, - smc->nr_xirqs + SPAPR_XIRQ_BASE); + smc->nr_xirqs + SPAPR_IRQ_NR_IPIS); /** Mostly we don't actually need this until reset, except that not
Re: [PATCH v3 1/2] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
Quoted 65 lines · Cédric Le Goater
Quoted 64 lines · Harsh Prateek Bora
Quoted 6 lines · Cédric Le Goater
Quoted 5 lines · Harsh Prateek Bora
spapr_irq_initcurrently uses existing macroSPAPR_XIRQ_BASEto refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.Quoted 7 lines
Quoted 2 lines
Signed-off-by Harsh Prateek Bora <[email protected]>Suggested-by Cedric Le Goater <[email protected]>One comment below
Reviewed-by Cédric Le Goater <[email protected]>Thanks, responding below ..
Quoted 44 lines
Quoted 35 lines
---
include/hw/ppc/spapr_irq.h| 14 +++++++++++++-
hw/ppc/spapr_irq.c | 6 ++++--2 files changed, 17 insertions(+), 3 deletions(-)include/hw/ppc/spapr_irq.h +13
-1@@ -14,9 +14,21 @@ #include "qom/object.h" /* - * IRQ range offsets per device type + * The XIVE IRQ backend uses the same layout as the XICS backend but + * covers the full range of the IRQ number space. The IRQ numbers for + * the CPU IPIs are allocated at the bottom of this space, below 4K, + * to preserve compatibility with XICS which does not use that range. + */ + +/* + * CPU IPI range (XIVE only) */ #define SPAPR_IRQ_IPI 0x0 +#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE XICS_IRQ_BASE /* 0x1000 */ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)hw/ppc/spapr_irq.c +0
-0hw/ppc/spapr_irq.c line 25
Quoted 3 lines
hw/ppc/spapr_irq.c +2
-0@@ -23,6 +23,8 @@ #include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +I would have put the check in
include/hw/ppc/spapr_irq.hbut sinceSPAPR_XIRQ_BASEis only used inhw/ppc/spapr_irq.cwhich is always compiled, this is fine. You might want to change that in case a respin is asked for.
Quoted 5 lines
Quoted 1 line
I had initially tried keeping it in
spapr_irq.h, but that would give a build break forXICS_IRQ_BASEnot defined since that gets defined inspapr_xics.hand is included later in some files, however, theQEMU_BUILD_BUG_ONexpects it to be defined before it reaches here.ah. good catch. this went unnoticed and is a bit ugly. We should fix in some ways. May with a define
SPAPR_XIRQ_BASEto0x1000simply ?
Hmm, I can do that if a re-spin is reqd, or can be done as a separate patch later also along with other improvements.
Quoted 6 lines
Also, we could probably define the ICS offset to
SPAPR_XIRQ_BASEdirectly underspapr_irq_init()and get rid ofics_instance_init(). The HW IRQ Number offset in the PNV ICS instances is assigned dynamically by the OS (seepnv_phb3). So it should befine to do the same for spapr. In which case we can get rid ofXICS_IRQ_BASE.
Hmm, I am not so familiar with XICS yet, so not sure if we really need to do that, but it can be done along with other improvements if needed.
regards,
Harsh
Quoted 41 lines
Thanks,
C.
Quoted 34 lines
regards,
HarshQuoted 30 lines
Thanks,
C.
Quoted 24 lines
hw/ppc/spapr_irq.c +1
-1static const TypeInfo spapr_intc_info = { .name = TYPE_SPAPR_INTC, .parent = TYPE_INTERFACE,@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) int i; dev = qdev_new(TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_XIRQ_BASE); + qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs +SPAPR_IRQ_NR_IPIS ); /** 8 XIVE END structures per CPU. One for each available
* priorityhw/ppc/spapr_irq.c +1
-1@@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs = qemu_allocate_irqs(spapr_set_irq, spapr, - smc->nr_xirqs +SPAPR_XIRQ_BASE ); + smc->nr_xirqs + SPAPR_IRQ_NR_IPIS); /** Mostly we don't actually need this until reset, except that not
Re: [PATCH v3 1/2] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
Quoted 68 lines · Harsh Prateek Bora
Quoted 65 lines · Cédric Le Goater
Quoted 64 lines · Harsh Prateek Bora
Quoted 6 lines · Cédric Le Goater
Quoted 5 lines · Harsh Prateek Bora
spapr_irq_initcurrently uses existing macroSPAPR_XIRQ_BASEto refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.Quoted 7 lines
Quoted 2 lines
Signed-off-by Harsh Prateek Bora <[email protected]>Suggested-by Cedric Le Goater <[email protected]>One comment below
Reviewed-by Cédric Le Goater <[email protected]>Thanks, responding below ..
Quoted 44 lines
Quoted 35 lines
---
include/hw/ppc/spapr_irq.h| 14 +++++++++++++-
hw/ppc/spapr_irq.c | 6 ++++--2 files changed, 17 insertions(+), 3 deletions(-)include/hw/ppc/spapr_irq.h +13
-1@@ -14,9 +14,21 @@ #include "qom/object.h" /* - * IRQ range offsets per device type + * The XIVE IRQ backend uses the same layout as the XICS backend but + * covers the full range of the IRQ number space. The IRQ numbers for + * the CPU IPIs are allocated at the bottom of this space, below 4K, + * to preserve compatibility with XICS which does not use that range. + */ + +/* + * CPU IPI range (XIVE only) */ #define SPAPR_IRQ_IPI 0x0 +#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE XICS_IRQ_BASE /* 0x1000 */ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)hw/ppc/spapr_irq.c +0
-0hw/ppc/spapr_irq.c line 25
Quoted 3 lines
hw/ppc/spapr_irq.c +2
-0@@ -23,6 +23,8 @@ #include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +I would have put the check in
include/hw/ppc/spapr_irq.hbut sinceSPAPR_XIRQ_BASEis only used inhw/ppc/spapr_irq.cwhich is always compiled, this is fine. You might want to change that in case a respin is asked for.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I had initially tried keeping it in
spapr_irq.h, but that would give a build break forXICS_IRQ_BASEnot defined since that gets defined inspapr_xics.hand is included later in some files, however, theQEMU_BUILD_BUG_ONexpects it to be defined before it reaches here.ah. good catch. this went unnoticed and is a bit ugly. We should fix in some ways. May with a define
SPAPR_XIRQ_BASEto0x1000simply ?Hmm, I can do that if a re-spin is reqd, or can be done as a separate patch later also along with other improvements.
yes. This is food for thoughts for further improvements.
Thanks,
C.
Quoted 49 lines
Quoted 7 lines
Also, we could probably define the ICS offset to
SPAPR_XIRQ_BASEdirectly underspapr_irq_init()and get rid ofics_instance_init(). The HW IRQ Number offset in the PNV ICS instances is assigned dynamically by the OS (seepnv_phb3). So it should befine to do the same for spapr. In which case we can get rid ofXICS_IRQ_BASE.Hmm, I am not so familiar with XICS yet, so not sure if we really need to do that, but it can be done along with other improvements if needed.
regards,
HarshQuoted 35 lines
Thanks,
C.
Quoted 28 lines
regards,
HarshQuoted 24 lines
Thanks,
C.
Quoted 18 lines
hw/ppc/spapr_irq.c +2
-2static const TypeInfo spapr_intc_info = { .name = TYPE_SPAPR_INTC, .parent = TYPE_INTERFACE,@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) int i; dev = qdev_new(TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_XIRQ_BASE); + qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_IRQ_NR_IPIS); /** 8 XIVE END structures per CPU. One for each available * priority @@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs = qemu_allocate_irqs(spapr_set_irq, spapr, - smc->nr_xirqs + SPAPR_XIRQ_BASE); + smc->nr_xirqs + SPAPR_IRQ_NR_IPIS); /** Mostly we don't actually need this until reset, except that not
Re: [PATCH v3 1/2] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
Quoted 151 lines · Cédric Le Goater
Quoted 74 lines · Harsh Prateek Bora
Quoted 71 lines · Cédric Le Goater
Quoted 70 lines · Harsh Prateek Bora
On 11/23/23 14:20, CI've applied these patches and verified on the latest upstream qemu. The code is working as expected.
Quoted 6 lines · Harsh Prateek Bora
Quoted 5 lines
spapr_irq_initcurrently uses existing macroSPAPR_XIRQ_BASEto refer to the range of CPU IPIs during initialization of nr-irqs property. It is more appropriate to have its own define which can be further reused as appropriate for correct interpretation.Quoted 7 lines
Quoted 2 lines
Signed-off-by Harsh Prateek Bora <[email protected]>Suggested-by Cedric Le Goater <[email protected]>One comment below
Reviewed-by Cédric Le Goater <[email protected]>Thanks, responding below ..
Quoted 48 lines
Quoted 39 lines
---
include/hw/ppc/spapr_irq.h| 14 +++++++++++++-
hw/ppc/spapr_irq.c | 6 ++++--2 files changed, 17 insertions(+), 3 deletions(-)include/hw/ppc/spapr_irq.h +1
-1@@ -14,9 +14,21 @@ #include "qom/object.h" /* -* IRQ range offsets per device type +* The XIVE IRQ backend uses the same layout as the XICS backend but
+ * covers the full range of the IRQ number space. The IRQ numbers for
+ * the CPU IPIs are allocated at the bottom of this space, below 4K,
+ * to preserve compatibility with XICS which does not use that range.
+ */include/hw/ppc/spapr_irq.h +3
-0+ +/* +* CPU IPI range (XIVE only) */
#define SPAPR_IRQ_IPI0x0include/hw/ppc/spapr_irq.h +5
-0+#define SPAPR_IRQ_NR_IPIS 0x1000 + +/* +* IRQ range offsets per device type +*/ #define SPAPR_XIRQ_BASE
XICS_IRQ_BASE/*0x1000*/ #define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE+0x0000)hw/ppc/spapr_irq.c +0
-0hw/ppc/spapr_irq.c line 25
Quoted 3 lines
hw/ppc/spapr_irq.c +2
-0@@ -23,6 +23,8 @@ #include "trace.h" +QEMU_BUILD_BUG_ON (SPAPR_IRQ_NR_IPIS >SPAPR_XIRQ_BASE ); +I would have put the check in
include/hw/ppc/spapr_irq.hbut sinceSPAPR_XIRQ_BASEis only used inhw/ppc/spapr_irq.cwhich is always compiled, this is fine. You might want to change that in case a respin is asked for.Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I had initially tried keeping it in
spapr_irq.h, but that would give a build break forXICS_IRQ_BASEnot defined since that gets defined inspapr_xics.hand is included later in some files, however, theQEMU_BUILD_BUG_ONexpects it to be defined before it reaches here.ah. good catch. this went unnoticed and is a bit ugly. We should fix in some ways. May with a define
SPAPR_XIRQ_BASEto0x1000simply ?Hmm, I can do that if a re-spin is reqd, or can be done as a separate patch later also along with other improvements.
yes. This is food for thoughts for further improvements.
Thanks,
C.
Quoted 8 lines
Quoted 7 lines
Also, we could probably define the ICS offset to
SPAPR_XIRQ_BASEdirectly underspapr_irq_init()and get rid ofics_instance_init(). The HW IRQ Number offset in the PNV ICS instances is assigned dynamically by the OS (seepnv_phb3). So it should befine to do the same for spapr. In which case we can get rid ofXICS_IRQ_BASE.Quoted 47 lines
Hmm, I am not so familiar with XICS yet, so not sure if we really need to do that, but it can be done along with other improvements if needed.
regards,
HarshQuoted 41 lines
Thanks,
C.
Quoted 34 lines
regards,
HarshQuoted 30 lines
Thanks,
C.
Quoted 24 lines
hw/ppc/spapr_irq.c +1
-1static const TypeInfo spapr_intc_info = { .name = TYPE_SPAPR_INTC, .parent = TYPE_INTERFACE,@@ -329,7 +331,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) int i; dev = qdev_new(TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs + SPAPR_XIRQ_BASE); + qdev_prop_set_uint32(dev, "nr-irqs", smc->nr_xirqs +SPAPR_IRQ_NR_IPIS ); /** 8 XIVE END structures per CPU. One for each available
* priorityhw/ppc/spapr_irq.c +1
-1@@ -356,7 +358,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) } spapr->qirqs = qemu_allocate_irqs(spapr_set_irq, spapr, - smc->nr_xirqs +SPAPR_XIRQ_BASE ); + smc->nr_xirqs + SPAPR_IRQ_NR_IPIS); /** Mostly we don't actually need this until reset, except that not
I've applied these patches and verified on the latest upstream qemu. The code is working as expected.
Tested-by Kowshik Jois<[email protected]>
Re: [PATCH v3 2/2] ppc/spapr: Initialize max_cpus limit to SPAPR_IRQ_NR_IPIS.
In reply to Cédric Le GoaterQuoted 76 lines · Cédric Le Goater
Quoted 30 lines · Harsh Prateek Bora
Initialize the machine specific
max_cpuslimit as per the maximum range of CPU IPIs available. Keeping between 4096 to 8192 will throw IRQ not free error due to XIVE/XICS limitation and keeping beyond 8192 will hit assert intcg_region_initorspapr_xive_claim_irq.Logs:
Without patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: IRQ 4096 is not free
[root@host build]#On LPAR:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193 **
ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size>= 2 *page_size)
Bail out! ERROR:../tcg/region.c:774:tcg_region_init: assertion failed:
(region_size>= 2 *page_size)
Aborted (core dumped)
[root@host build]#On x86:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=8193
qemu-system-ppc64:../hw/intc/spapr_xive.c:596:spapr_xive_claim_irq:
Assertion `lisn <xive->nr_irqs' failed.
Aborted (core dumped)
[root@host build]#Quoted 7 lines
With patch fix:
[root@host build]# qemu-system-ppc64 -accel tcg -smp 10,maxcpus=4097
qemu-system-ppc64: Invalid SMP CPUs 4097. The max CPUs supported by machine 'pseries-8.2' is 4096
[root@host build]#Signed-off-by Harsh Prateek Bora <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Thanks,
C.
Quoted 20 lines
---
hw/ppc/spapr.c| 9 +++------1 file changed, 3 insertions(+), 6 deletions(-)hw/ppc/spapr.c +2
-5@@ -4647,13 +4647,10 @@ static voidspapr_machine_class_init (ObjectClass *oc, void *data) mc->block_default_type = IF_SCSI; /* -* Setting max_cpus to INT32_MAX. Both KVM and TCG max_cpus values -* should be limited by the host capability instead of hardcoded. -* max_cpus for KVM guests will be checked in kvm_init(), and TCG -* guests are welcome to have as many CPUs as the host are capable -* of emulate. +* While KVM determines max cpus in kvm_init() using kvm_max_vcpus(), +* In TCG the limit is restricted by the range of CPU IPIs Quoted 6 lines
available.
*/
-mc->max_cpus=INT32_MAX;
+mc->max_cpus=SPAPR_IRQ_NR_IPIS;
mc->no_parallel= 1;
mc->default_boot_order= "";I've applied these patches and verified on the latest upstream qemu. The code is working as expected. Tested-by: Kowshik Jois<[email protected]>