1 // SPDX-License-Identifier: GPL-2.0+
3 * efi_selftest_exception
7 * Test the handling of exceptions by trying to execute an undefined
11 #include <efi_selftest.h>
14 * undefined_instruction() - try to executed an undefined instruction
16 static void undefined_instruction(void)
18 #if defined(CONFIG_ARM)
20 * 0xe7f...f. is undefined in ARM mode
21 * 0xde.. is undefined in Thumb mode
23 asm volatile (".word 0xe7f7defb\n");
24 #elif defined(CONFIG_RISCV)
25 asm volatile (".word 0xffffffff\n");
26 #elif defined(CONFIG_X86)
27 asm volatile (".word 0xffff\n");
32 * execute() - execute unit test
34 * Return: EFI_ST_SUCCESS for success
36 static int execute(void)
38 undefined_instruction();
40 efi_st_error("An undefined instruction exception was not raised\n");
42 return EFI_ST_FAILURE;
45 EFI_UNIT_TEST(exception) = {
47 .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,