1 // SPDX-License-Identifier: GPL-2.0+
3 * efi_selftest_unaligned
5 * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
7 * Test unaligned memory access on ARMv7.
10 #include <efi_selftest.h>
12 struct aligned_buffer
{
13 char a
[8] __aligned(8);
17 * Return an u32 at a given address.
18 * If the address is not four byte aligned, an unaligned memory access
21 * @addr: address to read
22 * Return: value at the address
24 static inline u32
deref(void *addr
)
29 "ldr %[out], [%[in]]\n\t"
38 * An unaligned memory access is executed. The result is checked.
40 * Return: EFI_ST_SUCCESS for success
42 static int execute(void)
44 struct aligned_buffer buf
= {
45 {0, 1, 2, 3, 4, 5, 6, 7},
49 /* Read an unaligned address */
52 /* UEFI only supports low endian systems */
53 if (r
!= 0x04030201) {
54 efi_st_error("Unaligned access failed");
55 return EFI_ST_FAILURE
;
58 return EFI_ST_SUCCESS
;
61 EFI_UNIT_TEST(unaligned
) = {
62 .name
= "unaligned memory access",
63 .phase
= EFI_EXECUTE_BEFORE_BOOTTIME_EXIT
,