[PATCH 1/1] efi_selftest: on sandbox use host specific assembly

The selftest checking the handling of exceptions in UEFI binaries is using assembly to provide an undefined instruction. On the sandbox the correct form of the instruction depends on the host architecture.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- lib/efi_selftest/efi_selftest_miniapp_exception.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index 79f9a67859..a9ad381001 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -9,6 +9,7 @@
#include <common.h> #include <efi_api.h> +#include <host_arch.h>
/* * Entry point of the EFI application. @@ -33,10 +34,16 @@ 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_X86) + asm volatile (".word 0xffff\n"); #elif defined(CONFIG_SANDBOX) +#if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64) + asm volatile (".word 0xe7f7defb\n"); +#elif (HOST_ARCH == HOST_ARCH_RISCV32 || HOST_ARCH == HOST_ARCH_RISCV64) asm volatile (".word 0xffffffff\n"); -#elif defined(CONFIG_X86) +#elif (HOST_ARCH == HOST_ARCH_X86 || HOST_ARCH == HOST_ARCH_X86_64) asm volatile (".word 0xffff\n"); +#endif #endif con_out->output_string(con_out, u"Exception not triggered.\n"); return EFI_ABORTED;

On Fri, 2 Sept 2022 at 04:01, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
The selftest checking the handling of exceptions in UEFI binaries is using assembly to provide an undefined instruction. On the sandbox the correct form of the instruction depends on the host architecture.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/efi_selftest/efi_selftest_miniapp_exception.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index 79f9a67859..a9ad381001 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -9,6 +9,7 @@
#include <common.h> #include <efi_api.h> +#include <host_arch.h>
/*
- Entry point of the EFI application.
@@ -33,10 +34,16 @@ 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_X86)
asm volatile (".word 0xffff\n");
#elif defined(CONFIG_SANDBOX) +#if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64)
asm volatile (".word 0xe7f7defb\n");
+#elif (HOST_ARCH == HOST_ARCH_RISCV32 || HOST_ARCH == HOST_ARCH_RISCV64) asm volatile (".word 0xffffffff\n"); -#elif defined(CONFIG_X86) +#elif (HOST_ARCH == HOST_ARCH_X86 || HOST_ARCH == HOST_ARCH_X86_64) asm volatile (".word 0xffff\n"); +#endif #endif con_out->output_string(con_out, u"Exception not triggered.\n"); return EFI_ABORTED; -- 2.37.2
Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org

Hi Heinrich,
On Thu, 1 Sept 2022 at 19:01, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
The selftest checking the handling of exceptions in UEFI binaries is using assembly to provide an undefined instruction. On the sandbox the correct form of the instruction depends on the host architecture.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/efi_selftest/efi_selftest_miniapp_exception.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index 79f9a67859..a9ad381001 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -9,6 +9,7 @@
#include <common.h> #include <efi_api.h> +#include <host_arch.h>
/*
- Entry point of the EFI application.
@@ -33,10 +34,16 @@ 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_X86)
asm volatile (".word 0xffff\n");
What actually are these instructions? Shouldn't we define them somewhere, or at least add a comment for each?
#elif defined(CONFIG_SANDBOX) +#if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64)
asm volatile (".word 0xe7f7defb\n");
+#elif (HOST_ARCH == HOST_ARCH_RISCV32 || HOST_ARCH == HOST_ARCH_RISCV64) asm volatile (".word 0xffffffff\n"); -#elif defined(CONFIG_X86) +#elif (HOST_ARCH == HOST_ARCH_X86 || HOST_ARCH == HOST_ARCH_X86_64) asm volatile (".word 0xffff\n"); +#endif #endif con_out->output_string(con_out, u"Exception not triggered.\n"); return EFI_ABORTED; -- 2.37.2
Regards, Simon
participants (3)
-
Heinrich Schuchardt
-
Ilias Apalodimas
-
Simon Glass