From nobody Wed May 8 08:11:55 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; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1636418921; cv=none; d=zohomail.com; s=zohoarc; b=DPVgsukJ8j/x9Zjf81k2wOcaJvHh6QHhGoubOSfKyT5lW41Kn1m2Qdf1XyoZU/ZI6YfYx2mfUFOWSew2cqNwOczrZ1SWC336fjTe69lLGaw8tMY+nHowxc3jPS0H0uA/DcXGIn5kkn920LdZ2U9SAZXOpvy5IdpciDKEBQwFeEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636418921; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=wFzUdHAJJrAG8njE8xCmAkbI+6lanKsw6SoqOl0w3DE=; b=Qc0PwJyYf5/Osfbj9G3mVvot7Vph0Vhb0sC4ZQ8yR0Y3tCnnIF+vCTpbQZurC1yyy/m5eOam6c7O+yhOoi+HY10zrLXjbKU+6ETl7qwITaWg9q/KWAMBK1TR25qmFud6w938Kog2OoeGYdbVnKbS5/9RvzLDSnFTxOJneXppg2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636418921838801.6976076783718; Mon, 8 Nov 2021 16:48:41 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223659.386446 (Exim 4.92) (envelope-from ) id 1mkFJB-0002Yg-Pd; Tue, 09 Nov 2021 00:48:17 +0000 Received: by outflank-mailman (output) from mailman id 223659.386446; Tue, 09 Nov 2021 00:48:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkFJB-0002YZ-Me; Tue, 09 Nov 2021 00:48:17 +0000 Received: by outflank-mailman (input) for mailman id 223659; Tue, 09 Nov 2021 00:48:17 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkFJB-0002YT-3x for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 00:48:17 +0000 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b7cc76d4-40f6-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 01:48:15 +0100 (CET) Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A7E761167; Tue, 9 Nov 2021 00:48:12 +0000 (UTC) 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: b7cc76d4-40f6-11ec-9787-a32c541c8605 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636418892; bh=TrtiRf/jbn1eppoSVzKa2iW99vW6lQ7QCO5L2IMDUHE=; h=From:To:Cc:Subject:Date:From; b=Q8alWq82akG41dbfi0CUWKW5S8CjKptuR0IVdlWZlCaZZBba2Y16Clsq3vx3CanTx OKvElavpF+tDG6dekANq/Hy8OGb6O/e8MXbdYfrwLfS4UTH/HISl9+R7vi4H6tz0cx DaoHgI6hV89U+EYH+LIQnuFBV1XlvH7J9TuFYNVyKKflKYa17SP8pYhFFaRFFbhRLw FUOp5UuhInjEkzAL86KrPQ9y/AJWfqt5OeWzlhOhl2lsquzs18bYjEdaHDZJzZrK5s UFOXKF2Bb8/0muoCHwqXdjJt941MJzpFNXZdfnFWkzaOug/RArcl6CkqNpyjdvN2Tx ojo+eICCCbQFA== From: Stefano Stabellini To: julien@xen.org Cc: Penny.Zheng@arm.com, Bertrand.Marquis@arm.com, Wei.Chen@arm.com, sstabellini@kernel.org, iwj@xenproject.org, Volodymyr_Babchuk@epam.com, xen-devel@lists.xenproject.org, Stefano Stabellini Subject: [PATCH for-4.16] xen/arm: don't assign domU static-mem to dom0 as reserved-memory Date: Mon, 8 Nov 2021 16:48:08 -0800 Message-Id: <20211109004808.115906-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1636418925344100001 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini DomUs static-mem ranges are added to the reserved_mem array for accounting, but they shouldn't be assigned to dom0 as the other regular reserved-memory ranges in device tree. In make_memory_nodes, fix the error by skipping banks with xen_domain set to true in the reserved-memory array. Also make sure to use the first valid (!xen_domain) start address for the memory node name. Signed-off-by: Stefano Stabellini --- This patch should be considered for 4.16 as it fixes an incorrect behavior. The risk is low for two reasons: - the change is simple - make_memory_node is easily tested because it gets called at every boot, e.g. gitlab-ci and OSSTest exercise this path I tested this patch successfully with and without xen,static-mem. --- xen/arch/arm/domain_build.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 1fbafeaea8..56d3ff9d08 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -874,11 +874,17 @@ static int __init make_memory_node(const struct domai= n *d, if ( mem->nr_banks =3D=3D 0 ) return -ENOENT; =20 + for ( i =3D 0; i < mem->nr_banks && mem->bank[i].xen_domain; i++ ) + ; + /* No reserved-memory ranges to expose to Dom0 */ + if ( i =3D=3D mem->nr_banks ) + return 0; + dt_dprintk("Create memory node (reg size %d, nr cells %d)\n", reg_size, nr_cells); =20 /* ePAPR 3.4 */ - snprintf(buf, sizeof(buf), "memory@%"PRIx64, mem->bank[0].start); + snprintf(buf, sizeof(buf), "memory@%"PRIx64, mem->bank[i].start); res =3D fdt_begin_node(fdt, buf); if ( res ) return res; @@ -888,11 +894,14 @@ static int __init make_memory_node(const struct domai= n *d, return res; =20 cells =3D ®[0]; - for ( i =3D 0 ; i < mem->nr_banks; i++ ) + for ( ; i < mem->nr_banks; i++ ) { u64 start =3D mem->bank[i].start; u64 size =3D mem->bank[i].size; =20 + if ( mem->bank[i].xen_domain ) + continue; + dt_dprintk(" Bank %d: %#"PRIx64"->%#"PRIx64"\n", i, start, start + size); =20 --=20 2.25.1