aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2016-06-27 09:52:38 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2016-07-31 05:27:58 -0400
commitbe2412c247c16c0ea4dd3293e8046e1b383c3bb6 (patch)
treec266913e26887b660c926aaad972914ca5b7c1f0
parentcf9fdfea5f01bfebeeb28b4b27dc5151c7ea29d3 (diff)
s390/als: convert architecture level set code to C
There is no reason to have this code in assembly language. Therefore convert it to C. Note that this code needs special treatment: it is called very early and one of the side effects is that e.g. the bss section is not cleared. Therefore the preferred way for static variables is to put them on the stack which has a size of 16KB. There is no functional change with this patch. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/boot/compressed/Makefile2
-rw-r--r--arch/s390/kernel/Makefile10
-rw-r--r--arch/s390/kernel/als.c46
-rw-r--r--arch/s390/kernel/entry.h2
-rw-r--r--arch/s390/kernel/head.S43
5 files changed, 60 insertions, 43 deletions
diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile
index 98ec652cc332..13723c39e58e 100644
--- a/arch/s390/boot/compressed/Makefile
+++ b/arch/s390/boot/compressed/Makefile
@@ -18,7 +18,7 @@ KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
18 18
19GCOV_PROFILE := n 19GCOV_PROFILE := n
20 20
21OBJECTS := $(addprefix $(objtree)/arch/s390/kernel/, head.o sclp.o ebcdic.o) 21OBJECTS := $(addprefix $(objtree)/arch/s390/kernel/, head.o sclp.o ebcdic.o als.o)
22OBJECTS += $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o 22OBJECTS += $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o
23 23
24LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T 24LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index f37be37edd3a..07fca5e642b4 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -4,6 +4,7 @@
4 4
5KCOV_INSTRUMENT_early.o := n 5KCOV_INSTRUMENT_early.o := n
6KCOV_INSTRUMENT_sclp.o := n 6KCOV_INSTRUMENT_sclp.o := n
7KCOV_INSTRUMENT_als.o := n
7 8
8ifdef CONFIG_FUNCTION_TRACER 9ifdef CONFIG_FUNCTION_TRACER
9# Don't trace early setup code and tracing code 10# Don't trace early setup code and tracing code
@@ -32,13 +33,16 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
32CFLAGS_sysinfo.o += -w 33CFLAGS_sysinfo.o += -w
33 34
34# 35#
35# Use -march=z900 for sclp.c to be able to print an error message if 36# Use -march=z900 for sclp.c and als.c to be able to print an error
36# the kernel is started on a machine which is too old 37# message if the kernel is started on a machine which is too old
37# 38#
38CFLAGS_REMOVE_sclp.o = $(CC_FLAGS_FTRACE) 39CFLAGS_REMOVE_sclp.o = $(CC_FLAGS_FTRACE)
40CFLAGS_REMOVE_als.o = $(CC_FLAGS_FTRACE)
39ifneq ($(CC_FLAGS_MARCH),-march=z900) 41ifneq ($(CC_FLAGS_MARCH),-march=z900)
40CFLAGS_REMOVE_sclp.o += $(CC_FLAGS_MARCH) 42CFLAGS_REMOVE_sclp.o += $(CC_FLAGS_MARCH)
41CFLAGS_sclp.o += -march=z900 43CFLAGS_sclp.o += -march=z900
44CFLAGS_REMOVE_als.o += $(CC_FLAGS_MARCH)
45CFLAGS_als.o += -march=z900
42AFLAGS_REMOVE_head.o += $(CC_FLAGS_MARCH) 46AFLAGS_REMOVE_head.o += $(CC_FLAGS_MARCH)
43AFLAGS_head.o += -march=z900 47AFLAGS_head.o += -march=z900
44endif 48endif
@@ -46,7 +50,7 @@ GCOV_PROFILE_sclp.o := n
46 50
47obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o 51obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o
48obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o 52obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
49obj-y += debug.o irq.o ipl.o dis.o diag.o sclp.o vdso.o 53obj-y += debug.o irq.o ipl.o dis.o diag.o sclp.o vdso.o als.o
50obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o 54obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o
51obj-y += runtime_instr.o cache.o fpu.o dumpstack.o 55obj-y += runtime_instr.o cache.o fpu.o dumpstack.o
52obj-y += entry.o reipl.o relocate_kernel.o 56obj-y += entry.o reipl.o relocate_kernel.o
diff --git a/arch/s390/kernel/als.c b/arch/s390/kernel/als.c
new file mode 100644
index 000000000000..f96a577972c4
--- /dev/null
+++ b/arch/s390/kernel/als.c
@@ -0,0 +1,46 @@
1/*
2 * Copyright IBM Corp. 2016
3 */
4#include <linux/kernel.h>
5#include <linux/init.h>
6#include <asm/processor.h>
7#include <asm/facility.h>
8#include <asm/lowcore.h>
9#include <asm/sclp.h>
10#include "entry.h"
11
12/*
13 * The code within this file will be called very early. It may _not_
14 * access anything within the bss section, since that is not cleared
15 * yet and may contain data (e.g. initrd) that must be saved by other
16 * code.
17 * For temporary objects the stack (16k) should be used.
18 */
19
20static unsigned long als[] __initdata = { FACILITIES_ALS };
21
22void __init verify_facilities(void)
23{
24 int i;
25
26 for (i = 0; i < ARRAY_SIZE(S390_lowcore.stfle_fac_list); i++)
27 S390_lowcore.stfle_fac_list[i] = 0;
28 asm volatile(
29 " stfl 0(0)\n"
30 : "=m" (S390_lowcore.stfl_fac_list));
31 S390_lowcore.stfle_fac_list[0] = (u64)S390_lowcore.stfl_fac_list << 32;
32 if (S390_lowcore.stfl_fac_list & 0x01000000) {
33 register unsigned long reg0 asm("0") = ARRAY_SIZE(als) - 1;
34
35 asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
36 : "+d" (reg0)
37 : "a" (&S390_lowcore.stfle_fac_list)
38 : "memory", "cc");
39 }
40 for (i = 0; i < ARRAY_SIZE(als); i++) {
41 if ((S390_lowcore.stfle_fac_list[i] & als[i]) == als[i])
42 continue;
43 _sclp_print_early("The Linux kernel requires more recent processor hardware");
44 disabled_wait(0x8badcccc);
45 }
46}
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index bedd2f55d860..e79f030dd276 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -79,4 +79,6 @@ long sys_s390_pci_mmio_read(unsigned long, void __user *, size_t);
79 79
80DECLARE_PER_CPU(u64, mt_cycles[8]); 80DECLARE_PER_CPU(u64, mt_cycles[8]);
81 81
82void verify_facilities(void);
83
82#endif /* _ENTRY_H */ 84#endif /* _ENTRY_H */
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index fcaefb041364..56e4d8234ef2 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -306,49 +306,14 @@ ENTRY(startup_kdump)
306 stck __LC_LAST_UPDATE_CLOCK 306 stck __LC_LAST_UPDATE_CLOCK
307 spt 6f-.LPG0(%r13) 307 spt 6f-.LPG0(%r13)
308 mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13) 308 mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13)
309 stfl 0(%r0) # store facilities @ __LC_STFL_FAC_LIST 309 l %r15,.Lstack-.LPG0(%r13)
310 mvc __LC_STFLE_FAC_LIST(4),__LC_STFL_FAC_LIST
311 tm __LC_STFLE_FAC_LIST,0x01 # stfle available ?
312 jz 0f
313 lghi %r0,FACILITIES_ALS_DWORDS-1
314 .insn s,0xb2b00000,__LC_STFLE_FAC_LIST # store facility list extended
315 # verify if all required facilities are supported by the machine
3160: la %r1,__LC_STFLE_FAC_LIST
317 la %r2,3f+8-.LPG0(%r13)
318 lhi %r3,FACILITIES_ALS_DWORDS
3191: lg %r0,0(%r1)
320 ng %r0,0(%r2)
321 clg %r0,0(%r2)
322 jne 2f
323 la %r1,8(%r1)
324 la %r2,8(%r2)
325 ahi %r3,-1
326 jnz 1b
327 j 4f
3282: l %r15,.Lstack-.LPG0(%r13)
329 ahi %r15,-STACK_FRAME_OVERHEAD 310 ahi %r15,-STACK_FRAME_OVERHEAD
330 la %r2,.Lals_string-.LPG0(%r13) 311 brasl %r14,verify_facilities
331 l %r3,.Lsclp_print-.LPG0(%r13)
332 basr %r14,%r3
333 lpsw 3f-.LPG0(%r13) # machine type not good enough, crash
334.Lals_string:
335 .asciz "The Linux kernel requires more recent processor hardware"
336.Lsclp_print:
337 .long _sclp_print_early
338.Lstack:
339 .long 0x8000 + (1<<(PAGE_SHIFT+THREAD_ORDER))
340 .align 16
3413: .long 0x000a0000,0x8badcccc
342
343# List of facilities that are required. If not all facilities are present
344# the kernel will crash.
345
346 .quad FACILITIES_ALS
347
3484:
349 /* Continue with startup code in head64.S */ 312 /* Continue with startup code in head64.S */
350 jg startup_continue 313 jg startup_continue
351 314
315.Lstack:
316 .long 0x8000 + (1<<(PAGE_SHIFT+THREAD_ORDER))
352 .align 8 317 .align 8
3536: .long 0x7fffffff,0xffffffff 3186: .long 0x7fffffff,0xffffffff
354 319