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

Kernel: Add support for QEMU ISA-PC & QEMU MicroVM machine types #12046

Merged
merged 9 commits into from
Mar 2, 2022

Conversation

supercomputer7
Copy link
Member

This PR sets a goal to create basic abstractions in the kernel to allow us to boot SerenityOS on a pure ISA-PC machine type.

@supercomputer7
Copy link
Member Author

supercomputer7 commented Jan 21, 2022

I know this could be a questionable patch (because SerenityOS is not about supporting really really old stuff like ISA-only PCs), so I'll quote one of the commit messages here:

This is mainly a good environment for testing abstractions in the kernel
space, and can help with improving on them for the sake of porting the
OS to other chipsets and CPU architectures.

Another goal I have in the future is to support the QEMU microvm machine type, which doesn't support PCI nor ACPI by default. That type of machine could be used on CI machines to test userland utilities without holding us to have the overhead of a fully-emulated chipset like the i440FX or Q35 machines. It really can help also to have good abstractions for platforms that don't use PCI at all (so everything is memory mapped and there's a device tree, like for the microvm machine).
This might also assist some people (like me) to test the system on bare metal, if we have a bug/problem in the PCI subsystem/PCI based driver in the kernel.

@supercomputer7
Copy link
Member Author

supercomputer7 commented Jan 22, 2022

A "wild" idea that was suggested by @boricj on the discord server today is to write support for FDT (Flattened Device Tree) and use it together with the ISA-PC machine type (this could be supplied as boot module from the multiboot bootloader) to know which devices exist in such environment. This in theory provide great platform to expand for other architectures which rely on FDTs instead of ACPI.
Keeping this note here as we might want to implement it sometime in the future :)

@supercomputer7 supercomputer7 force-pushed the isapc branch 2 times, most recently from 24fb849 to 0c9ea4b Compare January 27, 2022 19:21
@supercomputer7 supercomputer7 marked this pull request as draft January 29, 2022 13:27
@supercomputer7
Copy link
Member Author

Making this a draft as I tested this with #11368 and a couple of problems were discovered when I tried it together.

@supercomputer7 supercomputer7 force-pushed the isapc branch 3 times, most recently from bdcc410 to dab958e Compare February 18, 2022 17:27
@supercomputer7 supercomputer7 marked this pull request as ready for review February 18, 2022 17:27
@supercomputer7
Copy link
Member Author

Ready for review again :)

@supercomputer7 supercomputer7 changed the title Kernel: Add support for QEMU ISA-PC machine type Kernel: Add support for QEMU ISA-PC & QEMU MicroVM machine types Feb 18, 2022
@supercomputer7
Copy link
Member Author

Apparently adding support to run the microvm machine type was quite an easy task after making sure we have the appropriate abstractions. I added another commit to add such option in run.sh :)

@awesomekling
Copy link
Contributor

This branch has conflicts that must be resolved

This change allow the user to request the kernel to not use any PCI
resources/devices at all.

Also, don't try to initialize devices that rely on PCI if disabled.
To declare that we don't have a PCI bus in the system we do two things:
1. Probe IO ports before enabling access -
In case we are using the QEMU ISA-PC machine type, IO probing results in
floating bus condition (returning 0xFF values), thus, we know we don't
have PCI bus on the system.
2. Allow the user to specify to not use the PCI bus at all in the kernel
commandline.
Reading from /proc/pci assumes we have PCI enabled and also enumerated.
However, if PCI is disabled for some reason, we can't allow the user to
read from it as there's no valuable data we can supply.
If there's no PCI bus, then it's safe to assume that the x86 machine we
run on supports VGA text mode console output with an ISA VGA adapter.
If this is the case, we just instantiate a ISAVGAAdapter object that
assumes this situation and allows us to boot into VGA text mode console.
If there's no PCI bus, then it's safe to assume that we run on a x86
machine that has an ISA IDE controller in the system. In such case, we
just instantiate a ISAIDEController object that assumes fixed locations
of IDE IO ports.
The ISA-PC machine type provides no PCI bus support, no IOAPIC support
and other modern PC features of our generation.

This is mainly a good environment for testing abstractions in the kernel
space, and can help with improving on them for the sake of porting the
OS to other chipsets and CPU architectures.
The microvm machine type is a modern tool for kernel and firmware
developers to test their software against features like FDTs, second
IOAPIC, lack of legacy devices by default, the ability of using PCIe
without using PCI x86 IO ports, etc.

We can boot into such machine but we are limited in the functionality we
support currently for this type of virtual machine.
@supercomputer7
Copy link
Member Author

This branch has conflicts that must be resolved

Rebased to solve the merge conflict.

@awesomekling awesomekling merged commit 629eed3 into SerenityOS:master Mar 2, 2022
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.

2 participants