From nobody Wed May 1 12:33:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1608571889; cv=none; d=zohomail.com; s=zohoarc; b=Poo/AOJwnpQZLAO/x3EMZ9DZI7dLv5taHluRIXcD/xBgBBoAjfn8mDaFuU96rSqAMQhflXdvSmv60W6nJleEK2eUmqYdTX2TrKcw/lw/SXEhfpKaxpesrtTrZE9lZuEVsaANKTz3u3VgForgPtkStMB7tEN2oQtXa9V6ns5h9j0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608571889; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=WTw54bJj+2yCn381ricaMYHoR/mR9hpxDDkfafFYz0g=; b=BncNmTyAQwXE7OPVUFEcOoSerGEMFWTgpSiYHAhaaUGftqoTfxxEgdRzNWGmurgbFwnfSD2pd4atFIrxS4xkTlUIwzwTinKNCUR/+2kGMAiiMOYiIulIO0UtcGt+KdMCEO7s4zvXUKAAjRNVFY8N1gzAqnKxqcP3XmZtYRtkbhI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of 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.zohomail.com with SMTPS id 1608571889759720.4582834943477; Mon, 21 Dec 2020 09:31:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.57470.100559 (Exim 4.92) (envelope-from ) id 1krP1J-0004ub-RC; Mon, 21 Dec 2020 17:30:53 +0000 Received: by outflank-mailman (output) from mailman id 57470.100559; Mon, 21 Dec 2020 17:30:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1krP1J-0004uU-O7; Mon, 21 Dec 2020 17:30:53 +0000 Received: by outflank-mailman (input) for mailman id 57470; Mon, 21 Dec 2020 17:30:53 +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.92) (envelope-from ) id 1krP1J-0004uP-06 for xen-devel@lists.xenproject.org; Mon, 21 Dec 2020 17:30:53 +0000 Received: from mailhost.m5p.com (unknown [74.104.188.4]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 400ffe58-c914-4293-816a-ab04875593e1; Mon, 21 Dec 2020 17:30:52 +0000 (UTC) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.15.2/8.15.2) with ESMTPS id 0BLHUYPq078964 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 21 Dec 2020 12:30:40 -0500 (EST) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.15.2/8.15.2/Submit) id 0BLHUYRm078963; Mon, 21 Dec 2020 09:30:34 -0800 (PST) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 400ffe58-c914-4293-816a-ab04875593e1 Date: Mon, 21 Dec 2020 09:30:34 -0800 From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Ian Jackson Subject: [RESEND] [RFC PATCH] xen/arm: domain_build: Ignore empty memory bank Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=0.0 required=10.0 tests=KHOP_HELO_FCRDNS autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mattapan.m5p.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously Xen had stopped processing Device Trees if an empty (size =3D=3D 0) memory bank was found. Commit 5a37207df52066efefe419c677b089a654d37afc changed this behavior to ignore such banks. Unfortunately this means these empty nodes are visible to code which accesses the device trees. Have domain_build also ignore these entries. --- This is tagged "RFC" due to issues. Authorship of this is unclean. In the first version (checked in, but never sent to the list and never compiled) a different condition was used and the comment was absent. When examing the code it became clear a condition identical to 5a37207df52066efefe419c677b089a654d37afc was appropriate and so I changed to !size. Since what the code is doing was sufficiently similar, the comment was grabbed. How far does this dilute authorship? I diagnosed the bug and figured out where to add the lines, but the amount inspired by Julien Grall gives Julien Grall some level of claim of authorship. Advice is needed. Commit 7d2b21fd36c2a47799eed71c67bae7faa1ec4272 is an outright bug for me. I don't know what percentage of users will experience this bug, but being observed this quickly suggests this is major enough to be urgent for the stable-4.14 branch. I doubt this is the only bug exposed by 5a37207df52066efefe419c677b089a654d37afc. This might actually effect most uses of the device-tree code. I think either the core needs to be fixed to hide zero-sized entries from anything outside of xen/common/device_tree.c, otherwise all uses of the device-tree core need to be audited to ensure they ignore zero-sized entries. Notably this is the second location where zero-size device-tree entries need to be ignored, preemptive action should be taken before a third is found by bugreport. Perhaps this fix is appropriate for the stable-4.14 branch and a proper solution should be implemented for the main branch? The error message which first showed was "Unable to retrieve address %u for %s\n". Where the number in %u was 0, this seems a poor error message. Version 0.1 (which never got compiled) had been: if(!addr) continue; As I thought the 0 it was reporting was an address of 0. Perhaps the message should instead be: "Unable to retrieve address for index %u of %s\n"? --- xen/arch/arm/domain_build.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e824ba34b0..0b83384bd3 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1405,6 +1405,11 @@ static int __init handle_device(struct domain *d, st= ruct dt_device_node *dev, { struct map_range_data mr_data =3D { .d =3D d, .p2mt =3D p2mt }; res =3D dt_device_get_address(dev, i, &addr, &size); + + /* Some DT may describe empty bank, ignore them */ + if ( !size ) + continue; + if ( res ) { printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445