]> xenbits.xensource.com Git - people/royger/xen.git/commit
efi: fix alignment of function parameters in compat mode efi-clang-v2 gitlab/efi-clang-v2
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 17 Nov 2021 15:32:04 +0000 (16:32 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Wed, 17 Nov 2021 16:59:23 +0000 (17:59 +0100)
commit1269f0ba20af2de35c889f7de8fd7f592c6a32bb
tree408772c67fad72f2812860d3b63ad692bcf8ba2f
parentf949ee8c724b44e27c39404b6b9036a6da7da861
efi: fix alignment of function parameters in compat mode

Currently the max_store_size, remain_store_size and max_size in
compat_pf_efi_runtime_call are 4 byte aligned, which makes clang
complain with:

In file included from compat.c:30:
./runtime.c:646:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 2 of 'QueryVariableInfo' may result in an unaligned pointer access [-Werror,-Walign-mismatch]
            &op->u.query_variable_info.max_store_size,
            ^
./runtime.c:647:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 3 of 'QueryVariableInfo' may result in an unaligned pointer access [-Werror,-Walign-mismatch]
            &op->u.query_variable_info.remain_store_size,
            ^
./runtime.c:648:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 4 of 'QueryVariableInfo' may result in an unaligned pointer access [-Werror,-Walign-mismatch]
            &op->u.query_variable_info.max_size);
            ^
Fix this by bouncing the variables on the stack in order for them to
be 8 byte aligned.

Note this could be done in a more selective manner to only apply to
compat code calls, but given the overhead of making an EFI call doing
an extra copy of 3 variables doesn't seem to warrant the special
casing.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - Copy back the results.
---
Cc: Ian Jackson <iwj@xenproject.org>
Tagged for possible inclusion into the release, as it's a likely
candidate for backport. It shouldn't introduce any functional change
from a caller PoV. I think the risk is getting the patch wrong and not
passing the right parameters, or broken EFI implementations corrupting
data on our stack instead of doing it in xenpf_efi_runtime_call.
xen/common/efi/runtime.c