Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/kexec: Enable secureboot tests for PowerPC

Existing test cases determine secureboot state using efi variable, which
is available only on x86 architecture. Add support for determining
secureboot state using device tree property on PowerNV architecture.

Signed-off-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
Reviewed-by: Nayna Jain <nayna@linux.ibm.com>
Tested-by: Nayna Jain <nayna@linux.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>

authored by

Nageswara R Sastry and committed by
Mimi Zohar
65e38e32 520451e9

+39 -9
+1 -1
tools/testing/selftests/kexec/Makefile
··· 4 4 uname_M := $(shell uname -m 2>/dev/null || echo not) 5 5 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) 6 6 7 - ifeq ($(ARCH),x86) 7 + ifeq ($(ARCH),$(filter $(ARCH),x86 ppc64le)) 8 8 TEST_PROGS := test_kexec_load.sh test_kexec_file_load.sh 9 9 TEST_FILES := kexec_common_lib.sh 10 10
+32 -6
tools/testing/selftests/kexec/kexec_common_lib.sh
··· 91 91 return 0; 92 92 } 93 93 94 + # On powerpc platform, check device-tree property 95 + # /proc/device-tree/ibm,secureboot/os-secureboot-enforcing 96 + # to detect secureboot state. 97 + get_ppc64_secureboot_mode() 98 + { 99 + local secure_boot_file="/proc/device-tree/ibm,secureboot/os-secureboot-enforcing" 100 + # Check for secure boot file existence 101 + if [ -f $secure_boot_file ]; then 102 + log_info "Secureboot is enabled (Device tree)" 103 + return 1; 104 + fi 105 + log_info "Secureboot is not enabled (Device tree)" 106 + return 0; 107 + } 108 + 109 + # Return the architecture of the system 110 + get_arch() 111 + { 112 + echo $(arch) 113 + } 114 + 94 115 # Check efivar SecureBoot-$(the UUID) and SetupMode-$(the UUID). 95 116 # The secure boot mode can be accessed either as the last integer 96 117 # of "od -An -t u1 /sys/firmware/efi/efivars/SecureBoot-*" or from ··· 121 100 get_secureboot_mode() 122 101 { 123 102 local secureboot_mode=0 103 + local system_arch=$(get_arch) 124 104 125 - get_efivarfs_secureboot_mode 126 - secureboot_mode=$? 127 - 128 - # fallback to using the efi_var files 129 - if [ $secureboot_mode -eq 0 ]; then 130 - get_efi_var_secureboot_mode 105 + if [ "$system_arch" == "ppc64le" ]; then 106 + get_ppc64_secureboot_mode 131 107 secureboot_mode=$? 108 + else 109 + get_efivarfs_secureboot_mode 110 + secureboot_mode=$? 111 + # fallback to using the efi_var files 112 + if [ $secureboot_mode -eq 0 ]; then 113 + get_efi_var_secureboot_mode 114 + secureboot_mode=$? 115 + fi 132 116 fi 133 117 134 118 if [ $secureboot_mode -eq 0 ]; then
+6 -2
tools/testing/selftests/kexec/test_kexec_file_load.sh
··· 226 226 secureboot=$? 227 227 228 228 # Are there pe and ima signatures 229 - check_for_pesig 230 - pe_signed=$? 229 + if [ "$(get_arch)" == 'ppc64le' ]; then 230 + pe_signed=0 231 + else 232 + check_for_pesig 233 + pe_signed=$? 234 + fi 231 235 232 236 check_for_imasig 233 237 ima_signed=$?