Introduce SPAPR_IRQ_NR_IPIS and fix max-cpus
v4 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().
v4: added "Reported-by" and "Tested-by" from Kowshik
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 v4 1/2 ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs.
spapr_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
PATCH v4 2/2 ppc/spapr: Initialize max_cpus limit to SPAPR_IRQ_NR_IPIS.
In reply to Harsh Prateek BoraInitialize 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
@@ -4639,13 +4639,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