diff mbox series

[v2,3/4] efi_selftest: implement exception test for sandbox

Message ID 20201111232959.11241-4-xypron.glpk@gmx.de
State Accepted
Commit 04cc7914f2697cdc43b1cd5e0d7ab73893327966
Delegated to: Simon Glass
Headers show
Series sandbox: exception handling | expand

Commit Message

Heinrich Schuchardt Nov. 11, 2020, 11:29 p.m. UTC
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>
---
v2:
	no change
---
 lib/efi_selftest/efi_selftest_miniapp_exception.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.28.0

Comments

Simon Glass Nov. 16, 2020, 11:53 p.m. UTC | #1
On Wed, 11 Nov 2020 at 16:30, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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>
> ---
> v2:
>         no change
> ---
>  lib/efi_selftest/efi_selftest_miniapp_exception.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c
> index 63c63d75f1..59b7e5100a 100644
> --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c
> +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c
> @@ -33,6 +33,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
>         asm volatile (".word 0xe7f7defb\n");
>  #elif defined(CONFIG_RISCV)
>         asm volatile (".word 0xffffffff\n");
> +#elif defined(CONFIG_SANDBOX)
> +       asm volatile (".word 0xffffffff\n");

Does this work on ARM hosts?


>  #elif defined(CONFIG_X86)
>         asm volatile (".word 0xffff\n");
>  #endif
> --
> 2.28.0
>
Heinrich Schuchardt Nov. 19, 2020, 9:12 p.m. UTC | #2
On 17.11.20 00:53, Simon Glass wrote:
> On Wed, 11 Nov 2020 at 16:30, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> 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>
>> ---
>> v2:
>>         no change
>> ---
>>  lib/efi_selftest/efi_selftest_miniapp_exception.c | 2 ++
>>  1 file changed, 2 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
>>
>> diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c
>> index 63c63d75f1..59b7e5100a 100644
>> --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c
>> +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c
>> @@ -33,6 +33,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
>>         asm volatile (".word 0xe7f7defb\n");
>>  #elif defined(CONFIG_RISCV)
>>         asm volatile (".word 0xffffffff\n");
>> +#elif defined(CONFIG_SANDBOX)
>> +       asm volatile (".word 0xffffffff\n");
>
> Does this work on ARM hosts?

Yes it works on aarch64.

Best regards

Heinrich

>
>
>>  #elif defined(CONFIG_X86)
>>         asm volatile (".word 0xffff\n");
>>  #endif
>> --
>> 2.28.0
>>
Simon Glass Dec. 10, 2020, 12:26 a.m. UTC | #3
On 17.11.20 00:53, Simon Glass wrote:
> On Wed, 11 Nov 2020 at 16:30, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> 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>
>> ---
>> v2:
>>         no change
>> ---
>>  lib/efi_selftest/efi_selftest_miniapp_exception.c | 2 ++
>>  1 file changed, 2 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
>>
Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c
index 63c63d75f1..59b7e5100a 100644
--- a/lib/efi_selftest/efi_selftest_miniapp_exception.c
+++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c
@@ -33,6 +33,8 @@  efi_status_t EFIAPI efi_main(efi_handle_t handle,
 	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