OSDN Git Service

s390: introduce CPU alternatives
authorVasily Gorbik <gor@linux.vnet.ibm.com>
Fri, 27 Apr 2018 05:36:45 +0000 (07:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 29 Apr 2018 05:50:02 +0000 (07:50 +0200)
commit4eaf8dace704fb5392b330a01dbf579d3190b0b3
treea9435ba5f253a972280099503cfc01cb4623087f
parent8cd93573813bb6f00093ae826a457fbbddf393b8
s390: introduce CPU alternatives

[ Upstream commit 686140a1a9c41d85a4212a1c26d671139b76404b ]

Implement CPU alternatives, which allows to optionally patch newer
instructions at runtime, based on CPU facilities availability.

A new kernel boot parameter "noaltinstr" disables patching.

Current implementation is derived from x86 alternatives. Although
ideal instructions padding (when altinstr is longer then oldinstr)
is added at compile time, and no oldinstr nops optimization has to be
done at runtime. Also couple of compile time sanity checks are done:
1. oldinstr and altinstr must be <= 254 bytes long,
2. oldinstr and altinstr must not have an odd length.

alternative(oldinstr, altinstr, facility);
alternative_2(oldinstr, altinstr1, facility1, altinstr2, facility2);

Both compile time and runtime padding consists of either 6/4/2 bytes nop
or a jump (brcl) + 2 bytes nop filler if padding is longer then 6 bytes.

.altinstructions and .altinstr_replacement sections are part of
__init_begin : __init_end region and are freed after initialization.

Signed-off-by: Vasily Gorbik <gor@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/kernel-parameters.txt
arch/s390/Kconfig
arch/s390/include/asm/alternative.h [new file with mode: 0644]
arch/s390/kernel/Makefile
arch/s390/kernel/alternative.c [new file with mode: 0644]
arch/s390/kernel/module.c
arch/s390/kernel/setup.c
arch/s390/kernel/vmlinux.lds.S