arm64: wipe old initrd addresses when patching the DTB
Subsystems (2)
PATCH 1/1 arm64: wipe old initrd addresses when patching the DTB
When copying the DTB from the current kernel, if the user didn't pass an initrd on the command-line, make sure that the new DTB doesn't contain initrd properties with stale addresses. Otherwise the next kernel will try to unpack the initramfs from a location that contains junk, since the initial initrd is long gone:
[ 49.370026] Initramfs unpacking failed: junk in compressed archive
This issue used to be hidden by a successful recovery, but since commit ff1522bb7d98 ("initramfs: cleanup incomplete rootfs") in Linux, the kernel removes the default /root mountpoint after failing to load an initramfs, and cannot mount the rootfs passed on the command-line anymore.
--- kexec/arch/arm64/kexec-arm64.c | 5 +++++ kexec/dt-ops.c | 6 ++++++ kexec/dt-ops.h | 1 + 3 files changed, 12 insertions(+)
kexec/arch/arm64/kexec-arm64.c +5 -0
@@ -713,6 +713,11 @@ int arm64_load_other_segments(struct kexec_info *info, } } +if (!initrd_buf) { +/* Don't reuse the initrd addresses from 1st DTB */ +dtb_clear_initrd ((char **)&dtb.buf, &dtb.size); + } +/* Check size limit as specified in booting.txt. */ if (dtb.size >MiB (2 )) {
kexec/dt-ops.c +6 -0
@@ -45,6 +45,12 @@ int dtb_set_initrd(char **dtb, off_t *dtb_size, off_t start, off_t end)return 0 ; } +void dtb_clear_initrd (char **dtb,off_t *dtb_size) +{ +dtb_delete_property (*dtb, n_chosen, p_initrd_start); +dtb_delete_property (*dtb, n_chosen, p_initrd_end); +} +int dtb_set_bootargs (char **dtb,off_t *dtb_size,const char *command_line) { return dtb_set_property(dtb, dtb_size, n_chosen, p_bootargs,
kexec/dt-ops.h +1 -0
@@ -4,6 +4,7 @@#include <sys/types.h> int dtb_set_initrd (char **dtb,off_t *dtb_size,off_t start,off_t end); +void dtb_clear_initrd (char **dtb,off_t *dtb_size);int dtb_set_bootargs (char **dtb,off_t *dtb_size,const char *command_line);int dtb_set_property (char **dtb,off_t *dtb_size,const char *node,const char *prop,const void *value,int value_len);
Signature · 7 lines
2.20.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedQuoted 8 lines · Jean-Philippe Brucker
When copying the DTB from the current kernel, if the user didn't pass an initrd on the command-line, make sure that the new DTB doesn't contain initrd properties with stale addresses. Otherwise the next kernel will try to unpack the initramfs from a location that contains junk, since the initial initrd is long gone:
[ 49.370026] Initramfs unpacking failed: junk in compressed archive
Quoted 7 lines
This issue used to be hidden by a successful recovery, but since commit
ff1522bb7d98("initramfs: cleanup incomplete rootfs") in Linux, the kernel removes the default /root mountpoint after failing to load an initramfs, and cannot mount the rootfs passed on the command-line anymore.Signed-off-by Jean-Philippe Brucker <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec