aarch64 msr CNTFRQ_EL0

Bug #1771948 reported by manuel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Undecided
Unassigned

Bug Description

Hello,

I'm running qemu 2.12 on a raspberry pi 3 with the command:

qemu-system-aarch64 -M raspi3 -serial stdio -kernel executable.bin

On my start file (right in the beginning with the highest EL), the following instructions:

ldr x0 , =19200000
msr CNTFRQ_EL0, x0

and qemu halts on the "msr CNTFRQ_EL0, x0" instruction.

I believe this is not a normal behavior.

Thank you

Tags: arm Edit Tag help
Revision history for this message
Peter Maydell (pmaydell) wrote :

Mmm, that's not really supposed to happen. Do you have a test guest binary you can attach that I can reproduce with?

Peter Maydell (pmaydell)
tags: added: arm
Revision history for this message
Peter Maydell (pmaydell) wrote :

Looking more closely at this, I think this is because you've passed QEMU a file which it is treating as a Linux kernel. (-kernel treats raw binaries and uimage files as Linux kernels; it treats ELF files as not being Linux kernels). Linux expects to be started in EL2, so although the emulated CPU has EL3, we start your program in EL2. Your program is therefore not running at the highest available exception level, and can't write to CNTFRQ_EL0.

For "bare metal" images where you want to do things at EL3, it may be better to build them as ELF files which are linked to load at address 0. Note that all four cores will start at address zero simultaneously, so you'll need a bit of "pen code" to sort the secondaries out from the primary. https://github.com/raspberrypi/tools/blob/master/armstubs/armstub8.S might be useful reference. As I understand it, this is how your code would be run on real raspi3 hardware too.

Revision history for this message
manuel (manuelq) wrote :

Thank you for your reply. Sorry to take so long (was on vacations).

Your comment seems correct to me. I tried with the ELF file instead of the binary file and it worked perfectly (and all the cores were running instead of just core 0).

From my point of view, this bug can be marked as invalid.

Thank you again.

Thomas Huth (th-huth)
Changed in qemu:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers