linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.18 02/27] s390/hibernate: fix error handling when suspend cpu != resume cpu
Date: Mon, 22 Oct 2018 06:18:59 -0400	[thread overview]
Message-ID: <20181022101924.40531-2-sashal@kernel.org> (raw)
In-Reply-To: <20181022101924.40531-1-sashal@kernel.org>

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

[ Upstream commit 55a5542a546238354d1f209f794414168cf8c71d ]

The resume code checks if the resume cpu is the same as the suspend cpu.
If not, and if it is also not possible to switch to the suspend cpu, an
error message should be printed and the resume process should be stopped
by loading a disabled wait psw.

The current logic is broken in multiple ways, the message is never printed,
and the disabled wait psw never loaded because the kernel panics before that:
- sam31 and SIGP_SET_ARCHITECTURE to ESA mode is wrong, this will break
  on the first 64bit instruction in sclp_early_printk().
- The init stack should be used, but the stack pointer is not set up correctly
  (missing aghi %r15,-STACK_FRAME_OVERHEAD).
- __sclp_early_printk() checks the sclp_init_state. If it is not
  sclp_init_state_uninitialized, it simply returns w/o printing anything.
  In the resumed kernel however, sclp_init_state will never be uninitialized.

This patch fixes those issues by removing the sam31/ESA logic, adding a
correct init stack pointer, and also introducing sclp_early_printk_force()
to allow using sclp_early_printk() even when sclp_init_state is not
uninitialized.

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/include/asm/sclp.h        |  3 ++-
 arch/s390/kernel/early_printk.c     |  2 +-
 arch/s390/kernel/swsusp.S           |  8 +++-----
 drivers/s390/char/sclp_early_core.c | 11 ++++++++---
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index 3cae9168f63c..e44a8d7959f5 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -108,7 +108,8 @@ int sclp_early_get_core_info(struct sclp_core_info *info);
 void sclp_early_get_ipl_info(struct sclp_ipl_info *info);
 void sclp_early_detect(void);
 void sclp_early_printk(const char *s);
-void __sclp_early_printk(const char *s, unsigned int len);
+void sclp_early_printk_force(const char *s);
+void __sclp_early_printk(const char *s, unsigned int len, unsigned int force);
 
 int _sclp_get_core_info(struct sclp_core_info *info);
 int sclp_core_configure(u8 core);
diff --git a/arch/s390/kernel/early_printk.c b/arch/s390/kernel/early_printk.c
index 9431784d7796..40c1dfec944e 100644
--- a/arch/s390/kernel/early_printk.c
+++ b/arch/s390/kernel/early_printk.c
@@ -10,7 +10,7 @@
 
 static void sclp_early_write(struct console *con, const char *s, unsigned int len)
 {
-	__sclp_early_printk(s, len);
+	__sclp_early_printk(s, len, 0);
 }
 
 static struct console sclp_early_console = {
diff --git a/arch/s390/kernel/swsusp.S b/arch/s390/kernel/swsusp.S
index a049a7b9d6e8..c1a080b11ae9 100644
--- a/arch/s390/kernel/swsusp.S
+++ b/arch/s390/kernel/swsusp.S
@@ -198,12 +198,10 @@ pgm_check_entry:
 
 	/* Suspend CPU not available -> panic */
 	larl	%r15,init_thread_union
-	ahi	%r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
+	aghi	%r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
+	aghi	%r15,-STACK_FRAME_OVERHEAD
 	larl	%r2,.Lpanic_string
-	lghi	%r1,0
-	sam31
-	sigp	%r1,%r0,SIGP_SET_ARCHITECTURE
-	brasl	%r14,sclp_early_printk
+	brasl	%r14,sclp_early_printk_force
 	larl	%r3,.Ldisabled_wait_31
 	lpsw	0(%r3)
 4:
diff --git a/drivers/s390/char/sclp_early_core.c b/drivers/s390/char/sclp_early_core.c
index eceba3858cef..2f61f5579aa5 100644
--- a/drivers/s390/char/sclp_early_core.c
+++ b/drivers/s390/char/sclp_early_core.c
@@ -210,11 +210,11 @@ static int sclp_early_setup(int disable, int *have_linemode, int *have_vt220)
  * Output one or more lines of text on the SCLP console (VT220 and /
  * or line-mode).
  */
-void __sclp_early_printk(const char *str, unsigned int len)
+void __sclp_early_printk(const char *str, unsigned int len, unsigned int force)
 {
 	int have_linemode, have_vt220;
 
-	if (sclp_init_state != sclp_init_state_uninitialized)
+	if (!force && sclp_init_state != sclp_init_state_uninitialized)
 		return;
 	if (sclp_early_setup(0, &have_linemode, &have_vt220) != 0)
 		return;
@@ -227,5 +227,10 @@ void __sclp_early_printk(const char *str, unsigned int len)
 
 void sclp_early_printk(const char *str)
 {
-	__sclp_early_printk(str, strlen(str));
+	__sclp_early_printk(str, strlen(str), 0);
+}
+
+void sclp_early_printk_force(const char *str)
+{
+	__sclp_early_printk(str, strlen(str), 1);
 }
-- 
2.17.1


  reply	other threads:[~2018-10-22 10:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 10:18 [PATCH AUTOSEL 4.18 01/27] ARM: dts: imx53-qsb: disable 1.2GHz OPP Sasha Levin
2018-10-22 10:18 ` Sasha Levin [this message]
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 03/27] perf report: Don't try to map ip to invalid map Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 04/27] Input: i8042 - enable keyboard wakeups by default when s2idle is used Sasha Levin
2018-10-22 16:58   ` Dmitry Torokhov
2018-10-23 15:48     ` Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 05/27] Input: mousedev - add a schedule point in mousedev_write() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 06/27] perf python: Use -Wno-redundant-decls to build with PYTHON=python3 Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 07/27] perf record: Use unmapped IP for inline callchain cursors Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 08/27] Input: evdev - add a schedule point in evdev_write() Sasha Levin
2018-10-22 17:02   ` Dmitry Torokhov
2018-10-23 15:49     ` Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 09/27] Input: uinput - add a schedule point in uinput_inject_events() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 10/27] rxrpc: Don't check RXRPC_CALL_TX_LAST after calling rxrpc_rotate_tx_window() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 11/27] rxrpc: Carry call state out of locked section in rxrpc_rotate_tx_window() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 12/27] rxrpc: Only take the rwind and mtu values from latest ACK Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 13/27] rxrpc: Fix connection-level abort handling Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 14/27] KVM: x86: support CONFIG_KVM_AMD=y with CONFIG_CRYPTO_DEV_CCP_DD=m Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 15/27] net: ena: fix warning in rmmod caused by double iounmap Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 16/27] net: ena: fix rare bug when failed restart/resume is followed by driver removal Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 17/27] net: ena: fix NULL dereference due to untimely napi initialization Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 18/27] libertas: call into generic suspend code before turning off power Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 19/27] gpio: Assign gpio_irq_chip::parents to non-stack pointer Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 20/27] IB/mlx5: Unmap DMA addr from HCA before IOMMU Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 21/27] rds: RDS (tcp) hangs on sendto() to unresponding address Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 22/27] selftests: rtnetlink.sh explicitly requires bash Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 23/27] selftests: udpgso_bench.sh " Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 24/27] vmlinux.lds.h: Fix incomplete .text.exit discards Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 25/27] vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 26/27] afs: Fix cell proc list Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 27/27] fs/fat/fatent.c: add cond_resched() to fat_count_free_clusters() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022101924.40531-2-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=gerald.schaefer@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).