diff options
| author | Heiko Carstens <hca@linux.ibm.com> | 2025-02-07 15:48:56 +0100 |
|---|---|---|
| committer | Vasily Gorbik <gor@linux.ibm.com> | 2025-03-04 17:18:05 +0100 |
| commit | b7e81efc2436c553ca29eae5f069480de3d9f975 (patch) | |
| tree | 26b31206db6b9854df1c06a76d75f055d0d517d4 /arch/s390/kernel | |
| parent | 949b73c9902613bddb789d9375981afbffe596fc (diff) | |
s390: Static branches for machine features infrastructure
Provide infrastructure which allows to generate machine_has_<feature>()
functions, which are replacing the existing MACHINE_HAS_<feature> macros.
Such function usages generate a static branch depending on <feature>. The
static branch is patched using an alternative.
Each <feature> correlates with a bit set in the machine_features bit
field. If the corresponding bit is set, the branch will be patched. In
order to have any effect on branch patching feature bits must be set with
set_machine_features() in the decompressor before alternatives patching of
the kernel image.
It is possible to use clear_machine_feature() and test_machine_feature()
for machine features which cannot be completely detected within the
decompressor, e.g. if common code command line parameters allow to enable
or disable certain features. In such cases test_machine_feature() instead
of machine_has_feature() must be used within the kernel. This results in a
runtime check and not a static branch.
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch/s390/kernel')
| -rw-r--r-- | arch/s390/kernel/alternative.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/s390/kernel/alternative.c b/arch/s390/kernel/alternative.c index 8d5d0de35de0..d3839fc0543d 100644 --- a/arch/s390/kernel/alternative.c +++ b/arch/s390/kernel/alternative.c @@ -5,6 +5,10 @@ #include <asm/abs_lowcore.h> #include <asm/alternative.h> #include <asm/facility.h> +#include <asm/sections.h> +#include <asm/machine.h> + +unsigned long __bootdata_preserved(machine_features[1]); void __apply_alternatives(struct alt_instr *start, struct alt_instr *end, unsigned int ctx) { @@ -23,6 +27,9 @@ void __apply_alternatives(struct alt_instr *start, struct alt_instr *end, unsign case ALT_TYPE_FACILITY: replace = test_facility(a->data); break; + case ALT_TYPE_FEATURE: + replace = test_machine_feature(a->data); + break; case ALT_TYPE_SPEC: replace = nobp_enabled(); break; |
