From: Paolo Bonzini <pbonzini@redhat.com>
To: Kenneth Adam Miller <kennethadammiller@gmail.com>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: Bootloading within QEMU?
Date: Tue, 17 Aug 2021 17:56:33 +0200 [thread overview]
Message-ID: <30c3d9c2-08c3-6159-103d-d61ed41efb01@redhat.com> (raw)
In-Reply-To: <CAK7rcp9HQ+uoPqu5vwCD8sCca99N5bV+aqD9Oea=VpTVT7Mb+A@mail.gmail.com>
On 17/08/21 16:31, Kenneth Adam Miller wrote:
>
>
> I am trying to discover how to schedule QEMU to begin actual emulation
> as currently my target correctly starts QEMU but only shows the shell,
> and not even boot loading occurs within QEMU. I'm trying to learn from
> example, and so will focus my questions only on X86. I can see the
> MachineClass and MachineState types, and I have tried to follow QEMU
> with the debugger and found where QEMU calls qemu_init and
> qemu_main_loop under qemu/softmmu/main.c, and even tried to follow
> through from init to main loop to see where it would begin booting, but
> I cannot see where the bootloader is scheduled or specified or started
> from within the target occurs.
There are two possibilities:
1) QEMU loads a fixed firmware file, usually at a fixed address in
memory so that the reset vector of the CPU is inside the firmware. This
is what happens for example on x86. The firmware ultimately boots the
machine (e.g. on x86 you have BIOS->GRUB->Linux or something like that).
2) QEMU loads a binary specified on the command line---typically with
-kernel, which is stored in current_machine->kernel_filename---and
somehow arranges for the guest to execute that file when it starts. For
example one possibility is to write a jump instruction at the CPU reset
vector (see riscv_setup_rom_reset_vec for an example). The functions
you want to look at for the loading part are load_elf_ram*, and
load_uimage_as and load_image_targphys_as.
Note that on platforms that use a fixed firmware file there's still the
possibility of using -kernel. In that case, the firmware initializes
the system, then places the binary in memory and jumps to it. qboot
(https://github.com/qemu/qboot) is a very small x86 firmware that is
able to boot a Linux or multiboot kernel.
Paolo
next prev parent reply other threads:[~2021-08-17 15:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 14:31 Bootloading within QEMU? Kenneth Adam Miller
2021-08-17 15:56 ` Paolo Bonzini [this message]
2021-08-17 16:18 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30c3d9c2-08c3-6159-103d-d61ed41efb01@redhat.com \
--to=pbonzini@redhat.com \
--cc=kennethadammiller@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).