Disable scrubbing memory pages during initial balloon down
Balloon driver scrub memory page before giving it back to the
hypervisor. Normally this is a good thing, to avoid leaking VM's memory
data into Xen and other domains. But during initial startup when maxmem
is bigger than initial memory, on HVM and PVH, Populate-on-Demand (PoD) is in use.
This means every page on initial balloon down needs to be first mapped
by Xen into VM's memory (as it wasn't populated before - and in fact
didn't have any data), scrubbed by the kernel and then given back to
Xen. This is great waste of time. Such operation with default settings
(initial memory 400M, maxmem 4000M) can take few seconds, delaying every
VM startup (including DispVM). In extreme situation, when running inside
nested virtualization, the effect is much worse.
Avoid this problem by disabling memory scrubbing during initial boot,
and re-enable it as soon as user space kicks in - in initramfs, before
mounting root filesystem, to be sure it's enabled before memory contains
any kind of secrets.
This commit handle only one case - when kernel in managed by the VM
itself. It is critical to enable initramfs module whenever
xen_scrub_pages=0 kernel option is given, so make them depend on the
same condition and ship them in the same package.
Fixes QubesOS/qubes-issues#1963
2019-01-18 22:53:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# postinst script for qubes-kernel-vm-support
|
|
|
|
#
|
|
|
|
# see: dh_installdeb(1)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# The postinst script may be called in the following ways:
|
|
|
|
# * <postinst> 'configure' <most-recently-configured-version>
|
|
|
|
# * <old-postinst> 'abort-upgrade' <new version>
|
|
|
|
# * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
|
|
|
|
# <new-version>
|
|
|
|
# * <postinst> 'abort-remove'
|
|
|
|
# * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
|
|
|
|
# <failed-install-package> <version> 'removing'
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
#
|
|
|
|
# For details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or
|
|
|
|
# the debian-policy package
|
|
|
|
|
|
|
|
|
|
|
|
case "${1}" in
|
|
|
|
configure)
|
|
|
|
if [ -x /usr/sbin/update-initramfs ]; then
|
2019-02-25 00:17:07 +00:00
|
|
|
if update-initramfs -u; then
|
|
|
|
# "milestone" initramfs update version:
|
|
|
|
# 1 - addition of xen scrub_pages enabling code
|
|
|
|
echo 1 > /var/lib/qubes/initramfs-updated
|
|
|
|
fi
|
Disable scrubbing memory pages during initial balloon down
Balloon driver scrub memory page before giving it back to the
hypervisor. Normally this is a good thing, to avoid leaking VM's memory
data into Xen and other domains. But during initial startup when maxmem
is bigger than initial memory, on HVM and PVH, Populate-on-Demand (PoD) is in use.
This means every page on initial balloon down needs to be first mapped
by Xen into VM's memory (as it wasn't populated before - and in fact
didn't have any data), scrubbed by the kernel and then given back to
Xen. This is great waste of time. Such operation with default settings
(initial memory 400M, maxmem 4000M) can take few seconds, delaying every
VM startup (including DispVM). In extreme situation, when running inside
nested virtualization, the effect is much worse.
Avoid this problem by disabling memory scrubbing during initial boot,
and re-enable it as soon as user space kicks in - in initramfs, before
mounting root filesystem, to be sure it's enabled before memory contains
any kind of secrets.
This commit handle only one case - when kernel in managed by the VM
itself. It is critical to enable initramfs module whenever
xen_scrub_pages=0 kernel option is given, so make them depend on the
same condition and ship them in the same package.
Fixes QubesOS/qubes-issues#1963
2019-01-18 22:53:20 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`${1}'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
|
|
# generated by other debhelper scripts.
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|