From patchwork Thu Jan 24 19:02:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 14279 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2AF5F23E57 for ; Thu, 24 Jan 2013 19:02:35 +0000 (UTC) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by fiordland.canonical.com (Postfix) with ESMTP id 3687FA18ABE for ; Thu, 24 Jan 2013 19:02:34 +0000 (UTC) Received: by mail-vc0-f170.google.com with SMTP id p16so1654093vcq.15 for ; Thu, 24 Jan 2013 11:02:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=8ac9ZN6xtP+bTOln2BB8IF24rB2OsU+pND/bTTWAj7w=; b=XEHpEc+Y19CatMvWniXYaTswxJxWMXbDbY/aw/TZKMD6Qy9V5CGi0lrmaH83Eg9X22 SVf8OlO+YphouC6qHJ8mgkPCmnkeG5Kr2wpk3UVOYlzrKYEuIYzN3JccTyEJXEZLWA1r TSk6tXd1bjL8vL61uuE+gW8+lbBCJqtqu6iZ4QXNSZp2bLwo6hP3vBx+6mA/XYTBluvU /Qyk8NIDP7tcmmj1smYKOoQVscAcOBaryVXeuHcnWlmlLkLtX8KOeNffhM/toIJsYEo0 om1vyOjayW1vMj1x/UJD+8QEyDTzs5VDR7Y6WOMb7RfJi81esiIHxalnC8olC4HTZ1zz Ruqw== X-Received: by 10.52.176.6 with SMTP id ce6mr2764814vdc.57.1359054153631; Thu, 24 Jan 2013 11:02:33 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp81122veb; Thu, 24 Jan 2013 11:02:32 -0800 (PST) X-Received: by 10.194.108.229 with SMTP id hn5mr5093845wjb.8.1359054151381; Thu, 24 Jan 2013 11:02:31 -0800 (PST) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id uz4si9026128wjc.251.2013.01.24.11.02.30 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 11:02:31 -0800 (PST) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1TyS4C-00036D-I6; Thu, 24 Jan 2013 19:02:28 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Grant Likely , Alexander Graf Subject: [PATCH for-1.4] hw/arm_boot: Align device tree to 4KB boundary, not page Date: Thu, 24 Jan 2013 19:02:28 +0000 Message-Id: <1359054148-11890-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQm3ZhBpD8a4ozPgknjdpOhk4ISiXHxH3JRsh6gxQrvFxAIX3Qm9nGlS3ZGS6MBxVtIy3cmt Align the device tree blob to a 4KB boundary, not to QEMU's idea of a page boundary -- the latter is the smallest possible page size for the architecture, which on ARM is 1KB. The documentation for Linux does not impose separation or alignment requirements on the device tree blob, but in practice some kernels will happily trash the entire page the initrd ends in after they have finished uncompressing the initrd. So 4KB-align the DTB to ensure it does not get trampled by these kernels. Signed-off-by: Peter Maydell --- For 1.4 because this causes us problems booting 3.8 kernels with dtb, and the symptoms are highly confusing. I think this is a kernel bug, but it is one that is worth working around. In general I think code in hw/ that looks at TARGET_PAGE_* is probably a bit suspect... hw/arm_boot.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 115f583..4065424 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -441,9 +441,12 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) * we point to the kernel args. */ if (info->dtb_filename) { - /* Place the DTB after the initrd in memory */ - hwaddr dtb_start = TARGET_PAGE_ALIGN(info->initrd_start + - initrd_size); + /* 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); if (load_dtb(dtb_start, info)) { exit(1); }