From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Jaeyeong Lee <lee@jaeyeong.cc>,
Bradley Morgan <bradley.morgan@linux.dev>
Cc: u-boot@lists.u-boot-project.org, Heiko Schocher <hs@nabladev.com>,
Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH] serial: mpc8xx: prevent DPRAM overlap with SPI descriptors
Date: Fri, 27 Nov 2026 17:42:16 +0100 [thread overview]
Message-ID: <f917b336-db53-4bfa-9caf-11827755ff03@kernel.org> (raw)
In-Reply-To: <179579209485.3201180.9953622119991566579.u-boot@jaeyeong.cc>
Hi Jaeyeong,
Le 27/11/2026 à 16:08, Jaeyeong Lee a écrit :
> [Vous ne recevez pas souvent de courriers de lee@jaeyeong.cc. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>
> The MPC8xx serial object starts at DPRAM offset 0x800 while the SPI
> receive descriptor starts at 0x840. The serial receive buffer begins at
> offset 0x14 and is followed by the one-byte transmit buffer.
>
> Limit SYS_SMC_RXBUFLEN to 43 when MPC8XX_SPI is enabled. A value of 44
> would put the transmit byte at 0x840, and larger values also overlap the
> SPI descriptor with the receive buffer. Add a static assertion to keep
> future layout changes from reintroducing the overlap.
Not sure we need something so sophisticated. No defconfig redefines it
so everyone uses it likely with the default value of 1.
Just limit it to 32 regardless of whether SPI is active or not, that
should be enough. I don't like the idea of a dependency between the two
drivers.
We don't need that assert, it should be enough to put a comment close to
the definition of CPM_SPI_BASE.
Christophe
>
> Link: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fu-boot%2F179024275173.70674.16356876476594066413%40proton.me%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7Cdff89d20fc924d5d92df08df4c98563f%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639313889303482082%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=%2BX3U4TMa8vSsaduwcMtKmvbp9U8ghNs1OgNAws11K1k%3D&reserved=0
> Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
> ---
> drivers/serial/Kconfig | 4 ++++
> drivers/serial/serial_mpc8xx.c | 4 ++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 9ebc251d891..73c36ea79b0 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -1201,6 +1201,7 @@ config SYS_SMC_RXBUFLEN
> int "Console Rx buffer length"
> depends on MPC8XX_CONS
> default 1
> + range 1 43 if MPC8XX_SPI
> help
> With CONFIG_SYS_SMC_RXBUFLEN it is possible to define
> the maximum receive buffer length for the SMC.
> @@ -1208,6 +1209,9 @@ config SYS_SMC_RXBUFLEN
> If using CONFIG_SYS_SMC_RXBUFLEN also CONFIG_SYS_MAXIDLE
> must be defined, to setup the maximum idle timeout for
> the SMC.
> + When the MPC8XX SPI driver is enabled, the receive buffer is
> + limited so that it and the transmit byte do not overlap the
> + SPI buffer descriptors in dual-port RAM.
>
> config SYS_MAXIDLE
> int "maximum idle timeout"
> diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c
> index 9ce3fc3d9ec..feb0c905594 100644
> --- a/drivers/serial/serial_mpc8xx.c
> +++ b/drivers/serial/serial_mpc8xx.c
> @@ -36,6 +36,10 @@ struct serialbuffer {
> uchar txbuf; /* tx buffers */
> };
>
> +static_assert(!IS_ENABLED(CONFIG_MPC8XX_SPI) ||
> + sizeof(struct serialbuffer) <= CPM_SPI_BASE - CPM_SERIAL_BASE,
> + "MPC8xx serial buffers overlap the SPI descriptors");
> +
> static void serial_setdivisor(cpm8xx_t __iomem *cp, int baudrate)
> {
> int divisor = (gd->cpu_clk + 8 * baudrate) / 16 / baudrate;
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2026-11-27 16:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <179024275173.70674.16356876476594066413@proton.me>
2026-09-25 4:30 ` [SECURITY] MPC8xx serial RX buffer overlaps SPI descriptors in DPRAM Heiko Schocher
2026-11-27 15:08 ` [PATCH] serial: mpc8xx: prevent DPRAM overlap with SPI descriptors Jaeyeong Lee
2026-11-27 16:42 ` Christophe Leroy (CS GROUP) [this message]
2026-11-27 17:09 ` Bradley Morgan
2026-11-28 8:00 ` Christophe Leroy (CS GROUP)
2026-11-27 23:22 ` [PATCH v2] serial: mpc8xx: cap SMC receive buffer length Jaeyeong Lee
2026-11-28 7:58 ` Christophe Leroy (CS GROUP)
2026-11-30 5:19 ` Heiko Schocher
2026-11-30 16:15 ` Bradley Morgan
2026-12-01 4:16 ` Heiko Schocher
2026-11-30 19:32 ` Bradley Morgan
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=f917b336-db53-4bfa-9caf-11827755ff03@kernel.org \
--to=chleroy@kernel.org \
--cc=bradley.morgan@linux.dev \
--cc=hs@nabladev.com \
--cc=lee@jaeyeong.cc \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.