This is a cache of https://discuss.96boards.org/t/crypto-on-ubuntu-dragonboard410c/259. It is a snapshot of the page at 2024-10-31T09:12:37.834+0000.
Crypto on Ubuntu Dragonboard410c? - DragonBoard410c - 96Boards Forum

Crypto on Ubuntu Dragonboard410c?

Hello. Today I successfully installed the developer version of Ubuntu via fastboot as described in the Installation Guide. The system appears to be running well.

Except, I’m having trouble accessing the Cortex-A53 crypto features.


dragon> cat test.c
#include <arm_neon.h>
int main() {
    uint8x16_t x;
    x = vaeseq_u8(x,x);
    return 0;
}
dragon>gcc -march=armv8-a+crypto test.c 
dragon> a.out
Illegal instruction

I’m able to compile and run non-crypto programs just fine, but

Hi krovetz,

Thank you for your report.

We just tried bellow and it seems to be OK on our side.

root@linaro-alip:~# vi test.c
root@linaro-alip:~# cat test.c
#include <arm_neon.h>

int main() {

    uint8x16_t x;

    x = vaeseq_u8(x,x);

    return 0;

}

root@linaro-alip:~# gcc -march=armv8-a+crypto test.c
root@linaro-alip:~# ./a.out
root@linaro-alip:~#

The rootfs or build is different from yours.
Do you mind teaching us which image are you using from which download link?

Thanks a lot for looking into my issue…

I followed the fastboot instructions at https://github.com/96boards/documentation/wiki/Dragonboard-410c-Installation-Guide-for-Linux-and-Android

Using

http://builds.96boards.org/releases/dragonboard410c/linaro/ubuntu/latest/boot-linaro-vivid-qcom-snapdragon-arm64*.img.gz

and

http://builds.96boards.org/releases/dragonboard410c/linaro/ubuntu/latest/linaro-vivid-developer-qcom-snapdragon-arm64*.img.gz

I can confirm that error as well.
I installed linux via SD recently (latest release) via this link:
https://builds.96boards.org/releases/dragonboard410c/linaro/ubuntu/latest/dragonboard410c_sdcard_install_ubuntu*.zip

following the exact same path, I end up with ‘illegal instruction’ as well.
I used this arm_neon.h:
https://raw.githubusercontent.com/gcc-mirror/gcc/master/gcc/config/aarch64/arm_neon.h

linaro@linaro-alip:~/neon$ gcc -march=armv8-a+crypto test.c linaro@linaro-alip:~/neon$ ./a.out Illegal instruction

Also I am a bit puzzled that the option ’ -mfpu=neon ’ is not recognized:
linaro@linaro-alip:~/neon$ gcc -mfpu=neon -march=armv8-a+crypto -ftree-vectorize test.c
gcc: error: unrecognized command line option ‘-mfpu=neon’

gcc -v:
gcc version 4.9.2 (Ubuntu/Linaro 4.9.2-10ubuntu13)

I believe the test above where we confirmed the functionality was run on Hikey’s v3.18 kernel instead of using the Dragon 410c v4.x kernel so this is very likely a kernel issue.

let me try to replicate your setup and do some debugging.

yes I can see the issue on the 410c as well as a console trace.
It should be easy to track.

[ 94.034359] a.out[994]: undefined instruction: pc=0000000000400574
[ 94.034394] Code: 3d8007e0 3d8003e1 3dc007e0 3dc003e1 (4e284820)

This seems to be the undefined instruction:
400574: 4e284820 aese v0.16b, v1.16b

Ok so the bads news are that the 410c processor does not implement the AARCH64 crypto extensions (these are optional for the architecture)

410c:
root@linaro-alip:~# cat /proc/cpuinfo 
processor       : 0
Features        : fp asimd evtstrm crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 0

However the Hikey board does:

hikey:
processor       : 0
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

And alternatively and for development purposes only (clearly you will take a performance hit) you could consider emulating the AES instructions (Ard Biesheuvel posted a patch some time ago).

Shoot! I had thought the crypto instructions were a core part of Aarch64. I guess I was wrong.

Anyway… Thanks for looking into it for me.

-Ted

Thanks for the effort!
Any idea why -mfpu fails as gcc option? Here, the issue is probably fully on my side/understanding.

1 Like

-mfpu is not a valid/required option anymore for aarch64.
Both floating-point and NEON are required in all standard ARMv8 implementations.
See AArch64 Options (Using the GNU Compiler Collection (gcc))

I use DragonBoard 410c which is ARM Cortex-A53.
What is the right gcc options to fully utilize the processor NEON/SIMD, etc?
Should we use -mfpu=neon or -mfpu=asimd or something like that?
I use -mcpu=cortex-a53 -ftree-vectorize
Is there anything else I should add?

I use DragonBoard 410c which is ARM Cortex-A53.
What is the right gcc options to fully utilize the processor NEON/SIMD, etc?
Should we use -mfpu=neon or -mfpu=asimd or something like that?
I use -mcpu=cortex-a53 -ftree-vectorize
Is there anything else I should add?

AArch64 doesn’t use -mfpu for this purpose. Instruction set extensions
are provided as modifiers for -mcpu and -march. However both fp and simd
are enabled by default so I don’t think there’s any need to add anything
else.