[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen/arm: add warning if memory modules overlap


  • To: Julien Grall <julien.grall@xxxxxxx>
  • From: Brian Woods <brian.woods@xxxxxxxxxx>
  • Date: Fri, 11 Oct 2019 09:43:26 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=epam.com smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X3FOJxpxFyPs6qs80DOE2Kj0KYM4kPO0SVkruifjanc=; b=hqzMHdQ/0Rtr3h+Xr5oGVJdhMe7U4WbI1+uWCgQ7dkY9W/MeVBVBxaFSLyvs8LhXAjNSfegQ4k/oHWUVf7jjLdK7QnOqsjDunlvBnjtfMUdav2KoTqh5Dqn6MTURvUpSlz0bgcjTpSDqY+s3WyR6LUuMmyYjgyOa9SFYlJrrdMdE0Cc+7IaywM4e/Q1jzDRVIA/yoLbsyQt5FK/xjGxgXXojuCIiAx3TwHbDZxwIqGhm+lITNQQsLLPoeWdkdD/pm3wT/t289ew1j+yBCOWK+YEWs6QfAGlE5yY7hYClBx4P+kRVfu4fcLEru11CiMnoDWPQC2HxsOse3sIrd+AScQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hIJdcKazWjxieYgjxFLtJbkWwnwrPvcB0VurILLiHfu+36Z8ujeFKakS9qPsyKNmCuQ8J7FS6ljeQBolCbM/Aq34OGBoIIIF4GYiGur5F4VK2WYAvypbAmVnnIPeRNyQ1gkJWL/IxmRPlonF5OeAGsC8m/KTTGx2bbH/gnHh49UjYupKGtwFX6oJCzEWrSEOM4UVHPGK6eMLn91j9fb8zCN63NGJ24BZ1GGnJn1CNLBJXHu6ZRQVbDclSGsbhIteNagW19RQS4q+eVOZmGjbEVohUS0DZ68xa8rVbTYy/snRPK6rT9wq3ZOoWVrYIoYue38uy77C2U7TXWaF2IthkA==
  • Authentication-results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; epam.com; dkim=none (message not signed) header.d=none;epam.com; dmarc=bestguesspass action=none header.from=xilinx.com;
  • Cc: Brian Woods <brian.woods@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 11 Oct 2019 16:43:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Oct 10, 2019 at 04:39:07PM +0100, Julien Grall wrote:
> Hi Brian,
> 
> Thank you for the patch.
> 
> On 10/9/19 8:47 PM, Brian Woods wrote:
> >It's possible for a misconfigured device tree to cause Xen to crash when
> >there are overlapping addresses in the memory modules.  Add a warning
> >when printing the addresses to let the user know there's a possible
> >issue when DEBUG is enabled.
> >
> >Signed-off-by: Brian Woods <brian.woods@xxxxxxxxxx>
> >---
> >sample output:
> >...
> >(XEN) MODULE[0]: 0000000001400000 - 000000000153b8f1 Xen
> >(XEN) MODULE[1]: 00000000076d2000 - 00000000076dc080 Device Tree
> >(XEN) MODULE[2]: 00000000076df000 - 0000000007fff364 Ramdisk
> >(XEN) MODULE[3]: 0000000000080000 - 0000000003180000 Kernel
> >(XEN)  RESVD[0]: 00000000076d2000 - 00000000076dc000
> >(XEN)  RESVD[1]: 00000000076df000 - 0000000007fff364
> >(XEN)
> >(XEN) WARNING: modules Xen          and Kernel       overlap
> >(XEN)
> >(XEN) Command line: console=dtuart dtuart=serial0 dom0_mem=1G bootscrub=0 
> >maxcpus=1 timer_slop=0
> >...
> >
> >  xen/arch/arm/bootfdt.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> >diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> >index 08fb59f..3cb0c43 100644
> >--- a/xen/arch/arm/bootfdt.c
> >+++ b/xen/arch/arm/bootfdt.c
> >@@ -387,6 +387,23 @@ static void __init early_print_info(void)
> >                 mem_resv->bank[j].start + mem_resv->bank[j].size - 1);
> >      }
> >      printk("\n");
> >+
> >+#ifndef NDEBUG
> >+    /*
> >+     * Assuming all combinations are checked, only the starting address
> >+     * has to be checked if it's in another memory module's range.
> >+     */
> >+    for ( i = 0 ; i < mods->nr_mods; i++ )
> >+        for ( j = 0 ; j < mods->nr_mods; j++ )
> >+            if ( (i != j) &&
> >+                 (mods->module[i].start >= mods->module[j].start) &&
> >+                 (mods->module[i].start <
> >+                  mods->module[j].start + mods->module[j].size) )
> >+                printk("WARNING: modules %-12s and %-12s overlap\n",
> >+                       boot_module_kind_as_string(mods->module[i].kind),
> >+                       boot_module_kind_as_string(mods->module[j].kind));
> 
> I am not entirely happy with the double for-loop here.
> 
> As we already go through all the modules in add_boot_module(). Could you
> look whether this check could be part of it?
> 
> This should also allow to have this check for non-debug build as well.
> 
> Cheers,
> 
> -- 
> Julien Grall

To make sure the module is going to get added, you'd need to do the
check after the for loop.  This means there's going to be multiple for
loops just spread over the course of adding the boot modules rather than
one place.

I had this before but decided against it but after changing it to both
starts rather than the stand and end (ends look much uglier), it looks
cleaner.

    for ( i = 0 ; i < mods->nr_mods-1; i++ )
        for ( j = i+1 ; j < mods->nr_mods; j++ )
            if ( ((mods->module[i].start >= mods->module[j].start) &&
                  (mods->module[i].start <=
                   mods->module[j].start + mods->module[j].size)) ||
                 ((mods->module[j].start >= mods->module[i].start) &&
                  (mods->module[j].start <=
                   mods->module[i].start + mods->module[i].size)) )
                printk("WARNING: modules %-12s and %-12s overlap\n",
                       boot_module_kind_as_string(mods->module[i].kind),
                       boot_module_kind_as_string(mods->module[j].kind));

That's also a possibility.

I just don't see a way around it, computationally.  You can split where
the loops are executed but in the end the same amount of checks/total
iterations have to be run.

I was talking to someone and he suggested you could just check Xen at
early boot and then check other modules later.

-- 
Brian Woods

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.