[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/5] xen/domain: Allocate d->vcpu[] earlier during domain_create()
With config->max_vcpus now being audited by the check_domain_config() path, we can alloate d->vcpu[] before calling arch_domain_create(). Doing do allows for the removal of domain_max_vcpus(), which on the ARM side removes vgic_max_vcpus() and the .max_vcpus field from vgic_ops. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Julien Grall <julien.grall@xxxxxxx> --- xen/arch/arm/vgic-v2.c | 1 - xen/arch/arm/vgic-v3.c | 5 ----- xen/arch/arm/vgic.c | 5 ----- xen/arch/arm/vgic/vgic-init.c | 3 --- xen/arch/arm/vgic/vgic.c | 16 ---------------- xen/common/domain.c | 27 ++++++++++++++------------- xen/include/asm-arm/domain.h | 6 ------ xen/include/asm-arm/vgic.h | 4 ---- xen/include/asm-x86/domain.h | 2 -- 9 files changed, 14 insertions(+), 55 deletions(-) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index f6c11f1..055a30a 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -724,7 +724,6 @@ static const struct vgic_ops vgic_v2_ops = { .domain_free = vgic_v2_domain_free, .lpi_to_pending = vgic_v2_lpi_to_pending, .lpi_get_priority = vgic_v2_lpi_get_priority, - .max_vcpus = 8, }; int vgic_v2_init(struct domain *d, int *mmio_count) diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index efe824c..b4476f3 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1822,11 +1822,6 @@ static const struct vgic_ops v3_ops = { .emulate_reg = vgic_v3_emulate_reg, .lpi_to_pending = vgic_v3_lpi_to_pending, .lpi_get_priority = vgic_v3_lpi_get_priority, - /* - * 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, }; int vgic_v3_init(struct domain *d, int *mmio_count) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 5a4f082..664aa0b 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -667,11 +667,6 @@ void vgic_free_virq(struct domain *d, unsigned int virq) clear_bit(virq, d->arch.vgic.allocated_irqs); } -unsigned int vgic_max_vcpus(const struct domain *d) -{ - 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/vgic-init.c b/xen/arch/arm/vgic/vgic-init.c index bfd3d09..62ae553 100644 --- a/xen/arch/arm/vgic/vgic-init.c +++ b/xen/arch/arm/vgic/vgic-init.c @@ -112,9 +112,6 @@ int domain_vgic_register(struct domain *d, int *mmio_count) BUG(); } - if ( d->max_vcpus > domain_max_vcpus(d) ) - return -E2BIG; - d->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF; d->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF; d->arch.vgic.vgic_redist_base = VGIC_ADDR_UNDEF; diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 7c3cfc5..e1ee216 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -949,22 +949,6 @@ void vgic_sync_hardware_irq(struct domain *d, spin_unlock_irqrestore(&desc->lock, flags); } -unsigned int vgic_max_vcpus(const struct domain *d) -{ - unsigned int vgic_vcpu_limit; - - switch ( d->arch.vgic.version ) - { - case GIC_V2: - vgic_vcpu_limit = VGIC_V2_MAX_CPUS; - break; - default: - BUG(); - } - - return min_t(unsigned int, MAX_VIRT_CPUS, vgic_vcpu_limit); -} - #ifdef CONFIG_GICV3 /* Dummy implementation to allow building without actual vGICv3 support. */ void vgic_v3_setup_hw(paddr_t dbase, diff --git a/xen/common/domain.c b/xen/common/domain.c index 9882550..ee7b889 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -354,6 +354,20 @@ struct domain *domain_create(domid_t domid, TRACE_1D(TRC_DOM0_DOM_ADD, d->domain_id); + /* + * Allocate d->vcpu[] and set ->max_vcpus up early. Various per-domain + * resources want to be sized based on max_vcpus. + */ + if ( !is_system_domain(d) ) + { + err = -ENOMEM; + d->vcpu = xzalloc_array(struct vcpu *, config->max_vcpus); + if ( !d->vcpu ) + goto fail; + + d->max_vcpus = config->max_vcpus; + } + lock_profile_register_struct(LOCKPROF_TYPE_PERDOM, d, domid, "Domain"); if ( (err = xsm_alloc_security_domain(d)) != 0 ) @@ -405,19 +419,6 @@ struct domain *domain_create(domid_t domid, if ( !is_idle_domain(d) ) { - /* Check d->max_vcpus and allocate d->vcpu[]. */ - err = -EINVAL; - if ( config->max_vcpus < 1 || - config->max_vcpus > domain_max_vcpus(d) ) - goto fail; - - err = -ENOMEM; - d->vcpu = xzalloc_array(struct vcpu *, config->max_vcpus); - if ( !d->vcpu ) - goto fail; - - d->max_vcpus = config->max_vcpus; - watchdog_domain_init(d); init_status |= INIT_watchdog; diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index d682307..175de44 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -208,12 +208,6 @@ void vcpu_show_execution_state(struct vcpu *); void vcpu_show_registers(const struct vcpu *); void vcpu_switch_to_aarch64_mode(struct vcpu *); -/* On ARM, the number of VCPUs is limited by the type of GIC emulated. */ -static inline unsigned int domain_max_vcpus(const struct domain *d) -{ - return vgic_max_vcpus(d); -} - /* * Due to the restriction of GICv3, the number of vCPUs in AFF0 is * limited to 16, thus only the first 4 bits of AFF0 are legal. We will diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 374fdaa..5cf2858 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -238,8 +238,6 @@ struct vgic_ops { /* lookup the struct pending_irq for a given LPI interrupt */ struct pending_irq *(*lpi_to_pending)(struct domain *d, unsigned int vlpi); int (*lpi_get_priority)(struct domain *d, uint32_t vlpi); - /* Maximum number of vCPU supported */ - const unsigned int max_vcpus; }; /* Number of ranks of interrupt registers for a domain */ @@ -354,8 +352,6 @@ extern void vgic_clear_pending_irqs(struct vcpu *v); extern bool vgic_emulate(struct cpu_user_regs *regs, union hsr hsr); -unsigned int vgic_max_vcpus(const struct domain *d); - void vgic_v2_setup_hw(paddr_t dbase, paddr_t cbase, paddr_t csize, paddr_t vbase, uint32_t aliased_offset); diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index cb0721e..9854a74 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -659,8 +659,6 @@ unsigned long pv_guest_cr4_to_real_cr4(const struct vcpu *v); X86_CR4_OSXSAVE | X86_CR4_SMEP | \ X86_CR4_FSGSBASE | X86_CR4_SMAP | X86_CR4_PCIDE)) -#define domain_max_vcpus(d) (is_hvm_domain(d) ? HVM_MAX_VCPUS : MAX_VIRT_CPUS) - static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void) { return vmalloc(sizeof(struct vcpu_guest_context)); -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |