efi: Add missing __nocfi annotations to runtime wrappers
authorArd Biesheuvel <ardb@kernel.org>
Tue, 4 Jun 2024 15:45:20 +0000 (17:45 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 5 Jun 2024 08:18:58 +0000 (10:18 +0200)
commit99280413a5b785f22d91e8a8a66dc38f4a214495
tree78ef25de736cc0ab71983cb986e04bc8e88e0f91
parent290be0a40276ca36a5110b191d73a71b8bbe466f
efi: Add missing __nocfi annotations to runtime wrappers

The EFI runtime wrappers are a sandbox for calling into EFI runtime
services, which are invoked using indirect calls. When running with kCFI
enabled, the compiler will require the target of any indirect call to be
type annotated.

Given that the EFI runtime services prototypes and calling convention
are governed by the EFI spec, not the Linux kernel, adding such type
annotations for firmware routines is infeasible, and so the compiler
must be informed that prototype validation should be omitted.

Add the __nocfi annotation at the appropriate places in the EFI runtime
wrapper code to achieve this.

Note that this currently only affects 32-bit ARM, given that other
architectures that support both kCFI and EFI use an asm wrapper to call
EFI runtime services, and this hides the indirect call from the
compiler.

Fixes: 1a4fec49efe5 ("ARM: 9392/2: Support CLANG CFI")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/runtime-wrappers.c