aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/early.c
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2008-04-30 07:38:45 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-04-30 07:38:47 -0400
commit2e5061e40af88070984e3769eafb5a06022375fd (patch)
tree2964cc88a68f826fc8e025d145f692e1e78740e0 /arch/s390/kernel/early.c
parent8fc63658681f32e6e29f6d1138de933d7272e0ec (diff)
[S390] Convert machine feature detection code to C.
From: Heiko Carstens <heiko.carstens@de.ibm.com> From: Carsten Otte <cotte@de.ibm.com> This lets us use defines for the magic bits in machine flags instead of using plain numbers all over the place. In addition on newer machines features/facilities are indicated by the result of the stfl instruction. So we use these bits instead of trying to execute new instructions and check wether we get an exception or not. Also the mvpg instruction is always available when in zArch mode, whereas the idte instruction is only available in zArch mode. This results in some minor optimizations. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/early.c')
-rw-r--r--arch/s390/kernel/early.c109
1 files changed, 106 insertions, 3 deletions
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 68ec4083bf73..bd188f6bd0e2 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -139,15 +139,15 @@ static noinline __init void detect_machine_type(void)
139 139
140 /* Running under z/VM ? */ 140 /* Running under z/VM ? */
141 if (cpuinfo->cpu_id.version == 0xff) 141 if (cpuinfo->cpu_id.version == 0xff)
142 machine_flags |= 1; 142 machine_flags |= MACHINE_FLAG_VM;
143 143
144 /* Running on a P/390 ? */ 144 /* Running on a P/390 ? */
145 if (cpuinfo->cpu_id.machine == 0x7490) 145 if (cpuinfo->cpu_id.machine == 0x7490)
146 machine_flags |= 4; 146 machine_flags |= MACHINE_FLAG_P390;
147 147
148 /* Running under KVM ? */ 148 /* Running under KVM ? */
149 if (cpuinfo->cpu_id.version == 0xfe) 149 if (cpuinfo->cpu_id.version == 0xfe)
150 machine_flags |= 64; 150 machine_flags |= MACHINE_FLAG_KVM;
151} 151}
152 152
153#ifdef CONFIG_64BIT 153#ifdef CONFIG_64BIT
@@ -268,6 +268,103 @@ static noinline __init void setup_lowcore_early(void)
268 s390_base_pgm_handler_fn = early_pgm_check_handler; 268 s390_base_pgm_handler_fn = early_pgm_check_handler;
269} 269}
270 270
271static __init void detect_mvpg(void)
272{
273#ifndef CONFIG_64BIT
274 int rc;
275
276 asm volatile(
277 " la 0,0\n"
278 " mvpg %2,%2\n"
279 "0: la %0,0\n"
280 "1:\n"
281 EX_TABLE(0b,1b)
282 : "=d" (rc) : "0" (-EOPNOTSUPP), "a" (0) : "memory", "cc", "0");
283 if (!rc)
284 machine_flags |= MACHINE_FLAG_MVPG;
285#endif
286}
287
288static __init void detect_ieee(void)
289{
290#ifndef CONFIG_64BIT
291 int rc, tmp;
292
293 asm volatile(
294 " efpc %1,0\n"
295 "0: la %0,0\n"
296 "1:\n"
297 EX_TABLE(0b,1b)
298 : "=d" (rc), "=d" (tmp): "0" (-EOPNOTSUPP) : "cc");
299 if (!rc)
300 machine_flags |= MACHINE_FLAG_IEEE;
301#endif
302}
303
304static __init void detect_csp(void)
305{
306#ifndef CONFIG_64BIT
307 int rc;
308
309 asm volatile(
310 " la 0,0\n"
311 " la 1,0\n"
312 " la 2,4\n"
313 " csp 0,2\n"
314 "0: la %0,0\n"
315 "1:\n"
316 EX_TABLE(0b,1b)
317 : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc", "0", "1", "2");
318 if (!rc)
319 machine_flags |= MACHINE_FLAG_CSP;
320#endif
321}
322
323static __init void detect_diag9c(void)
324{
325 unsigned int cpu_address;
326 int rc;
327
328 cpu_address = stap();
329 asm volatile(
330 " diag %2,0,0x9c\n"
331 "0: la %0,0\n"
332 "1:\n"
333 EX_TABLE(0b,1b)
334 : "=d" (rc) : "0" (-EOPNOTSUPP), "d" (cpu_address) : "cc");
335 if (!rc)
336 machine_flags |= MACHINE_FLAG_DIAG9C;
337}
338
339static __init void detect_diag44(void)
340{
341#ifdef CONFIG_64BIT
342 int rc;
343
344 asm volatile(
345 " diag 0,0,0x44\n"
346 "0: la %0,0\n"
347 "1:\n"
348 EX_TABLE(0b,1b)
349 : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc");
350 if (!rc)
351 machine_flags |= MACHINE_FLAG_DIAG44;
352#endif
353}
354
355static __init void detect_machine_facilities(void)
356{
357#ifdef CONFIG_64BIT
358 unsigned int facilities;
359
360 facilities = stfl();
361 if (facilities & (1 << 28))
362 machine_flags |= MACHINE_FLAG_IDTE;
363 if (facilities & (1 << 4))
364 machine_flags |= MACHINE_FLAG_MVCOS;
365#endif
366}
367
271/* 368/*
272 * Save ipl parameters, clear bss memory, initialize storage keys 369 * Save ipl parameters, clear bss memory, initialize storage keys
273 * and create a kernel NSS at startup if the SAVESYS= parm is defined 370 * and create a kernel NSS at startup if the SAVESYS= parm is defined
@@ -285,6 +382,12 @@ void __init startup_init(void)
285 create_kernel_nss(); 382 create_kernel_nss();
286 sort_main_extable(); 383 sort_main_extable();
287 setup_lowcore_early(); 384 setup_lowcore_early();
385 detect_mvpg();
386 detect_ieee();
387 detect_csp();
388 detect_diag9c();
389 detect_diag44();
390 detect_machine_facilities();
288 sclp_read_info_early(); 391 sclp_read_info_early();
289 sclp_facilities_detect(); 392 sclp_facilities_detect();
290 memsize = sclp_memory_detect(); 393 memsize = sclp_memory_detect();