On 12/18/2017 03:07 PM, Kevin Darbyshire-Bryant wrote:
> 
> 
>> On 18 Dec 2017, at 10:12, Felix Fietkau <n...@nbd.name> wrote:
>>
>> On 2017-12-18 11:07, Kevin Darbyshire-Bryant wrote:
>>> Hi Felix,
>>>
>>> Thanks for explaining that.  I suspect you’re right that there’s an 
>>> underlying bug in gcc mips.  So ideally we need some code that exposes the 
>>> bug when using -O2 (or even just -funroll_loops) Looking at FS 814 there’s 
>>> a hint in there that uhttpd was similarly affected…and not solved by the 
>>> patch drop.  So what to do if there’s a bug just lurking to bite us?
>>
>> If possible, reproduce it on uhttpd with an unmodified upstream version
>> of GCC and open up a bug report.
>>
>> - Felix
> 
> Sadly I’m unable to reproduce the uhttpd issue - frustrating.
> 
> Cheers,
> 
> Kevin D-B

Hi,

The attached patch also made the problem disappear.
This patch builds the code with -funroll-loops in addition, otherwise
only the default settings are used.

Hauke
From 2b58f2cac799c4eca511b12d068bd043c7f8b014 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <ha...@hauke-m.de>
Date: Sun, 17 Dec 2017 14:43:28 +0100
Subject: [PATCH] dropbear: fix libtommath for GCC 7

This adds a workaround needef for GCC 7 into the libtommath.
With this workaorund dropbear is able to generate a RSA key, otherwise not.

Size before:
ipk:       86.469
dropbear: 172.405

Size with this cahnge on MIPS BE 24KEc
ipk:       87.660
dropbear: 172.405

Signed-off-by: Hauke Mehrtens <ha...@hauke-m.de>
---
 .../patches/700-use-unroll-loops-for-gcc7.patch        | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 package/network/services/dropbear/patches/700-use-unroll-loops-for-gcc7.patch

diff --git a/package/network/services/dropbear/patches/700-use-unroll-loops-for-gcc7.patch b/package/network/services/dropbear/patches/700-use-unroll-loops-for-gcc7.patch
new file mode 100644
index 0000000000..7d30f10db9
--- /dev/null
+++ b/package/network/services/dropbear/patches/700-use-unroll-loops-for-gcc7.patch
@@ -0,0 +1,18 @@
+When we compile the libtommath math library without -funroll-loops for 
+MIPS BE 24KEc with GCC 7.2 the math library will not work correctly. 
+This was not seen on older gcc versions. 
+You can test it with "/usr/bin/dropbearkey -t rsa -f /tmp/rsa-key" on a 
+MIPS BE 24KEc CPU, if it returns in about 1 minute it is ok otherwise 
+you hit the bug. The If C is too low check in the mp_invmod_slow() 
+function  will never finish.
+
+--- a/libtommath/Makefile.in
++++ b/libtommath/Makefile.in
+@@ -11,6 +11,7 @@ srcdir=@srcdir@
+ # So that libtommath can include Dropbear headers for options and m_burn()
+ CFLAGS += -I. -I$(srcdir) -I../libtomcrypt/src/headers/ -I$(srcdir)/../libtomcrypt/src/headers/ -I../ -I$(srcdir)/../
+ 
++CFLAGS += -funroll-loops -Wall
+ ifndef IGNORE_SPEED
+ 
+ #for speed 
-- 
2.11.0

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to