From patchwork Fri Mar 9 15:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 131143 Delivered-To: patch@linaro.org Received: by 10.80.194.209 with SMTP id u17csp1135431edf; Fri, 9 Mar 2018 07:14:01 -0800 (PST) X-Google-Smtp-Source: AG47ELv9DVl6YaZwJ0XsjPJ3sWy3ZMDOk5PS1UnzgslmuU/pDU+06KutJ/g5m7W8NWDWYzbTksGe X-Received: by 10.107.58.139 with SMTP id h133mr37544592ioa.250.1520608441492; Fri, 09 Mar 2018 07:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520608441; cv=none; d=google.com; s=arc-20160816; b=D2c3q35iIDi6dzdxqARNGF8tBdUXDAxQtiEu2Cos5SFxT9XyfPEypoF9roRO8ZFbrA AGpVdR8U4j3wfOAvrUBNDPGLEd5JjkPqVvxd7IJDtBBXmNNGUMWVJL0z09ET1oQaWlod hkftgsWjQf5hnxpcCa0ejWsoP3SJNB6TMusNWHhnQa0Y6TsuKvn81s8QvXtrezqyqgXF QXCVnmoAMvsAl9VVYCO0sAo4mD7vxWir1Y1o6pl0+QESHkdCDs4fJajEf1o1193NFZgG RQdZdJTkRc4goSEMMD4BPkgFwVOBh/l8tkqpQM5dFkazhv7lYSdTifpZzNTnLR26CD87 fkgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=RvSPXngViuImtoa16cEcJ+ys2E0UQK8UQby2OwfiRi4=; b=sYsN6g3oFQ81OsPKaiYJnFwZxhYPtQ8OhsVbo6KwSPMVfT7nmsnp2XjzXH72OSNrg3 ztZqobCioGSdi7AQNQIGLEAMIP2o87LjheG5Kix+QktNaOdUWnN8Z26hGBuydIMAJ97r lpNCV+Kz0Q2Ct5RHZDTMch4xt0hRcJZkDt/+S2V4GpFapmE86zhmUq80Nusibq5Y7ljW 71ZAjtiK5PFlHnoSGWiiOijbHRBv0656QqNmhNBNOJuqT/CHMVTeVe5AmXAqVM7hd8lQ TFcFBO01BeN3leqwwikARi8gW0OfN9V2v+jrxgB5gIN85AGsP8NLaziBqbVRmRt71oCh 2Fyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IQFvh/KZ; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 80si1277009itm.121.2018.03.09.07.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 07:14:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IQFvh/KZ; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euJgY-0005sM-GB; Fri, 09 Mar 2018 15:11:54 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euJgW-0005rB-LN for xen-devel@lists.xenproject.org; Fri, 09 Mar 2018 15:11:52 +0000 X-Inumbo-ID: 06ce5528-23ac-11e8-ba59-bc764e045a96 Received: from mail-wm0-x242.google.com (unknown [2a00:1450:400c:c09::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 06ce5528-23ac-11e8-ba59-bc764e045a96; Fri, 09 Mar 2018 16:10:40 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id h21so4507599wmd.1 for ; Fri, 09 Mar 2018 07:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/K3y4nMZD134khETbVaWbEEfq/+vHKdm8wis5myJSG0=; b=IQFvh/KZENqiQCxFoXDuOoDRz4xgf01zoHighNLDhOE4n4hOLf6ltNBOq1hkmYT5Gn HFfLTdH5AgFCukUSuJ9FJZHM/08O7vzRzbBo/4/J9hYjbBUte5f6XS1fjQsZT6KcEHGf HolLOoDsTZ7ypV2r/cDVw3ZuutCsmgmkxfa+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/K3y4nMZD134khETbVaWbEEfq/+vHKdm8wis5myJSG0=; b=lBM5+ZJTUATeNdpbn8Z+hZAdDLMAlIUvu840c6WFdAiKzUWl4DJOwPjzmeJcetQDdW /MHZHE5Uz72xSNi//ZOe02aiqIU+Lp7ecP2hlufudJYKgZTBTJm3ItwWAwD1xWnGAK9j 63M756wBFZat1RIYuuRfs13ZMtaB/vNES4Hf8dET/7ipxfr6NqSz7kAKRrdRtCjj+tjD TYMrI0YyekCByM9whn/88/N3DeVIgenKHNNX75wbZZXxtNB9q77eFhia9OBgvv7a6no0 uOuu19Cq1iTB9qJdcwQ+dAYF5FMVwYT91l0jeLDHjcNsiill7O/f5GHRCY4qHwLY47L8 UcHg== X-Gm-Message-State: AElRT7ECNCF8huCqUSNilsMGXr8FGmkEpDEJhZLA9Z10qjElV4Fb6fiW KOkmUsiEIJ8jMDENBGCOvKIOTQ1V30M= X-Received: by 10.28.195.133 with SMTP id t127mr2293479wmf.156.1520608310462; Fri, 09 Mar 2018 07:11:50 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id 1sm1721198wmj.35.2018.03.09.07.11.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 07:11:50 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Fri, 9 Mar 2018 15:11:23 +0000 Message-Id: <20180309151133.31371-8-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180309151133.31371-1-andre.przywara@linaro.org> References: <20180309151133.31371-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 07/17] ARM: VGIC: Adjust domain_max_vcpus() to be VGIC specific X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" domain_max_vcpus(), which is used by generic Xen code, returns the maximum number of VCPUs for a domain, which on ARM is mostly limited by the VGIC model emulated (a (v)GICv2 can only handle 8 CPUs). Our current implementation lives in arch/arm/domain.c, but reaches into VGIC internal data structures. Move the actual functionality into vgic.c, and provide a shim in domain.h, to keep this VGIC internal. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall --- Changelog: - rename helper function and wrap in domain.h xen/arch/arm/domain.c | 14 -------------- xen/arch/arm/vgic.c | 14 ++++++++++++++ xen/include/asm-arm/domain.h | 6 +++++- xen/include/asm-arm/vgic.h | 2 ++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 8de4c0a343..6b902fa30f 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -967,20 +967,6 @@ 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.c b/xen/arch/arm/vgic.c index 34269bcf27..fa00c21a69 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -665,6 +665,20 @@ 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) +{ + /* + * 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/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index c6aa5cf389..e730e07fcf 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -289,7 +289,11 @@ void vcpu_show_execution_state(struct vcpu *); void vcpu_show_registers(const struct vcpu *); void vcpu_switch_to_aarch64_mode(struct vcpu *); -unsigned int domain_max_vcpus(const struct domain *); +/* 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 diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index d03298e12c..afb4776ad4 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -254,6 +254,8 @@ static inline int vgic_allocate_spi(struct domain *d) extern void vgic_free_virq(struct domain *d, unsigned int virq); +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);