Bug 1624813 - [fftw] SIGILL Illegal instruction (core dumped) on Allwinner A10
Summary: [fftw] SIGILL Illegal instruction (core dumped) on Allwinner A10
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: fftw
Version: rawhide
Hardware: armv7hl
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Conrad Meyer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-09-03 11:11 UTC by Jaroslav Škarvada
Modified: 2019-05-06 12:51 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-05-04 01:08:48 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Reproducer (335 bytes, text/x-csrc)
2018-09-03 11:11 UTC, Jaroslav Škarvada
no flags Details

Description Jaroslav Škarvada 2018-09-03 11:11:09 UTC
Created attachment 1480508 [details]
Reproducer

Description of problem:
FFTW code can SIGILL on Allwinner A10. I am not ARM expert, so feel free to correct me if I am wrong, but it seems the CNTVCT register for precision time measurement is not defined in ARMv7-A architecture profile [1]. It's defined in ARMv8-A architecture profile [2]. We are compiling for ARMv7-A (-march=armv7-a), so such instruction shouldn't be used. 

The problematic code is in:
kernel/cycle.h:518,
the getticks function is directly using assembly instruction 'mrrc' for CNTVCT register access, e.g.: 
mrrc    15, 1, sl, r9, cr14
which codes into 0xEC59AF1E opcode which causes the SIGILL.

It seems there is compile time check for CNTVCT support in configure.ac:727:
AC_MSG_CHECKING([armv7a has 64 bits readable CNTVCT])

But it seems to be wrong approach, because the builder may support it, but the target CPU needn't. The check should be performed runtime (like e.g openssl do) or the code should be compiled without CNTVCT support.

I tried to patch-out the CNTVCT timer code and it seems it works on my A10 without problem.

[1] https://www.cs.utexas.edu/~simon/378/resources/ARMv7-AR_TRM.pdf
[2] https://static.docs.arm.com/ddi0487/ca/DDI0487C_a_armv8_arm.pdf

Version-Release number of selected component (if applicable):
fftw-3.3.5-11.fc28.armv7hl

How reproducible:
Always on A10 and maybe others

Steps to Reproduce:
1. gcc -o test ./test.c -lfftw3f
2. ./test
3.

Actual results:
Illegal instruction (core dumped)

Expected results:
Working code

Additional info:
This causes other packages using fftw like gr-osmosdr, gqrx, ... to SIGILL on A10 and maybe others.

It seems there is an typo in the fftw source code. Sometimes the CNTVCT is referred correctly, sometimes as CNTCVT, like e.g. ARMV7A_HAS_CNTCVT, which is incorrect.

Comment 1 Ben Cotton 2019-05-02 20:59:42 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Jaroslav Škarvada 2019-05-03 10:11:32 UTC
Moving to rawhide.

Comment 3 Conrad Meyer 2019-05-03 15:29:16 UTC
Please report this upstream.  I don't know anything about ARM myself.

Comment 4 Conrad Meyer 2019-05-03 15:31:14 UTC
Actually, please see http://www.fftw.org/release-notes.html .

> FFTW 3.3.7:
> ...
>     Fixes for armv7a cycle counter.

Is that maybe the issue in question?

Comment 5 Conrad Meyer 2019-05-04 01:08:48 UTC
Anyway, we've had 3.3.8 since bug 1413425.  Please give that a shot and let me know if it fixes the issue.  If it doesn't, please file an FFTW bug :-).

Comment 6 Jaroslav Škarvada 2019-05-06 12:51:16 UTC
It seems fixed, thanks.


Note You need to log in before you can comment on or make changes to this bug.