Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix soft-reboot to support secure boot enabled platforms #56

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading