xen/arm: Add support for S32CC platforms and LINFlexD UART
cover xen/arm: Add support for S32CC platforms and LINFlexD UART
From: Andrei Cherechesu <[email protected]>
This patch series adds support for NXP Automotive S32CC platform family, which includes S32G [0] and S32R [1].
First patch adds the driver for the NXP LINFlexD UART, available on S32V, S32G and S32R automotive processors. The compatibles in the driver match the ones in upstream Linux [2]. The second patch adds early printk support via LINFlexD UART.
The third patch introduces the S32CC platforms and adds the platform-specific code, which enables forwarding SCMI over SMC calls to software running at EL3. The fourth patch adds support for an early printk menuconfig option for S32CC platforms using the LINFlexD UART.
The fifth patch enables the workaround for ARM Cortex-A53 erratum 1530924, already implemented in Xen for other cores via ARM64_WORKAROUND_AT_SPECULATE.
[0] https://www.nxp.com/products/processors-and-microcontrollers/s32-automotive-platform/s32g-vehicle-network-processors:S32G-PROCESSORS
[1] https://www.nxp.com/products/processors-and-microcontrollers/s32-automotive-platform/s32r-radar-processing:S32R-FAMILY
[2] https://elixir.bootlin.com/linux/v6.11-rc7/source/Documentation/devicetree/bindings/serial/fsl,s32-linflexuart.yaml#L27
Andrei Cherechesu (5):
xen/arm: Add NXP LINFlexD UART Driver
xen/arm: Add NXP LINFlexD UART early printk support xen/arm: platforms: Add NXP S32CC platform code xen/arm: Enable early printk for S32CC via LINFlexD UART xen/arm: Enable workaround for Cortex-A53 erratum #1530924
docs/misc/arm/silicon-errata.txt | 1 + xen/arch/arm/Kconfig.debug | 18 ++ xen/arch/arm/arm64/debug-linflex.inc | 58 ++++ xen/arch/arm/cpuerrata.c | 6 + xen/arch/arm/include/asm/linflex-uart.h | 62 ++++ xen/arch/arm/platforms/Kconfig | 10 + xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/s32cc.c | 84 ++++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/linflex-uart.c | 365 ++++++++++++++++++++++++ 11 files changed, 614 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-linflex.inc create mode 100644 xen/arch/arm/include/asm/linflex-uart.h create mode 100644 xen/arch/arm/platforms/s32cc.c create mode 100644 xen/drivers/char/linflex-uart.c
Signature · 1 line
2.45.2
PATCH 1/5 xen/arm: Add NXP LINFlexD UART Driver
From: Andrei Cherechesu <[email protected]>
The LINFlexD UART is an UART controller available on NXP S32 processors family targeting automotive (for example: S32G2, S32G3, S32R).
S32G3 Reference Manual:
https://www.nxp.com/webapp/Download?colCode=RMS32G3.
--- xen/arch/arm/include/asm/linflex-uart.h | 62 ++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/linflex-uart.c | 365 ++++++++++++++++++++++++ 4 files changed, 436 insertions(+) create mode 100644 xen/arch/arm/include/asm/linflex-uart.h create mode 100644 xen/drivers/char/linflex-uart.c
xen/arch/arm/include/asm/linflex-uart.h new file +62 -0
@@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* xen/arch/arm/include/asm/linflex-uart.h +* +* Common constant definition between early printk and the UART driver +* for NXP LINFlexD UART. +* +* Andrei Cherechesu <[email protected]> +* Copyright 2018, 2021, 2024 NXP +*/ + +#ifndef __ASM_ARM_LINFLEX_UART_H +#define __ASM_ARM_LINFLEX_UART_H + +/* 32-bit register offsets */ +#define LINCR1 (0x0) +#define LINIER (0x4) +#define LINSR (0x8) +#define UARTCR (0x10) +#define UARTSR (0x14) +#define LINFBRR (0x24) +#define LINIBRR (0x28) +#define BDRL (0x38) +#define BDRM (0x3C) +#define UARTPTO (0x50) + +#define LINCR1_INIT BIT(0, U) +#define LINCR1_MME BIT(4, U) +#define LINCR1_BF BIT(7, U) + +#define LINSR_LINS GENMASK(15, 12) +#define LINSR_LINS_INIT BIT(12, U) + +#define LINIER_DRIE BIT(2, U) +#define LINIER_DTIE BIT(1, U) + +#define UARTCR_UART BIT(0, U) +#define UARTCR_WL0 BIT(1, U) +#define UARTCR_PC0 BIT(3, U) +#define UARTCR_TXEN BIT(4, U) +#define UARTCR_RXEN BIT(5, U) +#define UARTCR_PC1 BIT(6, U) +#define UARTCR_TFBM BIT(8, U) +#define UARTCR_RFBM BIT(9, U) +#define UARTCR_RDFLRFC GENMASK(12, 10) +#define UARTCR_TDFLTFC GENMASK(15, 13) +#define UARTCR_ROSE BIT(23, U) +#define UARTCR_OSR GENMASK(27, 24) + +#define UARTSR_DTFTFF BIT(1, U) +#define UARTSR_DRFRFE BIT(2, U) + +#endif /* __ASM_ARM_LINFLEX_UART_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/drivers/char/Kconfig +8 -0
@@ -13,6 +13,14 @@ config HAS_CADENCE_UART This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq based board, say Y. +config HAS_LINFLEX + bool "NXP LINFlexD UART driver" + default y + depends on ARM_64 + help + This selects the NXP LINFlexD UART. If you have an NXP S32G or S32R + based board, say Y. + config HAS_IMX_LPUART bool "i.MX LPUART driver" default y
xen/drivers/char/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_HAS_SCIF) += scif-uart.o obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o obj-$(CONFIG_XHCI) += xhci-dbc.o obj-$(CONFIG_HAS_IMX_LPUART) += imx-lpuart.o +obj-$(CONFIG_HAS_LINFLEX) += linflex-uart.o obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.o obj-$(CONFIG_XEN_GUEST) += xen_pv_console.o
xen/drivers/char/linflex-uart.c new file +365 -0
365 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH v1 1/5] xen/arm: Add NXP LINFlexD UART Driver
Hi,
Quoted 8 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
The LINFlexD UART is an UART controller available on NXP S32 processors family targeting automotive (for example: S32G2, S32G3, S32R).
S32G3 Reference Manual:
https://www.nxp.com/webapp/Download?colCode=RMS32G3.
It looks like you need to create an account. Is there any public version of the specification?
Quoted 18 lines
Signed-off-by Andrei Cherechesu <[email protected]>Signed-off-by Peter van der Perk <[email protected]>--- xen/arch/arm/include/asm/linflex-uart.h | 62 ++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/linflex-uart.c | 365 ++++++++++++++++++++++++ 4 files changed, 436 insertions(+)create mode 100644
xen/arch/arm/include/asm/linflex-uart.hcreate mode 100644xen/drivers/char/linflex-uart.cxen/arch/arm/include/asm/linflex-uart.h new file +0
-0
xen/arch/arm/include/asm/linflex-uart.h line 1
Quoted 1 line
xen/arch/arm/include/asm/linflex-uart.h new file +1
-0@@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */
The identifier GPL-2.0 was deprecated (see LICENSES/GPL-2.0). The new tag should be GPL-2.0-only. The resulting license is the same.
Quoted 98 lines
xen/arch/arm/include/asm/linflex-uart.h new file +61
-0+/* +* xen/arch/arm/include/asm/linflex-uart.h +* +* Common constant definition between early printk and the UART driver +* for NXP LINFlexD UART. +* +* Andrei Cherechesu <[email protected]> +* Copyright 2018, 2021, 2024 NXP +*/ + +#ifndef __ASM_ARM_LINFLEX_UART_H +#define __ASM_ARM_LINFLEX_UART_H + +/* 32-bit register offsets */ +#define LINCR1 (0x0) +#define LINIER (0x4) +#define LINSR (0x8) +#define UARTCR (0x10) +#define UARTSR (0x14) +#define LINFBRR (0x24) +#define LINIBRR (0x28) +#define BDRL (0x38) +#define BDRM (0x3C) +#define UARTPTO (0x50) + +#define LINCR1_INIT BIT(0, U) +#define LINCR1_MME BIT(4, U) +#define LINCR1_BF BIT(7, U) + +#define LINSR_LINS GENMASK(15, 12) +#define LINSR_LINS_INIT BIT(12, U) + +#define LINIER_DRIE BIT(2, U) +#define LINIER_DTIE BIT(1, U) + +#define UARTCR_UART BIT(0, U) +#define UARTCR_WL0 BIT(1, U) +#define UARTCR_PC0 BIT(3, U) +#define UARTCR_TXEN BIT(4, U) +#define UARTCR_RXEN BIT(5, U) +#define UARTCR_PC1 BIT(6, U) +#define UARTCR_TFBM BIT(8, U) +#define UARTCR_RFBM BIT(9, U) +#define UARTCR_RDFLRFC GENMASK(12, 10) +#define UARTCR_TDFLTFC GENMASK(15, 13) +#define UARTCR_ROSE BIT(23, U) +#define UARTCR_OSR GENMASK(27, 24) + +#define UARTSR_DTFTFF BIT(1, U) +#define UARTSR_DRFRFE BIT(2, U) + +#endif /* __ASM_ARM_LINFLEX_UART_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/char/Kconfig +8
-0@@ -13,6 +13,14 @@ config HAS_CADENCE_UART This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq based board, say Y. +config HAS_LINFLEX + bool "NXP LINFlexD UART driver" + default y + depends on ARM_64 + help + This selects the NXP LINFlexD UART. If you have an NXP S32G or S32R + based board, say Y. + config HAS_IMX_LPUART bool "i.MX LPUART driver" default yxen/drivers/char/Makefile +1
-0@@ -10,6 +10,7 @@ obj-$(CONFIG_HAS_SCIF) += scif-uart.o obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o obj-$(CONFIG_XHCI) += xhci-dbc.o obj-$(CONFIG_HAS_IMX_LPUART) += imx-lpuart.o +obj-$(CONFIG_HAS_LINFLEX) += linflex-uart.o obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.o obj-$(CONFIG_XEN_GUEST) += xen_pv_console.oxen/drivers/char/linflex-uart.c new file +0
-0
xen/drivers/char/linflex-uart.c line 1
Quoted 1 line
xen/drivers/char/linflex-uart.c new file +1
-0@@ -0,0 +1,365 @@ +/* SPDX-License-Identifier: GPL-2.0 */
Ditto.
xen/drivers/char/linflex-uart.c line 14
Quoted 13 lines
xen/drivers/char/linflex-uart.c new file +13
-0+/* +* xen/drivers/char/linflex-uart.c +* +* Driver for NXP LINFlexD UART. +* +* Andrei Cherechesu <[email protected]> +* Copyright 2018, 2021-2022, 2024 NXP +*/ + +#include <xen/config.h> +#include <xen/console.h> +#include <xen/errno.h> +#include <xen/serial.h>
In Xen, we tend to order the include alphabetically within the same directory. So this wants to be after xen/mm.h.
Quoted 29 lines
xen/drivers/char/linflex-uart.c new file +29
-0+#include <xen/init.h> +#include <xen/irq.h> +#include <xen/mm.h> +#include <asm/device.h> +#include <asm/io.h> +#include <asm/linflex-uart.h> + +#define LINFLEX_CLK_FREQ (125000000) +#define LINFLEX_BAUDRATE (115200) +#define LINFLEX_LDIV_MULTIPLIER (16) + +static struct linflex_uart { +uint32_t baud, clock_hz; +uint32_t irq; +char __iomem *regs; +struct irqaction irqaction; +struct vuart_info vuart; +} linflex_com; + +static uint32_t linflex_uart_readl (struct linflex_uart *uart,uint32_t off) +{ +return readl (uart->regs + off); +} + +static void linflex_uart_writel (struct linflex_uart *uart,uint32_t off, +uint32_t val) +{ +writel (val, uart->regs + off); +}
xen/drivers/char/linflex-uart.c line 53
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+ +static void linflex_uart_writeb (struct linflex_uart *uart,uint32_t off, +uint8_t val) +{ +writeb (val, uart->regs + off); +} + +static uint32_t linflex_uart_get_osr (uint32_t uartcr) +{ +return (uartcr &UARTCR_OSR ) >>24 ;
Please provide a define for 24. This would also make easier to correlate with UARTCR_OSR.
xen/drivers/char/linflex-uart.c line 56
Quoted 3 lines
xen/drivers/char/linflex-uart.c new file +3
-0+} + +static uint32_t linflex_uart_tx_fifo_mode (struct linflex_uart *uart)
AFAICT, UARTCR_TFBM is one-bit. So should this return a bool?
xen/drivers/char/linflex-uart.c line 61
Quoted 5 lines
xen/drivers/char/linflex-uart.c new file +5
-0+{ +return linflex_uart_readl (uart,UARTCR ) &UARTCR_TFBM ; +} + +static uint32_t linflex_uart_rx_fifo_mode (struct linflex_uart *uart)
Same here.
Quoted 8 lines
xen/drivers/char/linflex-uart.c new file +8
-0+{ +return linflex_uart_readl (uart,UARTCR ) &UARTCR_RFBM ; +} + +static uint32_t linflex_uart_ldiv_multiplier (struct linflex_uart *uart) +{ +uint32_t uartcr, mul =LINFLEX_LDIV_MULTIPLIER ; +
xen/drivers/char/linflex-uart.c line 79
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+ uartcr =linflex_uart_readl (uart,UARTCR ); +if ( uartcr &UARTCR_ROSE ) + mul =linflex_uart_get_osr (uartcr); + +return mul; +} + +static void linflex_uart_flush (struct serial_port *port) +{ +struct linflex_uart *uart = port->uart;
Above, youa re using tab hard but above you use soft tab. Is the code intended to follow Xen coding style? If so, you want to use soft tab.
xen/drivers/char/linflex-uart.c line 83
Quoted 4 lines
xen/drivers/char/linflex-uart.c new file +4
-0+ +if (linflex_uart_tx_fifo_mode (uart) ) +while (linflex_uart_readl (uart,UARTCR ) &UARTCR_TDFLTFC ); +cpu_relax ();
The indentation is really confusing here. It leads to think that cpu_relax() should be part of while() but you are using ';'. I guess you really intended to have cpu_relax() within the while loop?
xen/drivers/char/linflex-uart.c line 87
Quoted 4 lines
xen/drivers/char/linflex-uart.c new file +4
-0+ +if (linflex_uart_rx_fifo_mode (uart) ) +while (linflex_uart_readl (uart,UARTCR ) &UARTCR_RDFLRFC ); +cpu_relax ();
Same here.
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+} + +static void __init linflex_uart_init_preirq (struct serial_port *port) +{ +struct linflex_uart *uart = port->uart; +uint32_t ibr, fbr, divisr, dividr, ctrl;
xen/drivers/char/linflex-uart.c line 103
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+ +/* Disable RX/TX before init mode */ + ctrl =linflex_uart_readl (uart,UARTCR ); + ctrl &= ~(UARTCR_RXEN |UARTCR_TXEN ); +linflex_uart_writel (uart,UARTCR , ctrl); + +/* +* Smoothen the transition from early_printk by waiting +* for all pending characters to transmit +*/
The indentation for comment in Xen is:
/*
* Foor
* Bar
*/
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+linflex_uart_flush (port); + +/* Init mode */ + ctrl =LINCR1_INIT ; +linflex_uart_writel (uart,LINCR1 , ctrl); + +/* Waiting for init mode entry */ +while ( (linflex_uart_readl (uart,LINSR ) &LINSR_LINS ) !=LINSR_LINS_INIT ) +cpu_relax (); +
xen/drivers/char/linflex-uart.c line 123
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+/* Set Master Mode */ + ctrl |=LINCR1_MME ; +linflex_uart_writel (uart,LINCR1 , ctrl); + +/* Provide data bits, parity, stop bit, etc */ + divisr = uart->clock_hz; + dividr = (uint32_t )(uart->baud *linflex_uart_ldiv_multiplier (uart)); + + ibr = (uint32_t )(divisr / dividr); + fbr = (uint32_t )((divisr % dividr) *16 / dividr) &0xF ;
On the 3 lines above, why do you need to cast to 32-bit? Is this because the result is 64-bit? If so, why do you need to ignore the top bits?
Quoted 43 lines
xen/drivers/char/linflex-uart.c new file +42
-0+linflex_uart_writel (uart,LINIBRR , ibr); +linflex_uart_writel (uart,LINFBRR , fbr); + +/* Set preset timeout register value */ +linflex_uart_writel (uart,UARTPTO ,0xF ); + +/* Setting UARTCR[UART] bit is required for writing other bits in UARTCR */ +linflex_uart_writel (uart,UARTCR ,UARTCR_UART ); + +/* 8 bit data, no parity, UART mode, Buffer mode */ +linflex_uart_writel (uart,UARTCR ,UARTCR_PC1 |UARTCR_PC0 |UARTCR_WL0 | +UARTCR_UART ); + +/* end init mode */ + ctrl =linflex_uart_readl (uart,LINCR1 ); + ctrl &= ~LINCR1_INIT ; +linflex_uart_writel (uart,LINCR1 , ctrl); + +/* Enable RX/TX after exiting init mode */ + ctrl =linflex_uart_readl (uart,UARTCR ); + ctrl |=UARTCR_RXEN |UARTCR_TXEN ; +linflex_uart_writel (uart,UARTCR , ctrl); +} + +static void linflex_uart_interrupt (int irq,void *data) +{ +struct serial_port *port = data; +struct linflex_uart *uart = port->uart; +uint32_t sts; + + sts =linflex_uart_readl (uart,UARTSR ); + +if ( sts &UARTSR_DRFRFE ) +serial_rx_interrupt (port); + +if ( sts &UARTSR_DTFTFF ) +serial_tx_interrupt (port); +} + +static void __init linflex_uart_init_postirq (struct serial_port *port) +{ +struct linflex_uart *uart = port->uart;
xen/drivers/char/linflex-uart.c line 176
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+uint32_t temp; + + uart->irqaction.handler = linflex_uart_interrupt; + uart->irqaction.name ="linflex_uart" ; + uart->irqaction.dev_id = port; + +if (setup_irq (uart->irq,0 , &uart->irqaction) !=0 ) + { +dprintk (XENLOG_ERR ,"Failed to allocate linflex_uart IRQ %d\n" , + uart->irq);
NIT: This should only be called once during boot. So I would consider to use printk() so it can be printed in production.
xen/drivers/char/linflex-uart.c line 184
Quoted 8 lines
xen/drivers/char/linflex-uart.c new file +8
-0+return ; + } + +/* Enable interrupts */ + temp =linflex_uart_readl (uart,LINIER ); + temp |= (LINIER_DRIE |LINIER_DTIE ); +linflex_uart_writel (uart,LINIER , temp); +dprintk (XENLOG_DEBUG ,"IRQ %d enabled\n" , uart->irq);
Same here.
xen/drivers/char/linflex-uart.c line 197
Quoted 13 lines
xen/drivers/char/linflex-uart.c new file +13
-0+} + +static int linflex_uart_tx_ready (struct serial_port *port) +{ +struct linflex_uart *uart = port->uart; + +if (linflex_uart_tx_fifo_mode (uart) ) +return (linflex_uart_readl (uart,UARTSR ) &UARTSR_DTFTFF ) ==0 ?1 :0 ; + +/* +* Buffer Mode => TX is waited to be ready after sending a char, +* so we can assume it is always ready before. +*/
Coding style. See above how it should be done for multi-line comments.
Quoted 50 lines
xen/drivers/char/linflex-uart.c new file +50
-0+return 1 ; +} + +static void linflex_uart_putc (struct serial_port *port,char c) +{ +struct linflex_uart *uart = port->uart; +uint32_t uartsr; + +if ( c =='\n' ) +linflex_uart_putc (port,'\r' ); + +linflex_uart_writeb (uart,BDRL , c); + +/* Buffer Mode */ +if ( !linflex_uart_tx_fifo_mode (uart) ) + { +while ( (linflex_uart_readl (uart,UARTSR ) &UARTSR_DTFTFF ) ==0 ) +cpu_relax (); + + uartsr =linflex_uart_readl (uart,UARTSR ) | (UARTSR_DTFTFF ); +linflex_uart_writel (uart,UARTSR , uartsr); + } +} + +static int linflex_uart_getc (struct serial_port *port,char *pc) +{ +struct linflex_uart *uart = port->uart; +uint32_t ch, uartsr, rx_fifo_mode; + + rx_fifo_mode =linflex_uart_rx_fifo_mode (uart); + +if ( rx_fifo_mode ) +while (linflex_uart_readl (uart,UARTSR ) &UARTSR_DRFRFE ) +cpu_relax (); +else +while ( !(linflex_uart_readl (uart,UARTSR ) &UARTSR_DRFRFE ) ) +cpu_relax (); + + ch =linflex_uart_readl (uart,BDRM ); + *pc = ch &0xff ; + +if ( !rx_fifo_mode ) { + uartsr =linflex_uart_readl (uart,UARTSR ) |UARTSR_DRFRFE ; +linflex_uart_writel (uart,UARTSR , uartsr); + } + +return 1 ; +} + +static int __init linflex_uart_irq (struct serial_port *port)
xen/drivers/char/linflex-uart.c line 257
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+{ +struct linflex_uart *uart = port->uart; + +return ((uart->irq >0 ) ? uart->irq :-1 ); +} + +static const struct vuart_info *linflex_uart_vuart_info ( +struct serial_port *port) +{ +struct linflex_uart *uart = port->uart;
NIT: You are not modifying uart. So this coul be const.
Quoted 98 lines
xen/drivers/char/linflex-uart.c new file +98
-0+ +return &uart->vuart; +} + +static void linflex_uart_start_tx (struct serial_port *port) +{ +struct linflex_uart *uart = port->uart; +uint32_t temp; + + temp =linflex_uart_readl (uart,LINIER ); +linflex_uart_writel (uart,LINIER , temp |LINIER_DTIE ); +} + +static void linflex_uart_stop_tx (struct serial_port *port) +{ +struct linflex_uart *uart = port->uart; +uint32_t temp; + + temp =linflex_uart_readl (uart,LINIER ); + temp &= ~(LINIER_DTIE ); +linflex_uart_writel (uart,LINIER , temp); +} + +static struct uart_driver __read_mostly linflex_uart_driver = { + .init_preirq = linflex_uart_init_preirq, + .init_postirq = linflex_uart_init_postirq, + .tx_ready = linflex_uart_tx_ready, + .putc = linflex_uart_putc, + .flush = linflex_uart_flush, + .getc = linflex_uart_getc, + .irq = linflex_uart_irq, + .start_tx = linflex_uart_start_tx, + .stop_tx = linflex_uart_stop_tx, + .vuart_info = linflex_uart_vuart_info, +}; + +static int __init linflex_uart_init (struct dt_device_node *dev,const void *data) +{ +const char *config = data; +struct linflex_uart *uart; +paddr_t addr, size; +int res; + +if (strcmp (config,"" ) ) +printk ("WARNING: UART configuration is not supported\n" ); + + uart = &linflex_com; + + res =dt_device_get_paddr (dev,0 , &addr, &size); +if ( res ) + { +printk ("linflex-uart: Unable to retrieve the base address of the UART\n" ); +return res; + } + + res =platform_get_irq (dev,0 ); +if ( res <0 ) + { +printk ("linflex-uart: Unable to retrieve the IRQ\n" ); +return -EINVAL ; + } + uart->irq = res; + + uart->regs =ioremap_nocache (addr, size); +if ( !uart->regs ) + { +printk ("linflex-uart: Unable to map the UART memory\n" ); +return -ENOMEM ; + } + + uart->clock_hz =LINFLEX_CLK_FREQ ; + uart->baud =LINFLEX_BAUDRATE ; + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off =BDRL ; + uart->vuart.status_off =UARTSR ; + uart->vuart.status =UARTSR_DTFTFF ; + +/* Register with generic serial driver */ +serial_register_uart (SERHND_DTUART , &linflex_uart_driver, uart); + +dt_device_set_used_by (dev,DOMID_XEN ); + +return 0 ; +} + +static const struct dt_device_match linflex_uart_dt_compat[]__initconst = +{ +DT_MATCH_COMPATIBLE ("nxp,s32g2-linflexuart" ), +DT_MATCH_COMPATIBLE ("nxp,s32g3-linflexuart" ), +DT_MATCH_COMPATIBLE ("fsl,s32v234-linflexuart" ), + {/* sentinel */ }, +}; + +DT_DEVICE_START (linflex_uart,"NXP LINFlexD UART" ,DEVICE_SERIAL ) + .dt_match = linflex_uart_dt_compat, + .init = linflex_uart_init,
xen/drivers/char/linflex-uart.c line 365
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+DT_DEVICE_END + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 1/5] xen/arm: Add NXP LINFlexD UART Driver
Hi, Julien, and thank you for the review!
Quoted 5 lines · Julien Grall
Hi,
Quoted 2 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Quoted 9 lines
Quoted 6 lines
The LINFlexD UART is an UART controller available on NXP S32 processors family targeting automotive (for example: S32G2, S32G3, S32R).
S32G3 Reference Manual:
https://www.nxp.com/webapp/Download?colCode=RMS32G3.It looks like you need to create an account. Is there any public version of the specification?
Unfortunately, the Reference Manual requires registration on NXP website, as per company policy. The only public resource I can provide is the Data Sheet: https://www.nxp.com/docs/en/data-sheet/S32G3.pdf.
Quoted 12 lines
Quoted 12 lines
Signed-off-by Andrei Cherechesu <[email protected]>Signed-off-by Peter van der Perk <[email protected]>---
xen/arch/arm/include/asm/linflex-uart.h| 62 ++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/linflex-uart.c | 365 ++++++++++++++++++++++++4 files changed, 436 insertions(+)create mode 100644
xen/arch/arm/include/asm/linflex-uart.hcreate mode 100644xen/drivers/char/linflex-uart.c
Quoted 9 lines
xen/arch/arm/include/asm/linflex-uart.h line 1
Quoted 7 lines
xen/arch/arm/include/asm/linflex-uart.h new file +1
-0@@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */ The identifier GPL-2.0 was deprecated (see
LICENSES/GPL-2.0). The new tag should be GPL-2.0-only. The resulting license is the same.
Will fix in v2.
Quoted 93 lines
Quoted 93 lines
xen/arch/arm/include/asm/linflex-uart.h new file +61
-0+/* +* xen/arch/arm/include/asm/linflex-uart.h +* +* Common constant definition between early printk and the UART driver +* for NXP LINFlexD UART. +* +* Andrei Cherechesu <[email protected]> +* Copyright 2018, 2021, 2024 NXP +*/ + +#ifndef __ASM_ARM_LINFLEX_UART_H +#define __ASM_ARM_LINFLEX_UART_H + +/* 32-bit register offsets */ +#define LINCR1 (0x0) +#define LINIER (0x4) +#define LINSR (0x8) +#define UARTCR (0x10) +#define UARTSR (0x14) +#define LINFBRR (0x24) +#define LINIBRR (0x28) +#define BDRL (0x38) +#define BDRM (0x3C) +#define UARTPTO (0x50) + +#define LINCR1_INIT BIT(0, U) +#define LINCR1_MME BIT(4, U) +#define LINCR1_BF BIT(7, U) + +#define LINSR_LINS GENMASK(15, 12) +#define LINSR_LINS_INIT BIT(12, U) + +#define LINIER_DRIE BIT(2, U) +#define LINIER_DTIE BIT(1, U) + +#define UARTCR_UART BIT(0, U) +#define UARTCR_WL0 BIT(1, U) +#define UARTCR_PC0 BIT(3, U) +#define UARTCR_TXEN BIT(4, U) +#define UARTCR_RXEN BIT(5, U) +#define UARTCR_PC1 BIT(6, U) +#define UARTCR_TFBM BIT(8, U) +#define UARTCR_RFBM BIT(9, U) +#define UARTCR_RDFLRFC GENMASK(12, 10) +#define UARTCR_TDFLTFC GENMASK(15, 13) +#define UARTCR_ROSE BIT(23, U) +#define UARTCR_OSR GENMASK(27, 24) + +#define UARTSR_DTFTFF BIT(1, U) +#define UARTSR_DRFRFE BIT(2, U) + +#endif /* __ASM_ARM_LINFLEX_UART_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/drivers/char/Kconfig +0
-0@@ -13,6 +13,14 @@ config HAS_CADENCE_UARTThis selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq based board, say Y.
+configHAS_LINFLEX
+ bool "NXP LINFlexD UART driver"
+ default y
+ depends onARM_64
+ help
+ This selects the NXP LINFlexD UART. If you have an NXP S32G or S32R + based board, say Y.
+
configHAS_IMX_LPUART
bool "i.MX LPUART driver"
default yxen/drivers/char/Makefile +0
-0@@ -10,6 +10,7 @@ obj-$(CONFIG_HAS_SCIF) += scif-uart.oobj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
obj-$(CONFIG_XHCI) += xhci-dbc.o
obj-$(CONFIG_HAS_IMX_LPUART) += imx-lpuart.o
+obj-$(CONFIG_HAS_LINFLEX) += linflex-uart.o
obj-$(CONFIG_ARM) += arm-uart.o
obj-y += serial.o
obj-$(CONFIG_XEN_GUEST) += xen_pv_console.oxen/drivers/char/linflex-uart.c +0
-0
Quoted 8 lines
xen/drivers/char/linflex-uart.c line 1
Quoted 6 lines
new file mode 100644
index 0000000000..4ca8f732aexen/drivers/char/linflex-uart.c new file +1
-0@@ -0,0 +1,365 @@ +/* SPDX-License-Identifier: GPL-2.0 */ Ditto.
Will fix in v2.
Quoted 17 lines
Quoted 5 lines
xen/drivers/char/linflex-uart.c new file +3
-0+/* +* xen/drivers/char/linflex-uart.c +* xen/drivers/char/linflex-uart.c line 14
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+* Driver for NXP LINFlexD UART. +* +* Andrei Cherechesu <[email protected]> +* Copyright 2018, 2021-2022, 2024 NXP +*/ + +#include <xen/config.h> +#include <xen/console.h> +#include <xen/errno.h> +#include <xen/serial.h> In Xen, we tend to order the include alphabetically within the same directory. So this wants to be after
xen/mm.h.
Right, will address in v2.
Quoted 35 lines
Quoted 35 lines
xen/drivers/char/linflex-uart.c new file +33
-0+#include <xen/init.h> +#include <xen/irq.h> +#include <xen/mm.h> +#include <asm/device.h> +#include <asm/io.h> +#include <asm/linflex-uart.h> + +#define LINFLEX_CLK_FREQ (125000000) +#define LINFLEX_BAUDRATE (115200) +#define LINFLEX_LDIV_MULTIPLIER (16) + +static struct linflex_uart { + uint32_t baud, clock_hz; + uint32_t irq; + char __iomem *regs; + struct irqaction irqaction; + struct vuart_info vuart; +} linflex_com; + +static uint32_t linflex_uart_readl (struct linflex_uart *uart,uint32_t off) +{ + return readl(uart->regs + off); +} + +static void linflex_uart_writel (struct linflex_uart *uart,uint32_t off, + uint32_t val) +{ + writel(val, uart->regs + off); +} + +static void linflex_uart_writeb (struct linflex_uart *uart,uint32_t off, + uint8_t val) +{
Quoted 8 lines
xen/drivers/char/linflex-uart.c line 53
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+ writeb(val, uart->regs + off); +} + +static uint32_t linflex_uart_get_osr (uint32_t uartcr) +{ + return (uartcr & UARTCR_OSR) >> 24;Please provide a define for 24. This would also make easier to correlate with
UARTCR_OSR.
Will address in v2.
Quoted 7 lines
xen/drivers/char/linflex-uart.c line 56
Quoted 5 lines
xen/drivers/char/linflex-uart.c new file +3
-0+} + +static uint32_t linflex_uart_tx_fifo_mode (struct linflex_uart *uart)AFAICT,
UARTCR_TFBMis one-bit. So should this return a bool?
Yes, it is one bit and I agree a bool would fit better. Will address in v2.
Quoted 9 lines
xen/drivers/char/linflex-uart.c line 61
Quoted 7 lines
xen/drivers/char/linflex-uart.c new file +5
-0+{ + return linflex_uart_readl(uart, UARTCR) & UARTCR_TFBM; +} + +static uint32_t linflex_uart_rx_fifo_mode (struct linflex_uart *uart)Same here.
Will address in v2.
Quoted 13 lines
Quoted 13 lines
xen/drivers/char/linflex-uart.c new file +12
-0+{ + return linflex_uart_readl(uart, UARTCR) & UARTCR_RFBM; +} + +static uint32_t linflex_uart_ldiv_multiplier (struct linflex_uart *uart) +{ + uint32_t uartcr, mul = LINFLEX_LDIV_MULTIPLIER; + + uartcr = linflex_uart_readl(uart, UARTCR); + if ( uartcr & UARTCR_ROSE ) + mul = linflex_uart_get_osr(uartcr); +
Quoted 8 lines
xen/drivers/char/linflex-uart.c line 79
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+ return mul; +} + +static void linflex_uart_flush (struct serial_port *port) +{ + struct linflex_uart *uart = port->uart;Above, youa re using tab hard but above you use soft tab. Is the code intended to follow Xen coding style? If so, you want to use soft tab.
Will fix in v2.
Quoted 8 lines
xen/drivers/char/linflex-uart.c line 83
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +4
-0+ + if ( linflex_uart_tx_fifo_mode(uart) ) + while ( linflex_uart_readl(uart, UARTCR) & UARTCR_TDFLTFC ); + cpu_relax();The indentation is really confusing here. It leads to think that
cpu_relax()should be part ofwhile()but you are using ';'. I guess you really intended to havecpu_relax()within the while loop?
Indeed, the intention was to have cpu_relax() called within the while loop, but functionally, this variant works almost the same. Thank you for spotting the mistake!
Quoted 28 lines
xen/drivers/char/linflex-uart.c line 87
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +4
-0+ + if ( linflex_uart_rx_fifo_mode(uart) ) + while ( linflex_uart_readl(uart, UARTCR) & UARTCR_RDFLRFC ); + cpu_relax();Same here.
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+} + +static void __init linflex_uart_init_preirq (struct serial_port *port) +{ + struct linflex_uart *uart = port->uart; + uint32_t ibr, fbr, divisr, dividr, ctrl;xen/drivers/char/linflex-uart.c line 103
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+ + /* Disable RX/TX before init mode */ + ctrl = linflex_uart_readl(uart, UARTCR); + ctrl &= ~(UARTCR_RXEN | UARTCR_TXEN); + linflex_uart_writel(uart, UARTCR, ctrl); + + /* +* Smoothen the transition from early_printk by waiting +* for all pending characters to transmit +*/ The indentation for comment in Xen is:
Quoted 5 lines
/*
* Foor
* Bar
*/
Will fix in v2.
Quoted 14 lines
Quoted 14 lines
xen/drivers/char/linflex-uart.c new file +14
-0+ linflex_uart_flush(port); + + /* Init mode */ + ctrl = LINCR1_INIT; + linflex_uart_writel(uart, LINCR1, ctrl); + + /* Waiting for init mode entry */ + while ( (linflex_uart_readl(uart, LINSR) & LINSR_LINS) != LINSR_LINS_INIT ) + cpu_relax(); + + /* Set Master Mode */ + ctrl |= LINCR1_MME; + linflex_uart_writel(uart, LINCR1, ctrl); +
Quoted 9 lines
xen/drivers/char/linflex-uart.c line 123
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+ /* Provide data bits, parity, stop bit, etc */ + divisr = uart->clock_hz; + dividr = (uint32_t)(uart->baud * linflex_uart_ldiv_multiplier(uart)); + + ibr = (uint32_t)(divisr / dividr); + fbr = (uint32_t)((divisr % dividr) * 16 / dividr) & 0xF;On the 3 lines above, why do you need to cast to 32-bit? Is this because the result is 64-bit? If so, why do you need to ignore the top bits?
Indeed, the casts are not needed. The maximum baud rate supported by LINFlexD is 2000000 bps, and the maximum value returned by linflex_uart_ldiv_multiplier() is 16. Thus, "dividr" should never overflow (32000000 max value) and neither should the "fbr" computation. In v2, I will remove the casts and upper bound the baud rate to the maximum supported value, if that's ok for you.
It would be also nice having a generic CONFIG_BAUDRATE (or similar) set by each platform, similar to U-Boot, to make this configurable.
Quoted 47 lines
Quoted 47 lines
xen/drivers/char/linflex-uart.c new file +46
-0+ linflex_uart_writel(uart, LINIBRR, ibr); + linflex_uart_writel(uart, LINFBRR, fbr); + + /* Set preset timeout register value */ + linflex_uart_writel(uart, UARTPTO, 0xF); + + /* Setting UARTCR[UART] bit is required for writing other bits in UARTCR */ + linflex_uart_writel(uart, UARTCR, UARTCR_UART); + + /* 8 bit data, no parity, UART mode, Buffer mode */ + linflex_uart_writel(uart, UARTCR, UARTCR_PC1 | UARTCR_PC0 | UARTCR_WL0 | + UARTCR_UART); + + /* end init mode */ + ctrl = linflex_uart_readl(uart, LINCR1); + ctrl &= ~LINCR1_INIT; + linflex_uart_writel(uart, LINCR1, ctrl); + + /* Enable RX/TX after exiting init mode */ + ctrl = linflex_uart_readl(uart, UARTCR); + ctrl |= UARTCR_RXEN | UARTCR_TXEN; + linflex_uart_writel(uart, UARTCR, ctrl); +} + +static void linflex_uart_interrupt (int irq,void *data) +{ + struct serial_port *port = data; + struct linflex_uart *uart = port->uart; + uint32_t sts; + + sts = linflex_uart_readl(uart, UARTSR); + + if ( sts & UARTSR_DRFRFE ) + serial_rx_interrupt(port); + + if ( sts & UARTSR_DTFTFF ) + serial_tx_interrupt(port); +} + +static void __init linflex_uart_init_postirq (struct serial_port *port) +{ + struct linflex_uart *uart = port->uart; + uint32_t temp; + + uart->irqaction.handler = linflex_uart_interrupt; + uart->irqaction.name = "linflex_uart";
Quoted 8 lines
xen/drivers/char/linflex-uart.c line 176
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+ uart->irqaction.dev_id = port; + + if ( setup_irq(uart->irq, 0, &uart->irqaction) != 0 ) + { + dprintk(XENLOG_ERR, "Failed to allocate linflex_uart IRQ %d\n", + uart->irq);NIT: This should only be called once during boot. So I would consider to use
printk()so it can be printed in production.
Will fix in v2.
Quoted 11 lines
xen/drivers/char/linflex-uart.c line 184
Quoted 9 lines
xen/drivers/char/linflex-uart.c new file +8
-0+ return; + } + + /* Enable interrupts */ + temp = linflex_uart_readl(uart, LINIER); + temp |= (LINIER_DRIE | LINIER_DTIE); + linflex_uart_writel(uart, LINIER, temp); + dprintk(XENLOG_DEBUG, "IRQ %d enabled\n", uart->irq);Same here.
Will fix in v2.
Quoted 16 lines
Quoted 4 lines
xen/drivers/char/linflex-uart.c new file +3
-0+} + +static int linflex_uart_tx_ready (struct serial_port *port)xen/drivers/char/linflex-uart.c line 197
Quoted 10 lines
xen/drivers/char/linflex-uart.c new file +10
-0+{ + struct linflex_uart *uart = port->uart; + + if ( linflex_uart_tx_fifo_mode(uart) ) + return (linflex_uart_readl(uart, UARTSR) & UARTSR_DTFTFF) == 0 ? 1 : 0; + + /* +* Buffer Mode => TX is waited to be ready after sending a char, +* so we can assume it is always ready before. +*/ Coding style. See above how it should be done for multi-line comments.
Will fix in v2.
Quoted 55 lines
Quoted 55 lines
xen/drivers/char/linflex-uart.c new file +54
-0+ return 1; +} + +static void linflex_uart_putc (struct serial_port *port,char c) +{ + struct linflex_uart *uart = port->uart; + uint32_t uartsr; + + if ( c == '\n' ) + linflex_uart_putc(port, '\r'); + + linflex_uart_writeb(uart, BDRL, c); + + /* Buffer Mode */ + if ( !linflex_uart_tx_fifo_mode(uart) ) + { + while ( (linflex_uart_readl(uart, UARTSR) & UARTSR_DTFTFF) == 0 ) + cpu_relax(); + + uartsr = linflex_uart_readl(uart, UARTSR) | (UARTSR_DTFTFF); + linflex_uart_writel(uart, UARTSR, uartsr); + } +} + +static int linflex_uart_getc (struct serial_port *port,char *pc) +{ + struct linflex_uart *uart = port->uart; + uint32_t ch, uartsr, rx_fifo_mode; + + rx_fifo_mode = linflex_uart_rx_fifo_mode(uart); + + if ( rx_fifo_mode ) + while ( linflex_uart_readl(uart, UARTSR) & UARTSR_DRFRFE ) + cpu_relax(); + else + while ( !(linflex_uart_readl(uart, UARTSR) & UARTSR_DRFRFE) ) + cpu_relax(); + + ch = linflex_uart_readl(uart, BDRM); + *pc = ch & 0xff; + + if ( !rx_fifo_mode ) { + uartsr = linflex_uart_readl(uart, UARTSR) | UARTSR_DRFRFE; + linflex_uart_writel(uart, UARTSR, uartsr); + } + + return 1; +} + +static int __init linflex_uart_irq (struct serial_port *port) +{ + struct linflex_uart *uart = port->uart; + + return ((uart->irq > 0) ? uart->irq : -1);
Quoted 8 lines
xen/drivers/char/linflex-uart.c line 257
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+} + +static const struct vuart_info *linflex_uart_vuart_info ( + struct serial_port *port) +{ + struct linflex_uart *uart = port->uart;NIT: You are not modifying uart. So this coul be const.
Sure, but no other driver does this. Actually, this applies to most functions in this driver, right? I can implement this in v2 if you agree to break the pattern.
Quoted 104 lines
Quoted 104 lines
xen/drivers/char/linflex-uart.c new file +102
-0+ + return &uart->vuart; +} + +static void linflex_uart_start_tx (struct serial_port *port) +{ + struct linflex_uart *uart = port->uart; + uint32_t temp; + + temp = linflex_uart_readl(uart, LINIER); + linflex_uart_writel(uart, LINIER, temp | LINIER_DTIE); +} + +static void linflex_uart_stop_tx (struct serial_port *port) +{ + struct linflex_uart *uart = port->uart; + uint32_t temp; + + temp = linflex_uart_readl(uart, LINIER); + temp &= ~(LINIER_DTIE); + linflex_uart_writel(uart, LINIER, temp); +} + +static struct uart_driver __read_mostly linflex_uart_driver = { + .init_preirq = linflex_uart_init_preirq, + .init_postirq = linflex_uart_init_postirq, + .tx_ready = linflex_uart_tx_ready, + .putc = linflex_uart_putc, + .flush = linflex_uart_flush, + .getc = linflex_uart_getc, + .irq = linflex_uart_irq, + .start_tx = linflex_uart_start_tx, + .stop_tx = linflex_uart_stop_tx, + .vuart_info = linflex_uart_vuart_info, +}; + +static int __init linflex_uart_init (struct dt_device_node *dev,const void *data) +{ + const char *config = data; + struct linflex_uart *uart; + paddr_t addr, size; + int res; + + if ( strcmp(config, "") ) + printk("WARNING: UART configuration is not supported\n"); + + uart = &linflex_com; + + res = dt_device_get_paddr(dev, 0, &addr, &size); + if ( res ) + { + printk("linflex-uart: Unable to retrieve the base address of the UART\n"); + return res; + } + + res = platform_get_irq(dev, 0); + if ( res < 0 ) + { + printk("linflex-uart: Unable to retrieve the IRQ\n"); + return -EINVAL; + } + uart->irq = res; + + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("linflex-uart: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->clock_hz = LINFLEX_CLK_FREQ; + uart->baud = LINFLEX_BAUDRATE; + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off = BDRL; + uart->vuart.status_off = UARTSR; + uart->vuart.status = UARTSR_DTFTFF; + + /* Register with generic serial driver */ + serial_register_uart(SERHND_DTUART, &linflex_uart_driver, uart); + + dt_device_set_used_by(dev, DOMID_XEN); + + return 0; +} + +static const struct dt_device_match linflex_uart_dt_compat[]__initconst = +{ + DT_MATCH_COMPATIBLE("nxp,s32g2-linflexuart"), + DT_MATCH_COMPATIBLE("nxp,s32g3-linflexuart"), + DT_MATCH_COMPATIBLE("fsl,s32v234-linflexuart"), + { /* sentinel */ }, +}; + +DT_DEVICE_START (linflex_uart,"NXP LINFlexD UART" ,DEVICE_SERIAL ) + .dt_match = linflex_uart_dt_compat, + .init = linflex_uart_init, +DT_DEVICE_END + +/* +* Local variables:
Quoted 9 lines
xen/drivers/char/linflex-uart.c line 364
Quoted 6 lines
xen/drivers/char/linflex-uart.c new file +6
-0+* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ Cheers,
Regards,
Andrei Cherechesu
PATCH 2/5 xen/arm: Add NXP LINFlexD UART early printk support
In reply to Andrei Cherechesu (OSS)From: Andrei Cherechesu <[email protected]>
This adds support for early printk debug via the NXP LINFlexD UART controller.
--- xen/arch/arm/Kconfig.debug | 14 +++++++ xen/arch/arm/arm64/debug-linflex.inc | 58 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-linflex.inc
xen/arch/arm/Kconfig.debug +14 -0
@@ -68,6 +68,16 @@ choice provide the parameters for the i.MX LPUART rather than selecting one of the platform specific options below if you know the parameters for the port. + config EARLY_UART_CHOICE_LINFLEX + select EARLY_UART_LINFLEX + depends on ARM_64 + bool "Early printk via NXP LINFlexD UART" + help + Say Y here if you wish the early printk to direct their + output to an NXP LINFlexD UART. You can use this option to + provide the parameters for the NXP LINFlexD UART rather than + selecting one of the platform specific options below if + you know the parameters for the port. config EARLY_UART_CHOICE_MESON select EARLY_UART_MESON depends on ARM_64
@@ -199,6 +209,9 @@ config EARLY_UART_EXYNOS4210 config EARLY_UART_IMX_LPUART select EARLY_PRINTK bool +config EARLY_UART_LINFLEX + select EARLY_PRINTK + bool config EARLY_UART_MESON select EARLY_PRINTK bool
@@ -304,6 +317,7 @@ config EARLY_PRINTK_INC default "debug-cadence.inc" if EARLY_UART_CADENCE default "debug-exynos4210.inc" if EARLY_UART_EXYNOS4210 default "debug-imx-lpuart.inc" if EARLY_UART_IMX_LPUART + default "debug-linflex.inc" if EARLY_UART_LINFLEX default "debug-meson.inc" if EARLY_UART_MESON default "debug-mvebu.inc" if EARLY_UART_MVEBU default "debug-pl011.inc" if EARLY_UART_PL011
xen/arch/arm/arm64/debug-linflex.inc new file +58 -0
59 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH v1 2/5] xen/arm: Add NXP LINFlexD UART early printk support
Hi,
Quoted 58 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
This adds support for early printk debug via the NXP LINFlexD UART controller.
Signed-off-by Andrei Cherechesu <[email protected]>Signed-off-by Peter van der Perk <[email protected]>--- xen/arch/arm/Kconfig.debug | 14 +++++++ xen/arch/arm/arm64/debug-linflex.inc | 58 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+)create mode 100644 xen/arch/arm/arm64/debug-linflex.inc
xen/arch/arm/Kconfig.debug +14
-0@@ -68,6 +68,16 @@ choice provide the parameters for the i.MX LPUART rather than selecting one of the platform specific options below if you know the parameters for the port. + config EARLY_UART_CHOICE_LINFLEX + select EARLY_UART_LINFLEX + depends on ARM_64 + bool "Early printk via NXP LINFlexD UART" + help + Say Y here if you wish the early printk to direct their + output to an NXP LINFlexD UART. You can use this option to + provide the parameters for the NXP LINFlexD UART rather than + selecting one of the platform specific options below if + you know the parameters for the port. config EARLY_UART_CHOICE_MESON select EARLY_UART_MESON depends on ARM_64@@ -199,6 +209,9 @@ config EARLY_UART_EXYNOS4210 config EARLY_UART_IMX_LPUART select EARLY_PRINTK bool +config EARLY_UART_LINFLEX + select EARLY_PRINTK + bool config EARLY_UART_MESON select EARLY_PRINTK bool@@ -304,6 +317,7 @@ config EARLY_PRINTK_INC default "debug-cadence.inc" if EARLY_UART_CADENCE default "debug-exynos4210.inc" if EARLY_UART_EXYNOS4210 default "debug-imx-lpuart.inc" if EARLY_UART_IMX_LPUART + default "debug-linflex.inc" if EARLY_UART_LINFLEX default "debug-meson.inc" if EARLY_UART_MESON default "debug-mvebu.inc" if EARLY_UART_MVEBU default "debug-pl011.inc" if EARLY_UART_PL011xen/arch/arm/arm64/debug-linflex.inc new file +0
-0
xen/arch/arm/arm64/debug-linflex.inc line 1
Quoted 1 line
xen/arch/arm/arm64/debug-linflex.inc new file +1
-0@@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0 */
GPL-2.0 is deprecated and replaced by GPL-2.0-only.
Quoted 48 lines
xen/arch/arm/arm64/debug-linflex.inc new file +48
-0+/* + * xen/arch/arm/arm64/debug-linflex.inc + * + * NXP LINFlexD UART specific debug code + * + * Andrei Cherechesu <[email protected]> + * Copyright 2018, 2021, 2023-2024 NXP + */ + +#include <asm/asm_defns.h> +#include <asm/linflex-uart.h> + +/* + * wait LINFlexD UART to be ready to transmit + * xb: register which contains the UART base address + * c: scratch register number + */ +.macro early_uart_ready xb, c + ldr w\c, [\xb, #UARTCR] /* <= Control Register */ + and w\c, w\c, #UARTCR_TFBM /* Check Buffer/FIFO (0/1) Mode */ + cbz w\c, 2f /* Buffer Mode => return */ +1: + ldrb w\c, [\xb, #UARTSR] /* <= Status Register */ + tst w\c, #UARTSR_DTFTFF /* FIFO Mode => Check DTF bit */ + b.ne 1b +2: +.endm + +/* + * LINFlexD UART transmit character + * xb: register which contains the UART base address + * wt: register which contains the character to transmit + */ +.macro early_uart_transmit xb, wt + strb \wt, [\xb, #BDRL] + + ldr \wt, [\xb, #UARTCR] /* <= Control Register */ + and \wt, \wt, #UARTCR_TFBM /* Check Buffer/FIFO (0/1) Mode */ + cbnz \wt, 2f /* FIFO Mode => goto exit */ + +3: /* Buffer Mode */ + ldrb \wt, [\xb, #UARTSR] /* <= Status Register */ + and \wt, \wt, #UARTSR_DTFTFF /* Check Transmission Completed */ + cbz \wt, 3b + + ldr \wt, [\xb, #UARTSR] /* <= Status Register */ + orr \wt, \wt, #UARTSR_DTFTFF /* Clear DTF bit */ + str \wt, [\xb, #UARTSR]
xen/arch/arm/arm64/debug-linflex.inc line 58
Quoted 10 lines
xen/arch/arm/arm64/debug-linflex.inc new file +9
-0+2: +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */
The file should end with a newline.
I haven't looked at the specifics of the UART. But the code integration in Xen LGTM. So with the two comments addressed:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 2/5] xen/arm: Add NXP LINFlexD UART early printk support
Quoted 56 lines · Julien Grall
Hi,
Quoted 53 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
This adds support for early printk debug via the NXP LINFlexD UART controller.
Signed-off-by Andrei Cherechesu <[email protected]>Signed-off-by Peter van der Perk <[email protected]>---
xen/arch/arm/Kconfig.debug | 14 +++++++ xen/arch/arm/arm64/debug-linflex.inc | 58 ++++++++++++++++++++++++++++2 files changed, 72 insertions(+)create mode 100644 xen/arch/arm/arm64/debug-linflex.inc
xen/arch/arm/Kconfig.debug +0
-0@@ -68,6 +68,16 @@ choiceprovide the parameters for the i.MX LPUART rather than selecting one of the platform specific options below if you know the parameters for the port.
+ configEARLY_UART_CHOICE_LINFLEX
+ selectEARLY_UART_LINFLEX
+ depends onARM_64
+ bool "Early printk via NXP LINFlexD UART"
+ help
+ Say Y here if you wish the early printk to direct their + output to an NXP LINFlexD UART. You can use this option to + provide the parameters for the NXP LINFlexD UART rather than + selecting one of the platform specific options below if + you know the parameters for the port.
configEARLY_UART_CHOICE_MESON
selectEARLY_UART_MESON
depends onARM_64xen/arch/arm/Kconfig.debug +0
-0@@ -199,6 +209,9 @@ config EARLY_UART_EXYNOS4210config
EARLY_UART_IMX_LPUART
selectEARLY_PRINTK
bool
+configEARLY_UART_LINFLEX
+ selectEARLY_PRINTK
+ bool
configEARLY_UART_MESON
selectEARLY_PRINTK
boolxen/arch/arm/Kconfig.debug +0
-0@@ -304,6 +317,7 @@ config EARLY_PRINTK_INCdefault "debug-cadence.inc" if
EARLY_UART_CADENCEdefault "debug-exynos4210.inc" ifEARLY_UART_EXYNOS4210default "debug-imx-lpuart.inc" ifEARLY_UART_IMX_LPUART+ default "debug-linflex.inc" ifEARLY_UART_LINFLEXdefault "debug-meson.inc" ifEARLY_UART_MESONdefault "debug-mvebu.inc" ifEARLY_UART_MVEBUdefault "debug-pl011.inc" ifEARLY_UART_PL011xen/arch/arm/arm64/debug-linflex.inc +0
-0
Quoted 8 lines
xen/arch/arm/arm64/debug-linflex.inc line 1
Quoted 6 lines
new file mode 100644
index 0000000000..6ed704e104xen/arch/arm/arm64/debug-linflex.inc new file +1
-0@@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0 */GPL-2.0 is deprecated and replaced by GPL-2.0-only.
Will fix in v2.
Quoted 53 lines
Quoted 53 lines
xen/arch/arm/arm64/debug-linflex.inc new file +52
-0+/* + * xen/arch/arm/arm64/debug-linflex.inc + * + * NXP LINFlexD UART specific debug code + * + * Andrei Cherechesu <[email protected]> + * Copyright 2018, 2021, 2023-2024 NXP + */ + +#include <asm/asm_defns.h> +#include <asm/linflex-uart.h> + +/* + * wait LINFlexD UART to be ready to transmit + * xb: register which contains the UART base address + * c: scratch register number + */ +.macro early_uart_ready xb, c + ldr w\c, [\xb, #UARTCR] /* <= Control Register */ + and w\c, w\c, #UARTCR_TFBM /* Check Buffer/FIFO (0/1) Mode */ + cbz w\c, 2f /* Buffer Mode => return */ +1: + ldrb w\c, [\xb, #UARTSR] /* <= Status Register */ + tst w\c, #UARTSR_DTFTFF /* FIFO Mode => Check DTF bit */ + b.ne 1b +2: +.endm + +/* + * LINFlexD UART transmit character + * xb: register which contains the UART base address + * wt: register which contains the character to transmit + */ +.macro early_uart_transmit xb, wt + strb \wt, [\xb, #BDRL] + + ldr \wt, [\xb, #UARTCR] /* <= Control Register */ + and \wt, \wt, #UARTCR_TFBM /* Check Buffer/FIFO (0/1) Mode */ + cbnz \wt, 2f /* FIFO Mode => goto exit */ + +3: /* Buffer Mode */ + ldrb \wt, [\xb, #UARTSR] /* <= Status Register */ + and \wt, \wt, #UARTSR_DTFTFF /* Check Transmission Completed */ + cbz \wt, 3b + + ldr \wt, [\xb, #UARTSR] /* <= Status Register */ + orr \wt, \wt, #UARTSR_DTFTFF /* Clear DTF bit */ + str \wt, [\xb, #UARTSR] +2: +.endm + +/*
Quoted 9 lines
xen/arch/arm/arm64/debug-linflex.inc line 58
Quoted 6 lines
xen/arch/arm/arm64/debug-linflex.inc new file +5
-0+ * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */The file should end with a newline.
Will fix in v2.
Quoted 6 lines
I haven't looked at the specifics of the UART. But the code integration in Xen LGTM. So with the two comments addressed:
Acked-by Julien Grall <[email protected]>Cheers,
Thanks for the review!
Regards,
Andrei C
PATCH 3/5 xen/arm: platforms: Add NXP S32CC platform code
In reply to Andrei Cherechesu (OSS)From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
S32CC platforms use the NXP LINFlexD UART driver for console by default.
--- xen/arch/arm/platforms/Kconfig | 10 ++++ xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/s32cc.c | 84 +++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 xen/arch/arm/platforms/s32cc.c
xen/arch/arm/platforms/Kconfig +10 -0
@@ -37,6 +37,13 @@ config MPSOC help Enable all the required drivers for Xilinx Ultrascale+ MPSoC +config S32CC + bool "NXP S32CC platforms support" + depends on ARM_64 + select HAS_LINFLEX + help + Enable all the required drivers for NXP S32CC platforms + config NO_PLAT bool "No Platforms" help
@@ -56,3 +63,6 @@ config MPSOC_PLATFORM bool default (ALL64_PLAT || MPSOC) +config S32CC_PLATFORM + bool + default (ALL64_PLAT || S32CC)
xen/arch/arm/platforms/Makefile +1 -0
@@ -10,5 +10,6 @@ obj-$(CONFIG_ALL64_PLAT) += thunderx.o obj-$(CONFIG_ALL64_PLAT) += xgene-storm.o obj-$(CONFIG_ALL64_PLAT) += brcm-raspberry-pi.o obj-$(CONFIG_ALL64_PLAT) += imx8qm.o +obj-$(CONFIG_S32CC_PLATFORM) += s32cc.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp-eemi.o
xen/arch/arm/platforms/s32cc.c new file +84 -0
85 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Hi,
Quoted 6 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would benefit everyone and increase the security posture (we could restrict access).
Cheers,
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Quoted 12 lines · Julien Grall
Hi,
Quoted 6 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Quoted 7 lines
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would benefit everyone and increase the security posture (we could restrict access).
Hi Andrei, Julien,
SCMI is very flexible and can be configured in a number of ways. In general, Julien has a point that typically forwarding to firmware all SCMI requests from Xen domains is not the desired behavior.
An an example, imagine the case where device1 is assigned to domain1 and device2 is assigned to domain2. Now imagine that they both share a clock. Domain1 and domain2 could fight over the clock frequency settings using SCMI to change it, without being aware of each other activities. It is likely that the system would malfunction.
If this kind of situations can happen on NXP S32CC platforms, then this patch might not be a good idea. As Julien suggested, you might want to have a look at Oleksii's approach. We could probably allow Dom0 to make all SCMI calls. If you think that is OK, you need to add a (is_hardware_domain(d)) check.
On the other hand, if your SCMI server implementation has a way to prevent possible harmful activities from happening, or maybe all clocks are fixed-clocks so there are actually no SCMI operations to control the clocks, then it could be possible that this patch might be fine. I admit it is unlikely because there is a number of ways SCMI could be used by one domain to hurt another domain.
Can you please give us a brief overview on how SCMI is expected to work on NXP S32CC?
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Hi Julien, Stefano,
Quoted 11 lines · Stefano Stabellini
Quoted 10 lines · Julien Grall
Hi,
Quoted 6 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Quoted 4 lines
Quoted 4 lines
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Quoted 4 lines
Quoted 4 lines
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would benefit everyone and increase the security posture (we could restrict access).
I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0]. I'm curious why the SCMI mediator patch series did not progress.
[0] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/
Quoted 7 lines
Hi Andrei, Julien,
SCMI is very flexible and can be configured in a number of ways. In general, Julien has a point that typically forwarding to firmware all SCMI requests from Xen domains is not the desired behavior.
Quoted 5 lines
An an example, imagine the case where device1 is assigned to domain1 and device2 is assigned to domain2. Now imagine that they both share a clock. Domain1 and domain2 could fight over the clock frequency settings using SCMI to change it, without being aware of each other activities. It is likely that the system would malfunction.
I completely agree and we are aware of the possible resource contention. Another (simpler?) scenariowhere access control is needed, besides the one you described, is when Domain1 would directly try to perform some requests for some resources that affect Device2 (owned by Domain2). If Domain1 knows the clock IDs used by Device2, for example, without any access control it could perform a SCMI clock request affecting Device2's clocks, which should be out of his control.
Quoted 13 lines
If this kind of situations can happen on NXP S32CC platforms, then this patch might not be a good idea. As Julien suggested, you might want to have a look at Oleksii's approach. We could probably allow Dom0 to make all SCMI calls. If you think that is OK, you need to add a (
is_hardware_domain(d)) check.
On the other hand, if your SCMI server implementation has a way to prevent possible harmful activities from happening, or maybe all clocks are fixed-clocks so there are actually no SCMI operations to control the clocks, then it could be possible that this patch might be fine. I admit it is unlikely because there is a number of ways SCMI could be used by one domain to hurt another domain.
Quoted 2 lines
Can you please give us a brief overview on how SCMI is expected to work on NXP S32CC?
Well, we normally rely on most SCMI protocols to access system-level resources from agents: Base, Power Domain, System Power, Performance Domain, Clock, Reset Domain. Linux jumps to EL3 via SMC carrying an SCMI message, and FW running at EL3 decides how to handle it. Basically, Linux cannot directly control most system-level resources.
With Xen, we currently don't allow unprivileged Domains to do SCMI requests. The SMCs are of course trapped at EL2 and that's why we enabled forwarding to EL3 without any access control, knowing it shouldn't break anything, and to let everything function as normal. In some passthrough scenarios the unprivileged domains rely on settings already made by firmware (for clocks, pins, etc) that their assigned devices require, and in DT we replace them with e.g. fixed-clock for clocks.
An "is_hardware_domain(d)" check should be enough for the moment to harden the code, but I agree that this should not be something platform-specific in the future, and the handling must be done in a generic way. So I would proceed with this approach for this patch series, if that's ok for you, and I will also take a look at Oleksii's approach.
Regards,
Andrei C
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Quoted 77 lines · Andrei Cherechesu
Hi Julien, Stefano,
On 11/09/2024 08:19, Stefano Stabellini wrote:On Tue, 10 Sep 2024, Julien Grall wrote:
Hi,
On 10/09/2024 15:34, Andrei Cherechesu (OSS) wrote:
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would
benefit everyone and increase the security posture (we could restrict access).I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0]. I'm curious why the SCMI mediator patch series did not progress.
[0] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/Hi Andrei, Julien,
SCMI is very flexible and can be configured in a number of ways. In general, Julien has a point that typically forwarding to firmware all SCMI requests from Xen domains is not the desired behavior.
An an example, imagine the case where device1 is assigned to domain1 and device2 is assigned to domain2. Now imagine that they both share a clock. Domain1 and domain2 could fight over the clock frequency settings using SCMI to change it, without being aware of each other activities. It is likely that the system would malfunction.
I completely agree and we are aware of the possible resource contention. Another (simpler?) scenario where access control is needed, besides the one you described, is when Domain1 would directly try to perform some requests for some resources that affect Device2 (owned by Domain2). If Domain1 knows the clock IDs used by Device2, for example, without any access control it could perform a SCMI clock request affecting Device2's clocks, which should be out of his control.
If this kind of situations can happen on NXP S32CC platforms, then this patch might not be a good idea. As Julien suggested, you might want to have a look at Oleksii's approach. We could probably allow Dom0 to make all SCMI calls. If you think that is OK, you need to add a (
is_hardware_domain(d)) check.On the other hand, if your SCMI server implementation has a way to prevent possible harmful activities from happening, or maybe all clocks are fixed-clocks so there are actually no SCMI operations to control the clocks, then it could be possible that this patch might be fine. I admit it is unlikely because there is a number of ways SCMI could be used by one domain to hurt another domain.
Can you please give us a brief overview on how SCMI is expected to work on NXP S32CC?
Well, we normally rely on most SCMI protocols to access system-level resources from agents: Base, Power Domain, System Power, Performance Domain, Clock, Reset Domain. Linux jumps to EL3 via SMC carrying an SCMI message, and FW running at EL3 decides how to handle it. Basically, Linux cannot directly control most system-level resources.
Quoted 8 lines
With Xen, we currently don't allow unprivileged Domains to do SCMI requests. The SMCs are of course trapped at EL2 and that's why we enabled forwarding to EL3 without any access control, knowing it shouldn't break anything, and to let everything function as normal. In some passthrough scenarios the unprivileged domains rely on settings already made by firmware (for clocks, pins, etc) that their assigned devices require, and in DT we replace them with e.g. fixed-clock for clocks.
An "
is_hardware_domain(d)" check should be enough for the moment to harden the code, but I agree that this should not be something platform-specific in the future, and the handling must be done in a generic way.
So I would proceed with this approach for this patch series, if that's ok for you, and I will also take a look at Oleksii's approach.
I know how hard is to solve this properly and it might take months. I wouldn't want to stop Xen from working on NXP S32CC until a proper SCMI solution is found. For now, I would say to add the "is_hardware_domain(d)" check.
Julien, do you also agree?
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
In reply to Andrei CherechesuHi Andrei,
Quoted 27 lines · Andrei Cherechesu
Hi Julien, Stefano,
Quoted 6 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall
Hi,
On 10/09/2024 15:34, Andrei Cherechesu (OSS) wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Quoted 5 lines
Quoted 5 lines
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would
benefit everyone and increase the security posture (we could restrict access).
I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0]. I'm curious why the SCMI mediator patch series did not progress.
[0] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/
Sorry it seems i missed that one.
There are several initiatives ongoing to investigate the global problem of clock handling and more specifically SCMI "sharing".
The SCMI protocol contains some features to have virtual channels and the question is how to make a transport that is hypervisor agnostic to prevent to require the hypervisors to have to "decode" SCMI messages.
Virtio-scmi is not really used for clock management per say at the moment and more specifically I do not think it is a good solution to manage clocks of non virtio devices.
In Soafee and in Linaro people are looking at using FF-A as a tansport for SCMI.
The idea would be that the hypervisor is configuring the virtual SCMI channels using FF-A as a transport and then VMs are using FF-A to communicate with an SCMI server (probably sitting in secure world, at least as a proxy). This is an investigation for now.
Requiring Xen to act as a mediator is also a solution but might require a lot of platform specific code which i think we should prevent.
For now having a solution in Xen where SCMI calls through SMC are only allowed by Dom0 is the only short term solution I think.
Cheers
Bertrand
Quoted 41 lines
Quoted 7 lines
Hi Andrei, Julien,
SCMI is very flexible and can be configured in a number of ways. In general, Julien has a point that typically forwarding to firmware all SCMI requests from Xen domains is not the desired behavior.
Quoted 5 lines
An an example, imagine the case where device1 is assigned to domain1 and device2 is assigned to domain2. Now imagine that they both share a clock. Domain1 and domain2 could fight over the clock frequency settings using SCMI to change it, without being aware of each other activities. It is likely that the system would malfunction.
I completely agree and we are aware of the possible resource contention. Another (simpler?) scenario where access control is needed, besides the one you described, is when Domain1 would directly try to perform some requests for some resources that affect Device2 (owned by Domain2). If Domain1 knows the clock IDs used by Device2, for example, without any access control it could perform a SCMI clock request affecting Device2's clocks, which should be out of his control.
Quoted 13 lines
If this kind of situations can happen on NXP S32CC platforms, then this patch might not be a good idea. As Julien suggested, you might want to have a look at Oleksii's approach. We could probably allow Dom0 to make all SCMI calls. If you think that is OK, you need to add a (
is_hardware_domain(d)) check.
On the other hand, if your SCMI server implementation has a way to prevent possible harmful activities from happening, or maybe all clocks are fixed-clocks so there are actually no SCMI operations to control the clocks, then it could be possible that this patch might be fine. I admit it is unlikely because there is a number of ways SCMI could be used by one domain to hurt another domain.Quoted 2 lines
Can you please give us a brief overview on how SCMI is expected to work on NXP S32CC?
Well, we normally rely on most SCMI protocols to access system-level resources from agents: Base, Power Domain, System Power, Performance Domain, Clock, Reset Domain. Linux jumps to EL3 via SMC carrying an SCMI message, and FW running at EL3 decides how to handle it. Basically, Linux cannot directly control most system-level resources.
With Xen, we currently don't allow unprivileged Domains to do SCMI requests. The SMCs are of course trapped at EL2 and that's why we enabled forwarding to EL3 without any access control, knowing it shouldn't break anything, and to let everything function as normal. In some passthrough scenarios the unprivileged domains rely on settings already made by firmware (for clocks, pins, etc) that their assigned devices require, and in DT we replace them with e.g. fixed-clock for clocks.
An "
is_hardware_domain(d)" check should be enough for the moment to harden the code, but I agree that this should not be something platform-specific in the future, and the handling must be done in a generic way. So I would proceed with this approach for this patch series, if that's ok for you, and I will also take a look at Oleksii's approach.Regards,
Andrei C
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Quoted 53 lines · Bertrand Marquis
Hi Andrei,
Quoted 27 lines · Andrei Cherechesu
Hi Julien, Stefano,
Quoted 6 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall
Hi,
On 10/09/2024 15:34, Andrei Cherechesu (OSS) wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Quoted 5 lines
Quoted 5 lines
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would
benefit everyone and increase the security posture (we could restrict access).
I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0]. I'm curious why the SCMI mediator patch series did not progress.
[0] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/Sorry it seems i missed that one.
There are several initiatives ongoing to investigate the global problem of clock handling and more specifically SCMI "sharing".
The SCMI protocol contains some features to have virtual channels and the question is how to make a transport that is hypervisor agnostic to prevent to require the hypervisors to have to "decode" SCMI messages.Virtio-scmi is not really used for clock management per say at the moment and more specifically I do not think it is a good solution to manage clocks of non virtio devices.
In Soafee and in Linaro people are looking at using FF-A as a tansport for SCMI.
The idea would be that the hypervisor is configuring the virtual SCMI channels using FF-A as a transport and then VMs are using FF-A to communicate with an SCMI server (probably sitting in secure world, at least as a proxy). This is an investigation for now.
Quoted 5 lines
Requiring Xen to act as a mediator is also a solution but might require a lot of platform specific code which i think we should prevent.
For now having a solution in Xen where SCMI calls through SMC are only allowed by Dom0 is the only short term solution I think.
+1
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Hi,
Quoted 54 lines · Stefano Stabellini
Quoted 53 lines · Bertrand Marquis
Hi Andrei,
Quoted 27 lines · Andrei Cherechesu
Hi Julien, Stefano,
Quoted 6 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall
Hi,
On 10/09/2024 15:34, Andrei Cherechesu (OSS) wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Quoted 5 lines
Quoted 5 lines
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would
benefit everyone and increase the security posture (we could restrict access).
I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0]. I'm curious why the SCMI mediator patch series did not progress.
[0] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/Sorry it seems i missed that one.
There are several initiatives ongoing to investigate the global problem of clock handling and more specifically SCMI "sharing".
The SCMI protocol contains some features to have virtual channels and the question is how to make a transport that is hypervisor agnostic to prevent to require the hypervisors to have to "decode" SCMI messages.Virtio-scmi is not really used for clock management per say at the moment and more specifically I do not think it is a good solution to manage clocks of non virtio devices.
In Soafee and in Linaro people are looking at using FF-A as a tansport for SCMI.
The idea would be that the hypervisor is configuring the virtual SCMI channels using FF-A as a transport and then VMs are using FF-A to communicate with an SCMI server (probably sitting in secure world, at least as a proxy). This is an investigation for now.
Quoted 7 lines
Quoted 5 lines
Requiring Xen to act as a mediator is also a solution but might require a lot of platform specific code which i think we should prevent.
For now having a solution in Xen where SCMI calls through SMC are only allowed by Dom0 is the only short term solution I think.
+1
I am open to go this way. But I would like the commit message to contain some details on whether this will always work fine for dom0 (this would tell whether the feature can be supported or needs to be in experimental/tech preview).
At least my main concern is anything to do with RAM. On Matrix, Bertrand suggested that none of the messages should contain addresses. What about the transport? Is it using buffer? If so, are they fixed?
Brief looking at Linux, there are multiple DT compatible. IIUC, we would only support "arm,scmi-smc" with the implementation. If so, maybe we should check the DT.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Hi,
Quoted 61 lines · Julien Grall
Quoted 60 lines · Stefano Stabellini
Quoted 58 lines · Bertrand Marquis
Hi Andrei,
Quoted 27 lines · Andrei Cherechesu
Hi Julien, Stefano,
Quoted 6 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall
Hi,
On 10/09/2024 15:34, Andrei Cherechesu (OSS) wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
From: Andrei Cherechesu <[email protected]>
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Quoted 5 lines
Quoted 5 lines
Furthermore, I was under the impression that we can't blindly forward everything from a domain to the firmware. While it might be okayish for dom0, you also seem to give access to all the domains on the system is it intended?
In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see [1]). I think it would be preferable to focus on getting it merged as it would
benefit everyone and increase the security posture (we could restrict access).
I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0]. I'm curious why the SCMI mediator patch series did not progress.
[0] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/Sorry it seems i missed that one.
There are several initiatives ongoing to investigate the global problem of clock handling and more specifically SCMI "sharing".
The SCMI protocol contains some features to have virtual channels and the question is how to make a transport that is hypervisor agnostic to prevent to require the hypervisors to have to "decode" SCMI messages.Virtio-scmi is not really used for clock management per say at the moment and more specifically I do not think it is a good solution to manage clocks of non virtio devices.
In Soafee and in Linaro people are looking at using FF-A as a tansport for SCMI.
The idea would be that the hypervisor is configuring the virtual SCMI channels using FF-A as a transport and then VMs are using FF-A to communicate with an SCMI server (probably sitting in secure world, at least as a proxy). This is an investigation for now.Requiring Xen to act as a mediator is also a solution but might require a lot of platform specific code which i think we should prevent.
For now having a solution in Xen where SCMI calls through SMC are only allowed by Dom0 is the only short term solution I think.
Quoted 6 lines
Quoted 1 line
+1
I am open to go this way. But I would like the commit message to contain some details on whether this will always work fine for dom0 (this would tell whether the feature can be supported or needs to be in experimental/tech preview).
At least my main concern is anything to do with RAM. On Matrix, Bertrand suggested that none of the messages should contain addresses. What about the transport? Is it using buffer? If so, are they fixed?
Brief looking at Linux, there are multiple DT compatible. IIUC, we would only support "arm,scmi-smc" with the implementation. If so, maybe we should check the DT.
Some clarifications as I was asked on Matrix. The issue described in this patch is not specific to SCMI. So I think the SCMI trapping & forward should be part of common code. If it we are not sure whether it is safe, then it should be protected by CONFIG_EXPERT or CONFIG_UNSUPPORTED.
I hope this clarifies what I would like. Not sure if the others agree though.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/5] xen/arm: platforms: Add NXP S32CC platform code
Quoted 99 lines · Julien Grall
Quoted 90 lines · Julien Grall
Quoted 79 lines · Stefano Stabellini
Quoted 78 lines · Bertrand Marquis
Hi Andrei,
Quoted 42 lines
On 11 Sep 2024, at 23:05, Andrei Cherechesu
<[email protected]> wrote:Hi Julien, Stefano,
Quoted 8 lines · Stefano Stabellini
Quoted 6 lines · Julien Grall
Hi,
Quoted 2 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Added support for NXP S32CC platforms (S32G2, S32G3, S32R45), which need SCMI over SMC calls forwarded to the firmware running at EL3 (TF-A). Linux relies on the SCMI Platform for system services such as clocking, reset, etc.
Is it SMCI as in the Arm spec? If so, this should not be platform specific.
Yes, it is SCMI as defined by Arm. I agree it shouldn't be platform specific.
Quoted 8 lines
Quoted 8 lines
Furthermore, I was under the impression that we can't blindly forward
everything from a domain to the firmware. While it might be okayish for dom0,
you also seem to give access to all the domains on the system is it intended?In our case, only Dom0 has access to the SCMI mailbox. Hence, the other unprivileged domains are not aware of SCMI and do not make any SCMI requests to FW.
Quoted 9 lines
Quoted 9 lines
Anyway, there is a series on the ML to add a mediator for SCMI in Xen (see
[1]). I think it would be preferable to focus on getting it merged as it wouldbenefit everyone and increase the security posture (we could restrict access).
Quoted 7 lines
I also asked a few months ago on the ML in a virtio related thread if there are any updates regarding
SCMI awareness for Xen and guests, then Stefano CCed Bertrand, but he did not comment [0].
I'm curious why the SCMI mediator patch series did not progress.
[0]
https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2401111627360.3675@ubuntu-linux-20-04-desktop/Sorry it seems i missed that one.
There are several initiatives ongoing to investigate the global problem of clock handling and more specifically
SCMI "sharing".
The SCMI protocol contains some features to have virtual channels and the question is how to make a transport
that is hypervisor agnostic to prevent to require the hypervisors to have to "decode" SCMI messages.Virtio-scmi is not really used for clock management per say at the moment and more specifically I do not
think it is a good solution to manage clocks of non virtio devices.In Soafee and in Linaro people are looking at using FF-A as a tansport for SCMI.
The idea would be that the hypervisor is configuring the virtual SCMI channels using FF-A as a transport
and then VMs are using FF-A to communicate with an SCMI server (probably sitting in secure world, at
least as a proxy). This is an investigation for now.Requiring Xen to act as a mediator is also a solution but might require a lot of platform specific code
which i think we should prevent.Quoted 5 lines
Quoted 3 lines
For now having a solution in Xen where SCMI calls through SMC are only allowed by Dom0 is the only
short term solution I think.+1
I am open to go this way. But I would like the commit message to contain some details on whether this will always work fine for dom0 (this would tell whether the feature can be supported or needs to be in experimental/tech preview).
Quoted 7 lines
At least my main concern is anything to do with RAM. On Matrix, Bertrand suggested that none of the messages should contain addresses. What about the transport? Is it using buffer? If so, are they fixed?
Brief looking at Linux, there are multiple DT compatible. IIUC, we would only support "arm,scmi-smc" with the implementation. If so, maybe we should check the DT.
Quoted 6 lines
Some clarifications as I was asked on Matrix. The issue described in this patch is not specific to SCMI. So I think the SCMI trapping & forward should be part of common code. If it we are not sure whether it is safe, then it should be protected by
CONFIG_EXPERTorCONFIG_UNSUPPORTED.I hope this clarifies what I would like. Not sure if the others agree though.
I think it is a good idea to make the SCMI trapping and forwarding in common code. I am fine with that. I think it is OK to enable it by default without CONFIG_EXPERT. I am OK with or without using CONFIG_UNSUPPORTED. I am happy either way. Thanks Julien, good suggestion.
PATCH 4/5 xen/arm: Enable early printk for S32CC via LINFlexD UART
In reply to Andrei Cherechesu (OSS)From: Andrei Cherechesu <[email protected]>
Enabled the support for debug through early printk on S32CC platforms via the NXP LINFlexD UART driver.
--- xen/arch/arm/Kconfig.debug | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/arm/Kconfig.debug +4 -0
@@ -168,6 +168,9 @@ choice config EARLY_PRINTK_RCAR3 bool "Early printk with SCIF2 on Renesas R-Car Gen3 processors" select EARLY_UART_SCIF + config EARLY_PRINTK_S32CC + bool "Early printk with NXP LINFlexD UART on NXP S32CC processors" + select EARLY_UART_LINFLEX config EARLY_PRINTK_SEATTLE bool "Early printk with pl011 for AMD Seattle processor" select EARLY_UART_PL011
@@ -243,6 +246,7 @@ config EARLY_UART_BASE_ADDRESS default 0xd0012000 if EARLY_PRINTK_MVEBU default 0x48020000 if EARLY_PRINTK_OMAP5432 default 0xe6e88000 if EARLY_PRINTK_RCAR3 + default 0x401c8000 if EARLY_PRINTK_S32CC default 0xe1010000 if EARLY_PRINTK_SEATTLE default 0x01c28000 if EARLY_PRINTK_SUN6I default 0x01c28000 if EARLY_PRINTK_SUN7I
Signature · 1 line
2.45.2
Re: [PATCH v1 4/5] xen/arm: Enable early printk for S32CC via LINFlexD UART
Hi,
Quoted 3 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Enabled the support for debug through early printk on S32CC
NIT: We tend to avoid using past tense when describing the change. So s/Enabled/Enable/. However...
Quoted 12 lines
platforms via the NXP LINFlexD UART driver.
Signed-off-by Andrei Cherechesu <[email protected]>--- xen/arch/arm/Kconfig.debug | 4 ++++ 1 file changed, 4 insertions(+)xen/arch/arm/Kconfig.debug +0
-0
xen/arch/arm/Kconfig.debug choice · line 173
Quoted 6 lines
xen/arch/arm/Kconfig.debug +3
-0@@ -168,6 +168,9 @@ choice config EARLY_PRINTK_RCAR3 bool "Early printk with SCIF2 on Renesas R-Car Gen3 processors" select EARLY_UART_SCIF + config EARLY_PRINTK_S32CC + bool "Early printk with NXP LINFlexD UART on NXP S32CC processors" + select EARLY_UART_LINFLEX
... we stopped adding platform specific early printk a while ago because this is not scalable.
Instead, we prefer to write a page in [1] which will provide all the information how to setup and debug Xen on a SoC (could be one per family).
Cheers,
[1] https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions
Signature · 1 line
Julien Grall
PATCH 5/5 xen/arm: Enable workaround for Cortex-A53 erratum #1530924
In reply to Andrei Cherechesu (OSS)From: Andrei Cherechesu <[email protected]>
All versions of Cortex-A53 cores are affected by the speculative AT instruction erratum, as mentioned in the Cortex-A53 Revision r0 SDEN v21 documentation.
Enabled ARM64_WORKAROUND_AT_SPECULATE for all versions of Cortex-A53 cores, to avoid corrupting the TLB if performing a speculative AT instruction during a guest context switch.
--- docs/misc/arm/silicon-errata.txt | 1 + xen/arch/arm/cpuerrata.c | 6 ++++++ 2 files changed, 7 insertions(+)
docs/misc/arm/silicon-errata.txt +1 -0
@@ -46,6 +46,7 @@ stable hypervisors. | ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 | | ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 | | ARM | Cortex-A53 | #843419 | ARM64_ERRATUM_843419 | +| ARM | Cortex-A53 | #1530924 | N/A | | ARM | Cortex-A55 | #1530923 | N/A | | ARM | Cortex-A57 | #852523 | N/A | | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 |
xen/arch/arm/cpuerrata.c +6 -0
@@ -683,6 +683,12 @@ static const struct arm_cpu_capabilities arm_errata[] = { .capability = ARM64_WORKAROUND_AT_SPECULATE, MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), }, + { +/* Cortex-A53 (All versions) */ + .desc = "ARM erratum 1530924", + .capability = ARM64_WORKAROUND_AT_SPECULATE, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A53), + }, {}, };
Signature · 1 line
2.45.2
Re: [PATCH v1 5/5] xen/arm: Enable workaround for Cortex-A53 erratum #1530924
Hi,
Quoted 11 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
All versions of Cortex-A53 cores are affected by the speculative AT instruction erratum, as mentioned in the Cortex-A53 Revision r0 SDEN v21 documentation.
Enabled
ARM64_WORKAROUND_AT_SPECULATEfor all versions of Cortex-A53 cores, to avoid corrupting the TLB if performing a speculative AT instruction during a guest context switch.Signed-off-by Andrei Cherechesu <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 5/5] xen/arm: Enable workaround for Cortex-A53 erratum #1530924
Hi,
Quoted 7 lines · Julien Grall
Quoted 6 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
All versions of Cortex-A53 cores are affected by the speculative AT instruction erratum, as mentioned in the Cortex-A53 Revision r0 SDEN v21 documentation.
Quoted 7 lines
Quoted 5 lines
Enabled
ARM64_WORKAROUND_AT_SPECULATEfor all versions of Cortex-A53 cores, to avoid corrupting the TLB if performing a speculative AT instruction during a guest context switch.Signed-off-by Andrei Cherechesu <[email protected]>Acked-by Julien Grall <[email protected]>
I have committed this patch.
Cheers,
Signature · 1 line
Julien Grall
Hello,
I think it would be a good idea to update the CHANGELOG.md as well and mention that support for the S32CC platform has been added.
Thanks.
~ Oleksii
Quoted 52 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
This patch series adds support for NXP Automotive S32CC platform family, which includes S32G [0] and S32R [1].
First patch adds the driver for the NXP LINFlexD UART, available on S32V, S32G and S32R automotive processors. The compatibles in the driver match the ones in upstream Linux [2]. The second patch adds early printk support via LINFlexD UART.
The third patch introduces the S32CC platforms and adds the platform-specific code, which enables forwarding SCMI over SMC calls to software running at EL3. The fourth patch adds support for an early printk menuconfig option for S32CC platforms using the LINFlexD UART.
The fifth patch enables the workaround for ARM Cortex-A53 erratum 1530924, already implemented in Xen for other cores via
ARM64_WORKAROUND_AT_SPECULATE.[0]
https://www.nxp.com/products/processors-and-microcontrollers/s32-automotive-platform/s32g-vehicle-network-processors:S32G-PROCESSORS
[1]
https://www.nxp.com/products/processors-and-microcontrollers/s32-automotive-platform/s32r-radar-processing:S32R-FAMILY
[2]
https://elixir.bootlin.com/linux/v6.11-rc7/source/Documentation/devicetree/bindings/serial/fsl,s32-linflexuart.yaml#L27Andrei Cherechesu (5):
xen/arm: Add NXP LINFlexD UART Driver
xen/arm: Add NXP LINFlexD UART early printk support xen/arm: platforms: Add NXP S32CC platform code xen/arm: Enable early printk for S32CC via LINFlexD UART xen/arm: Enable workaround for Cortex-A53 erratum #1530924docs/misc/arm/silicon-errata.txt | 1 + xen/arch/arm/Kconfig.debug | 18 ++ xen/arch/arm/arm64/debug-linflex.inc | 58 ++++ xen/arch/arm/cpuerrata.c | 6 +
xen/arch/arm/include/asm/linflex-uart.h| 62 ++++ xen/arch/arm/platforms/Kconfig | 10 + xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/s32cc.c | 84 ++++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/linflex-uart.c | 365
++++++++++++++++++++++++11 files changed, 614 insertions(+)create mode 100644 xen/arch/arm/arm64/debug-linflex.inc create mode 100644
xen/arch/arm/include/asm/linflex-uart.hcreate mode 100644xen/arch/arm/platforms/s32cc.ccreate mode 100644xen/drivers/char/linflex-uart.c