@@ -271,14 +271,23 @@ function teardown_control_plane_assistant()
271
271
fi
272
272
}
273
273
274
+ function is_secureboot() {
275
+ grep -Eq ' secure_boot_enable=[1y]' /proc/cmdline
276
+ }
277
+
274
278
function setup_reboot_variables()
275
279
{
276
280
# Kernel and initrd image
277
281
NEXT_SONIC_IMAGE=$( sonic-installer list | grep " Next: " | cut -d ' ' -f 2)
278
282
IMAGE_PATH=" /host/image-${NEXT_SONIC_IMAGE# SONiC-OS-} "
279
283
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
282
291
elif grep -q onie_platform= /host/machine.conf; then
283
292
KERNEL_OPTIONS=$( cat /host/grub/grub.cfg | sed " /$NEXT_SONIC_IMAGE '/,/}/" ' !' " g" | grep linux)
284
293
KERNEL_IMAGE=" /host$( echo $KERNEL_OPTIONS | cut -d ' ' -f 2) "
@@ -332,6 +341,18 @@ function reboot_pre_check()
332
341
fi
333
342
}
334
343
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
+
335
356
function unload_kernel()
336
357
{
337
358
# Unload the previously loaded kernel if any loaded
@@ -412,8 +433,12 @@ if [[ "$sonic_asic_type" == "mellanox" ]]; then
412
433
fi
413
434
fi
414
435
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
417
442
418
443
if [[ " $REBOOT_TYPE " = " fast-reboot" ]]; then
419
444
# Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6
0 commit comments