From nobody Thu Dec 18 19:38:10 2025 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=1560783829; cv=none; d=zoho.com; s=zohoarc; b=dDWW+RmeivMRWnVqi2L8dDBOFEV6r1K0BbWcrkwclYjH4YD+N7fm4RVg8Hu7jnGaEzT6tmAn3BANSsdp2SUgN/JW0BSsPLeuOJ0Ax2o5s5r9wfcyo8Q6bf9xbtAhPmj5VvhZqcekQ05u8jopscEAk5HRcpH10cxmq6ikZ4NQYiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560783829; h=Content-Type:Content-Transfer-Encoding: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=s25YCdPicJAtgC6ByMpACHrwGTStXvqFM1wqHAvS9fE=; b=m0Z7ytiYIR3TYQNMeOXuq33sM4AzOIZitmZMXdWU7ekD8Fj+QI3XxSBmek6KmkAAEuYXijyhzAjgQqKwPONflZAVGzOkK+joMjzFp/21PkFnrmkQbyz/5/Npgd7UZy+2zauH9nA8/LPH3qXEkc09NUV4QnvcU05JXbC1xBbqLxk= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560783829148401.43216311379126; Mon, 17 Jun 2019 08:03:49 -0700 (PDT) Received: from localhost ([::1]:48278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hctAX-0004nl-8u for importer@patchew.org; Mon, 17 Jun 2019 11:03:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46568) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcsiF-0003R4-EU for qemu-devel@nongnu.org; Mon, 17 Jun 2019 10:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcsiE-0007zi-8i for qemu-devel@nongnu.org; Mon, 17 Jun 2019 10:34:23 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hcsiE-0007wG-0L for qemu-devel@nongnu.org; Mon, 17 Jun 2019 10:34:22 -0400 Received: by mail-wr1-x442.google.com with SMTP id p13so10198541wru.10 for ; Mon, 17 Jun 2019 07:34:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a67sm13819985wmh.40.2019.06.17.07.34.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 07:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=s25YCdPicJAtgC6ByMpACHrwGTStXvqFM1wqHAvS9fE=; b=XCTIXWwFCofzeErDP/aCakt2vmm0Nm/6r1EQm0FF5qMDyRU+yfQ9EF69LipCRhk7u2 B8N8j0b8k2Cx50BEjiqdl3hlHEHVPFB1Gqked+jpX4WKFoAUB/6jyQWvZ6nT4bGD/wKq 8wJWQ3CwhtPqHljI6dj+EmFGL9cK1hlKvwJUUEPBnTM43B6K4TSM5LLvOdJgI63J8O0M Po8g6eLthjS6Oja93nGPcASM9pgYlZlrUJomhcr5fn3XqyaALKuBj8OmTpjitZ0i8ct1 tGQpTInzCl0Jm4qlLynHUfGQaCnTcjBI1UpChHsFDuMNlhx4Jsf5pr4hR1HEqeWI+H6D o8aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s25YCdPicJAtgC6ByMpACHrwGTStXvqFM1wqHAvS9fE=; b=cSXOIRIl1s1IxqgmPjYjI42QGpVHWTevRZHhmm03zaRy01AqHHkOPUV+SnOA1rVCqI MpA2hVqg7R842sFLkDOpMugab7kM9Pcztj0y18FSBgUZ1zhYgrHV2PgDPgrohFls1te/ b4J++kK6ZynQCJjI7OnTrnGhRl9LpbYb/gz6dce6CdBhi69EApiM6ElNS/lUoOgzsA5E FeKWKMM6011FS6sWAEWz01RZ3ztSjXrOz8z0c118lF3R1bKipsg6AEBpvqpWKvafLd6q cb+aMHJ/nGlpOUlFs8eLcu3RNdNEfwAjgjtkdHwC2QW/fKwofJtd23vy9DaQ1KG4pbDP ZvzA== X-Gm-Message-State: APjAAAVLC8iHdyaTLkJo8wUPCF3/s85lXQkgLP1FfJBpCnSZcpKLKFYh 5CTLdfdE5Hzv1N5bR12ZQRVItmM+Lpdbgw== X-Google-Smtp-Source: APXvYqzqCBHfdrOW3toIIUri6HNQywZX52l2TvDNdj/UEjaQFCGWUSpdJawPqxbbyWB3oj0oBArx4g== X-Received: by 2002:adf:eecf:: with SMTP id a15mr3091759wrp.354.1560782055545; Mon, 17 Jun 2019 07:34:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 15:33:49 +0100 Message-Id: <20190617143412.5734-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617143412.5734-1-peter.maydell@linaro.org> References: <20190617143412.5734-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::442 Subject: [Qemu-devel] [PULL 01/24] hw/arm/boot: Don't assume RAM starts at address zero X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Tested-by: Mark Rutland Message-id: 20190516144733.32399-2-peter.maydell@linaro.org --- 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 0261fdabab0..bb37a9383f3 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -977,6 +977,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; @@ -1048,8 +1049,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) { @@ -1063,12 +1063,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