vmm(4) accelerator support for Qemu
Student: AbhinavChavali ([email protected])
Mentor: JohnBaldwin ([email protected])
Project description
This project aims to add VMM acceleration support to QEMU on FreeBSD, bridging the gap between QEMU’s userspace emulation and FreeBSD’s kernel-based VMM hypervisor. Currently, QEMU on FreeBSD lacks hardware acceleration, forcing users to rely on slower TCG emulation or switch to Bhyve. I plan to modify QEMU’s memory management to work with VMM’s kernel-allocated guest memory. Additionally, I will adapt VMM to make non-critical devices (HPET, RTC) optional, letting QEMU handle them in user space. This would enable a hybrid interrupt model (kernel vLAPIC + emulated IOAPIC) that could make Qemu have competitive performance levels.
Approach to solving the problem
Deliverables
- QEMU -accel vmm option
- -M kernel-irqchip=offand -kernel-irqchip=split functionality
- Comparable performance with Bhyve on FreeBSD
What Was Done
I was able to successfully boot FreeBSD-14.1 using QEMU with the VMM accelerator. I also added support for certain kernel peripherals to passthrough QEMU, including the IOAPIC, LAPIC, and 8259 PIC. Performance is very comparable to Bhyve.
What I Still Have to Do
- Use kernel timers instead of QEMU for HPET, RTC, and PIT.
- Enable PCIe passthrough.
- Test other operating systems.
Milestones
Week |
Description |
Week 1 (June 2–8) |
Add QEMU compatibility mode to vmm: make kernel peripherals optional and add generic event injection to vmx. |
Week 2 (June 9–15) |
Create basic main vCPU thread in QEMU and configure accelerator options. |
Week 3 (June 16–22) |
Ensure proper memory allocation in QEMU. |
Week 4 (June 23–29) |
Implement Memory-Mapped IO handling. |
Week 5 (June 30–July 6) |
Implement Port-Mapped IO (PMIO) handling. |
Week 6 (July 7–13) |
Handle MSRs and all remaining VMExits. |
Week 7 (July 14–20) |
Create a QOM-based LAPIC model and connect it to the vmm virtual LAPIC. |
Week 8 (July 21–27) |
Begin kernel_irqchip integration (part 1). |
Week 9 (July 28–Aug 3) |
Continue kernel_irqchip integration (part 2). |
Week 10 (Aug 4–10) |
Continue kernel_irqchip integration (part 3). |
Week 11 (Aug 11–17) |
Finalize kernel_irqchip integration (part 4). |
Week 12 (Aug 18–25) |
Wrap-up tasks and write documentation. |
Final Notes
This project was a fantastic experience. I learned an immense amount about the inner workings of operating systems, hypervisors, and the complex interaction between kernel and userspace components. It was a lot of fun to work on such a challenging and rewarding project and I would love to do take on another project like this with FreeBSD.
The Code
QEMU: https://github.com/dumrich/qemu.git