From patchwork Mon Jun 17 14:33:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 167060 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2977392ilk; Mon, 17 Jun 2019 08:05:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyprHJ816KPRpo/qKL3NCUsAmIqwpxbhx5nDK3XPlT1pWDfcMo5PWdfRT4z8uvhxwXR5xwx X-Received: by 2002:a5d:4b12:: with SMTP id v18mr11979317wrq.123.1560783943739; Mon, 17 Jun 2019 08:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560783943; cv=none; d=google.com; s=arc-20160816; b=d4Pwvo9JPb6AawaTuScgqwm/q2r5EC+/jhkB/v4s0EvLWdMIQZ9795KPPoTkgrzRfX Z4TuDSTGcxwlWzotZj/WBCMD8GsNMHmfZsdqmsfnPDYQpq6wtUdpb8OB/NIG9BB4lG9Q QpeWtNOPVRBSi6qFau2a76W9IRRxMbq5a4qi1b+ZJZRMk69X6UfIaQZlfu3CHoO/aXZa jCnyMptB9cqRvGnZYEK6II1k6i9v6430gmU7M7ufk+DwL8CGOei/IRKxkkLEOPOBa90O K8AY+8aQHDkUu+GkpzLx4Hdr42xG0CX7mwmJJ6lG4Yre9sKFWTn9WhZ2uUm5z/nZhnX3 EPJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=s25YCdPicJAtgC6ByMpACHrwGTStXvqFM1wqHAvS9fE=; b=Amn5tgmSPutQeMXmUTdqFzwTr/KGeOxOWR2ZrL8icjVu3oW87QmDHcKR3pqROfcuZK IEwTLnZbZ75fiaP6PPyT3SQxU0iYVoaPYSfCKkbEDpAQSJF6qqFOHAPtN7e/jgPKFaEp slJhGbfngCSkl9CU6jutNPX3PPu0nH6haMxQa7FzdOxNMzTnD8LmUhRusWOu1uBfH7fw HIx4AvSq8NCBXvVYzNuSmdbOwinvJ7SOo2Y1Qoi0SscoCh9/SKP7TXbz1rOSML+XnOIp xGIPqEBIJe2gY0NqepaQjZM7pMuYDLSTvgArFWSxXDA/Nn/Yfubive4v0ovbFwB2XyMA Fodw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XCTIXWwF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m3si7123770ejb.288.2019.06.17.08.05.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Jun 2019 08:05:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XCTIXWwF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hctCY-0007Eo-Eb for patch@linaro.org; Mon, 17 Jun 2019 11:05:42 -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) 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-Received: by 2002:adf:eecf:: with SMTP id a15mr3091759wrp.354.1560782055545; Mon, 17 Jun 2019 07:34:15 -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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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(-) -- 2.20.1 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 = info->loader_start + info->ram_size; if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { primary_loader = bootloader_aarch64; @@ -1048,8 +1049,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, /* 32-bit ARM */ entry = info->loader_start + KERNEL_LOAD_ADDR; kernel_size = load_image_targphys_as(info->kernel_filename, entry, - info->ram_size - KERNEL_LOAD_ADDR, - as); + ram_end - KERNEL_LOAD_ADDR, as); is_linux = 1; } if (kernel_size < 0) { @@ -1063,12 +1063,11 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, if (info->initrd_filename) { initrd_size = load_ramdisk_as(info->initrd_filename, info->initrd_start, - info->ram_size - info->initrd_start, - as); + ram_end - info->initrd_start, as); if (initrd_size < 0) { initrd_size = load_image_targphys_as(info->initrd_filename, info->initrd_start, - info->ram_size - + ram_end - info->initrd_start, as); }