Panic when loading modules with CONFIG_ARM64_BTI_KERNEL

D Scott Phillips scott at os.amperecomputing.com
Thu Aug 18 09:22:39 PDT 2022


Mark Brown <broonie at kernel.org> writes:

> On Wed, Aug 17, 2022 at 04:42:43PM -0700, D Scott Phillips wrote:
>
>> In the meantime, should we mark BTI_KERNEL as broken? or any other ideas
>
> The clang versions I have to hand appear fine with your userspace test
> program, it emits a BTI C at the start of func with -O1 so I guess
> that'd only be for GCC.  Ideally we'd be able to detect particular
> configurations that would trigger this but I don't think we can.

Good point, it looks like LLVM is specifically aware that veneers might
get added and so inserts `bti c` at the start of *all* functions IIUC:

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp#L80

> // Even in cases where a function has internal linkage and is only
> // called directly in its translation unit, it can still be called
> // indirectly if the linker decides to add a thunk to it for whatever
> // reason (say, for example, if it is finally placed far from its call
> // site and a BL is not long-range enough).



More information about the linux-arm-kernel mailing list