Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fbe76568 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky
Browse files

s390/smp: make absolute lowcore / cpu restart parameter accesses more robust



Setting the cpu restart parameters is done in three different fashions:
- directly setting the four parameters individually
- copying the four parameters with memcpy (using 4 * sizeof(long))
- copying the four parameters using a private structure

In addition code in entry*.S relies on a certain order of the restart
members of struct _lowcore.

Make all of this more robust to future changes by adding a
mem_absolute_assign(dest, val) define, which assigns val to dest
using absolute addressing mode. Also the load multiple instructions
in entry*.S have been split into separate load instruction so the
order of the struct _lowcore members doesn't matter anymore.

In addition move the prototypes of memcpy_real/absolute from uaccess.h
to processor.h. These memcpy* variants are not related to uaccess at all.
string.h doesn't seem to match as well, so lets use processor.h.

Also replace the eight byte array in struct _lowcore which represents a
misaliged u64 with a u64. The compiler will always create code that
handles the misaligned u64 correctly.

Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 72f6e3a8
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -302,12 +302,7 @@ struct _lowcore {
	 */
	__u64	ipib;				/* 0x0e00 */
	__u32	ipib_checksum;			/* 0x0e08 */
	/*
	 * Because the vmcore_info pointer is not 8 byte aligned it never
	 * should not be accessed directly. For accessing the pointer, first
	 * copy it to a local pointer variable.
	 */
	__u8	vmcore_info[8];			/* 0x0e0c */
	__u64	vmcore_info;			/* 0x0e0c */
	__u8	pad_0x0e14[0x0e18-0x0e14];	/* 0x0e14 */
	__u64	os_info;			/* 0x0e18 */
	__u8	pad_0x0e20[0x0f00-0x0e20];	/* 0x0e20 */
+10 −0
Original line number Diff line number Diff line
@@ -348,4 +348,14 @@ extern void (*s390_base_ext_handler_fn)(void);
	".previous\n"
#endif

extern int memcpy_real(void *, void *, size_t);
extern void memcpy_absolute(void *, void *, size_t);

#define mem_assign_absolute(dest, val) {			\
	__typeof__(dest) __tmp = (val);				\
								\
	BUILD_BUG_ON(sizeof(__tmp) != sizeof(val));		\
	memcpy_absolute(&(dest), &__tmp, sizeof(__tmp));	\
}

#endif                                 /* __ASM_S390_PROCESSOR_H           */
+0 −2
Original line number Diff line number Diff line
@@ -381,8 +381,6 @@ clear_user(void __user *to, unsigned long n)
	return n;
}

extern int memcpy_real(void *, void *, size_t);
extern void memcpy_absolute(void *, void *, size_t);
extern int copy_to_user_real(void __user *dest, void *src, size_t count);
extern int copy_from_user_real(void *dest, void __user *src, size_t count);

+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ int main(void)
	DEFINE(__LC_PANIC_STACK, offsetof(struct _lowcore, panic_stack));
	DEFINE(__LC_RESTART_STACK, offsetof(struct _lowcore, restart_stack));
	DEFINE(__LC_RESTART_FN, offsetof(struct _lowcore, restart_fn));
	DEFINE(__LC_RESTART_DATA, offsetof(struct _lowcore, restart_data));
	DEFINE(__LC_RESTART_SOURCE, offsetof(struct _lowcore, restart_source));
	DEFINE(__LC_USER_ASCE, offsetof(struct _lowcore, user_asce));
	DEFINE(__LC_INT_CLOCK, offsetof(struct _lowcore, int_clock));
	DEFINE(__LC_MCCK_CLOCK, offsetof(struct _lowcore, mcck_clock));
+3 −1
Original line number Diff line number Diff line
@@ -724,7 +724,9 @@ ENTRY(restart_int_handler)
	mvc	__PT_PSW(8,%r15),__LC_RST_OLD_PSW # store restart old psw
	ahi	%r15,-STACK_FRAME_OVERHEAD	# create stack frame on stack
	xc	0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
	lm	%r1,%r3,__LC_RESTART_FN		# load fn, parm & source cpu
	l	%r1,__LC_RESTART_FN		# load fn, parm & source cpu
	l	%r2,__LC_RESTART_DATA
	l	%r3,__LC_RESTART_SOURCE
	ltr	%r3,%r3				# test source cpu address
	jm	1f				# negative -> skip source stop
0:	sigp	%r4,%r3,SIGP_SENSE		# sigp sense to source cpu
Loading