From patchwork Wed Jul 15 16:25:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 51130 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78FE120300 for ; Wed, 15 Jul 2015 16:27:41 +0000 (UTC) Received: by lafd3 with SMTP id d3sf12083807laf.1 for ; Wed, 15 Jul 2015 09:27:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=GJJKt4yocfhemMenr7dlWjegWHvxIf1riGxHLHTaSsw=; b=jEchW5FPGEYu7dhAhT6NJHrrOaVU7oZhLvnB6DaMvfkR5Nb4hulR9Dxpwz6uueDfVq iRXVKPK48btPa95WXGxTuJWGrvu5WWj+7JPK9rEcYlrLOJLlG3cqlD7Bjf/7TTEc0AEM PqXosGg3MLgq6Si2zFuTCTuJPiOnVFr2rVrCTFJpsSznLACP7m1LyKcl8Y6fIaIBEx/E ILyJw6/HNISEy95qO8DYMi7vOW8pE3gRwbJdLPEPUtp5qTcigaPtOiInks+sCgNNIKfk SAp7KHghHatZsXyG4azWixDRcmi8xct4DjCvBy98Ro9azhWdQuiUdoyrza4B475eeKHt kthg== X-Gm-Message-State: ALoCoQn9GEBlhG/zKJHnopEFCoMi4u4yanCoxolyoeK2HmrJpQnAlgEzGFyZK9anWMm0RWInboRQ X-Received: by 10.112.148.101 with SMTP id tr5mr2488869lbb.13.1436977660413; Wed, 15 Jul 2015 09:27:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.105 with SMTP id lv9ls223711lac.66.gmail; Wed, 15 Jul 2015 09:27:40 -0700 (PDT) X-Received: by 10.112.126.42 with SMTP id mv10mr5165297lbb.58.1436977660273; Wed, 15 Jul 2015 09:27:40 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id mr8si4432515lbb.104.2015.07.15.09.27.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 09:27:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lblf12 with SMTP id f12so28211581lbl.2 for ; Wed, 15 Jul 2015 09:27:40 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr5168240lbb.56.1436977660135; Wed, 15 Jul 2015 09:27:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3201191lbb; Wed, 15 Jul 2015 09:27:39 -0700 (PDT) X-Received: by 10.194.235.169 with SMTP id un9mr9845395wjc.136.1436977659376; Wed, 15 Jul 2015 09:27:39 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id ek3si565368wid.100.2015.07.15.09.27.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 Jul 2015 09:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:36682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFPX0-0001WS-0w for patch@linaro.org; Wed, 15 Jul 2015 12:27:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFPVQ-0007tU-RE for qemu-devel@nongnu.org; Wed, 15 Jul 2015 12:26:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFPVP-0002oj-LX for qemu-devel@nongnu.org; Wed, 15 Jul 2015 12:26:00 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFPVP-0002lZ-2S for qemu-devel@nongnu.org; Wed, 15 Jul 2015 12:25:59 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZFPVG-00084E-MQ for qemu-devel@nongnu.org; Wed, 15 Jul 2015 17:25:50 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 15 Jul 2015 17:25:50 +0100 Message-Id: <1436977550-30977-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1436977550-30977-1-git-send-email-peter.maydell@linaro.org> References: <1436977550-30977-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 2/2] 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alexander Graf 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. We leave the existing 4k alignment for 32bit kernels to not cause any regressions due to space constraints. Reported-by: Andreas Schwab Signed-off-by: Alexander Graf Signed-off-by: Peter Maydell --- hw/arm/boot.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index f48ed2d..5b969cd 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -735,12 +735,28 @@ 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. - */ - hwaddr dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, - 4096); + hwaddr align; + hwaddr dtb_start; + + if (elf_machine == EM_AARCH64) { + /* + * Some AArch64 kernels on early bootup map the fdt region as + * + * [ ALIGN_DOWN(fdt, 2MB) ... ALIGN_DOWN(fdt, 2MB) + 2MB ] + * + * Let's play safe and prealign it to 2MB to give us some space. + */ + align = 2 * 1024 * 1024; + } else { + /* + * Some 32bit kernels will trash anything in the 4K page the + * initrd ends in, so make sure the DTB isn't caught up in that. + */ + align = 4096; + } + + /* Place the DTB after the initrd in memory with alignment. */ + dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, align); if (load_dtb(dtb_start, info, 0) < 0) { exit(1); }