From patchwork Fri Oct 4 01:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11173597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6A181599 for ; Fri, 4 Oct 2019 01:16:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C149E20865 for ; Fri, 4 Oct 2019 01:16:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="sgiowjkP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C149E20865 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none 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 1iGCBj-0003UP-9w; Fri, 04 Oct 2019 01:15:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iGCBh-0003TW-Kw for xen-devel@lists.xen.org; Fri, 04 Oct 2019 01:15:17 +0000 X-Inumbo-ID: 63f2a7fa-e644-11e9-9bee-bc764e2007e4 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 63f2a7fa-e644-11e9-9bee-bc764e2007e4; Fri, 04 Oct 2019 01:15:02 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9043321D71; Fri, 4 Oct 2019 01:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570151701; bh=9b5Q4fUFm1N2zXKGpJ+iYtS4HLpRGDPMjhiZ1hjB7pY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sgiowjkPSAzt1H7U7B/6hlpuK0wRL5soJbo1rdJh5JpoRif8RgKmhJhtmJ21tjYq0 RZrvHp0QiTrp0e+ZlIuf63QD3NwFwvKKHJ+/6CklNwPW82ibYCaYbGMNTTLrh1BZsi t+AnWLOEOSW+3M2ZRJ25qIPCQb8YMad8ev3CXOKY= From: Stefano Stabellini To: julien.grall@arm.com Date: Thu, 3 Oct 2019 18:14:56 -0700 Message-Id: <20191004011457.11126-7-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v9 7/8] xen/arm: introduce nr_spis 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: Stefano Stabellini , sstabellini@kernel.org, andrii_anisov@epam.com, Achin.Gupta@arm.com, xen-devel@lists.xen.org, Volodymyr_Babchuk@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We don't have a clear way to know how many virtual SPIs we need for the dom0-less domains. Introduce a new option under xen,domain to specify the number of SPIs to allocate for a domain. The property is optional. When absent, we'll use the physical number of GIC lines for dom0-less domains, or GUEST_VPL011_SPI+1 if vpl011 is requested, whichever is greater. Remove the old setting of nr_spis based on the presence of the vpl011. The implication of this change is that without nr_spis dom0less domains get the same amount of SPI allocated as dom0, regardless of how many physical devices they have assigned, and regardless of whether they have a virtual pl011 (which also needs an emulated SPI). This is done because the SPIs allocation needs to be done before parsing any passthrough information, so we have to account for any potential physical SPI assigned to the domain. When nr_spis is present, the domain gets exactly nr_spis allocated SPIs. If the number is too low, it might not be enough for the devices assigned it to it. If the number is less than GUEST_VPL011_SPI, the virtual pl011 won't work. Signed-off-by: Stefano Stabellini Reviewed-by: Volodymyr Babchuk Acked-by: Julien Grall --- Changes in v5: - improve commit message - allocate enough SPIs for vpl011 Changes in v4: - improve commit message Changes in v3: - improve commit message - introduce nr_spis --- xen/arch/arm/domain_build.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 030fc32416..d4c4fc40d1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2410,7 +2410,6 @@ void __init create_domUs(void) struct domain *d; struct xen_domctl_createdomain d_cfg = { .arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE, - .arch.nr_spis = 0, .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, .max_evtchn_port = -1, .max_grant_frames = 64, @@ -2420,9 +2419,6 @@ void __init create_domUs(void) if ( !dt_device_is_compatible(node, "xen,domain") ) continue; - if ( dt_property_read_bool(node, "vpl011") ) - d_cfg.arch.nr_spis = GUEST_VPL011_SPI - 32 + 1; - if ( !dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus) ) panic("Missing property 'cpus' for domain %s\n", dt_node_name(node)); @@ -2430,6 +2426,19 @@ void __init create_domUs(void) if ( dt_find_compatible_node(node, NULL, "multiboot,device-tree") ) d_cfg.flags |= XEN_DOMCTL_CDF_iommu; + if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) ) + { + d_cfg.arch.nr_spis = gic_number_lines() - 32; + + /* + * vpl011 uses one emulated SPI. If vpl011 is requested, make + * sure that we allocate enough SPIs for it. + */ + if ( dt_property_read_bool(node, "vpl011") ) + d_cfg.arch.nr_spis = MAX(d_cfg.arch.nr_spis, + GUEST_VPL011_SPI - 32 + 1); + } + d = domain_create(++max_init_domid, &d_cfg, false); if ( IS_ERR(d) ) panic("Error creating domain %s\n", dt_node_name(node));