1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright IBM Corp. 2016
5 #include <linux/kernel.h>
6 #include <asm/processor.h>
7 #include <asm/facility.h>
8 #include <asm/lowcore.h>
12 * The code within this file will be called very early. It may _not_
13 * access anything within the bss section, since that is not cleared
14 * yet and may contain data (e.g. initrd) that must be saved by other
16 * For temporary objects the stack (16k) should be used.
19 static unsigned long als
[] = { FACILITIES_ALS
};
21 static void u16_to_hex(char *str
, u16 val
)
25 for (i
= 1; i
<= 4; i
++) {
26 num
= (val
>> (16 - 4 * i
)) & 0xf;
34 static void print_machine_type(void)
36 static char mach_str
[80] = "Detected machine-type number: ";
41 u16_to_hex(type_str
, id
.machine
);
42 strcat(mach_str
, type_str
);
43 strcat(mach_str
, "\n");
44 sclp_early_printk(mach_str
);
47 static void u16_to_decimal(char *str
, u16 val
)
51 while (div
* 10 <= val
)
54 *str
++ = '0' + val
/ div
;
61 static void print_missing_facilities(void)
63 static char als_str
[80] = "Missing facilities: ";
69 for (i
= 0; i
< ARRAY_SIZE(als
); i
++) {
70 val
= ~S390_lowcore
.stfle_fac_list
[i
] & als
[i
];
71 for (j
= 0; j
< BITS_PER_LONG
; j
++) {
72 if (!(val
& (1UL << (BITS_PER_LONG
- 1 - j
))))
77 * Make sure we stay within one line. Consider that
78 * each facility bit adds up to five characters and
79 * z/VM adds a four character prefix.
81 if (strlen(als_str
) > 70) {
82 strcat(als_str
, "\n");
83 sclp_early_printk(als_str
);
86 u16_to_decimal(val_str
, i
* BITS_PER_LONG
+ j
);
87 strcat(als_str
, val_str
);
91 strcat(als_str
, "\n");
92 sclp_early_printk(als_str
);
93 sclp_early_printk("See Principles of Operations for facility bits\n");
96 static void facility_mismatch(void)
98 sclp_early_printk("The Linux kernel requires more recent processor hardware\n");
100 print_missing_facilities();
101 disabled_wait(0x8badcccc);
104 void verify_facilities(void)
108 for (i
= 0; i
< ARRAY_SIZE(S390_lowcore
.stfle_fac_list
); i
++)
109 S390_lowcore
.stfle_fac_list
[i
] = 0;
112 : "=m" (S390_lowcore
.stfl_fac_list
));
113 S390_lowcore
.stfle_fac_list
[0] = (u64
)S390_lowcore
.stfl_fac_list
<< 32;
114 if (S390_lowcore
.stfl_fac_list
& 0x01000000) {
115 register unsigned long reg0
asm("0") = ARRAY_SIZE(als
) - 1;
117 asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
119 : "a" (&S390_lowcore
.stfle_fac_list
)
122 for (i
= 0; i
< ARRAY_SIZE(als
); i
++) {
123 if ((S390_lowcore
.stfle_fac_list
[i
] & als
[i
]) != als
[i
])