linuxyne wrote:
With -O0, the compiler saves FP registers q0 to q7. I think that might be causing an undefined instruction exception, if the FP unit is not yet setup. You may want to ask the compiler to not generate FP instructions: "-march=armv8-a+nofp", or similar.
I don't think FP registers are a problem in this case. Passing an elf file to -kernel will have qemu put you in the highest supported EL (so EL3 in this case) since it thinks you're giving it firmware instead of a kernel. And since you're in the highest EL possible, no one had the chance to set up trapping the regs (reset value is in this case to not trap as per the Cortex-A53 TRM).
EDIT: while technically true, to get to EL2 or EL3 one would need to add a flag to the machine, and indeed at EL1 it is set to trap by default, my bad!
Also, as klange mentioned, "-mgeneral-regs-only" works as well to disable the use of FP regs.
Also also, you can pass "-d int" to qemu to have it tell you what faults have happened, perhaps with the help of
https://esr.arm64.dev/ to decode the ESR.