[PATCH] x86: add 'runtime constant' infrastructure

Linus Torvalds torvalds at linux-foundation.org
Sat Jun 8 13:55:04 PDT 2024


On Sat, 8 Jun 2024 at 12:43, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> Needs more comments and testing, but it works, and has a generic
> fallback for architectures that don't support it.

.. and here is the TOTALLY UNTESTED patch to implement the arm64
version of runtime constants.

It almost certainly does not work. I'm too scared to test it.  I may
start to recognize arm64 instructions, but rewriting them on the fly
is another thing entirely, and I'm fairly sure this needs an  I$ sync
and probably modifying the instructions using another address even
during early boot.

So this is a "throw it over the fence to the actually competent arm64
people" patch.

Catalin, Will? This depends on the infrastructure that I added in

   https://lore.kernel.org/all/20240608193504.429644-2-torvalds@linux-foundation.org/

which is actually tested on the x86-64 side.

I did test that the code generation looks superficially sane, and this generates

        mov     x1, #0xcdef
        movk    x1, #0x89ab, lsl #16
        movk    x1, #0x4567, lsl #32
        movk    x1, #0x123, lsl #48
        ...
        lsr     w0, w25, #12
        ldr     x0, [x1, x0, lsl #3]

for the dcache hash lookup (those constants are obviously the ones
that get rewritten after the hash table has been allocated and the
size becomes fixed).

And honestly, I may have gotten even the simple part of instruction
rewriting wrong (ie maybe I'm filling in the wrong bit locations - I'm
reading the architecture manual, not actually *testing* anything).

Think of this patch mostly as a "look, adding another architecture
isn't *that* hard - even if the constant value is spread out in the
instructions".

                Linus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-arm64-add-runtime-const-support.patch
Type: text/x-patch
Size: 3122 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240608/8c1fbe0a/attachment.bin>


More information about the linux-arm-kernel mailing list