[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug 1853781] Re: Baremetal kernel built from assembly runs multiple tim
From: |
Philippe Mathieu-Daudé |
Subject: |
[Bug 1853781] Re: Baremetal kernel built from assembly runs multiple times |
Date: |
Mon, 25 Nov 2019 08:43:14 -0000 |
Hi Evan,
Your suspicion is correct, the QEMU model starts with the four cores
powered on, so your code is likely running on each core in simultaneous.
The hardware booting process is described [1]: your code is loaded as
the firmware loads kernel.img (the last step).
The ARM maintainer suggested [2] a way to bypass this: "[your binary]
could be wrapped in a small guest binary that deals with handling all
the secondary cores". This is not hard to do, but nobody volunteered to
do it yet :)
[1]
https://raspberrypi.stackexchange.com/questions/10442/what-is-the-boot-sequence
[2] https://www.mail-archive.com/address@hidden/msg655415.html
** Changed in: qemu
Status: New => Invalid
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1853781
Title:
Baremetal kernel built from assembly runs multiple times
Status in QEMU:
Invalid
Bug description:
QEMU version: 4.1.0.
Full command used to launch: qemu-system-arm -machine raspi2 -kernel
main
(Technically, the first term of the command is actually
"~/Applications/QEMU/qemu-4.1.0/build/arm-softmmu/qemu-system-arm",
but I shortened it for readability.)
Host information: Running debian 9.9 on a 64-bit x86 processor (Intel
i5-2520M).
Guest information: No operating system. I'm providing my own kernel,
which I assembled from a 60-line ARM assembly program using arm-none-
eabi-as and then linked with arm-none-eabi-ld, both version
2.28-5+9+b3.
Additional details: To view the screen output of the program, I am
using vncviewer version 6.19.1115 (r42122). All of the above software
packages were installed as debian packages using apt, except for QEMU,
which I built from source after downloading from the official website.
.
The issue here is that I have written a program in assembly and it
isn't doing what I expect it to when I emulate it. Here's a summary of
the code:
1) Read a number from zero-initialized memory.
2) Add one to the number and write it back.
3) Use the number to determine a screen location to write to.
4) Use the number to determine what color to write.
5) Write 4000 half-words to the screen starting at that offset and
using that color. This should result in a stripe across the whole
screen that's about 6 pixels tall.
The expected behavior is that *one* stripe should appear on the screen
in a single color. However, the actual behavior is that up to *four*
stripes appear, each in a different color. Furthermore, if I comment
out the line that writes the incremented counter back to memory, then
only one stripe will appear.
I will also note that the Raspberry Pi 2, which is the system I'm
emulating, has four cores. What I suspect is going on here is that my
code is being loaded onto all four cores of the emulated machine. I
couldn't find anything about this anywhere in the documentation, and
it strikes me as bug.
I have attached the assmebly code that I'm using, as well as a short
makefile. Since I can only add one attachment to this report, I've
combined the two into a single text file and labeled each. After
separating the two into two files, you will need to change the first
line of the makefile to point to your installation of qemu-system-arm
v4.1.0. After that, type "make run" to run the program.
Thanks in advance,
Evan Rysdam
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1853781/+subscriptions