Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	linux-mips@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH v3 01/10] MIPS: DEC: Ensure 32-bit stack location for o32 prom_printf()
Date: Tue, 26 May 2026 16:45:46 +0200	[thread overview]
Message-ID: <ahWyGm4X0ETXNupE@alpha.franken.de> (raw)
In-Reply-To: <alpine.DEB.2.21.2605062249160.46195@angie.orcam.me.uk>

On Wed, May 06, 2026 at 11:42:23PM +0100, Maciej W. Rozycki wrote:
> In 64-bit configurations calling any firmware entry points from a kernel 
> thread other than the initial one will result in a situation where the 
> stack has been placed in the XKPHYS 64-bit memory segment.
> 
> Consequently the stack pointer is no longer a 32-bit value and when the 
> 32-bit firmware code called uses 32-bit ALU operations to manipulate the 
> stack pointer, the calculated result is incorrect (in fact in the 64-bit 
> MIPS ISA almost all 32-bit ALU operations will produce an unpredictable 
> result when executed on 64-bit data) and control goes astray.
> 
> This may happen when no final console driver has been enabled in the
> configuration and consequently the initial console continues being used
> late into bootstrap, or with an upcoming change that will switch the zs
> driver to use a platform device, which in turn will make the console
> handover happen only after other kernel threads have already been
> started, and the kernel will hang at:
> 
>   pid_max: default: 32768 minimum: 301
> 
> or somewhat later, but always before:
> 
>   cblist_init_generic: Setting adjustable number of callback queues.
> 
> has been printed.
> 
> It seems that only the prom_printf() entry point is affected.  Of all 
> the other entry points wired only rex_slot_address() and rex_gettcinfo() 
> are called from a kernel thread other than the initial one, specifically 
> kernel_init(), and they are leaf functions that do no business with the 
> stack, having worked with no issue ever since 64-bit support was added 
> for the platform back in 2002.
> 
> To address this issue then, arrange for the stack to be switched in the 
> o32 wrapper as required for prom_printf() only, by supplying call_o32() 
> with a pointer to a chunk of initdata space, which is placed in the 
> CKSEG0 32-bit compatibility segment, observing that prom_printf() is 
> only called from console output handler and therefore with the console 
> lock held, implying no need for this code to be reentrant.
> 
> Other firmware entry points may be called with interrupts enabled and no 
> lock held, and may therefore require that call_o32() be reentrant.  They 
> trigger no issue at this point and "if it ain't broke, don't fix it," so 
> just leave them alone.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
> Cc: stable@vger.kernel.org # v2.6.12+
> ---
> No change from v2, 
> <https://lore.kernel.org/r/alpine.DEB.2.21.2605010132340.38805@angie.orcam.me.uk/>.
> 
> New change in v2.
> ---
>  arch/mips/dec/prom/init.c        |    6 +++++-
>  arch/mips/include/asm/dec/prom.h |   15 +++++++++++++--
>  2 files changed, 18 insertions(+), 3 deletions(-)

applied to mips-next

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

  reply	other threads:[~2026-05-26 14:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 22:42 [PATCH v3 00/10] MIPS: DEC: Fix serial device regressions + RTC cleanup Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 01/10] MIPS: DEC: Ensure 32-bit stack location for o32 prom_printf() Maciej W. Rozycki
2026-05-26 14:45   ` Thomas Bogendoerfer [this message]
2026-05-06 22:42 ` [PATCH v3 02/10] MIPS: DEC: Prevent initial console buffer from landing in XKPHYS Maciej W. Rozycki
2026-05-26 14:46   ` Thomas Bogendoerfer
2026-05-06 22:42 ` [PATCH v3 03/10] serial: dz: Fix bootconsole message clobbering at chip reset Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 04/10] serial: dz: Fix bootconsole handover lockup Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 05/10] serial: zs: " Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 06/10] serial: zs: Switch to using channel reset Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 07/10] serial: dz: Convert to use a platform device Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 08/10] serial: zs: " Maciej W. Rozycki
2026-05-06 22:42 ` [PATCH v3 09/10] serial: dz: Enable modular build Maciej W. Rozycki
2026-05-06 22:43 ` [PATCH v3 10/10] MIPS: DEC: Ensure RTC platform device deregistration upon failure Maciej W. Rozycki
2026-05-26 14:49   ` Thomas Bogendoerfer
2026-05-22 15:15 ` [PATCH v3 00/10] MIPS: DEC: Fix serial device regressions + RTC cleanup Maciej W. Rozycki
2026-05-26 14:48   ` Thomas Bogendoerfer
2026-05-26 15:08     ` Maciej W. Rozycki

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=ahWyGm4X0ETXNupE@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    /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