Skip to contentSkip to conversation

arm: dtb: Align dtb to 64K because some kernels use 64K page size.

PATCH In review Richard W.M. Jones 2 participants 2 messages Dec 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: dtb: Align dtb to 64K because some kernels use 64K page size.

Resolves: https://bugs.launchpad.net/qemu/+bug/1383857

---
 hw/arm/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/boot.c +2 -2
index 0014c34..a859922 100644
@@ -632,11 +632,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
          */
         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
+             * kernels will trash anything in the 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);
+                                             65536);
             if (load_dtb(dtb_start, info, 0) < 0) {
                 exit(1);
             }
Signature · 1 line
2.1.0
#1 lore raw
Quoted 2 lines · Richard W.M. Jones

Resolves: https://bugs.launchpad.net/qemu/+bug/1383857

This is really a kernel bug.
https://www.kernel.org/doc/Documentation/arm64/booting.txt
just says "The device tree blob (dtb) must be placed on an 8-byte boundary within the first 512 megabytes from the start of the kernel image and must not cross a 2-megabyte boundary."

and doesn't make any requirements about it not overlapping a page with the initrd.

Quoted 9 lines
---
 hw/arm/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/boot.c +0 -0
index 0014c34..a859922 100644

hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 639

Quoted 10 lines
hw/arm/boot.c +2 -2
@@ -632,11 +632,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
          */
         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
+             * kernels will trash anything in the 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);
+                                             65536);

I'd rather we didn't do this unconditionally, because for some of our board models 64K is a significant proportion of their total RAM.

-- PMM