From patchwork Mon Oct 1 18:57:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147928 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp4263592lji; Mon, 1 Oct 2018 11:59:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV63JCNuqXL31VNbQ6wFogwhw+43btWSfnAeXeXhWuIa4imWnimEHgd6We7VQFouD0zFRhUCu X-Received: by 2002:a24:4f53:: with SMTP id c80-v6mr11219339itb.71.1538420397076; Mon, 01 Oct 2018 11:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538420397; cv=none; d=google.com; s=arc-20160816; b=vb4JxPQ27pUtNUT90Nzp+FTJqHIMjQ8wbNxKQnBV5p0ktgHxXsxFANRem+sLSaaej3 M0fN8yarV8sBViXHopWrykupipU/btJwR5PYNoT0seB/1V3G788ehK8ZxYezUnLFtJqL HeAaRLivBThgc9biw9jZ7qMn8ml6dj7Z1p6GglH64qFUzTKlJyLcB+fmPTnPHcd22v4/ 1TkjbnWYAOOFK8FJ5WLCl6JvZnTkpg3h3+EpOABUcczArvTVx7PbyGGyCbj9kKx/ZdtA J3kgzyFAnOni7SXfDmMmfnjJ+Ph0N4jGsHlkXADqHtVaPM0fXiU2O1d/7JglrKvpeXcR kYqw== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=8SKfmQaae6tzSFdymomArYibdVI+haBOOsaxzKagKiY=; b=yzYIMjyaTExX34Y8H+CIgxOGAhuWirnjnIBb9nvW9mcCEY9sAT+Ti0xsCH6r1znFEZ S9dRUP4AeqerG5gkPkDYSofM34ciKQ9alAY856R6vIyGeE+oSEtbW+I3Q2gAbYZufWEG rxlVM1uvQ+y/fP4JytLIU3qn6CAWDT/s3cgr9rRhwaH6DUYG5jG3SpmuDHOcTYDPFw2V 4n9NgszrLU5odVa/Jx1XOxQE0DmUhCvGQiVbKspjFKi5h5UwA1smE0ZTAnWBvHnVFU3I 0IOBquzFr28vfg3HV1WUt2zAbC9tv0YEkgMIurSYYGjIr9YlCbyzGXjhxQ1ckuehBxbK npDw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p184-v6si7069535ita.112.2018.10.01.11.59.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 11:59:56 -0700 (PDT) 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; 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 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g73Nt-0001FP-SO; Mon, 01 Oct 2018 18:57:33 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g73Ns-0001FH-PU for xen-devel@lists.xenproject.org; Mon, 01 Oct 2018 18:57:32 +0000 X-Inumbo-ID: 85a8a5c6-c5ab-11e8-a8a5-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 85a8a5c6-c5ab-11e8-a8a5-bc764e045a96; Mon, 01 Oct 2018 20:55:10 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15D687A9; Mon, 1 Oct 2018 11:57:31 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.emea.arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A839F3F5B7; Mon, 1 Oct 2018 11:57:29 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 1 Oct 2018 19:57:18 +0100 Message-Id: <20181001185721.15467-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181001185721.15467-1-julien.grall@arm.com> References: <20181001185721.15467-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 1/2] xen/arm: vgic-v3: Delay the initialization of the domain information X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: sstabellini@kernel.org, wei.liu2@citrix.com, Andrew Cooper , ian.jackson@eu.citrix.com, Julien Grall , roger.pau@citrix.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A follow-up patch will require to know the number of vCPUs when initializating the vGICv3 domain structure. However this information is not available at domain creation. This is only known once XEN_DOMCTL_max_vpus is called for that domain. In order to get the max vCPUs around, delay the domain part of the vGIC v3 initialization until the first vCPU of the domain is initialized. Signed-off-by: Julien Grall Tested-by: Shameer Kolothum Acked-but-disliked-by: Stefano Stabellini --- Cc: Andrew Cooper This is nasty but I can't find a better way for Xen 4.11 and older. We still need it for unstable because the number of vCPUs is not known in arch_domain_init. There are discussion to rework the domain creation a bit further but I would hope to fix the bug first. Andrew, I have CCed you to know whether you have a better idea where to place this call on Xen 4.11 and older. Changes in v2: - The patch is also needed for the time being on unstable - Add Stefano's recently invented tag - Add Shameer's tested tag --- xen/arch/arm/vgic-v3.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 4b42739a52..df1bab3a35 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1573,9 +1573,11 @@ static const struct mmio_handler_ops vgic_distr_mmio_handler = { .write = vgic_v3_distr_mmio_write, }; +static int vgic_v3_real_domain_init(struct domain *d); + static int vgic_v3_vcpu_init(struct vcpu *v) { - int i; + int i, rc; paddr_t rdist_base; struct vgic_rdist_region *region; unsigned int last_cpu; @@ -1584,6 +1586,19 @@ static int vgic_v3_vcpu_init(struct vcpu *v) struct domain *d = v->domain; /* + * This is the earliest place where the number of vCPUs is + * known. This is required to initialize correctly the vGIC v3 + * domain structure. We only to do that when vCPU 0 is + * initilialized. + */ + if ( v->vcpu_id == 0 ) + { + rc = vgic_v3_real_domain_init(d); + if ( rc ) + return rc; + } + + /* * Find the region where the re-distributor lives. For this purpose, * we look one region ahead as we have only the first CPU in hand. */ @@ -1641,7 +1656,7 @@ static inline unsigned int vgic_v3_rdist_count(struct domain *d) GUEST_GICV3_RDIST_REGIONS; } -static int vgic_v3_domain_init(struct domain *d) +static int vgic_v3_real_domain_init(struct domain *d) { struct vgic_rdist_region *rdist_regions; int rdist_count, i, ret; @@ -1733,6 +1748,16 @@ static int vgic_v3_domain_init(struct domain *d) return 0; } +static int vgic_v3_domain_init(struct domain *d) +{ + /* + * The domain initialization for vGIC v3 is delayed until the first vCPU + * is created. This because the initialization may require to know the + * number of vCPUs that is not known when creating the domain. + */ + return 0; +} + static void vgic_v3_domain_free(struct domain *d) { vgic_v3_its_free_domain(d);