From patchwork Mon Jul 13 15:56:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 494639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 07D761402DE for ; Tue, 14 Jul 2015 01:57:08 +1000 (AEST) Received: from localhost ([::1]:55479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEg6L-000339-Ug for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2015 11:57:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEg5z-0002WH-KU for qemu-devel@nongnu.org; Mon, 13 Jul 2015 11:56:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEg5u-0001gj-LX for qemu-devel@nongnu.org; Mon, 13 Jul 2015 11:56:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47073 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEg5u-0001g8-FH for qemu-devel@nongnu.org; Mon, 13 Jul 2015 11:56:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C421AAAF2; Mon, 13 Jul 2015 15:56:37 +0000 (UTC) From: Alexander Graf To: qemu-devel@nongnu.org Date: Mon, 13 Jul 2015 17:56:37 +0200 Message-Id: <1436802997-170244-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.12.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH 2.4] hw/arm/boot: Increase fdt alignment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The Linux kernel on aarch64 creates a page table entry at early bootup that spans the 2MB range on memory spanning the fdt start address: [ ALIGN_DOWN(fdt, 2MB) ... ALIGN_DOWN(fdt, 2MB) + 2MB ] This means that when our current 4k alignment happens to fall at the end of the aligned region, Linux tries to access memory that is not mapped. The easy fix is to instead increase the alignment to 2MB, making Linux's logic always succeed. Reported-by: Andreas Schwab Signed-off-by: Alexander Graf --- hw/arm/boot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index f48ed2d..7594d7a 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -735,12 +735,12 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) * we point to the kernel args. */ if (have_dtb(info)) { - /* Place the DTB after the initrd in memory. Note that some - * kernels will trash anything in the 4K page the initrd - * ends in, so make sure the DTB isn't caught up in that. + /* Place the DTB after the initrd in memory. Note that the kernel + * maps [ ALIGN_DOWN(fdt, 2MB) ... ALGIN_DOWN(fdt, 2MB) + 2MB ] + * and thus needs the fdt be preferably in its own 2MB window. */ hwaddr dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, - 4096); + 2 * 1024 * 1024); if (load_dtb(dtb_start, info, 0) < 0) { exit(1); }