From patchwork Mon Feb 18 10:14:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158581 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2309073jaa; Mon, 18 Feb 2019 02:16:33 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaop5kKM8sdXvWhX1hpsDjGskw5vq8dcw6J+oQ6ZDwosDF3hMK+F388UWTb6yEJqlMD6KqT X-Received: by 2002:a81:a6d7:: with SMTP id d206mr18348623ywh.484.1550484993090; Mon, 18 Feb 2019 02:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550484993; cv=none; d=google.com; s=arc-20160816; b=uIwx1tPsxUBSENaYImBeqT/TtB92oHcNeI8VFRLoTpOFKLCuPsOf0WzbEEuK+YU9Tf y7TtAJTX3T9InLKxZfbXRaEkW+DTE7UanDGtySpl3CMkEqw+1oI5M1gdIZ6JH65+CFDl qgJVHCNfhcegqmuWDlcno+Om+602ANIjWXFz5wIGEIH7fuB+w/nTFJYm0Dtu/g2L3w2y /b0qwzTwRzCV/F7hBxaC9a/eH5oi2gBV6zYr02eXn1LU2WFCaZm5ifidNBTRcPXATEhF lA63c1kf18gSdIzxN/uI2z3CGhNo1XlqH4i++4VySWbvIF7gYA9J3aVIkXuWxhMU/4sb APMQ== 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:message-id:date:to:from; bh=akzcG3oq0dG5XzNxWz0wNkhJ4v4ZH/61ruR0PtghmEM=; b=TDavkvnh5hzqo70HRpT2AZZ8+BhcFu/nsg28XFT5k5mCL0//4LUb/ZD6yThsnnAxgU eERonYoAVzJ3HmoZEDiC6jMY+mbKwSBX2tcProt4JeE7NSMppvFc+d+I111iRzqp0cJt jMHkh8hiK35UyaFC0EaWS/TUvueWha5enaedUnqhL2Pmw1nVS+4Ff9oPDkmOXjxrRc9K 6IU3gFoiMzGIn2iPitCQErLDCkQ8uNL0TEA5FgiTLwtEu/2+GKGopMZBkGjIl8E8onJZ dcyo0tykKetEBHnGEV0XfMrhPHQmnSwXGLKhE6r6HyCuBCAyPIp/ECi5bk5neBfE0F2x elJA== 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 f5si7253836ybc.461.2019.02.18.02.16.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 02:16:32 -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; 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 1gvfwm-000247-SN; Mon, 18 Feb 2019 10:14:48 +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 1gvfwl-000242-J1 for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 10:14:47 +0000 X-Inumbo-ID: 044e7c3e-3366-11e9-acb5-f7f436f41648 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 044e7c3e-3366-11e9-acb5-f7f436f41648; Mon, 18 Feb 2019 10:14:46 +0000 (UTC) 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 2451780D; Mon, 18 Feb 2019 02:14:46 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C11DA3F720; Mon, 18 Feb 2019 02:14:44 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 10:14:36 +0000 Message-Id: <20190218101436.31127-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Subject: [Xen-devel] [PATCH for-4.12 v2] xen/arm: domain_build: Require the property "cpus" when building a domU 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: Artem_Mygaiev@epam.com, jgross@suse.com, sstabellini@kernel.org, Andrii_Anisov@epam.com, Oleksandr_Tyshchenko@epam.com, Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The 3rd argument of function dt_property_read_u32() is only valid when the call succeeded. So we cannot assume the value will not be modifed in case of failure. The documentation of Dom0less does not give a default value when the property "cpus" is not set. So require the property in the configuration. Coverity-ID: 1476825 Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2 - Add missing newline in panic --- xen/arch/arm/domain_build.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 31af989e63..c92f8c6be1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2069,7 +2069,6 @@ void __init create_domUs(void) .arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE, .arch.nr_spis = 0, .flags = XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap, - .max_vcpus = 1, .max_evtchn_port = -1, .max_grant_frames = 64, .max_maptrack_frames = 1024, @@ -2080,7 +2079,10 @@ void __init create_domUs(void) if ( dt_property_read_bool(node, "vpl011") ) d_cfg.arch.nr_spis = GUEST_VPL011_SPI - 32 + 1; - dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus); + + if ( !dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus) ) + panic("Missing property 'cpus' for domain %s\n", + dt_node_name(node)); d = domain_create(++max_init_domid, &d_cfg, false); if ( IS_ERR(d) )