2 * efi_selftest_unaligned
4 * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
6 * SPDX-License-Identifier: GPL-2.0+
8 * Test unaligned memory access on ARMv7.
11 #include <efi_selftest.h>
13 struct aligned_buffer {
14 char a[8] __aligned(8);
18 * Return an u32 at a give address.
19 * If the address is not four byte aligned, an unaligned memory access
22 * @addr: address to read
23 * @return: value at the address
25 static inline u32 deref(u32 *addr)
30 "ldr %[out], [%[in]]\n\t"
39 * An unaligned memory access is executed. The result is checked.
41 * @return: EFI_ST_SUCCESS for success
43 static int execute(void)
45 struct aligned_buffer buf = {
46 {0, 1, 2, 3, 4, 5, 6, 7},
51 /* Read an unaligned address */
54 /* UEFI only supports low endian systems */
55 if (r != 0x04030201) {
56 efi_st_error("Unaligned access failed");
57 return EFI_ST_FAILURE;
60 return EFI_ST_SUCCESS;
63 EFI_UNIT_TEST(unaligned) = {
64 .name = "unaligned memory access",
65 .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,