Skip to content

Commit 207ddb9

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/alternatives: Convert runtime sanity check into compile time check
__apply_alternatives() contains a runtime check which verifies that the size of the to be patched code area is even. Convert this to a compile time check using a similar ".org" trick, which is already used to verify that old and new code areas have the same size. Reviewed-by: Sven Schnelle <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent effb835 commit 207ddb9

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

arch/s390/include/asm/alternative-asm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
.long \alt_start - .
1616
.word \feature
1717
.byte \orig_end - \orig_start
18+
.org . - ( \orig_end - \orig_start ) & 1
1819
.org . - ( \orig_end - \orig_start ) + ( \alt_end - \alt_start )
1920
.org . - ( \alt_end - \alt_start ) + ( \orig_end - \orig_start )
2021
.endm

arch/s390/include/asm/alternative.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
5353
"\t.long " b_altinstr(num)"b - .\n" /* alt instruction */ \
5454
"\t.word " __stringify(facility) "\n" /* facility bit */ \
5555
"\t.byte " oldinstr_len "\n" /* instruction len */ \
56+
"\t.org . - (" oldinstr_len ") & 1\n" \
5657
"\t.org . - (" oldinstr_len ") + (" altinstr_len(num) ")\n" \
5758
"\t.org . - (" altinstr_len(num) ") + (" oldinstr_len ")\n"
5859

arch/s390/kernel/alternative.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ static void __init_or_module __apply_alternatives(struct alt_instr *start,
3333

3434
if (!__test_facility(a->facility, alt_stfle_fac_list))
3535
continue;
36-
37-
if (unlikely(a->instrlen % 2)) {
38-
WARN_ONCE(1, "cpu alternatives instructions length is "
39-
"odd, skipping patching\n");
40-
continue;
41-
}
42-
4336
s390_kernel_write(instr, replacement, a->instrlen);
4437
}
4538
}

0 commit comments

Comments
 (0)