From patchwork Tue Oct 8 01:15:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11178701 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 32D0615AB for ; Tue, 8 Oct 2019 01:16:22 +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 0D53820679 for ; Tue, 8 Oct 2019 01:16:22 +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="YkqwjX+e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D53820679 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 1iHe5h-0001PP-LE; Tue, 08 Oct 2019 01:15:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHe5g-0001Ov-76 for xen-devel@lists.xenproject.org; Tue, 08 Oct 2019 01:15:04 +0000 X-Inumbo-ID: 0e3ade40-e969-11e9-97c0-12813bfff9fa Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0e3ade40-e969-11e9-97c0-12813bfff9fa; Tue, 08 Oct 2019 01:15:03 +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 A311A21721; Tue, 8 Oct 2019 01:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570497302; bh=hiQQh+2Zwz+zNsgQjAOGWyiMN6Jk+cTk9K7Etev5C1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkqwjX+ezQJHy4Bizu9etCF1e+NTFbMtIHBWiFnLdl6l6QxTcBdhiwaDOlOmGJ8hf E95Bs2aErmMStNRY5Ywk7xvNd1azC98CKG+c+wb/YYSSUUY5BfA5uHO5GzRuPVHZMz YyQoGW6HXGAl/weagioW8HRNec8Ok25Ffto73LdI= From: Stefano Stabellini To: Julien.Grall@arm.com Date: Mon, 7 Oct 2019 18:15:00 -0700 Message-Id: <20191008011501.21038-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 2/3] xen/arm: make_memory_node return error on nr_banks == 0 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: jgross@suse.com, xen-devel@lists.xenproject.org, sstabellini@kernel.org, Volodymyr_Babchuk@epam.com, Stefano Stabellini MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Call make_memory_node for reserved_memory only if we actually have any reserved_memory regions to handle. Add a check in make_memory_node to return an error if it has been called with no memory banks as argument. Fixes: 248faa637d2 (xen/arm: add reserved-memory regions to the dom0 memory node) Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v2: - patch added --- xen/arch/arm/domain_build.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 60923a7051..ea01aada0b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -650,6 +650,8 @@ static int __init make_memory_node(const struct domain *d, __be32 *cells; BUG_ON(nr_cells >= ARRAY_SIZE(reg)); + if ( mem->nr_banks == 0 ) + return -ENOENT; dt_dprintk("Create memory node (reg size %d, nr cells %d)\n", reg_size, nr_cells); @@ -1540,10 +1542,13 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, * Create a second memory node to store the ranges covering * reserved-memory regions. */ - res = make_memory_node(d, kinfo->fdt, addrcells, sizecells, - &bootinfo.reserved_mem); - if ( res ) - return res; + if ( bootinfo.reserved_mem.nr_banks > 0 ) + { + res = make_memory_node(d, kinfo->fdt, addrcells, sizecells, + &bootinfo.reserved_mem); + if ( res ) + return res; + } } res = fdt_end_node(kinfo->fdt);