From 65a94b1417badaee2ed923fd07e23b651b25c729 Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Mon, 4 Apr 2011 09:43:29 +0200 Subject: [S390] oprofile s390: prevent stack corruption Prevent stack corruption by memcpy which copies more bytes then available at the destination. While at it use the new test_facility to test for the facility bit. Signed-off-by: Jan Glauber Signed-off-by: Martin Schwidefsky --- arch/s390/oprofile/hwsampler.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'arch') diff --git a/arch/s390/oprofile/hwsampler.c b/arch/s390/oprofile/hwsampler.c index 3d48f4db246..4952872d6f0 100644 --- a/arch/s390/oprofile/hwsampler.c +++ b/arch/s390/oprofile/hwsampler.c @@ -517,12 +517,8 @@ stop_exit: static int check_hardware_prerequisites(void) { - unsigned long long facility_bits[2]; - - memcpy(facility_bits, S390_lowcore.stfle_fac_list, 32); - if (!(facility_bits[1] & (1ULL << 59))) + if (!test_facility(68)) return -EOPNOTSUPP; - return 0; } /* -- cgit v1.2.3-70-g09d2 From 034e9e966cd86e5d8062cf0b3daba4bde187986c Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Mon, 4 Apr 2011 09:43:30 +0200 Subject: [S390] Fix parameter passing for smp_switch_to_cpu() After the execution has been switched to the destination CPU, the target function is called with the wrong parameter. According to the C calling convention on s390, the first parameter should be loaded into register 2. Currently in smp_restart_cpu() it is stored in register 3. To fix this, we load the parameter into the correct register 2. Signed-off-by: Michael Holzheu Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/switch_cpu.S | 4 +++- arch/s390/kernel/switch_cpu64.S | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/s390/kernel/switch_cpu.S b/arch/s390/kernel/switch_cpu.S index 469f11b574f..20530dd2eab 100644 --- a/arch/s390/kernel/switch_cpu.S +++ b/arch/s390/kernel/switch_cpu.S @@ -46,7 +46,9 @@ smp_restart_cpu: ltr %r4,%r4 /* New stack ? */ jz 1f lr %r15,%r4 -1: basr %r14,%r2 +1: lr %r14,%r2 /* r14: Function to call */ + lr %r2,%r3 /* r2 : Parameter for function*/ + basr %r14,%r14 /* Call function */ .gprregs_addr: .long .gprregs diff --git a/arch/s390/kernel/switch_cpu64.S b/arch/s390/kernel/switch_cpu64.S index d94aacc898c..5be3f43898f 100644 --- a/arch/s390/kernel/switch_cpu64.S +++ b/arch/s390/kernel/switch_cpu64.S @@ -42,7 +42,9 @@ smp_restart_cpu: ltgr %r4,%r4 /* New stack ? */ jz 1f lgr %r15,%r4 -1: basr %r14,%r2 +1: lgr %r14,%r2 /* r14: Function to call */ + lgr %r2,%r3 /* r2 : Parameter for function*/ + basr %r14,%r14 /* Call function */ .section .data,"aw",@progbits .gprregs: -- cgit v1.2.3-70-g09d2 From 8838101183bba239f100b0cfe31d9ebbfc2f1bd4 Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Mon, 4 Apr 2011 09:43:33 +0200 Subject: [S390] compile fix for latest binutils The latest binutils won't accept the stfl instruction with march=g5 which is the correct behaviour. Unfortunately head.S is assembled with -march=g5 even if the target cpu is z900 or later. To get 31-bit kernels compiled again the easiest fix is to use the .insn notation for the stfl instruction in head.S. Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S index 7061398341d..fb317bf2c37 100644 --- a/arch/s390/kernel/head.S +++ b/arch/s390/kernel/head.S @@ -460,7 +460,7 @@ startup: #ifndef CONFIG_MARCH_G5 # check capabilities against MARCH_{G5,Z900,Z990,Z9_109,Z10} xc __LC_STFL_FAC_LIST(8),__LC_STFL_FAC_LIST - stfl __LC_STFL_FAC_LIST # store facility list + .insn s,0xb2b10000,__LC_STFL_FAC_LIST # store facility list tm __LC_STFL_FAC_LIST,0x01 # stfle available ? jz 0f la %r0,0 -- cgit v1.2.3-70-g09d2