diff options
author | Peter Zijlstra <peterz@infradead.org> | 2021-03-26 16:12:01 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2021-04-02 12:41:17 +0200 |
commit | 23c1ad538f4f371bdb67d8a112314842d5db7e5a (patch) | |
tree | a057eba5ff709afba56b16586bc990340ec562c6 /arch/x86/lib | |
parent | Merge branch 'x86/cpu' into WIP.x86/core, to merge the NOP changes & resolve ... (diff) | |
download | linux-23c1ad538f4f371bdb67d8a112314842d5db7e5a.tar.xz linux-23c1ad538f4f371bdb67d8a112314842d5db7e5a.zip |
x86/alternatives: Optimize optimize_nops()
Currently, optimize_nops() scans to see if the alternative starts with
NOPs. However, the emit pattern is:
141: \oldinstr
142: .skip (len-(142b-141b)), 0x90
That is, when 'oldinstr' is short, the tail is padded with NOPs. This case
never gets optimized.
Rewrite optimize_nops() to replace any trailing string of NOPs inside
the alternative to larger NOPs. Also run it irrespective of patching,
replacing NOPs in both the original and replaced code.
A direct consequence is that 'padlen' becomes superfluous, so remove it.
[ bp:
- Adjust commit message
- remove a stale comment about needing to pad
- add a comment in optimize_nops()
- exit early if the NOP verif. loop catches a mismatch - function
should not not add NOPs in that case
- fix the "optimized NOPs" offsets output ]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20210326151259.442992235@infradead.org
Diffstat (limited to 'arch/x86/lib')
0 files changed, 0 insertions, 0 deletions