Here is a clean(er) patch 
https://github.com/NetBSD/src/compare/trunk...NetBSDfr:NetBSD-src:GENPVH

Rationale

Like previously explained, locore.S expects start_info being passed by the
calling hypervisor on %ebx to be located at the end of the symbol table.
Qemu and Firecracker don't follow this rule which is not part of the
official Xen ABI https://xenbits.xen.org/docs/unstable/misc/pvh.html

What our patch first does is make memory mapping loops happy by copying
the start_info structure where it's expected.
After that, memory locations and boot parameters are correctly found and
boot can proceed.
Of course, the hypervisor not being Xen, a lot of Xen-related code is
useless, hence the new VM_GUEST_GENPVH (for Generic PVH) vm_guest type,
as first suggested by Manuel, and a new kernel option, GENPVH.
I kept the Xen code structure as it was and changed very little code, only
some || vm_guest == VM_GUEST_GENPVH and a couple #ifndef GENPVH.

In order to build a Generic PVH kernel, the following options are needed

#Xen PV support for PVH and HVM guests
options         XENPVHVM
options         XEN
# Generic PVH support (qemu, firecracker...)
options         GENPVH

I've added 
https://github.com/NetBSDfr/NetBSD-src/blob/GENPVH/sys/arch/amd64/conf/MICROVM
as an example config file.
I'll probably end up ditching XENPVHVM and XEN but there's still quite
some work in there.

We still need to check if we didn't break anything on Xen side and test
Firecracker. FYI qemu-system-x86_64 also works with the "microvm"
machine type.

Feedback very welcome.

------------------------------------------------------------------------
Emile `iMil' Heitor <imil@{home.imil.net,NetBSD.org}> | https://imil.net

Reply via email to