• A
    efi: use 32-bit alignment for efi_guid_t literals · 5509e71c
    Ard Biesheuvel 提交于
    stable inclusion
    from stable-5.10.26
    commit 47ba0d4d2afb476e2a67f781166186e24b1e3bc1
    bugzilla: 51363
    
    --------------------------------
    
    commit fb98cc0b upstream.
    
    Commit 494c704f ("efi: Use 32-bit alignment for efi_guid_t") updated
    the type definition of efi_guid_t to ensure that it always appears
    sufficiently aligned (the UEFI spec is ambiguous about this, but given
    the fact that its EFI_GUID type is defined in terms of a struct carrying
    a uint32_t, the natural alignment is definitely >= 32 bits).
    
    However, we missed the EFI_GUID() macro which is used to instantiate
    efi_guid_t literals: that macro is still based on the guid_t type,
    which does not have a minimum alignment at all. This results in warnings
    such as
    
      In file included from drivers/firmware/efi/mokvar-table.c:35:
      include/linux/efi.h:1093:34: warning: passing 1-byte aligned argument to
          4-byte aligned parameter 2 of 'get_var' may result in an unaligned pointer
          access [-Walign-mismatch]
              status = get_var(L"SecureBoot", &EFI_GLOBAL_VARIABLE_GUID, NULL, &size,
                                              ^
      include/linux/efi.h:1101:24: warning: passing 1-byte aligned argument to
          4-byte aligned parameter 2 of 'get_var' may result in an unaligned pointer
          access [-Walign-mismatch]
              get_var(L"SetupMode", &EFI_GLOBAL_VARIABLE_GUID, NULL, &size, &setupmode);
    
    The distinction only matters on CPUs that do not support misaligned loads
    fully, but 32-bit ARM's load-multiple instructions fall into that category,
    and these are likely to be emitted by the compiler that built the firmware
    for loading word-aligned 128-bit GUIDs from memory
    
    So re-implement the initializer in terms of our own efi_guid_t type, so that
    the alignment becomes a property of the literal's type.
    
    Fixes: 494c704f ("efi: Use 32-bit alignment for efi_guid_t")
    Reported-by: NNathan Chancellor <nathan@kernel.org>
    Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: NNathan Chancellor <nathan@kernel.org>
    Tested-by: NNathan Chancellor <nathan@kernel.org>
    Link: https://github.com/ClangBuiltLinux/linux/issues/1327Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
    Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: NChen Jun <chenjun102@huawei.com>
    Acked-by: N  Weilong Chen <chenweilong@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    5509e71c
efi.h 41.4 KB