public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* compiler code model for the kernel
@ 2018-11-19 17:41 Ard Biesheuvel
  2018-11-19 17:48 ` Nick Desaulniers
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2018-11-19 17:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hello all,

Some of us (on cc) have discussed this a bit on various occasions, so
perhaps it's time to sit down and do something about it :-)

The Clang work that Nick is involved in has made explicit some
assumptions that we are currently making in the kernel with respect to
the behavior of GCC, and it would be good to formalise this so we can
keep relying on it in the future, and to clarify to other compiler
developers what is needed.

GCC for x86 has a -mcmodel=kernel parameter, so perhaps we should
introduce the same for AArch64. Under this model, we should be able to
make the following assumptions:
- symbol references are emitted as ADRP/ADD pairs
-  no absolute references in generated code like jump tables etc (like
-fpic/-fpie) [*]
- no shared library semantics (no GOT indirections to support symbol
preemption, or to reduce the CoW footprint and/or avoid text
relocations)
- resulting objects can be linked in -pie mode by ld.bfd

Another thing that came up is that we currently rely on the stack
pointer never to assume a value that is not 16-byte aligned, even
transiently.

Other things I've missed?

[*] This is only strictly required in parts of the code that may
execute at a different offset than the linked offset, even after
processing dynamic relocations at boot time (e.g., KVM hyp code
running in a different exception level) but avoiding those altogether
is reasonable. Note that GCC does the right thing for us here already,
but Clang current;y needs -fno-jump-tables to build the KVM hyp code.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-11-22 12:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-19 17:41 compiler code model for the kernel Ard Biesheuvel
2018-11-19 17:48 ` Nick Desaulniers
2018-11-22 11:53   ` Dave Martin
2018-11-22 12:06     ` Ard Biesheuvel
2018-11-19 23:54 ` Nick Desaulniers
2018-11-20 11:20   ` Peter Smith
2018-11-20 13:16     ` Ard Biesheuvel
2018-11-20 13:23 ` Will Deacon
2018-11-20 13:49   ` Ard Biesheuvel
2018-11-20 17:02     ` Ramana Radhakrishnan
2018-11-20 13:25 ` Ramana Radhakrishnan
2018-11-20 13:37   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox