fix: revert "Panic if manifest isn't aligned."
This reverts commit 933fa55b88a868cc2c035906ae8a57a6889830cc.
libfdt doesn't handle unaligned memory accesses. There is an alignment
fault while dtb processing if dtb is 2 bytes aligned.
Revert of the original commit:
This reverts commit 1de06beb55e96a1722edf1ca8dfd75337f9a6ab2. Parsing
is now done by libfdt which handles unaligned memory accesses.
Original commit:
Panic if manifest isn't aligned.
Otherwise it will fail later on with a confusing error message.
Change-Id: Idd1a08e2d2672ce8e64eed8e829ab15eb9c48ec4
Signed-off-by: Dmitrii Martynov <fkr655@yandex.ru>
diff --git a/docs/HafniumRamDisk.md b/docs/HafniumRamDisk.md
index f0a6640..fecdc80 100644
--- a/docs/HafniumRamDisk.md
+++ b/docs/HafniumRamDisk.md
@@ -7,6 +7,10 @@
* kernels for the VMs, whose names are described in the manifest (optional)
* initrd of the primary VM, whose name is described in the manifest (optional)
+The `manifest.dtb` must be the first file in the RAM disk, to ensure that it is
+properly aligned. Hafnium will not be able to read it if it is not aligned to a
+4 byte boundary.
+
Follow the [preparing Linux](PreparingLinux.md) instructions to produce
`vmlinuz` and `initrd.img` for a basic Linux primary VM.
diff --git a/src/init.c b/src/init.c
index a97fca1..c0bb1e2 100644
--- a/src/init.c
+++ b/src/init.c
@@ -130,6 +130,12 @@
manifest_it = fdt.buf;
}
+ dlog_verbose("Manifest range: %#x - %#x (%d bytes)\n", manifest_it.next,
+ manifest_it.limit, manifest_it.limit - manifest_it.next);
+ if (!is_aligned(manifest_it.next, 4)) {
+ panic("Manifest not aligned.");
+ }
+
manifest_ret = manifest_init(mm_stage1_locked, &manifest, &manifest_it,
&ppool);