[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 0/1] kern/xen: Add Xen command line parsing



The purpose of this patch is to allow the Xen hypervisor to pass extra
data to GRUB in the form of a kernel command line, allowing the host to
customize the boot process of the guest. The command line from Xen is
parsed, and any variables within that start with the string
`xen_grub_env_` are exposed as environment variables. The grub.cfg
script can then use those environment variables as it sees fit.

The main reason for doing this is to allow implementing boot modes in
Qubes OS while also using in-VM kernels. For more context on Qubes boot
modes, see [1]. In order for this to work with in-VM kernels, it is
necessary for dom0 to pass kernel parameters to the guest without
modifying the guest's grub.cfg manually. This patch allows this to be
done, by allowing dom0 to pass kernel parameters to GRUB, which then
provides them to grub.cfg as an environment variable. The grub.cfg
script within the VM can then append those variables to the kernel
command line.

The patch has been tested with both PV and PVH virtual machines, using
an otherwise unpatched GRUB source tree, building the patch on top of
the tip of git master at the time of this writing (commit 438f055). My
testing environment is a fully updated Arch Linux system with Xen built
from the stable-4.20 branch.

Changes from the previous version of the patch:

* Implemented changes suggested by Marek from Invisible Things Lab, who
  reviewed an earlier version of the patch. Specifically:
  * Added minor optimizations (avoided needlessly calling grub_strlen
    in a loop, got rid of an unneeded variable, removed a redundant
    string length check)
  * Made a couple of bit setting and unsetting operations in the parser
    more readable
  * Removed a superfluous extra NUL terminator from a string literal

The patch has been thoroughly tested by booting a patched GRUB with
various different parameters passed to it via the Xen-provided kernel
command line. The effects of these parameters on the bootloader's
environment were then tested, and then an Arch Linux image was booted
to ensure that boot still worked. The full list of test cases and their
results can be seen at [2] (pastebinned so as to not overload people's
email clients with 185-character-long lines). This is the same test
suite used for version 2 of the patch.

[1] https://github.com/QubesOS/qubes-linux-pvgrub2/pull/16
[2] https://bpa.st/5C7A

Aaron Rainbolt (1):
  kern/xen: Add Xen command line parsing

 docs/grub.texi                |  50 +++++
 grub-core/Makefile.core.def   |   2 +
 grub-core/kern/i386/xen/pvh.c |  14 ++
 grub-core/kern/main.c         |  12 ++
 grub-core/kern/xen/cmdline.c  | 343 ++++++++++++++++++++++++++++++++++
 include/grub/xen.h            |   2 +
 6 files changed, 423 insertions(+)
 create mode 100644 grub-core/kern/xen/cmdline.c

-- 
2.49.0

Attachment: pgpaFuuf2FJ4M.pgp
Description: OpenPGP digital signature


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.