The bug report says the 8171M and 8272CL have the problem. After applying the 
simple Intel approach Natanael is referring to, I was able to run on the 8171M  
(I have a run log to confirm it).

I used the patch from the bug report:
https://bugs.busybox.net/show_bug.cgi?id=15236

shaNI = ((ebx >> 28) & 2) - 1; /* bit 29 -> 1 or -1 */

Seems a lot more complicated than intel's approach:

shaNI = ((ebx >> 29) & 1);


> On 30 Mar 2023, at 5:09 PM, Natanael Copa <[email protected]> wrote:
> 
> On Wed, 29 Mar 2023 15:07:49 +0200
> Denys Vlasenko <[email protected]> wrote:
> 
>> On Wed, Mar 1, 2023 at 12:01*PM alice <[email protected]> wrote:
>>> On Tue Feb 28, 2023 at 11:17 PM CET,  wrote:  
>>>> I'm having an intermittent issue with "BusyBox v1.36.0 (2023-01-03 22:49:12
>>>> UTC)" (the one from the Docker image busybox:musl) when running on amd64 
>>>> GitHub
>>>> actions runner VMs (azure).
>>>> 
>>>> When I use sha256sum it is getting terminated with SIGILL, Illegal
>>>> instruction. The issue is hard to reproduce but I have a GitHub actions 
>>>> CI/CD
>>>> job that I can re-run repeatedly (no changes to code, environment, data 
>>>> input,
>>>> etc) that will occasionally have the issue. I managed to capture a core 
>>>> dump.  
>>> 
>>> this was also reported in 
>>> http://lists.busybox.net/pipermail/busybox/2023-January/090113.html
>>> 
>>> it's caused by having a cpu with AVX512 (the github runners do) but not 
>>> sha_ni,
>>> and the code that checks it is broken and misdetects sha_ni support when 
>>> avx512
>>> exists. the github runners don't have sha_ni, so it breaks exactly there.  
>> 
>> The code is:
>> 
>>                if (!shaNI) {
>>                        unsigned eax = 7, ebx = ebx, ecx = 0, edx = edx;
>>                        cpuid(&eax, &ebx, &ecx, &edx);
>>                        shaNI = ((ebx >> 29) << 1) - 1;
>>                }
>>                if (shaNI > 0)
>>                        ctx->process_block = sha1_process_block64_shaNI;
>> 
>> If ebx's bit 29 is set, then shaNI = 1. If it is clear, then shaNI = -1.
>> 
>> I checked
>> "IntelĀ® 64 and IA-32 Architectures Software Developer*s Manual
>> Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D and 4"
>> 
>> to verify that CPUID(EAX=7, ECX=0) and bit position (EBX.29)
>> is the correct check for SHA-NI.
>> 
>> I double-checked it in Linux kernel source.
>> 
>> I checked disassembly and it correctly sets up registers for CPUID.
>> 
>> Can someone tell me on what CPU this does not work?
> 
> Github runners. I created a job where it fails. See here:
> You have output of cpuinfo here:
> https://github.com/ncopa/busybox/actions/runs/3947969708/jobs/6757415539#step:4:1
> 
> I also tried to fix it with this change, but failed:
> https://github.com/ncopa/busybox/commit/e4ad5e7f2fed8e36d0779d918052169fe9a0bb95
> 
> This was based on the example function `int CheckForIntelShaExtensions()` in 
> https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sha-extensions.html
> 
> -nc
> _______________________________________________
> busybox mailing list
> [email protected]
> http://lists.busybox.net/mailman/listinfo/busybox

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to