Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Illegal instruction in libcrypto.so



Dear all,

I frequently encounter an illegal instruction when using SSL with python2.7 and wip/rawdog.

  $ uname -a
  NetBSD HOME 7.99.53 NetBSD 7.99.53 (YORICK.amd64) #0: Sun Jan  1 16:42:47 SAST 2017  root@HOME:/root/build.amd64.local/obj/sys/arch/amd64/compile/YORICK.amd64 amd64

It seems OpenSSL is using instructions which are not available on my CPU
(no known problems on 7-STABLE).

The last few entries of the the backtrace are:

  Core was generated by `python2.7'.
  Program terminated with signal SIGILL, Illegal instruction.
  #0  0x000071df7e9735ca in bn_GF2m_mul_2x2 () from /usr/lib/libcrypto.so.12
  [Current thread is 1 (LWP 1)]
  (gdb) bt
  #0  0x000071df7e9735ca in bn_GF2m_mul_2x2 () from /usr/lib/libcrypto.so.12
  #1  0x000071df7e96ebb7 in BN_GF2m_mod_mul_arr () from /usr/lib/libcrypto.so.12
  #2  0x000071df7e968cc9 in ec_GF2m_simple_is_on_curve () from /usr/lib/libcrypto.so.12
  #3  0x000071df7e927733 in ec_GF2m_simple_oct2point () from /usr/lib/libcrypto.so.12
  #4  0x000071df7ee45813 in ssl3_get_key_exchange () from /usr/lib/libssl.so.12
  #5  0x000071df7ee46789 in ssl3_connect () from /usr/lib/libssl.so.12
  #6  0x000071df7cc0bdbe in PySSL_SSLdo_handshake () from /usr/pkg/lib/python2.7/lib-dynload/_ssl.so
  #7  0x000071df842d39bd in PyEval_EvalFrameEx () from /usr/pkg/lib/libpython2.7.so.1.0

  Dump of assembler code for function bn_GF2m_mul_2x2:
     0x000071df7e9735a0 <+0>:     lea    0x2b30f5(%rip),%rax        # 0x71df7ec2669c <OPENSSL_ia32cap_P>
     0x000071df7e9735a7 <+7>:     bt     $0x21,%rax
     0x000071df7e9735ac <+12>:    jae    0x71df7e973610 <bn_GF2m_mul_2x2+112>
     0x000071df7e9735ae <+14>:    movq   %rsi,%xmm0
     0x000071df7e9735b3 <+19>:    movq   %rcx,%xmm1
     0x000071df7e9735b8 <+24>:    movq   %rdx,%xmm2
     0x000071df7e9735bd <+29>:    movq   %r8,%xmm3
     0x000071df7e9735c2 <+34>:    movdqa %xmm0,%xmm4
     0x000071df7e9735c6 <+38>:    movdqa %xmm1,%xmm5
  => 0x000071df7e9735ca <+42>:    pclmullqlqdq %xmm1,%xmm0
     0x000071df7e9735d0 <+48>:    pxor   %xmm2,%xmm4
     0x000071df7e9735d4 <+52>:    pxor   %xmm3,%xmm5
     0x000071df7e9735d8 <+56>:    pclmullqlqdq %xmm3,%xmm2
     0x000071df7e9735de <+62>:    pclmullqlqdq %xmm5,%xmm4

The CPU features clearly omit PCLMULQDQ:

  $ cpuctl identify 0
  cpu0: highest basic info 00000005
  cpu0: highest extended info 8000001b
  cpu0: "AMD Athlon(tm) II X3 450 Processor"
  cpu0: AMD Family 10h (686-class), 3200.27 MHz
  cpu0: family 0x10 model 0x5 stepping 0x3 (id 0x100f53)
  cpu0: features 0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE>
  cpu0: features 0x178bfbff<MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  cpu0: features1 0x802009<SSE3,MONITOR,CX16,POPCNT>
  cpu0: features2 0xefd3fbff<SYSCALL/SYSRET,NOX,MMXX,FFXSR,P1GB,RDTSCP,LONG>
  cpu0: features2 0xefd3fbff<3DNOW2,3DNOW>
  cpu0: features3 0x37ff<LAHF,CMPLEGACY,SVM,EAPIC,ALTMOVCR0,LZCNT,SSE4A>
  cpu0: features3 0x37ff<MISALIGNSSE,3DNOWPREFETCH,OSVW,IBS,SKINIT,WDT>
  cpu0: I-cache 64KB 64B/line 2-way, D-cache 64KB 64B/line 2-way
  cpu0: L2 cache 512KB 64B/line 16-way
  cpu0: ITLB 32 4KB entries fully associative, 16 2MB entries fully associative
  cpu0: DTLB 48 4KB entries fully associative, 48 2MB entries fully associative
  cpu0: L2 ITLB 512 4KB entries 4-way
  cpu0: L2 DTLB 512 4KB entries 4-way, 128 2MB entries 2-way
  cpu0: L1 1GB page DTLB 48 1GB entries fully associative
  cpu0: L2 1GB page DTLB 16 1GB entries 8-way
  cpu0: Initial APIC ID 0
  cpu0: AMD Power Management features: 0x1f9<TS,TTP,HTC,STC,100,HWP,TSC>
  cpu0: SVM Rev. 1
  cpu0: SVM NASID 64
  cpu0: SVM features 0xf<NP,LbrVirt,SVML,NRIPS>
  cpu0: UCode version: 0x10000c8


A wild guess is that this change is involved

 http://cvsweb.netbsd.org/bsdweb.cgi/src/crypto/external/bsd/openssl/dist/crypto/bn/asm/x86_64-gf2m.pl.diff?r1=1.3&r2=1.4

but I don't understand the change.

Any ideas what could be wrong?

-- 
Kind regards,

Yorick Hardy


Home | Main Index | Thread Index | Old Index