Linux – Can I use vpush/vpop in kernel code?

Can I use vpush/vpop in kernel code?… here is a solution to the problem.

Can I use vpush/vpop in kernel code?

I’m trying to add some asm code in the ko module, simply put:

asm volatile("vpush {d8}")

Error at compile time:

Error: selected processor does not support ARM mode `vpush {d8}'

Is this expected? Thank you.

Solution

float is generally not used for kernel development. Not every hardware supports FP, and some platforms may have advanced power capabilities that sometimes turn FP units on and off. It is very troublesome to deal with all this, and you can always find another way to solve your problem.

Linux Kernel Development by Robert Love

No (Easy) Use of Floating Point

… Using a floating point inside the kernel requires manually saving and restoring the floating point registers, among other possible chores. The short answer is: Don’t do it! Except in the rare cases, no floating-point operations are in the kernel.

And many more… https://stackoverflow.com/a/13886805/1163019

This is because your compiler call does not specify any MFPU directives that meet the above requirements, so you receive this error message.

Related Problems and Solutions