Skip to content

Commit

Permalink
Fix soft-reboot to support secure boot enabled platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekrnv authored Jul 23, 2024
1 parent 772ee79 commit 3f58cf2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ if is_secureboot && grep -q aboot_machine= /host/machine.conf; then
else
# check if secure boot is enable in UEFI
CHECK_SECURE_UPGRADE_ENABLED=0
SECURE_UPGRADE_ENABLED=$(bootctl status 2>/dev/null | grep -c "Secure Boot: enabled") || CHECK_SECURE_UPGRADE_ENABLED=$?
SECURE_UPGRADE_ENABLED=$(mokutil --sb-state 2>/dev/null | grep -c "enabled") || CHECK_SECURE_UPGRADE_ENABLED=$?
if [[ CHECK_SECURE_UPGRADE_ENABLED -ne 0 ]]; then
debug "Loading kernel without secure boot"
load_kernel
Expand Down
21 changes: 18 additions & 3 deletions scripts/soft-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function clear_lingering_reboot_config()
if [[ -f ${WARM_DIR}/${REDIS_FILE} ]]; then
mv -f ${WARM_DIR}/${REDIS_FILE} ${WARM_DIR}/${REDIS_FILE}.${TIMESTAMP} || /bin/true
fi
/sbin/kexec -u || /bin/true
/sbin/kexec -u -a || /bin/true
}
SCRIPT=$0
Expand Down Expand Up @@ -147,9 +147,17 @@ function setup_reboot_variables()
fi
}
function invoke_kexec() {
/sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS" $@
}
function load_kernel() {
# Load kernel into the memory
/sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS"
invoke_kexec -a
}
function load_kernel_secure() {
invoke_kexec -s
}
function reboot_pre_check()
Expand Down Expand Up @@ -215,7 +223,14 @@ stop_sonic_services
clear_lingering_reboot_config
load_kernel
# check if secure boot is enabled
CHECK_SECURE_UPGRADE_ENABLED=0
SECURE_UPGRADE_ENABLED=$(mokutil --sb-state 2>/dev/null | grep -c "enabled") || CHECK_SECURE_UPGRADE_ENABLED=$?
if [[ CHECK_SECURE_UPGRADE_ENABLED -ne 0 ]]; then
load_kernel
else
load_kernel_secure
fi
# Update the reboot cause file to reflect that user issued 'reboot' command
# Upon next boot, the contents of this file will be used to determine the
Expand Down

0 comments on commit 3f58cf2

Please sign in to comment.