From patchwork Tue Apr 30 21:02:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10924195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1BE1912 for ; Tue, 30 Apr 2019 21:04:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3B1D1FE6B for ; Tue, 30 Apr 2019 21:04:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79E728A56; Tue, 30 Apr 2019 21:04:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3AB7028A3E for ; Tue, 30 Apr 2019 21:04:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu2-0007jQ-CF; Tue, 30 Apr 2019 21:03:02 +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 1hLZu0-0007gU-Hu for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:03:00 +0000 X-Inumbo-ID: 55718702-6b8b-11e9-b7b5-1b0fe93ad1c4 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 55718702-6b8b-11e9-b7b5-1b0fe93ad1c4; Tue, 30 Apr 2019 21:02:59 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 885C221743; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658178; bh=8/4xOiePn9z3SrdryWW11nW/8QK/e4NhxngmXpkEtp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=avpozdf3Ngal5mDVzPmkEKGD688CCc4+nB9sUCCwvVTsrgPmVJFOc1/ohSqpRZwQ0 Zim42WWomCH++3IrHtxT2xFacA7aC1/XFQSx3k0P4iOkP/WuSzLxvuc1EoxjG0wiuP gfVg5Sonhqafmj1avTl6/7SHL3ipzq2Vf4KX2m8U= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:51 -0700 Message-Id: <1556658172-8824-9-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 09/10] xen/arm: map reserved-memory regions as normal memory in dom0 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 , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP reserved-memory regions should be mapped as normal memory. At the moment, they get remapped as device memory in dom0 because Xen doesn't know any better. Add an explicit check for it. reserved-memory regions overlap with memory nodes. The overlapping memory is reserved-memory and should be handled accordingly: consider_modules and dt_unreserved_regions should skip these regions the same way they are already skipping mem-reserve regions. Signed-off-by: Stefano Stabellini --- Changes in v2: - fix commit message: full overlap - remove check_reserved_memory - extend consider_modules and dt_unreserved_regions --- xen/arch/arm/domain_build.c | 7 +++++++ xen/arch/arm/setup.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 5e7f94c..e5d488d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1408,6 +1408,13 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, "WARNING: Path %s is reserved, skip the node as we may re-use the path.\n", path); + /* + * reserved-memory ranges should be mapped as normal memory in the + * p2m. + */ + if ( !strcmp(dt_node_name(node), "reserved-memory") ) + p2mt = p2m_mmio_direct_c; + res = handle_device(d, node, p2mt); if ( res) return res; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ccb0f18..908b52c 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -204,6 +204,19 @@ void __init dt_unreserved_regions(paddr_t s, paddr_t e, } } + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s = bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i+1); + dt_unreserved_regions(s, r_s, cb, i+1); + return; + } + } + cb(s, e); } @@ -390,7 +403,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, { const struct bootmodules *mi = &bootinfo.modules; int i; - int nr_rsvd; + int nr; s = (s+align-1) & ~(align-1); e = e & ~(align-1); @@ -416,9 +429,9 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, /* Now check any fdt reserved areas. */ - nr_rsvd = fdt_num_mem_rsv(device_tree_flattened); + nr = fdt_num_mem_rsv(device_tree_flattened); - for ( ; i < mi->nr_mods + nr_rsvd; i++ ) + for ( ; i < mi->nr_mods + nr; i++ ) { paddr_t mod_s, mod_e; @@ -440,6 +453,23 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, return consider_modules(s, mod_s, size, align, i+1); } } + + /* Now check for reserved-memory regions */ + nr += mi->nr_mods; + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s = bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + r_e = consider_modules(r_e, e, size, align, i+1); + if ( r_e ) + return r_e; + + return consider_modules(s, r_s, size, align, i+1); + } + } return e; } #endif