Skip to content

Commit 8e64106

Browse files
authored
Add secure fast/warm-reboot support for Aboot (sonic-net#994)
Instead of having multiple implementation of preparing a SWI image for secureboot, fast-reboot now reuses boot0. SWI images booting in regular mode will keep using the old behavior.
1 parent d1cf75f commit 8e64106

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

scripts/fast-reboot

+29-4
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,23 @@ function teardown_control_plane_assistant()
271271
fi
272272
}
273273
274+
function is_secureboot() {
275+
grep -Eq 'secure_boot_enable=[1y]' /proc/cmdline
276+
}
277+
274278
function setup_reboot_variables()
275279
{
276280
# Kernel and initrd image
277281
NEXT_SONIC_IMAGE=$(sonic-installer list | grep "Next: " | cut -d ' ' -f 2)
278282
IMAGE_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}"
279283
if grep -q aboot_platform= /host/machine.conf; then
280-
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
281-
BOOT_OPTIONS="$(cat "$IMAGE_PATH/kernel-cmdline" | tr '\n' ' ') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
284+
if is_secureboot; then
285+
KERNEL_IMAGE=""
286+
BOOT_OPTIONS="SONIC_BOOT_TYPE=${BOOT_TYPE_ARG} secure_boot_enable=1"
287+
else
288+
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
289+
BOOT_OPTIONS="$(cat "$IMAGE_PATH/kernel-cmdline" | tr '\n' ' ') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
290+
fi
282291
elif grep -q onie_platform= /host/machine.conf; then
283292
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
284293
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
@@ -332,6 +341,18 @@ function reboot_pre_check()
332341
fi
333342
}
334343
344+
function load_aboot_secureboot_kernel() {
345+
local next_image="$IMAGE_PATH/sonic.swi"
346+
echo "Loading next image from $next_image"
347+
unzip -qp "$next_image" boot0 | \
348+
swipath=$next_image kexec=true loadonly=true ENV_EXTRA_CMDLINE="$BOOT_OPTIONS" bash -
349+
}
350+
351+
function load_kernel() {
352+
# Load kernel into the memory
353+
/sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS"
354+
}
355+
335356
function unload_kernel()
336357
{
337358
# Unload the previously loaded kernel if any loaded
@@ -412,8 +433,12 @@ if [[ "$sonic_asic_type" == "mellanox" ]]; then
412433
fi
413434
fi
414435
415-
# Load kernel into the memory
416-
/sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS"
436+
437+
if is_secureboot && grep -q aboot_machine= /host/machine.conf; then
438+
load_aboot_secureboot_kernel
439+
else
440+
load_kernel
441+
fi
417442
418443
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
419444
# Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6

0 commit comments

Comments
 (0)