lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bjwxoyzo.wl-maz@kernel.org>
Date: Fri, 27 Dec 2024 16:46:19 +0000
From: Marc Zyngier <maz@...nel.org>
To: Dragan Simic <dsimic@...jaro.org>
Cc: linux-rockchip@...ts.infradead.org,
	heiko@...ech.de,
	tglx@...utronix.de,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	devicetree@...r.kernel.org,
	robh@...nel.org,
	krzk+dt@...nel.org,
	conor+dt@...nel.org,
	FUKAUMI Naoki <naoki@...xa.com>
Subject: Re: [PATCH 2/2] irqchip/gic-v3-its: Make "dma-noncoherent" preferred for RK358x errata

On Fri, 27 Dec 2024 15:42:24 +0000,
Dragan Simic <dsimic@...jaro.org> wrote:
> 
> The preferred way to denote hardware with non-coherent DMA is to use the
> "dma-noncoherent" DT property, [1] instead of relying on the compatibles. [2]
> Alas, older versions of the Rockchip RK3588 and RK3588S SoC dts(i) files
> failed to specify this DT property, which means that checking the compatibles
> remains required for backward SoC dts(i) compatibility.
> 
> Let's have the Rockchip 3588001 hardware errata handled the preferred way,
> with newer versions of the Rockchip RK3588, RK3588S and RK3582 SoC dts(i)
> files that properly specify the "dma-noncoherent" DT properties at both the
> GIC redistributor and the GIC ITS levels, while falling back to checking the
> compatibles for backward RK3588 and RK3588S SoC dts(i) compatibility.
> 
> [1] Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.yaml
> [2] https://lore.kernel.org/linux-rockchip/86msgoozqa.wl-maz@kernel.org/
> 
> Cc: Marc Zyngier <maz@...nel.org>
> Cc: FUKAUMI Naoki <naoki@...xa.com>
> Signed-off-by: Dragan Simic <dsimic@...jaro.org>
> ---
>  drivers/irqchip/irq-gic-v3-its.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index fdec478ba5e7..982dcbb30f39 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -4747,6 +4747,18 @@ static bool __maybe_unused its_enable_rk3588001(void *data)
>  {
>  	struct its_node *its = data;
>  
> +	/*
> +	 * The preferred way to denote hardware with non-coherent DMA is to use
> +	 * the "dma-noncoherent" DT property, which the older RK3588 SoC dts(i)
> +	 * files failed to specify, relying on the compatibles instead.
> +	 *
> +	 * Thus, check for the presence of "dma-noncoherent" DT property first,
> +	 * to let the hardware quirk be handled the preferred way, and fall back
> +	 * to checking the compatibles for backward dts(i) compatibility.
> +	 */
> +	if (!of_dma_is_coherent(to_of_node(its->fwnode_handle)))
> +		return false;
> +
>  	if (!of_machine_is_compatible("rockchip,rk3588") &&
>  	    !of_machine_is_compatible("rockchip,rk3588s"))
>  		return false;
> 

I'm sorry, but this patch serves no purpose. We already have a
workaround in place, and we don't need to handle it *twice*.

Worse, it is actively harmful. A DT that would only advertise the
property on the ITS would result in a broken system, while it would
work correctly with the current code.

Additionally, look at what of_dma_is_coherent() does, and how it will
fetch a property that is potentially completely unrelated to the GIC
node, or eventually return some random default. The binding documents
the dma-noncoherent property as part of the relevant nodes, and not
anywhere else.

In the end, this is just dead code, and potentially worse. So while
I'm rather supportive of your first patch in this series as it allows
OSs other than Linux to *maybe* avoid this hack, the Linux driver
doesn't need any change.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ