Skip to content

Commit 17e89e1

Browse files
svens-s390Vasily Gorbik
authored andcommitted
s390/facilities: move stfl information from lowcore to global data
With gcc-11, there are a lot of warnings because the facility functions are accessing lowcore through a null pointer. Fix this by moving the facility arrays away from lowcore. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent af9ad82 commit 17e89e1

File tree

14 files changed

+40
-50
lines changed

14 files changed

+40
-50
lines changed

arch/s390/boot/als.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void print_missing_facilities(void)
6868

6969
first = 1;
7070
for (i = 0; i < ARRAY_SIZE(als); i++) {
71-
val = ~S390_lowcore.stfle_fac_list[i] & als[i];
71+
val = ~stfle_fac_list[i] & als[i];
7272
for (j = 0; j < BITS_PER_LONG; j++) {
7373
if (!(val & (1UL << (BITS_PER_LONG - 1 - j))))
7474
continue;
@@ -106,9 +106,9 @@ void verify_facilities(void)
106106
{
107107
int i;
108108

109-
__stfle(S390_lowcore.stfle_fac_list, ARRAY_SIZE(S390_lowcore.stfle_fac_list));
109+
__stfle(stfle_fac_list, ARRAY_SIZE(stfle_fac_list));
110110
for (i = 0; i < ARRAY_SIZE(als); i++) {
111-
if ((S390_lowcore.stfle_fac_list[i] & als[i]) != als[i])
111+
if ((stfle_fac_list[i] & als[i]) != als[i])
112112
facility_mismatch();
113113
}
114114
}

arch/s390/boot/ipl_parm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ void setup_boot_command_line(void)
180180
static void modify_facility(unsigned long nr, bool clear)
181181
{
182182
if (clear)
183-
__clear_facility(nr, S390_lowcore.stfle_fac_list);
183+
__clear_facility(nr, stfle_fac_list);
184184
else
185-
__set_facility(nr, S390_lowcore.stfle_fac_list);
185+
__set_facility(nr, stfle_fac_list);
186186
}
187187

188188
static void check_cleared_facilities(void)
@@ -191,7 +191,7 @@ static void check_cleared_facilities(void)
191191
int i;
192192

193193
for (i = 0; i < ARRAY_SIZE(als); i++) {
194-
if ((S390_lowcore.stfle_fac_list[i] & als[i]) != als[i]) {
194+
if ((stfle_fac_list[i] & als[i]) != als[i]) {
195195
sclp_early_printk("Warning: The Linux kernel requires facilities cleared via command line option\n");
196196
print_missing_facilities();
197197
break;

arch/s390/boot/startup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ extern char __boot_data_preserved_start[], __boot_data_preserved_end[];
1717
unsigned long __bootdata_preserved(__kaslr_offset);
1818
unsigned long __bootdata(ident_map_size);
1919

20+
u64 __bootdata_preserved(stfle_fac_list[16]);
21+
u64 __bootdata_preserved(alt_stfle_fac_list[16]);
22+
2023
/*
2124
* Some code and data needs to stay below 2 GB, even when the kernel would be
2225
* relocated above 2 GB, because it has to use 31 bit addresses.

arch/s390/include/asm/facility.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
#include <linux/preempt.h>
1414
#include <asm/lowcore.h>
1515

16-
#define MAX_FACILITY_BIT (sizeof(((struct lowcore *)0)->stfle_fac_list) * 8)
16+
#define MAX_FACILITY_BIT (sizeof(stfle_fac_list) * 8)
17+
18+
extern u64 stfle_fac_list[16];
19+
extern u64 alt_stfle_fac_list[16];
1720

1821
static inline void __set_facility(unsigned long nr, void *facilities)
1922
{
@@ -56,7 +59,7 @@ static inline int test_facility(unsigned long nr)
5659
if (__test_facility(nr, &facilities_als))
5760
return 1;
5861
}
59-
return __test_facility(nr, &S390_lowcore.stfle_fac_list);
62+
return __test_facility(nr, &stfle_fac_list);
6063
}
6164

6265
static inline unsigned long __stfle_asm(u64 *stfle_fac_list, int size)
@@ -79,13 +82,15 @@ static inline unsigned long __stfle_asm(u64 *stfle_fac_list, int size)
7982
static inline void __stfle(u64 *stfle_fac_list, int size)
8083
{
8184
unsigned long nr;
85+
u32 stfl_fac_list;
8286

8387
asm volatile(
8488
" stfl 0(0)\n"
8589
: "=m" (S390_lowcore.stfl_fac_list));
90+
stfl_fac_list = S390_lowcore.stfl_fac_list;
91+
memcpy(stfle_fac_list, &stfl_fac_list, 4);
8692
nr = 4; /* bytes stored by stfl */
87-
memcpy(stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
88-
if (S390_lowcore.stfl_fac_list & 0x01000000) {
93+
if (stfl_fac_list & 0x01000000) {
8994
/* More facility bits available with stfle */
9095
nr = __stfle_asm(stfle_fac_list, size);
9196
nr = min_t(unsigned long, (nr + 1) * 8, size * 8);

arch/s390/include/asm/lowcore.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,7 @@ struct lowcore {
153153
__u64 vmcore_info; /* 0x0e0c */
154154
__u8 pad_0x0e14[0x0e18-0x0e14]; /* 0x0e14 */
155155
__u64 os_info; /* 0x0e18 */
156-
__u8 pad_0x0e20[0x0f00-0x0e20]; /* 0x0e20 */
157-
158-
/* Extended facility list */
159-
__u64 stfle_fac_list[16]; /* 0x0f00 */
160-
__u64 alt_stfle_fac_list[16]; /* 0x0f80 */
161-
__u8 pad_0x1000[0x11b0-0x1000]; /* 0x1000 */
156+
__u8 pad_0x0e20[0x11b0-0x0e20]; /* 0x0e20 */
162157

163158
/* Pointer to the machine check extended save area */
164159
__u64 mcesad; /* 0x11b0 */

arch/s390/kernel/alternative.c

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

79-
if (!__test_facility(a->facility,
80-
S390_lowcore.alt_stfle_fac_list))
79+
if (!__test_facility(a->facility, alt_stfle_fac_list))
8180
continue;
8281

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

arch/s390/kernel/asm-offsets.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ int main(void)
7575
OFFSET(__LC_SUBCHANNEL_NR, lowcore, subchannel_nr);
7676
OFFSET(__LC_IO_INT_PARM, lowcore, io_int_parm);
7777
OFFSET(__LC_IO_INT_WORD, lowcore, io_int_word);
78-
OFFSET(__LC_STFL_FAC_LIST, lowcore, stfl_fac_list);
79-
OFFSET(__LC_STFLE_FAC_LIST, lowcore, stfle_fac_list);
8078
OFFSET(__LC_MCCK_CODE, lowcore, mcck_interruption_code);
8179
OFFSET(__LC_EXT_DAMAGE_CODE, lowcore, external_damage_code);
8280
OFFSET(__LC_MCCK_FAIL_STOR_ADDR, lowcore, failing_storage_address);

arch/s390/kernel/early.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,9 @@ static noinline __init void setup_lowcore_early(void)
180180

181181
static noinline __init void setup_facility_list(void)
182182
{
183-
memcpy(S390_lowcore.alt_stfle_fac_list,
184-
S390_lowcore.stfle_fac_list,
185-
sizeof(S390_lowcore.alt_stfle_fac_list));
183+
memcpy(alt_stfle_fac_list, stfle_fac_list, sizeof(alt_stfle_fac_list));
186184
if (!IS_ENABLED(CONFIG_KERNEL_NOBP))
187-
__clear_facility(82, S390_lowcore.alt_stfle_fac_list);
185+
__clear_facility(82, alt_stfle_fac_list);
188186
}
189187

190188
static __init void detect_diag9c(void)

arch/s390/kernel/nospec-branch.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ static int __init nobp_setup_early(char *str)
1717
* The user explicitely requested nobp=1, enable it and
1818
* disable the expoline support.
1919
*/
20-
__set_facility(82, S390_lowcore.alt_stfle_fac_list);
20+
__set_facility(82, alt_stfle_fac_list);
2121
if (IS_ENABLED(CONFIG_EXPOLINE))
2222
nospec_disable = 1;
2323
} else {
24-
__clear_facility(82, S390_lowcore.alt_stfle_fac_list);
24+
__clear_facility(82, alt_stfle_fac_list);
2525
}
2626
return 0;
2727
}
2828
early_param("nobp", nobp_setup_early);
2929

3030
static int __init nospec_setup_early(char *str)
3131
{
32-
__clear_facility(82, S390_lowcore.alt_stfle_fac_list);
32+
__clear_facility(82, alt_stfle_fac_list);
3333
return 0;
3434
}
3535
early_param("nospec", nospec_setup_early);
@@ -40,7 +40,7 @@ static int __init nospec_report(void)
4040
pr_info("Spectre V2 mitigation: etokens\n");
4141
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
4242
pr_info("Spectre V2 mitigation: execute trampolines\n");
43-
if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
43+
if (__test_facility(82, alt_stfle_fac_list))
4444
pr_info("Spectre V2 mitigation: limited branch prediction\n");
4545
return 0;
4646
}
@@ -66,14 +66,14 @@ void __init nospec_auto_detect(void)
6666
*/
6767
if (__is_defined(CC_USING_EXPOLINE))
6868
nospec_disable = 1;
69-
__clear_facility(82, S390_lowcore.alt_stfle_fac_list);
69+
__clear_facility(82, alt_stfle_fac_list);
7070
} else if (__is_defined(CC_USING_EXPOLINE)) {
7171
/*
7272
* The kernel has been compiled with expolines.
7373
* Keep expolines enabled and disable nobp.
7474
*/
7575
nospec_disable = 0;
76-
__clear_facility(82, S390_lowcore.alt_stfle_fac_list);
76+
__clear_facility(82, alt_stfle_fac_list);
7777
}
7878
/*
7979
* If the kernel has not been compiled with expolines the
@@ -86,7 +86,7 @@ static int __init spectre_v2_setup_early(char *str)
8686
{
8787
if (str && !strncmp(str, "on", 2)) {
8888
nospec_disable = 0;
89-
__clear_facility(82, S390_lowcore.alt_stfle_fac_list);
89+
__clear_facility(82, alt_stfle_fac_list);
9090
}
9191
if (str && !strncmp(str, "off", 3))
9292
nospec_disable = 1;

arch/s390/kernel/nospec-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
1717
return sprintf(buf, "Mitigation: etokens\n");
1818
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
1919
return sprintf(buf, "Mitigation: execute trampolines\n");
20-
if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
20+
if (__test_facility(82, alt_stfle_fac_list))
2121
return sprintf(buf, "Mitigation: limited branch prediction\n");
2222
return sprintf(buf, "Vulnerable\n");
2323
}

0 commit comments

Comments
 (0)