]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: alternatives: Add dynamic patching feature
authorMarc Zyngier <marc.zyngier@arm.com>
Sun, 3 Dec 2017 12:02:14 +0000 (12:02 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 19 Mar 2018 13:03:17 +0000 (13:03 +0000)
commite6b8c891a0885c385ee6d7deccb2dd45d1ef7aac
tree4deed9a2d080a47d84be45ba50b665daa77657e8
parentb4d6f8c9f8fffd3c737f179205fee714331a88f0
arm64: alternatives: Add dynamic patching feature

We've so far relied on a patching infrastructure that only gave us
a single alternative, without any way to provide a range of potential
replacement instructions. For a single feature, this is an all or
nothing thing.

It would be interesting to have a more flexible grained way of patching
the kernel though, where we could dynamically tune the code that gets
injected.

In order to achive this, let's introduce a new form of dynamic patching,
assiciating a callback to a patching site. This callback gets source and
target locations of the patching request, as well as the number of
instructions to be patched.

Dynamic patching is declared with the new ALTERNATIVE_CB and alternative_cb
directives:

asm volatile(ALTERNATIVE_CB("mov %0, #0\n", callback)
     : "r" (v));
or
alternative_cb callback
mov x0, #0
alternative_cb_end

where callback is the C function computing the alternative.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/include/asm/alternative.h
arch/arm64/kernel/alternative.c