Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Default O2 optimization breaks libcrypto on Sparc64

From: Pyun YongHyeon <yongari(at)kt-is.co.kr>
Date: Mon Jul 21 2003 - 23:19:58 EDT


>Submitter-Id: net
>Originator: Pyun YongHyeon
>Organization: net
>Synopsis: Default O2 optimization breaks libcrypto on Sparc64
>Severity: serious
        

	System      : OpenBSD 3.3-current
	Architecture: OpenBSD.sparc64
	Machine     : sparc64

>Description:
Default generation of libcrypto on OpenBSD uses -O2 optimization. This creates an invalid intructions on Sparc64.(mine is Ultra2) Any applications that uses the library does not work as expected. For example, ssh-keygen can't generate 1024bit DSA keys. (Generating 512bit DSA key works but it takes a long time. Any other bits gerater than 512 does not work and the program hangs.) To find out the exact location of error I have used openssl-0.9.7b.tar.gz from < http://www.openssl.org>. My configuration for the OpenSSL is: %./config --prefix=/tmp/T no-threads no-asm no-rc5 no-idea %make depend %make %make test .... test BN_mod test BN_mod_mul test BN_mont test BN_mod_exp test BN_exp test BN_kronecker ...................................++++++ ............4654:error:0306F065:bignum routines:BN_mod_mul_reciprocal:bad reciprocal:bn_recp.c:193: *** Error code 1 Stop in /home/yongari/openssl-0.9.7b/test (line 219 of Makefile.ssl). *** Error code 1 Stop in /home/yongari/openssl-0.9.7b (line 674 of Makefile). So I removed all optimization flags. After this removal, I can manage to pass 'make test'. Armed with this information, I tried to remove default OpenBSD O2 compilation flags like this. --- /usr/src/lib/libssl/crypto/Makefile.ORG Tue Jul 22 05:58:16 2003 +++ /usr/src/lib/libssl/crypto/Makefile Tue Jul 22 21:01:24 2003
@@ -18,7 +18,11 @@
 .if ${MACHINE_ARCH} == "alpha"
 # no ENDIAN stuff defined for alpha
 .else
+.if ${MACHINE_ARCH} == "sparc64"
+CFLAGS= -DB_ENDIAN
+.else

 CFLAGS+= -DB_ENDIAN
+.endif
 .endif
 .endif
 .endif

	After installing the generated libcrypto I can genrate a 1024bit
	DSA keys within a mininute.
	BTW, I can hardly beleive this problem. Because OpenBSD have supported
	many Sparc64 systems for a long time. Does this problem only
	apply to my old Ultra2? I also attached my demsg output.
Do you need help?X
Note! The esp(4) driver was modified by me to support all 16 devices. The patch for esp(4) was posted to sparc@openbsd. Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2003 OpenBSD. All rights reserved. http://www.OpenBSD.org

OpenBSD 3.3-current (GENERIC) #3: Mon Jul 21 21:49:06 KST 2003

    root@daemon.kt-is.co.kr:/usr/src/sys/arch/sparc64/compile/GENERIC total memory = 268435456
avail memory = 240099328
using 1638 buffers containing 13418496 bytes of memory bootpath: /sbus@1f,0/SUNW,fas@e,8800000/sd@3,0 mainbus0 (root): Sun Ultra 2 UPA/SBus (2 X UltraSPARC-II 296MHz) cpu0 at mainbus0: SUNW,UltraSPARC-II @ 295.999 MHz, version 0 FPU cpu0: physical 32K instruction (32 b/l), 16K data (32 b/l), 2048K external (64 b/l) timer0 at mainbus0 addr 0xfffc3c00 irq vectors 7f0 and 7f1 sbus0 at mainbus0 addr 0xfffc8000: clock = 25 MHz STC0 on /mainbus enabled
DVMA map: ff800000 to ffffe000
IOTDB: f68000 to f6a000
audiocs0 at sbus0 slot 13 offset 0xc000000 vector 24 ipl 13 audio0 at audiocs0
auxio0 at sbus0 slot 15 offset 0x1900000 flashprom at sbus0 slot 15 offset 0x0 not configured SUNW,fdtwo at sbus0 class block slot 15 offset 0x1400000 vector 29 ipl 11 not configured clock0 at sbus0 slot 15 offset 0x1200000: mk48t59: hostid 8086aba4 zs0 at sbus0 slot 15 offset 0x1100000 vector 28 ipl 12 softpri 6 zstty0 at zs0 channel 0
zstty1 at zs0 channel 1
zs1 at sbus0 slot 15 offset 0x1000000 vector 28 ipl 12 softpri 6 zskbd0 at zs1 channel 0: layout 47
wskbd0 at zskbd0: console keyboard
zstty2 at zs1 channel 1, mouse
uperf0 at sbus0 slot 15 offset 0x1300000: model SUNW,sc-mp (0/3) ports 4 SUNW,pll at sbus0 slot 15 offset 0x1304000 not configured esp0 at sbus0 slot 14 offset 0x8800000 vector 20 ipl 3: dma rev fas esp0: FAS366/HME, 40MHz, SCSI ID 7
scsibus0 at esp0: 16 targets
sd0 at scsibus0 targ 0 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd0: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total sd1 at scsibus0 targ 1 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd1: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total sd2 at scsibus0 targ 2 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd2: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total sd3 at scsibus0 targ 3 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd3: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total sd4 at scsibus0 targ 4 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd4: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total sd5 at scsibus0 targ 5 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd5: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total cd0 at scsibus0 targ 6 lun 0: <TOSHIBA, XM5701TASUN12XCD, 0997> SCSI2 5/cdrom removable sd6 at scsibus0 targ 8 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed sd6: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total sd7 at scsibus0 targ 9 lun 0: <SEAGATE, ST39102LCSUN9.0G, 0828> SCSI2 0/direct fixed

sd7: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total
sd8 at scsibus0 targ 10 lun 0:  SCSI2 0/direct fixed
sd8: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total
sd9 at scsibus0 targ 11 lun 0:  SCSI2 0/direct fixed
sd9: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total
sd10 at scsibus0 targ 12 lun 0:  SCSI2 0/direct fixed
sd10: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total
sd11 at scsibus0 targ 13 lun 0:  SCSI2 0/direct fixed
sd11: 8637MB, 4926 cyl, 27 head, 133 sec, 512 bytes/sec, 17689267 sec total
sd12 at scsibus0 targ 14 lun 0:  SCSI2 0/direct fixed
sd12: 4094MB, 3882 cyl, 16 head, 135 sec, 512 bytes/sec, 8385121 sec total
sd13 at scsibus0 targ 15 lun 0: <SEAGATE, ST34371W SUN4.2G, 7462> SCSI2 0/direct fixed sd13: 4094MB, 3882 cyl, 16 head, 135 sec, 512 bytes/sec, 8385121 sec total hme0 at sbus0 slot 14 offset 0x8c00000 vector 21 ipl 6: address 08:00:20:86:ab:a4 nsphy0 at hme0 phy 1: DP83840 10/100 media interface, rev. 1 SUNW,bpp at sbus0 slot 14 offset 0xc800000 vector 22 ipl 2 not configured creator0 at mainbus0 addr 0xfec00000: Creator, model SUNW,501-2634, dac 10 wsdisplay0 at creator0: console (std, sun emulation), using wskbd0 pcons at mainbus0 not configured
root on sd3a
rootdev=0x730 rrootdev=0x1130 rawdev=0x1132

>How-To-Repeat:

	Generate 1024bit DSA key with ssh-keygen on Ultra2.
	%ssh-keygen -t dsa -b 1024

>Fix:
No source fixes are available. I'm afraid gcc optimizer generates corrupted code on Sparc64. Possible workaround: Remove O2 optimization flag in Makfile of libcrypto.
-- 
Pyun YongHyeon <
http://www.kr.freebsd.org/~yongari>
Received on Mon Jul 21 23:42:52 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:30:00 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library