lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250219142454.2761556-1-geert+renesas@glider.be>
Date: Wed, 19 Feb 2025 15:24:54 +0100
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: Claudiu Beznea <claudiu.beznea.uj@...renesas.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Jiri Slaby <jirislaby@...nel.org>,
	Wolfram Sang <wsa+renesas@...g-engineering.com>
Cc: linux-serial@...r.kernel.org,
	linux-renesas-soc@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH] serial: sh-sci: Save and restore SCDL and SCCKS

On (H)SCIF with a Baud Rate Generator for External Clock (BRG), there
are multiple ways to configure the requested serial speed.  If firmware
uses a different method than Linux, and if any debug info is printed
after the Bit Rate Register (SCBRR) is restored, but before termios is
reconfigured (which configures the alternative method), the system may
lock-up during resume.

Fix this by saving and restoring the contents of the Frequency Division
(DL) and Clock Select (CKS) registers as well.

Fixes: 22a6984c5b5df8ea ("serial: sh-sci: Update the suspend/resume support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
---
This can be reproduced on e.g. Salvator-X(S) by enabling the debug
print in sci_brg_calc(), and using s2ram with no_console_suspend.
---
 drivers/tty/serial/sh-sci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index df6512c9c0ff28db..70f34b8a93888eb9 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -109,6 +109,8 @@ struct sci_suspend_regs {
 	u16 scscr;
 	u16 scfcr;
 	u16 scsptr;
+	u16 scdl;
+	u16 sccks;
 	u8 scbrr;
 	u8 semr;
 };
@@ -3571,6 +3573,10 @@ static void sci_console_save(struct sci_port *s)
 		regs->scfcr = sci_serial_in(port, SCFCR);
 	if (sci_getreg(port, SCSPTR)->size)
 		regs->scsptr = sci_serial_in(port, SCSPTR);
+	if (sci_getreg(port, SCDL)->size)
+		regs->scdl = sci_serial_in(port, SCDL);
+	if (sci_getreg(port, SCCKS)->size)
+		regs->sccks = sci_serial_in(port, SCCKS);
 	if (sci_getreg(port, SCBRR)->size)
 		regs->scbrr = sci_serial_in(port, SCBRR);
 	if (sci_getreg(port, SEMR)->size)
@@ -3590,6 +3596,10 @@ static void sci_console_restore(struct sci_port *s)
 		sci_serial_out(port, SCFCR, regs->scfcr);
 	if (sci_getreg(port, SCSPTR)->size)
 		sci_serial_out(port, SCSPTR, regs->scsptr);
+	if (sci_getreg(port, SCDL)->size)
+		sci_serial_out(port, SCDL, regs->scdl);
+	if (sci_getreg(port, SCCKS)->size)
+		sci_serial_out(port, SCCKS, regs->sccks);
 	if (sci_getreg(port, SCBRR)->size)
 		sci_serial_out(port, SCBRR, regs->scbrr);
 	if (sci_getreg(port, SEMR)->size)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ