CPU feature detection code for Apple ARMv8/ARM64 gadgets?

5 views
Skip to first unread message

Jeffrey Walton

unread,
Aug 17, 2017, 4:53:16 PM8/17/17
to Crypto++ Users
Hi Everyone,

We need a way to determine when ARMv8 features are available on Apple 64-bit iOS devices. We can't use cpu probes because a SIGILL corrupts memory on Apple platforms.

I've got an ugly experimental hack at https://github.com/weidai11/cryptopp/blob/master/cpu.cpp#L450:

#elif defined(__APPLE__) && defined(__aarch64__)
    struct utsname systemInfo;
    systemInfo.machine[0] = '\0';
    uname(&systemInfo);
   
    std::string machine(systemInfo.machine);
    if (machine.substr(0, 7) == "iPhone6" || machine.substr(0, 7) == "iPhone7" ||
      machine.substr(0, 7) == "iPhone8" || machine.substr(0, 7) == "iPhone9" ||
      machine.substr(0, 5) == "iPad4" || machine.substr(0, 5) == "iPad5" ||
      machine.substr(0, 5) == "iPad6" || machine.substr(0, 5) == "iPad7")
    {
        return true;
    }
#endif

If anyone knows a better way to do things, then please speak up or make a pull request.

Jeff

Reply all
Reply to author
Forward
0 new messages