1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright IBM Corp. 2016
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <asm/processor.h>
8 #include <asm/facility.h>
9 #include <asm/lowcore.h>
14 * The code within this file will be called very early. It may _not_
15 * access anything within the bss section, since that is not cleared
16 * yet and may contain data (e.g. initrd) that must be saved by other
18 * For temporary objects the stack (16k) should be used.
21 static unsigned long als
[] __initdata
= { FACILITIES_ALS
};
23 static void __init
u16_to_hex(char *str
, u16 val
)
27 for (i
= 1; i
<= 4; i
++) {
28 num
= (val
>> (16 - 4 * i
)) & 0xf;
36 static void __init
print_machine_type(void)
38 static char mach_str
[80] __initdata
= "Detected machine-type number: ";
43 u16_to_hex(type_str
, id
.machine
);
44 strcat(mach_str
, type_str
);
45 strcat(mach_str
, "\n");
46 sclp_early_printk(mach_str
);
49 static void __init
u16_to_decimal(char *str
, u16 val
)
53 while (div
* 10 <= val
)
56 *str
++ = '0' + val
/ div
;
63 static void __init
print_missing_facilities(void)
65 static char als_str
[80] __initdata
= "Missing facilities: ";
71 for (i
= 0; i
< ARRAY_SIZE(als
); i
++) {
72 val
= ~S390_lowcore
.stfle_fac_list
[i
] & als
[i
];
73 for (j
= 0; j
< BITS_PER_LONG
; j
++) {
74 if (!(val
& (1UL << (BITS_PER_LONG
- 1 - j
))))
79 * Make sure we stay within one line. Consider that
80 * each facility bit adds up to five characters and
81 * z/VM adds a four character prefix.
83 if (strlen(als_str
) > 70) {
84 strcat(als_str
, "\n");
85 sclp_early_printk(als_str
);
88 u16_to_decimal(val_str
, i
* BITS_PER_LONG
+ j
);
89 strcat(als_str
, val_str
);
93 strcat(als_str
, "\n");
94 sclp_early_printk(als_str
);
95 sclp_early_printk("See Principles of Operations for facility bits\n");
98 static void __init
facility_mismatch(void)
100 sclp_early_printk("The Linux kernel requires more recent processor hardware\n");
101 print_machine_type();
102 print_missing_facilities();
103 disabled_wait(0x8badcccc);
106 void __init
verify_facilities(void)
110 for (i
= 0; i
< ARRAY_SIZE(S390_lowcore
.stfle_fac_list
); i
++)
111 S390_lowcore
.stfle_fac_list
[i
] = 0;
114 : "=m" (S390_lowcore
.stfl_fac_list
));
115 S390_lowcore
.stfle_fac_list
[0] = (u64
)S390_lowcore
.stfl_fac_list
<< 32;
116 if (S390_lowcore
.stfl_fac_list
& 0x01000000) {
117 register unsigned long reg0
asm("0") = ARRAY_SIZE(als
) - 1;
119 asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
121 : "a" (&S390_lowcore
.stfle_fac_list
)
124 for (i
= 0; i
< ARRAY_SIZE(als
); i
++) {
125 if ((S390_lowcore
.stfle_fac_list
[i
] & als
[i
]) != als
[i
])