Received: by 2002:a5d:51d0:0:0:0:0:0 with SMTP id n16csp7100364wrv; Mon, 22 Jul 2019 09:52:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+hoDxEAhoilQerr/BwvjecX4wEYC4Vrit6jpzOhxEzheDvqb7rbnOEmQ7eMEhpHDV8uh+ X-Received: by 2002:a1f:3c82:: with SMTP id j124mr25960251vka.47.1563814343286; Mon, 22 Jul 2019 09:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563814343; cv=none; d=google.com; s=arc-20160816; b=eAFW5JMhd2o411WJZ/oRJ74T56l7tkxWe1L0Si4D7B6pAp6eeNiI/yDrBPpOCn8nad AH4DRX0i5YSEjkS601i/IUrlibdnuRwxfDaPsyxm53DTm0nNQt1U7bVsVFtJZEYuco3E 0eHzQuctrl71eEx2NP7ftQPhlOZKId3/dMuyVpspiHHSeTwXDwQ8P3I3D83JEeB8+1AJ GnCrkgx+Q8AwObTSoL3QLS613ZyiellOI67kCqGwlvG7hINbE3q2+JQONY3dsRbHn//7 BTeYUSO0UmAgdTpO+T2uq9WXIkZ2UdKEU65wI0dXtegGyjnf/I8k7G6SZSLrgfrBajMN 6XeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:to:from:date; bh=sIFUH8/MtmQN8FiQU9rKLdGDeEOpUF2rqObC8PV34ks=; b=P69UIzlF0RO5hDB8hgRfBAeoEwpwVJgBkxKeKFTMBhUPBRp5nQMlbtFX/GeJ7DP1N/ NXRTYc32eO6g1rpboTiBpjrqHg3OVsNW0cktqC49ZhL+9YvlZHP19gPGPuqMsy4k+z5I Y4CVLLNKO3FgjzLIzORVJ0oHbZO1H49kxIzXAByLXU50H1Gp+6+E2G3/xnMUC3rnHU1L lw34ma+C7vUeW3JlE11FEr4xASm26X/8/F56sVRttl8nkAxi+faTcWe7wZ9N7voy9brZ M7HjCrIKh2dB7EPuzRcRPHbD66kWck9qozerqFz0/bvn1lkPMRmHwxmGMX/+q0XTwJ+S nabw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v21si9932668vsv.77.2019.07.22.09.52.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 09:52:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1]:35988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpbXy-0004e6-S8 for alex.bennee@linaro.org; Mon, 22 Jul 2019 12:52:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42744) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpbXu-0004dt-WF for qemu-arm@nongnu.org; Mon, 22 Jul 2019 12:52:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpbXt-00078v-U8 for qemu-arm@nongnu.org; Mon, 22 Jul 2019 12:52:18 -0400 Received: from foss.arm.com ([217.140.110.172]:40696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hpbXt-000782-Of; Mon, 22 Jul 2019 12:52:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7FE0F1509; Mon, 22 Jul 2019 09:52:16 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C8FBC3F694; Mon, 22 Jul 2019 09:52:15 -0700 (PDT) Date: Mon, 22 Jul 2019 17:52:08 +0100 From: Mark Rutland To: Peter Maydell Message-ID: <20190722165208.GA6261@lakrids.cambridge.arm.com> References: <20190722151804.25467-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190722151804.25467-1-peter.maydell@linaro.org> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.140.110.172 Subject: Re: [Qemu-arm] [PATCH for-4.1? 0/2] arm: further improve initrd positioning X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: WXFltJ7Gotn4 Hi Peter, On Mon, Jul 22, 2019 at 04:18:02PM +0100, Peter Maydell wrote: > In commit e6b2b20d9735d4ef we made the boot loader code try to avoid > putting the initrd on top of the kernel. However the expression used > to calculate the start of the initrd: > > info->initrd_start = info->loader_start + > MAX(MIN(info->ram_size / 2, 128 * 1024 * 1024), kernel_size); > > incorrectly uses 'kernel_size' as the offset within RAM of the > highest address to avoid. This is incorrect because the kernel > doesn't start at address 0, but slightly higher than that. This > means that we can still incorrectly end up overlaying the initrd on > the kernel in some cases, for example: > > * The kernel's image_size is 0x0a7a8000 > * The kernel was loaded at 0x40080000 > * The end of the kernel is 0x4A828000 > * The DTB was loaded at 0x4a800000 > > To get this right we need to track the actual highest address used > by the kernel and use that rather than kernel_size. We already > trace the low_addr and high_addr for ELF images; set them > also for the various other image types we support, and then use > high_addr as the lowest allowed address for the initrd. > > Patch 1 just does a preliminary variable rename; patch 2 is the meat. > > Only very lightly tested... FWIW, I've given this a spin, and it manages to boot my growing collection of problematic images, along with all the previously-working images I had lying around. For both patches, feel free to take that as: Tested-by: Mark Rutland > Marked as 'maybe for 4.1' because it is a bug fix and to code which > is new in 4.1. OTOH cases that fail now would have failed with 4.0 > so it is not a regression strictly speaking. And we're getting > steadily closer to release and I haven't very heavily tested this > patch. I incline towards including it, overall. Having these in 4.1 would be nice. AIUI the logic is correct, and this seems low risk to me, but it is your call. If you decide to hold off for a release, I can apply these patches locally without too much pain. Thanks for dealing with this, anyhow! Mark. > > thanks > -- PMM > > Peter Maydell (2): > hw/arm/boot: Rename elf_{low,high}_addr to image_{low,high}_addr > hw/arm/boot: Further improve initrd positioning code > > hw/arm/boot.c | 37 +++++++++++++++++++++++++++---------- > 1 file changed, 27 insertions(+), 10 deletions(-) > > -- > 2.20.1 >