You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SIGILL in _armv7_tick on ARM when using openssl 1.1.1k #17465
branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)help wantedIssue to be resolved or being resolved by community.triaged: bugThe issue/pr is/fixes a bug
We are using OpenSSL 1.1.1k. Intermittently we see SIGILL crash in _armv7_tick on ARM platform in the RAND_DRBG_bytes path as below. #4 #5 _armv7_tick () at crypto/armv4cpuid.S:136 #6 0xf57a00e8 in get_timer_bits () at ../openssl-1.1.1k/crypto/rand/rand_unix.c:833 #7 rand_pool_add_additional_data (pool=pool@entry=0xf1c5cd80) at ../openssl-1.1.1k/crypto/rand/rand_unix.c:789 #8 0xf579f46e in rand_drbg_get_additional_data (pool=0xf1c5cd80, pout=pout@entry=0xc8afe1e0) at ../openssl-1.1.1k/crypto/rand/rand_lib.c:289 #9 0xf579ea8e in RAND_DRBG_bytes (drbg=0xf1c6ef50, out=0xc8afe260 "", outlen=4) at ../openssl-1.1.1k/crypto/rand/drbg_lib.c:671
Found similar issues here (#14838, #17009).
Could you please help on how we can resolve this issue ?
It is interesting that this did not happen when the feature is first probed on startup.
You could set an environment to prevent this: export OPENSSL_armcap=0
the bits in the armcap are defined like this:
@bernd-edlinger Thank you for the feedback.
I see that here catboost/catboost@d7c6f1d, setting ARMV7_TICK is avoided. Is this an alternate way to explore? Is there any way to avoid impact on performance?
Currently we only access the timer for two purposes:
additional data for the RNG
seeding for the stochastic property cache flush
Neither of these needs to be fast, so we could add a dynamic check in the two armcap files or wrapper the call in armcap.c with an illegal instruction catcher.
add a dynamic check in the two armcap files or wrapper the call in armcap.c with an illegal instruction catcher.
Sorry, but I don't think that is a good idea, since changing the signal handlers affects the whole process, and is
therefore only acceptable because we do it only once when all the static constructors run (for ARM at least).
Setting OPENSSL_armcap to the features that are supported on your device should avoid this problem without impacting performance. The timer isn't used for anything critical.
Confirmed that OPENSSL_armcap_P value is not read from environment variable. It is set the end of OPENSSL_cpuid_setup routine to the value 611 (0x263). This value does not get modified during the course of firmware execution.
@paulidale do you mean, we can reset ARMV7_TICK bit in OPENSSL_armcap_P and keep the rest of the bits unmodified to address this issue?
@paulidale do you mean, we can reset ARMV7_TICK bit in OPENSSL_armcap_P and keep the rest of the bits unmodified to address this issue?
You should be able to set the OPENSSL_armcap environment variable to work around this. If this environment variable is defined, it's value is used instead of the probing. You need to match it to your system sans the ARMV7_TICK bit.
See #14838 which already includes a diagnosis of this problem for big.little systems. I suspect other folks running into this are running into the same thing.
The probing stuff OpenSSL does isn't a safe way to detect ARM features and should be removed in favor of supported APIs. Unfortunately, I couldn't find a relevant hwcap value for this instruction (but I may have missed it), so I guess the question is what is OpenSSL doing with it. Perhaps you all can find another way to do it... I see some entropy bits, but there are better sources of entropy, and something in code new to OpenSSL 3.0 to do something odd deep in the property system.
Our system isn't big little. We use a cortex A72 which has 4 identical cores. Furthermore, if this was the issue my test app running 5 threads calling the instruction as fast as possible should have reproduced it almost instantly. We do alot of "duration testing" and have only seen this specific problem happen about 2 or 3 times after the device has been running for days going in and out of sleep.
Also according to this comment someone else has also seen this on homogeneous systems: #14838 (comment)
branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)help wantedIssue to be resolved or being resolved by community.triaged: bugThe issue/pr is/fixes a bug
Activity
bernd-edlinger commentedon Jan 11, 2022
It is interesting that this did not happen when the feature is first probed on startup.
You could set an environment to prevent this:
export OPENSSL_armcap=0the bits in the armcap are defined like this:
so 0 should be safe, but maybe result in less performance.
mahendra-msp commentedon Jan 11, 2022
@bernd-edlinger Thank you for the feedback.
I see that here catboost/catboost@d7c6f1d, setting ARMV7_TICK is avoided. Is this an alternate way to explore? Is there any way to avoid impact on performance?
Thanks
Mahendra
bernd-edlinger commentedon Jan 11, 2022
when you encountered that problem, are you sure, that the OPENSSL_armcap was not set ?
dlegaultbbry commentedon Jan 11, 2022
This was reported previously if you have a system which uses Big.little where one set of CPUs can support some instructions and others not. See #14838
bernd-edlinger commentedon Jan 11, 2022
@mahendra-msp do you have such a non-symmetric-multi-processor-system, where some cores do support different instruction sets?
paulidale commentedon Jan 11, 2022
Currently we only access the timer for two purposes:
Neither of these needs to be fast, so we could add a dynamic check in the two armcap files or wrapper the call in armcap.c with an illegal instruction catcher.
bernd-edlinger commentedon Jan 12, 2022
Sorry, but I don't think that is a good idea, since changing the signal handlers affects the whole process, and is
therefore only acceptable because we do it only once when all the static constructors run (for ARM at least).
bernd-edlinger commentedon Jan 12, 2022
You could of course also use my feature branch at #11900
and set
OPENSSL_armcap=0x3dwhich makes it probe all features except ARMV7_TICK.paulidale commentedon Jan 12, 2022
Setting
OPENSSL_armcapto the features that are supported on your device should avoid this problem without impacting performance. The timer isn't used for anything critical.mahendra-msp commentedon Jan 12, 2022
Thank you all for the inputs.
Confirmed that OPENSSL_armcap_P value is not read from environment variable. It is set the end of OPENSSL_cpuid_setup routine to the value 611 (0x263). This value does not get modified during the course of firmware execution.
@paulidale do you mean, we can reset ARMV7_TICK bit in OPENSSL_armcap_P and keep the rest of the bits unmodified to address this issue?
bernd-edlinger commentedon Jan 12, 2022
I don't understand what the bit 0x200 bit means.
Do you use 1.1.1m or some other version?
mahendra-msp commentedon Jan 12, 2022
@bernd-edlinger I am re-checking OPENSSL_armcap_P value. I will confirm here again. We are using openssl 1.1.1k
paulidale commentedon Jan 12, 2022
You should be able to set the
OPENSSL_armcapenvironment variable to work around this. If this environment variable is defined, it's value is used instead of the probing. You need to match it to your system sans the ARMV7_TICK bit.mahendra-msp commentedon Jan 13, 2022
@bernd-edlinger I could re-check the OPENSSL_armcap_P and is set to 63 (0x3F). So all bits are set in OPENSSL_cpuid_setup()
@bernd-edlinger @paulidale Can you please give more info on the reason for this SIGILL error ? It would help us to know the issue better.
paulidale commentedon Jan 13, 2022
You could answer the question above for starters.
Your processor claims to have the ARMV7_TICK register but then fails to access it.
7 remaining items
jarkkokoivikko-code-q commentedon Jan 24, 2022
I think this is the same problem with my application. It happens irregularly. I would be happy to try a fix if one is available.
davidben commentedon Jan 24, 2022
See #14838 which already includes a diagnosis of this problem for big.little systems. I suspect other folks running into this are running into the same thing.
The probing stuff OpenSSL does isn't a safe way to detect ARM features and should be removed in favor of supported APIs. Unfortunately, I couldn't find a relevant hwcap value for this instruction (but I may have missed it), so I guess the question is what is OpenSSL doing with it. Perhaps you all can find another way to do it... I see some entropy bits, but there are better sources of entropy, and something in code new to OpenSSL 3.0 to do something odd deep in the property system.
marler8997 commentedon Jan 24, 2022
Our system isn't big little. We use a cortex A72 which has 4 identical cores. Furthermore, if this was the issue my test app running 5 threads calling the instruction as fast as possible should have reproduced it almost instantly. We do alot of "duration testing" and have only seen this specific problem happen about 2 or 3 times after the device has been running for days going in and out of sleep.
Also according to this comment someone else has also seen this on homogeneous systems: #14838 (comment)
bernd-edlinger commentedon Jan 25, 2022
That sounds almost like an A72 erratum.
Have you informed ARM about this?
marler8997 commentedon Jan 25, 2022
Will do if I can find a way to reliably reproduce it.
Workaround openssl cpu-feature check throwing SIGILL
Superpengun commentedon Mar 15, 2022
From the previous records, the cause of this problem still needs to be investigated............
Nathaniel100 commentedon Jul 22, 2022
I encountered the same issue,Openssl 1.1.1l,OPPO R15 PACM00,Android 10
fix bug with `armv7_tick` probing
fix bug with `armv7_tick` probing
t8m commentedon Feb 22, 2024
The version 1.1.1 is not supported anymore. Closing. If this is still an issue with currently supported releases, please open a new issue.