]> xenbits.xensource.com Git - xen.git/commit
xen/arm: alternative: add auto-nop infrastructure
authorMark Rutland <mark.rutland@arm.com>
Tue, 24 Sep 2019 11:25:47 +0000 (12:25 +0100)
committerJulien Grall <julien.grall@arm.com>
Fri, 1 Nov 2019 14:32:54 +0000 (14:32 +0000)
commitf11fda966365db591d280ac1522993409e20fd8c
tree98c10888e3291a9aeb9e938cd33b387b80a92f27
parent7afbbca21bbacb9011da05055a911bca6aa895c5
xen/arm: alternative: add auto-nop infrastructure

In some cases, one side of an alternative sequence is simply a number of
NOPs used to balance the other side. Keeping track of this manually is
tedious, and the presence of large chains of NOPs makes the code more
painful to read than necessary.

To ameliorate matters, this patch adds a new alternative_else_nop_endif,
which automatically balances an alternative sequence with a trivial NOP
sled.

In many cases, we would like a NOP-sled in the default case, and
instructions patched in in the presence of a feature. To enable the NOPs
to be generated automatically for this case, this patch also adds a new
alternative_if, and updates alternative_else and alternative_endif to
work with either alternative_if or alternative_endif.

The alternative infrastructure was originally ported from Linux. So this
is pretty much a straight backport from commit 792d47379f4d "arm64:
alternative: add auto-nop infrastructure". The only difference is the
nops macro added as not yet existing in Xen.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
[will: use new nops macro to generate nop sequences]
Signed-off-by: Will Deacon <will.deacon@arm.com>
[julien: Add nops and port to Xen]
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/include/asm-arm/alternative.h
xen/include/asm-arm/macros.h