RFR: 8297092: [macos_aarch64] Add support for SHA feature detection [v3]

Andrew Haley aph at openjdk.org
Wed Jan 11 14:05:19 UTC 2023


On Wed, 11 Jan 2023 13:14:46 GMT, Hao Sun <haosun at openjdk.org> wrote:

>> src/hotspot/os_cpu/bsd_aarch64/vm_version_bsd_aarch64.cpp line 75:
>> 
>>> 73:     _features |= CPU_CRC32;
>>> 74:   }
>>> 75:   if (cpu_has("hw.optional.armv8_1_atomics")) {
>> 
>> Why aren't we using `hw.optional.arm.FEAT_LSE` instead of `hw.optional.armv8_1_atomics` as per https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics ?
>
> Hi @gerard-ziemski, thanks for your useful link.
> 
> As denoted by the title of this PR, I originally added the support for crypto feature detection, i.e. SHA1, SHA2, SHA512 and SHA3. Hence, I didn't touch other CPU features except updating the code style (for CRC32 and your mentioned LSE).
> 
> Regarding your question, I think it's okay to check `hw.optional.arm.FEAT_LSE` inside this patch, as it's a small improvement as I see it. But I suggest
> 1) still checking the legacy name `hw.optional.armv8_1_atomics` as well (as what we did for SHA512 and SHA3 in this PR), for the sake of backward compatibility.
> 2) checking both `hw.optional.AdvSIMD` and `hw.optional.neon` (ASIMD feature has the similar issue as well).
> 
> Hi @theRealAph , 
> As shown by Apple developer document (shared by @gerard-ziemski), as parameters of function `sysctlbyname`, `hw.optional.armv8_1_atomics` is the legacy name for `hw.optional.arm.FEAT_LSE`. Hence, we can check `FEAT_LSE` to determine whether atomic instructions are available or not.
> 
> I'm afraid I didn't fully get your question.
> Do you mean, the usage of atomic instructions is quite different on Apple AArch64 compared to Linux AArch64 (perhaps, atomic instructions are not generated on Apple AArch64 platform?), hence there is no need to support CPU_LSE detection on Apple AArch64?

Sure, never mind. It's just that Apple always supports LSE, but that doesn't really matter.

-------------

PR: https://git.openjdk.org/jdk/pull/11382


More information about the hotspot-runtime-dev mailing list