mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-21 02:33:07 +00:00
04cc7914f2
Provide a unit test that causes an illegal instruction to occur. The test can be run with the following commands: => setenv efi_selftest exception => bootefi selftest This might be the output: Executing 'exception' EFI application triggers exception. Illegal instruction pc = 0x1444d016, pc_reloc = 0xffffaa078e8dd016 UEFI image [0x0000000000000000:0xffffffffffffffff] '/\selftest' UEFI image [0x000000001444b000:0x0000000014451fff] pc=0x2016 '/bug.efi' Resetting ... It would tell us that the exception was triggered by an instruction 0x2016 bytes after the load address of the binary with filename /bug.efi. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
43 lines
1 KiB
C
43 lines
1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* efi_selftest_miniapp_return
|
|
*
|
|
* Copyright (c) 2019 Heinrich Schuchardt
|
|
*
|
|
* This EFI application triggers an exception.
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <efi_api.h>
|
|
|
|
/*
|
|
* Entry point of the EFI application.
|
|
*
|
|
* @handle handle of the loaded image
|
|
* @systable system table
|
|
* @return status code
|
|
*/
|
|
efi_status_t EFIAPI efi_main(efi_handle_t handle,
|
|
struct efi_system_table *systable)
|
|
{
|
|
struct efi_simple_text_output_protocol *con_out = systable->con_out;
|
|
|
|
con_out->output_string(con_out,
|
|
L"EFI application triggers exception.\n");
|
|
|
|
#if defined(CONFIG_ARM)
|
|
/*
|
|
* 0xe7f...f. is undefined in ARM mode
|
|
* 0xde.. is undefined in Thumb mode
|
|
*/
|
|
asm volatile (".word 0xe7f7defb\n");
|
|
#elif defined(CONFIG_RISCV)
|
|
asm volatile (".word 0xffffffff\n");
|
|
#elif defined(CONFIG_SANDBOX)
|
|
asm volatile (".word 0xffffffff\n");
|
|
#elif defined(CONFIG_X86)
|
|
asm volatile (".word 0xffff\n");
|
|
#endif
|
|
con_out->output_string(con_out, L"Exception not triggered.\n");
|
|
return EFI_ABORTED;
|
|
}
|