Skip to content

Commit cf14899

Browse files
author
Martin Schwidefsky
committed
s390/alternative: use a copy of the facility bit mask
To be able to switch off specific CPU alternatives with kernel parameters make a copy of the facility bit mask provided by STFLE and use the copy for the decision to apply an alternative. Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent e2dd833 commit cf14899

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

arch/s390/include/asm/facility.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@
1515

1616
#define MAX_FACILITY_BIT (sizeof(((struct lowcore *)0)->stfle_fac_list) * 8)
1717

18+
static inline void __set_facility(unsigned long nr, void *facilities)
19+
{
20+
unsigned char *ptr = (unsigned char *) facilities;
21+
22+
if (nr >= MAX_FACILITY_BIT)
23+
return;
24+
ptr[nr >> 3] |= 0x80 >> (nr & 7);
25+
}
26+
27+
static inline void __clear_facility(unsigned long nr, void *facilities)
28+
{
29+
unsigned char *ptr = (unsigned char *) facilities;
30+
31+
if (nr >= MAX_FACILITY_BIT)
32+
return;
33+
ptr[nr >> 3] &= ~(0x80 >> (nr & 7));
34+
}
35+
1836
static inline int __test_facility(unsigned long nr, void *facilities)
1937
{
2038
unsigned char *ptr;

arch/s390/include/asm/lowcore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ struct lowcore {
151151
__u8 pad_0x0e20[0x0f00-0x0e20]; /* 0x0e20 */
152152

153153
/* Extended facility list */
154-
__u64 stfle_fac_list[32]; /* 0x0f00 */
154+
__u64 stfle_fac_list[16]; /* 0x0f00 */
155+
__u64 alt_stfle_fac_list[16]; /* 0x0f80 */
155156
__u8 pad_0x1000[0x11b0-0x1000]; /* 0x1000 */
156157

157158
/* Pointer to the machine check extended save area */

arch/s390/kernel/alternative.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static void __init_or_module __apply_alternatives(struct alt_instr *start,
7575
instr = (u8 *)&a->instr_offset + a->instr_offset;
7676
replacement = (u8 *)&a->repl_offset + a->repl_offset;
7777

78-
if (!test_facility(a->facility))
78+
if (!__test_facility(a->facility,
79+
S390_lowcore.alt_stfle_fac_list))
7980
continue;
8081

8182
if (unlikely(a->instrlen % 2 || a->replacementlen % 2)) {

arch/s390/kernel/early.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ static noinline __init void setup_facility_list(void)
193193
{
194194
stfle(S390_lowcore.stfle_fac_list,
195195
ARRAY_SIZE(S390_lowcore.stfle_fac_list));
196+
memcpy(S390_lowcore.alt_stfle_fac_list,
197+
S390_lowcore.stfle_fac_list,
198+
sizeof(S390_lowcore.alt_stfle_fac_list));
196199
}
197200

198201
static __init void detect_diag9c(void)

arch/s390/kernel/setup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ static void __init setup_lowcore(void)
340340
lc->preempt_count = S390_lowcore.preempt_count;
341341
lc->stfl_fac_list = S390_lowcore.stfl_fac_list;
342342
memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list,
343-
MAX_FACILITY_BIT/8);
343+
sizeof(lc->stfle_fac_list));
344+
memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list,
345+
sizeof(lc->alt_stfle_fac_list));
344346
nmi_alloc_boot_cpu(lc);
345347
vdso_alloc_boot_cpu(lc);
346348
lc->sync_enter_timer = S390_lowcore.sync_enter_timer;

arch/s390/kernel/smp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ static void pcpu_prepare_secondary(struct pcpu *pcpu, int cpu)
266266
__ctl_store(lc->cregs_save_area, 0, 15);
267267
save_access_regs((unsigned int *) lc->access_regs_save_area);
268268
memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list,
269-
MAX_FACILITY_BIT/8);
269+
sizeof(lc->stfle_fac_list));
270+
memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list,
271+
sizeof(lc->alt_stfle_fac_list));
270272
arch_spin_lock_setup(cpu);
271273
}
272274

0 commit comments

Comments
 (0)