From nobody Mon Feb 9 20:34:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558018190; cv=none; d=zoho.com; s=zohoarc; b=eHpwy1ttneFG9QJ4ARmG0a7IUIHMHMcnF4cq7qBma9qrMX5UoRo6y9x1KODrQwVUr52vrAOCvdaCvjenWJuzfBceZ9cxhjM3uGp4raDK2jMsviskTN4X+MkJJsdJHptT+rhby+tjRepfITTaMfBvAlK97tsbKZREwMw2LQLe3ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558018190; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZzmBM+wcCb9270VyvJ51TIpyGicjAazonG2iWSjoQgc=; b=WX29oQn0JD6PIF9cJ89+uE1x1yaSEOX+GgTJV49cA9FKdP0+y3bsouje0lHk1R5OPhhH9Qmin0QXNFfmrmHMyIOqWxCknDigwW0IedXveFc0QNC2KKPrpv4YzmMKemf6ExaPVTn7onPeEs5X/WibS19yBSz3OJ5p9pokYOcgFGA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155801819059359.92160313896443; Thu, 16 May 2019 07:49:50 -0700 (PDT) Received: from localhost ([127.0.0.1]:59417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRHhU-0003XY-Dd for importer@patchew.org; Thu, 16 May 2019 10:49:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRHfX-0002Za-6W for qemu-devel@nongnu.org; Thu, 16 May 2019 10:47:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRHfW-0008E8-0G for qemu-devel@nongnu.org; Thu, 16 May 2019 10:47:38 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36333) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRHfV-0008D3-Pm for qemu-devel@nongnu.org; Thu, 16 May 2019 10:47:37 -0400 Received: by mail-wr1-x444.google.com with SMTP id s17so3759008wru.3 for ; Thu, 16 May 2019 07:47:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o8sm7629018wra.4.2019.05.16.07.47.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 07:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZzmBM+wcCb9270VyvJ51TIpyGicjAazonG2iWSjoQgc=; b=dFH3g7apCsFiSnQ2IZ2+IxFvBA512Pz9PeYAWM4u3CIt80+JQzjym49JE2DGBwhMtN BoI4Zt7gWyn2jKFh2AapYyYPsqIU+HRUR8PpHaZf+wIwbb357YNddL1MZ3cMTmZDDrsy dgFdwil6BkvO6u/ksdDsqY7A+IN+97kYRrajt88UTMolwNa05NEZiiO1W3+DYp6fxcT6 381b7K6K6XIi2g1chgiONKrCU3zzO4Ux47rmSubsnh6JIkC8tQm41idgbTz27KONAq3x zyI/HSzB/oZxWlwq6KKRdNcwCBZbuTBhEAzgDtSFKAGsVZhctaqneKCnnLGya+ojIjgJ kM7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZzmBM+wcCb9270VyvJ51TIpyGicjAazonG2iWSjoQgc=; b=sDa2noDmsRZwHFmIJRd3EF2Q6jsSXU35IUjVMJUX66e8oGnN/7tm55IetVaaDcLyQU 3X8MPD5GRXhf0YJBwO45MsVDMPrya+ESfAZLKTywXeIDJ+4WJGLOYFwOv9phKbYc8DUW JUW4ok42jbXzu6qPqTyd/cxCg1SRUBQR5DnBzNYr99wOQCwUcPHSHxJy+qSqqJYoP1MZ C19xqNEhGzXkzBFefOwVfeZcPKjPz7SlLGXMM2fmIKtMsV8lvmgdoSpjZXfzSmGFl3i0 PcMTPtyayiF9LOzEh6bGlIhFMPVg4J8njW8+s94Ci3beE132vBr9vTTsBNwQbrN9gXFZ FViw== X-Gm-Message-State: APjAAAVqGaZVznndXIlkACuzJMQtIQEaXpv/AvKHddzEbXLcyXVr8rkF nmrr29Z/YDo3RKWI/viZW27AHA== X-Google-Smtp-Source: APXvYqyno3abO5WDcjRoEUpjErfabNhvEQ3prajEnTi2vpSofbX3VL+6PmCuiJvISI6uXiX5DPLabA== X-Received: by 2002:adf:c188:: with SMTP id x8mr20036758wre.256.1558018056982; Thu, 16 May 2019 07:47:36 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Thu, 16 May 2019 15:47:30 +0100 Message-Id: <20190516144733.32399-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190516144733.32399-1-peter.maydell@linaro.org> References: <20190516144733.32399-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v2 1/4] hw/arm/boot: Don't assume RAM starts at address zero X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In the Arm kernel/initrd loading code, in some places we make the incorrect assumption that info->ram_size can be treated as the address of the end of RAM, as for instance when we calculate the available space for the initrd using "info->ram_size - info->initrd_start". This is wrong, because many Arm boards (including "virt") specify a non-zero info->loader_start to indicate that their RAM area starts at a non-zero physical address. Correct the places which make this incorrect assumption. Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e --- hw/arm/boot.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index a830655e1af..0bb9a7d5b5c 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -976,6 +976,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, int elf_machine; hwaddr entry; static const ARMInsnFixup *primary_loader; + uint64_t ram_end =3D info->loader_start + info->ram_size; =20 if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { primary_loader =3D bootloader_aarch64; @@ -1047,8 +1048,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, /* 32-bit ARM */ entry =3D info->loader_start + KERNEL_LOAD_ADDR; kernel_size =3D load_image_targphys_as(info->kernel_filename, entr= y, - info->ram_size - KERNEL_LOAD_= ADDR, - as); + ram_end - KERNEL_LOAD_ADDR, a= s); is_linux =3D 1; } if (kernel_size < 0) { @@ -1062,12 +1062,11 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cp= u, if (info->initrd_filename) { initrd_size =3D load_ramdisk_as(info->initrd_filename, info->initrd_start, - info->ram_size - info->initrd_st= art, - as); + ram_end - info->initrd_start, as= ); if (initrd_size < 0) { initrd_size =3D load_image_targphys_as(info->initrd_filena= me, info->initrd_start, - info->ram_size - + ram_end - info->initrd_start, as); } --=20 2.20.1