dhruvvyas90 / qemu-rpi-kernel

Qemu kernel for emulating Rpi on QEMU

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Taking exception 1 [Undefined Instruction] .... - Emulation Problems on Arch Linux

Tix3Dev opened this issue · comments

Hi,

While executing my kernel on Arch Linux I get the following printed in the console (endlessly):

Taking exception 1 [Undefined Instruction] ...from EL2 to EL2 ...with ESR 0x0/0x2000000 ...with ELR 0x200 ...to EL2 PC 0x200 PSTATE 0x3c9

This occurs after my kernel clears out the bss section.
The bug would be clear, however this issue occurs on arch linux distros, while debian based distros do not get this issue at all (my friend who also works on this kernel has no problems at all).

Even with the most bare bones of a boot code (that is, halt but the primary all core, setup stack, call C code) the mini uart device does not seem to print anything to stdio (yes, I have added the -serial null -serial stdio flags).
Again, this only happens on Arch Linux.

Here is a short preview of boot.S:

.global _start
_start:
    //For now all but the primary core will be suspended
    mrs x0, mpidr_el1         //Multiprocessor Affinity Register
    and x0, x0, #0xFF           //Lower 8 bits indicate the core no.    
    cbz x0, 2f                 //Is the Core ID == 0? (Main core)
    b 1f                     //Stop the core

    //Every core that comes here != Core no. 0x0
    1:
        b 1b

    //Main core is the only thing executing useful code from here on
    2:    
        //Setup stack
        ldr x1, =[0x80000]
        mov sp, x1
        
        bl main        //Kernel entry point
    
    3:
        b 3b

Update: We found out that qemu isn't in account for this bug; sorry for that.