klauspost / cpuid

CPU feature identification for Go
MIT License
1.04k stars 128 forks source link

Change ARM implementation (SIGILL: illegal instruction) #52

Closed klauspost closed 3 years ago

klauspost commented 4 years ago

@fwessels

Looks like the only safe option is to use an OS call to get these features.

Maybe the Go runtime can provide some help?

https://github.com/golang/go/tree/master/src/internal/cpu

And some in the runtime:

https://github.com/golang/go/blob/8174f7fb2b64c221f7f80c9f7fd4d7eb317ac8bb/src/runtime/os_linux_arm64.go#L11

... though I haven't found where archauxv is actually called from.

fwessels commented 4 years ago

So it is clear that reading the registers is privileged. Since switching out of user mode is a non-starter, I am afraid we are stuck.

We can say that we support freebsd from 12.0 onwards, or we have to revert the functionality.

klauspost commented 4 years ago

@fwessels You can take a look at the Go implementation which uses a different approach.

klauspost commented 4 years ago

Called from here: https://github.com/golang/go/blob/8174f7fb2b64c221f7f80c9f7fd4d7eb317ac8bb/src/runtime/os_linux.go#L244

mholt commented 4 years ago

Has this been fixed? I see some ARM-related commits (and even a linked merged PR) but am not sure if I should update Caddy to the latest tag of this lib or not. Right now we've downgraded to v1.2.5.

klauspost commented 3 years ago

Will be fixed by https://github.com/klauspost/cpuid/pull/62

clausecker commented 3 years ago

On arm64/darwin, features can be detected using special sysctl keys. Unfortunately I do not have a machine to test that though.

klauspost commented 3 years ago

@clausecker I skipped this on purpose since I have no reasonable way of testing it.

Feel free to send a PR if you are able to test it prior.