Panic if manifest isn't aligned.

Otherwise it will fail later on with a confusing error message.

Bug: 150587116
Change-Id: Ia68d3aaa60ede2c0a76904e65a72ca863e27f24f
diff --git a/docs/HafniumRamDisk.md b/docs/HafniumRamDisk.md
index 6bd9c4f..c6d45d4 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 608dac0..9f8f829 100644
--- a/src/init.c
+++ b/src/init.c
@@ -129,6 +129,12 @@
 		panic("Could not find manifest in initrd.");
 	}
 
+	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(&manifest, &manifest_it);
 	if (manifest_ret != MANIFEST_SUCCESS) {
 		panic("Could not parse manifest: %s.",