[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v8 7/8] xen/arm: make domain_max_vcpus return value from vgic_ops
From: Chen Baozi <baozich@xxxxxxxxx> Each vGIC driver supports different maximum numbers of vCPU. For example, GICv2 is limited to 8 vCPUs, while GICv3 can support up to 4096 vCPUs if we use both AFF0 and AFF1. Thus, domain_max_vcpus should depend on not only MAX_VIRT_CPUS but also the version of vGIC that the guest uses. Since evtchn_init would call domain_max_vcpus to allocate poll_mask when the vgic_ops haven't been initialised yet, we make it return MAX_VIRT_CPUS at that time. On ARM32, event channel doesn't need to allocate the poll_mask because MAX_VIRT_CPUS < BITS_PER_LONG, while allocating more memory (2 unsigned long rather than 1) only for poll_mask on arm64 with GICv2 looks not so expensive. We didn't keep it as the old static inline form because it will break compilation when access the member of struct domain: In file included from xen/include/xen/domain.h:6:0, from xen/include/xen/sched.h:10, from arm64/asm-offsets.c:10: xen/include/asm/domain.h: In function âdomain_max_vcpusâ: xen/include/asm/domain.h:266:10: error: dereferencing pointer to incomplete type if (d->arch.vgic.version == GIC_V2) ^ Signed-off-by: Chen Baozi <baozich@xxxxxxxxx> --- xen/arch/arm/domain.c | 14 ++++++++++++++ xen/arch/arm/vgic-v2.c | 1 + xen/arch/arm/vgic-v3.c | 5 +++++ xen/include/asm-arm/domain.h | 5 +---- xen/include/asm-arm/vgic.h | 2 ++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 0cf147c..01d8ca89 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -890,6 +890,20 @@ void vcpu_block_unless_event_pending(struct vcpu *v) vcpu_unblock(current); } +unsigned int domain_max_vcpus(const struct domain *d) +{ + /* + * Since evtchn_init would call domain_max_vcpus for poll_mask + * allocation when the vgic_ops haven't been initialised yet, + * we return MAX_VIRT_CPUS if d->arch.vgic.handler is null. + */ + if ( !d->arch.vgic.handler ) + return MAX_VIRT_CPUS; + else + return min_t(unsigned int, MAX_VIRT_CPUS, + d->arch.vgic.handler->max_vcpus); +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 5949cf1..bbeb740 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -585,6 +585,7 @@ const struct vgic_ops vgic_v2_ops = { .domain_init = vgic_v2_domain_init, .get_irq_priority = vgic_v2_get_irq_priority, .get_target_vcpu = vgic_v2_get_target_vcpu, + .max_vcpus = 8, }; /* diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 93610d0..93af6c8 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1204,6 +1204,11 @@ const struct vgic_ops vgic_v3_ops = { .get_irq_priority = vgic_v3_get_irq_priority, .get_target_vcpu = vgic_v3_get_target_vcpu, .emulate_sysreg = vgic_v3_emulate_sysreg, + /* + * We use both AFF1 and AFF0 in (v)MPIDR. Thus, the max number of CPU + * that can be supported is up to 4096(256*16) in theory. + */ + .max_vcpus = 4096, }; /* diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 35b9a6d..23598dd 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -261,10 +261,7 @@ struct arch_vcpu void vcpu_show_execution_state(struct vcpu *); void vcpu_show_registers(const struct vcpu *); -static inline unsigned int domain_max_vcpus(const struct domain *d) -{ - return MAX_VIRT_CPUS; -} +unsigned int domain_max_vcpus(const struct domain *); /* * Due to the restriction of GICv3, the number of vCPUs in AFF0 is diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index d68539a..4477962 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -115,6 +115,8 @@ struct vgic_ops { struct vcpu *(*get_target_vcpu)(struct vcpu *v, unsigned int irq); /* vGIC sysreg emulation */ int (*emulate_sysreg)(struct cpu_user_regs *regs, union hsr hsr); + /* Maximum number of vCPU supported */ + const unsigned int max_vcpus; }; /* Number of ranks of interrupt registers for a domain */ -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |