Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for static X86_64 targets #244

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

matneutrality
Copy link

@matneutrality matneutrality commented Oct 31, 2024

This PR adds support for x86_64 hardware, with a QEMU emulated machine and an Odroid H2+ board as reference targets. X86 is quite a different beast compared to ARM and RISCV, so a few things to note about this port:

No device tree

On x86 we typically don't have a convenient device tree file describing the target and available at compile time. Instead the hardware is discovered at runtime by walking the ACPI tables, quering arcane BIOS ROMs, and sometimes by poking known memory addresses. The Microkit tool needs to emulate the seL4 boot on the target so we need to know some things about the target at compile time to build an image.

We do this by providing a machine description file to the Microkit tool when building x86 images. This is a simple JSON file that can be produced in various ways. Currently we use the bootable Microkit x86 Machine Dump tool that is run on the target board and produces the JSON file on a serial port. The boards that we target typically have serial ports, either physical or remotely accessible via the BMC/IPMI, so this simple tool covers our needs.

The example boards come with the machine.json files.

Boot protocol

The Microkit loader populates a region of memory with the contents of the PDs and passes this region to the seL4 kernel to be marked as device memory. On ARM and RISCV this region is passed via two extra registers when jumping to the seL4 entry point.

On x86 the kernel follows the multiboot boot protocol and generally use the popular GNU GRUB bootloader, alleviating the need for an ELF loader. The bootloader enables protected mode (32-bit) with a flat 1:1 memory map. We pass the extra memory region with the PDs to the kernel via a custom multiboot tag. This requires very few changes to the seL4 kernel code and fits nicely with the boot code. Since the bootloader can directly load 32-bit ELF files, the system image is packed as an ELF32 binary with the seL4 kernel and all PDs as segments, letting the bootloader do the work. The x86 Microkit loader therefore does not actually load anything: it only adds a tag to the multiboot tables received from the bootloader and jumps into the kernel entry point.

No VMMs

Virtualisation is a bit different on X86_64 and ARM. This commit does not support virtualisation on x86_64.

@matneutrality
Copy link
Author

And the matching PR for the changes to the seL4 kernel: seL4/seL4#1340

@matneutrality matneutrality force-pushed the microkit-x86-rust-rebased branch from b74d9ac to 4836909 Compare November 1, 2024 10:29
@matneutrality matneutrality marked this pull request as draft November 4, 2024 07:40
@matneutrality matneutrality force-pushed the microkit-x86-rust-rebased branch from aece431 to e159a1a Compare November 22, 2024 16:41
Signed-off-by: Mathieu Mirmont <[email protected]>
Signed-off-by: Mathieu Mirmont <[email protected]>
The boot protocol is sufficiently different on x86 compared to ARM and
RISC-V to justify making a custom loader.

Signed-off-by: Mathieu Mirmont <[email protected]>
Signed-off-by: Mathieu Mirmont <[email protected]>
Signed-off-by: Mathieu Mirmont <[email protected]>
Signed-off-by: Mathieu Mirmont <[email protected]>
This list can be quite handy when porting to a new board.

Signed-off-by: Mathieu Mirmont <[email protected]>
Signed-off-by: Mathieu Mirmont <[email protected]>
@matneutrality matneutrality force-pushed the microkit-x86-rust-rebased branch from e159a1a to 6643919 Compare December 17, 2024 17:57
@matneutrality matneutrality changed the title Microkit x86 Add support for static X86_64 targets Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant