From d6d7ab37f0eb9468f464252227503ed705cd36bc Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Thu, 19 Jan 2023 14:42:14 -0800 Subject: [PATCH] [warm-reboot] Use kexec_file_load instead of kexec_load when available (#2608) On some dev VMs, warm reboot on a VS image fails. Specifically, after kexec is called and the new kernel starts, the new kernel tries to load the initramfs, but fails to do so for whatever reason. There may be messages about gzip decompression failing and that it's corrupted. After some experimentation, it was found that when first loading the new kernel and initramfs into memory, using the `kexec_file_load` syscall (`-s` flag in kexec) worked fine, whereas using the default `kexec_load` syscall resulted in a failure. It's unknown why `kexec_file_load` worked fine when `kexec_load` didn't; there shouldn't be any difference for non-secure boot kernels, as far as I can tell. What was seen, however, was that when taking a KVM dump in the failure case, the memory that stored the initramfs had differences compared to what was on disk. It's unknown what caused these differences. As a workaround (and as a bit of a feature enhancement), use the `-a` flag with kexec, which tells it to use `kexec_file_load` if available, and `kexec_load` if it's not available or otherwise fails. armhf doesn't support `kexec_file_load`, whereas arm64 gained support for `kexec_file_load` in the 5.19 kernel (we're currently on 5.10). `amd64` has supported `kexec_file_load` since 3.17. This also makes it possible to do kexec on secure boot systems, where the kernel image must be loaded via `kexec_file_load`. Signed-off-by: Saikrishna Arcot Signed-off-by: Saikrishna Arcot --- scripts/fast-reboot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fast-reboot b/scripts/fast-reboot index 2fa0106acc..bfdc191b78 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -444,7 +444,7 @@ function load_aboot_secureboot_kernel() { function load_kernel() { # Load kernel into the memory - /sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS" + /sbin/kexec -a -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS" } function unload_kernel()