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  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]
Date:   Sun, 26 May 2019 06:19:00 -0300
From:   Alexandre Oliva <>
To:     "Maciej W. Rozycki" <>
Cc:     Aaro Koskinen <>, Tom Li <>,
        James Hogan <>,
        Jiaxun Yang <>,
        Huacai Chen <>,
        Ralf Baechle <>,,
Subject: Re: [RFC] On the Current Troubles of Mainlining Loongson Platform Drivers

On Mar  8, 2019, "Maciej W. Rozycki" <> wrote:

>  Anyway I meant: does `war_io_reorder_wmb' expand to `wmb' on your system?

No, it expands to `barrier' on the yeeloong:


I've finally managed to do the bisection on object files I mentioned I'd
do to try to pinpoint where __BUILT_IOPORT_PFX with barrier rather than
!barrier regressed.

I found that forcing barrier off for drivers/irqchip/irq-i8259 was
enough to avoid the problem.

(I further narrowed it down to byte I/O, which is no surprise
considering irq-i8259 doesn't seem to use any non-byte I/O.)

Then I narrowed it down to output only.

A Loongson2F kernel built with the patch below works at normal speed.
I've also keyed the -1 barrier selector to compiling the irq-i8259
driver only, and that got me a functional kernel, but I'm not confident
that the same issues that affect the interrupt controller, preventing it
from initializing correctly, is not also affecting other drivers, just
in less visible ways, so the patch conservatively reverts to the older
barriers for all I/O (i.e., non-mem) out primitives.

I've tested this on a yeeloong on top of v5.1.5.

I'm tempted to start using this patch in my Freeloong builds of GNU
Linux-libre for gnewsense/yeeloong of 5.0 and 5.1 stable releases, to
try to make them usable.  Can anyone suggest any reason why it might be
risky to do so, moving on as much as I could to the new barriers,
sticking to the 4.19-one only for non-mem out?  As in, could mixing the
barriers be riskier than reverting to the 4.19 barriers everywhere?

Thanks in advance for any insights and recommendations,

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 845fbbc7a2e3..04be4758d4ff 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -416,7 +416,7 @@ static inline void pfx##out##bwlq##p(type val, unsigned long port)	\
 	volatile type *__addr;						\
 	type __val;							\
-	if (barrier)							\
+	if (barrier > 0)						\
 		iobarrier_rw();						\
 	else								\
 		war_io_reorder_wmb();					\
@@ -467,13 +467,22 @@ BUILDIO_MEM(w, u16)
 BUILDIO_MEM(l, u32)
 BUILDIO_MEM(q, u64)
-#define __BUILD_IOPORT_PFX(bus, bwlq, type)				\
-	__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0,)			\
-	__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0, _p)
+#define __BUILD_IOPORT_PFX(bus, bwlq, type, barrier)			\
+	__BUILD_IOPORT_SINGLE(bus, bwlq, type, barrier, 0,)		\
+	__BUILD_IOPORT_SINGLE(bus, bwlq, type, barrier, 0, _p)
+/* Choose the kind of barrier used for out in __BUILD_IOPORT_SINGLE in
+   non-__mem_ variants.  On Loongson2F, irq-i8259 fails to initialize
+   when this is defined to 1.  */
+#if defined(CONFIG_CPU_LOONGSON2)
 #define BUILDIO_IOPORT(bwlq, type)					\
-	__BUILD_IOPORT_PFX(, bwlq, type)				\
-	__BUILD_IOPORT_PFX(__mem_, bwlq, type)
+	__BUILD_IOPORT_PFX(__mem_, bwlq, type, 2)

Alexandre Oliva, freedom fighter  he/him
Be the change, be Free!                 FSF Latin America board member
GNU Toolchain Engineer                        Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás - Che GNUevara

Powered by blists - more mailing lists