Skip to content

x/crypto/chacha20poly1305: illegal instruction on AMD E2-1800 APU #17464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jakobvarmose opened this issue Oct 16, 2016 · 1 comment
Closed
Milestone

Comments

@jakobvarmose
Copy link

What version of Go are you using (go version)?

go version go1.7.1 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/i/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build762679001=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

I'm trying to encrypt some data using "golang.org/x/crypto/chacha20poly1305". But I receive an illegal instruction error. I have tried disabling the ASM implementation and this makes the error go away. So apparently it fails to detect that my processor does not support the ASM implementation.

Processor information:

processor   : 0
vendor_id   : AuthenticAMD
cpu family  : 20
model       : 2
model name  : AMD E2-1800 APU with Radeon(tm) HD Graphics
stepping    : 0
microcode   : 0x500010d
cpu MHz     : 1360.000
cache size  : 512 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 6
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt arat hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall
bogomips    : 3393.80
TLB size    : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate

processor   : 1
vendor_id   : AuthenticAMD
cpu family  : 20
model       : 2
model name  : AMD E2-1800 APU with Radeon(tm) HD Graphics
stepping    : 0
microcode   : 0x500010d
cpu MHz     : 850.000
cache size  : 512 KB
physical id : 0
siblings    : 2
core id     : 1
cpu cores   : 2
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 6
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt arat hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall
bogomips    : 3393.80
TLB size    : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate

Example program:

package main

import (
    "crypto/rand"
    "fmt"

    "golang.org/x/crypto/chacha20poly1305"
)

func main() {
    key := make([]byte, 32)
    if _, err := rand.Read(key); err != nil {
        panic(err)
    }
    e, err := chacha20poly1305.New(key)
    if err != nil {
        panic(err)
    }
    nonce := make([]byte, e.NonceSize())
    adata := make([]byte, 10)
    plaintext := make([]byte, 10)
    ciphertext := e.Seal(nil, nonce, plaintext, adata)
    fmt.Printf("%x\n", ciphertext)
}

What did you expect to see?

I expected the program to complete without error.

What did you see instead?

SIGILL: illegal instruction
PC=0x467793 m=0

goroutine 1 [running]:
golang.org/x/crypto/chacha20poly1305.chacha20Poly1305Seal(0xc42000e360, 0x1a, 0x1a, 0xc420039d20, 0x10, 0x10, 0xc42000a410, 0xa, 0xa, 0xc42000a400, ...)
    /home/i/go/src/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s:1908 +0x1573 fp=0xc420039c80 sp=0xc420039b50
golang.org/x/crypto/chacha20poly1305.(*chacha20poly1305).seal(0xc42000e340, 0x0, 0x0, 0x0, 0xc42000a3f0, 0xc, 0xc, 0xc42000a410, 0xa, 0xa, ...)
    /home/i/go/src/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go:58 +0x18b fp=0xc420039d80 sp=0xc420039c80
golang.org/x/crypto/chacha20poly1305.(*chacha20poly1305).Seal(0xc42000e340, 0x0, 0x0, 0x0, 0xc42000a3f0, 0xc, 0xc, 0xc42000a410, 0xa, 0xa, ...)
    /home/i/go/src/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go:51 +0xf9 fp=0xc420039e30 sp=0xc420039d80
main.main()
    /home/i/sigill/test.go:22 +0x268 fp=0xc420039f48 sp=0xc420039e30
runtime.main()
    /usr/local/go/src/runtime/proc.go:183 +0x1f4 fp=0xc420039fa0 sp=0xc420039f48
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc420039fa8 sp=0xc420039fa0

rax    0x0
rbx    0xa
rcx    0xa
rdx    0x0
rdi    0xc42000e360
rsi    0xc42000a419
rbp    0xc420039b60
rsp    0xc420039b50
r8     0x79168a0100fe71
r9     0xa0
r10    0x35e5ad0c4e2ba2
r11    0x25d70b20504f835
r12    0x2
r13    0x4d7a40
r14    0x1e45a280403f9c4
r15    0xac789027608ba
rip    0x467793
rflags 0x10216
cs     0x33
fs     0x0
gs     0x0
@bradfitz bradfitz added this to the Go1.8 milestone Oct 16, 2016
@bradfitz bradfitz changed the title Illegal instruction in "golang.org/x/crypto/chacha20poly1305" x/crypto/chacha20poly1305: illegal instruction on AMD E2-1800 APU Oct 16, 2016
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/31187 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 17, 2017
c-expert-zigbee pushed a commit to c-expert-zigbee/crypto_go that referenced this issue Mar 28, 2022
The SSE code of chacha20poly1305 used PINSRB and PEXTRQ, which are only available
on machines supporting SSE4.1.

Fixes golang/go#17464

Change-Id: Ic7313433cb21f9a3709d23b50ab58ac1d87957af
Reviewed-on: https://go-review.googlesource.com/31187
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
c-expert-zigbee pushed a commit to c-expert-zigbee/crypto_go that referenced this issue Mar 29, 2022
The SSE code of chacha20poly1305 used PINSRB and PEXTRQ, which are only available
on machines supporting SSE4.1.

Fixes golang/go#17464

Change-Id: Ic7313433cb21f9a3709d23b50ab58ac1d87957af
Reviewed-on: https://go-review.googlesource.com/31187
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@rsc rsc unassigned agl Jun 23, 2022
LewiGoddard pushed a commit to LewiGoddard/crypto that referenced this issue Feb 16, 2023
The SSE code of chacha20poly1305 used PINSRB and PEXTRQ, which are only available
on machines supporting SSE4.1.

Fixes golang/go#17464

Change-Id: Ic7313433cb21f9a3709d23b50ab58ac1d87957af
Reviewed-on: https://go-review.googlesource.com/31187
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
BiiChris pushed a commit to BiiChris/crypto that referenced this issue Sep 15, 2023
The SSE code of chacha20poly1305 used PINSRB and PEXTRQ, which are only available
on machines supporting SSE4.1.

Fixes golang/go#17464

Change-Id: Ic7313433cb21f9a3709d23b50ab58ac1d87957af
Reviewed-on: https://go-review.googlesource.com/31187
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
desdeel2d0m added a commit to desdeel2d0m/crypto that referenced this issue Jul 1, 2024
The SSE code of chacha20poly1305 used PINSRB and PEXTRQ, which are only available
on machines supporting SSE4.1.

Fixes golang/go#17464

Change-Id: Ic7313433cb21f9a3709d23b50ab58ac1d87957af
Reviewed-on: https://go-review.googlesource.com/31187
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants