From: Vasily Gorbik <gor@linux.ibm.com>
Date: Fri, 22 Nov 2019 12:19:16 +0100
Subject: s390: disable preemption when switching to nodat stack with
CALL_ON_STACK
Git-commit: 7f28dad395243c5026d649136823bbc40029a828
Patch-mainline: v5.5-rc1
References: jsc#SLE-11178
Make sure preemption is disabled when temporary switching to nodat
stack with CALL_ON_STACK helper, because nodat stack is per cpu.
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
---
arch/s390/kernel/machine_kexec.c | 2 ++
arch/s390/mm/maccess.c | 12 +++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
--- a/arch/s390/kernel/machine_kexec.c
+++ b/arch/s390/kernel/machine_kexec.c
@@ -162,7 +162,9 @@ static int kdump_csum_valid(struct kimag
#ifdef CONFIG_CRASH_DUMP
int rc;
+ preempt_disable();
rc = CALL_ON_STACK(do_start_kdump, S390_lowcore.nodat_stack, 1, image);
+ preempt_enable();
return rc ? 0 : -EINVAL;
#else
return -EINVAL;
--- a/arch/s390/mm/maccess.c
+++ b/arch/s390/mm/maccess.c
@@ -114,9 +114,15 @@ static unsigned long _memcpy_real(unsign
*/
int memcpy_real(void *dest, void *src, size_t count)
{
- if (S390_lowcore.nodat_stack != 0)
- return CALL_ON_STACK(_memcpy_real, S390_lowcore.nodat_stack,
- 3, dest, src, count);
+ int rc;
+
+ if (S390_lowcore.nodat_stack != 0) {
+ preempt_disable();
+ rc = CALL_ON_STACK(_memcpy_real, S390_lowcore.nodat_stack, 3,
+ dest, src, count);
+ preempt_enable();
+ return rc;
+ }
/*
* This is a really early memcpy_real call, the stacks are
* not set up yet. Just call _memcpy_real on the early boot