diff -pruN 4.14.3+32-g9de3671772-1/automation/build/alpine/3.12-arm64v8.dockerfile 4.16.1-1/automation/build/alpine/3.12-arm64v8.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/alpine/3.12-arm64v8.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/build/alpine/3.12-arm64v8.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,53 @@
+FROM arm64v8/alpine:3.12
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN \
+  # apk
+  apk update && \
+  \
+  # xen build deps
+  apk add argp-standalone && \
+  apk add autoconf && \
+  apk add automake && \
+  apk add bash && \
+  apk add curl && \
+  apk add curl-dev && \
+  apk add dev86 && \
+  apk add dtc-dev && \
+  apk add gcc  && \
+  # gettext for Xen < 4.13
+  apk add gettext && \
+  apk add git && \
+  apk add iasl && \
+  apk add libaio-dev && \
+  apk add libfdt && \
+  apk add linux-headers && \
+  apk add make && \
+  apk add musl-dev  && \
+  apk add ncurses-dev && \
+  apk add patch  && \
+  apk add python3-dev && \
+  apk add texinfo && \
+  apk add util-linux-dev && \
+  apk add xz-dev && \
+  apk add yajl-dev && \
+  apk add zlib-dev && \
+  \
+  # qemu build deps
+  apk add bison && \
+  apk add flex && \
+  apk add glib-dev && \
+  apk add libattr && \
+  apk add libcap-ng-dev && \
+  apk add pixman-dev && \
+  \
+  # cleanup
+  rm -rf /tmp/* && \
+  rm -f /var/cache/apk/*
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/alpine/3.12.dockerfile 4.16.1-1/automation/build/alpine/3.12.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/alpine/3.12.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/build/alpine/3.12.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,55 @@
+FROM alpine:3.12
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN \
+  # apk
+  apk update && \
+  \
+  # xen build deps
+  apk add argp-standalone && \
+  apk add autoconf && \
+  apk add automake && \
+  apk add bash && \
+  apk add curl && \
+  apk add curl-dev && \
+  apk add dev86 && \
+  apk add gcc  && \
+  apk add g++ && \
+  apk add clang  && \
+  # gettext for Xen < 4.13
+  apk add gettext && \
+  apk add git && \
+  apk add iasl && \
+  apk add libaio-dev && \
+  apk add linux-headers && \
+  apk add make && \
+  apk add musl-dev  && \
+  apk add libc6-compat && \
+  apk add ncurses-dev && \
+  apk add patch  && \
+  apk add python3-dev && \
+  apk add texinfo && \
+  apk add util-linux-dev && \
+  apk add xz-dev && \
+  apk add yajl-dev && \
+  apk add zlib-dev && \
+  \
+  # qemu build deps
+  apk add bison && \
+  apk add flex && \
+  apk add glib-dev && \
+  apk add libattr && \
+  apk add libcap-ng-dev && \
+  apk add ninja && \
+  apk add pixman-dev && \
+  \
+  # cleanup
+  rm -rf /tmp/* && \
+  rm -f /var/cache/apk/*
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/archlinux/current.dockerfile 4.16.1-1/automation/build/archlinux/current.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/archlinux/current.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/archlinux/current.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -20,6 +20,7 @@ RUN pacman -S --refresh --sysupgrade --n
         iasl \
         inetutils \
         iproute \
+        # lib32-glibc for Xen < 4.15
         lib32-glibc \
         libaio \
         libcacard \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/archlinux/riscv64.dockerfile 4.16.1-1/automation/build/archlinux/riscv64.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/archlinux/riscv64.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/build/archlinux/riscv64.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,19 @@
+FROM archlinux
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+# Packages needed for the build
+RUN pacman --noconfirm --needed -Syu \
+    base-devel \
+    git \
+    inetutils \
+    riscv64-linux-gnu-binutils \
+    riscv64-linux-gnu-gcc \
+    riscv64-linux-gnu-glibc
+
+# Add compiler path
+ENV CROSS_COMPILE=riscv64-linux-gnu-
+
+RUN useradd --create-home user
+USER user
+WORKDIR /build
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/centos/6.dockerfile 4.16.1-1/automation/build/centos/6.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/centos/6.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/centos/6.dockerfile	1970-01-01 00:00:00.000000000 +0000
@@ -1,51 +0,0 @@
-FROM centos:6
-LABEL maintainer.name="The Xen Project" \
-      maintainer.email="xen-devel@lists.xenproject.org"
-
-RUN mkdir /build
-WORKDIR /build
-
-# work around https://github.com/moby/moby/issues/10180
-# and add EPEL for dev86
-RUN rpm --rebuilddb && \
-    yum -y install \
-        yum-plugin-ovl \
-        epel-release \
-    && yum clean all && \
-    rm -rf /var/cache/yum
-
-# install Xen depends
-RUN yum -y install \
-        gcc \
-        gcc-c++ \
-        ncurses-devel \
-        zlib-devel \
-        openssl-devel \
-        python-devel \
-        libuuid-devel \
-        pciutils-devel \
-        pkgconfig \
-        gettext \
-        flex \
-        bison \
-        libaio-devel \
-        glib2-devel \
-        yajl-devel \
-        pixman-devel \
-        glibc-devel \
-        glibc-devel.i686 \
-        make \
-        binutils \
-        git \
-        wget \
-        acpica-tools \
-        python-markdown \
-        patch \
-        checkpolicy \
-        dev86 \
-        iasl \
-        xz-devel \
-        bzip2 \
-        nasm \
-    && yum clean all && \
-    rm -rf /var/cache/yum
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/centos/7.2.dockerfile 4.16.1-1/automation/build/centos/7.2.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/centos/7.2.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/centos/7.2.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -26,6 +26,7 @@ RUN rpm --rebuilddb && \
         python-devel \
         libuuid-devel \
         pkgconfig \
+        # gettext for Xen < 4.13
         gettext \
         flex \
         bison \
@@ -34,6 +35,7 @@ RUN rpm --rebuilddb && \
         yajl-devel \
         pixman-devel \
         glibc-devel \
+        # glibc-devel.i686 for Xen < 4.15
         glibc-devel.i686 \
         make \
         binutils \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/centos/7.dockerfile 4.16.1-1/automation/build/centos/7.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/centos/7.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/centos/7.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -24,6 +24,7 @@ RUN yum -y install \
         python-devel \
         libuuid-devel \
         pkgconfig \
+        # gettext for Xen < 4.13
         gettext \
         flex \
         bison \
@@ -32,6 +33,7 @@ RUN yum -y install \
         yajl-devel \
         pixman-devel \
         glibc-devel \
+        # glibc-devel.i686 for Xen < 4.15
         glibc-devel.i686 \
         make \
         binutils \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/jessie.dockerfile 4.16.1-1/automation/build/debian/jessie.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/jessie.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/jessie.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -26,11 +26,13 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
         bcc \
         liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
         libc6-dev-i386 \
         libnl-3-dev \
         ocaml-nox \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/jessie-i386.dockerfile 4.16.1-1/automation/build/debian/jessie-i386.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/jessie-i386.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/jessie-i386.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -28,6 +28,7 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/stretch.dockerfile 4.16.1-1/automation/build/debian/stretch.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/stretch.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/stretch.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -27,11 +27,13 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
         bcc \
         liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
         libc6-dev-i386 \
         libnl-3-dev \
         ocaml-nox \
@@ -45,6 +47,8 @@ RUN apt-get update && \
         nasm \
         gnupg \
         apt-transport-https \
+        # for test phase, qemu-smoke-* jobs
+        qemu-system-x86 \
         && \
         apt-get autoremove -y && \
         apt-get clean && \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/stretch-i386.dockerfile 4.16.1-1/automation/build/debian/stretch-i386.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/stretch-i386.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/stretch-i386.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -29,6 +29,7 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/unstable-arm32-gcc.dockerfile 4.16.1-1/automation/build/debian/unstable-arm32-gcc.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/unstable-arm32-gcc.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/build/debian/unstable-arm32-gcc.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,24 @@
+FROM debian:unstable
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV USER root
+ENV CROSS_COMPILE /usr/bin/arm-linux-gnueabihf-
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN apt-get update && \
+    apt-get --quiet --yes install \
+        build-essential \
+        flex \
+        bison \
+        git \
+        gcc-arm-linux-gnueabihf \
+        && \
+        apt-get autoremove -y && \
+        apt-get clean && \
+        rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
+
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/unstable-arm64v8.dockerfile 4.16.1-1/automation/build/debian/unstable-arm64v8.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/unstable-arm64v8.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/unstable-arm64v8.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -27,6 +27,7 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         libfdt-dev \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/unstable.dockerfile 4.16.1-1/automation/build/debian/unstable.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/unstable.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/unstable.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -27,11 +27,13 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
         bcc \
         liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
         libc6-dev-i386 \
         libnl-3-dev \
         ocaml-nox \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/debian/unstable-i386.dockerfile 4.16.1-1/automation/build/debian/unstable-i386.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/debian/unstable-i386.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/debian/unstable-i386.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -29,6 +29,7 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/fedora/29.dockerfile 4.16.1-1/automation/build/fedora/29.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/fedora/29.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/fedora/29.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -2,9 +2,6 @@ FROM fedora:29
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="xen-devel@lists.xenproject.org"
 
-RUN mkdir /build
-WORKDIR /build
-
 # install Xen depends
 RUN dnf -y install \
         clang \
@@ -17,6 +14,7 @@ RUN dnf -y install \
         python3-devel \
         libuuid-devel \
         pkgconfig \
+        # gettext for Xen < 4.13
         gettext \
         flex \
         bison \
@@ -25,6 +23,7 @@ RUN dnf -y install \
         yajl-devel \
         pixman-devel \
         glibc-devel \
+        # glibc-devel.i686 for Xen < 4.15
         glibc-devel.i686 \
         make \
         binutils \
@@ -41,5 +40,11 @@ RUN dnf -y install \
         ocaml \
         ocaml-findlib \
         golang \
+        # QEMU
+        ninja-build \
     && dnf clean all && \
     rm -rf /var/cache/dnf
+
+RUN useradd --create-home user
+USER user
+WORKDIR /build
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/Makefile 4.16.1-1/automation/build/Makefile
--- 4.14.3+32-g9de3671772-1/automation/build/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -2,6 +2,7 @@
 # the base of where these containers will appear
 REGISTRY := registry.gitlab.com/xen-project/xen
 CONTAINERS = $(subst .dockerfile,,$(wildcard */*.dockerfile))
+DOCKER_CMD ?= docker
 
 help:
 	@echo "Builds containers for building Xen based on different distros"
@@ -10,9 +11,9 @@ help:
 	@echo "To push container builds, set the env var PUSH"
 
 %: %.dockerfile ## Builds containers
-	docker build -t $(REGISTRY)/$(@D):$(@F) -f $< $(<D)
+	$(DOCKER_CMD) build -t $(REGISTRY)/$(@D):$(@F) -f $< $(<D)
 	@if [ ! -z $${PUSH+x} ]; then \
-		docker push $(REGISTRY)/$(@D):$(@F); \
+		$(DOCKER_CMD) push $(REGISTRY)/$(@D):$(@F); \
 	fi
 
 .PHONY: all
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/README.md 4.16.1-1/automation/build/README.md
--- 4.14.3+32-g9de3671772-1/automation/build/README.md	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/README.md	2022-04-12 12:21:23.000000000 +0000
@@ -91,5 +91,17 @@ you have access to do so and have your D
 To login you must run `docker login registry.gitlab.com`. For more
 information see the [registry help].
 
+This example shows how to refresh a container for a rolling release
+such as openSUSE Tumbleweed. Login with the gitlab.com credentials.
+
+```
+docker login registry.gitlab.com/xen-project/xen
+make -C automation/build suse/opensuse-tumbleweed
+env CONTAINER_NO_PULL=1 \
+  CONTAINER=tumbleweed \
+  automation/scripts/containerize bash -exc './configure && make'
+make -C automation/build suse/opensuse-tumbleweed PUSH=1
+```
+
 [registry]: https://gitlab.com/xen-project/xen/container_registry
 [registry help]: https://gitlab.com/help/user/project/container_registry
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/suse/opensuse-leap.dockerfile 4.16.1-1/automation/build/suse/opensuse-leap.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/suse/opensuse-leap.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/suse/opensuse-leap.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -22,14 +22,15 @@ RUN zypper install -y --no-recommends \
         flex \
         gcc \
         gcc-c++ \
+        # gettext-tools for Xen < 4.13
         gettext-tools \
         git \
         glib2-devel \
         glibc-devel \
+        # glibc-devel-32bit for Xen < 4.15
         glibc-devel-32bit \
         gzip \
         hostname \
-        libSDL2-devel \
         libaio-devel \
         libbz2-devel \
         libext2fs-devel \
@@ -54,6 +55,9 @@ RUN zypper install -y --no-recommends \
         pandoc \
         patch \
         pkg-config \
+        'pkgconfig(libpci)' \
+        'pkgconfig(sdl)' \
+        'pkgconfig(sdl2)' \
         python \
         python-devel \
         python3-devel \
@@ -65,5 +69,7 @@ RUN zypper install -y --no-recommends \
         which \
         xz-devel \
         zlib-devel \
+        # QEMU
+        ninja \
         && \
         zypper clean -a
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/suse/opensuse-tumbleweed.dockerfile 4.16.1-1/automation/build/suse/opensuse-tumbleweed.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/suse/opensuse-tumbleweed.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/suse/opensuse-tumbleweed.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -7,7 +7,7 @@ ENV USER root
 RUN mkdir /build
 WORKDIR /build
 
-RUN zypper ref && zypper up -y --no-recommends
+RUN zypper ref && zypper dup -y --no-recommends
 RUN zypper install -y --no-recommends \
         acpica \
         bc \
@@ -22,14 +22,15 @@ RUN zypper install -y --no-recommends \
         flex \
         gcc \
         gcc-c++ \
+        # gettext-tools for Xen < 4.13
         gettext-tools \
         git \
         glib2-devel \
         glibc-devel \
+        # glibc-devel-32bit for Xen < 4.15
         glibc-devel-32bit \
         gzip \
         hostname \
-        libSDL2-devel \
         libaio-devel \
         libbz2-devel \
         libext2fs-devel \
@@ -43,10 +44,13 @@ RUN zypper install -y --no-recommends \
         libtasn1-devel \
         libuuid-devel \
         libyajl-devel \
+        libzstd-devel \
         lzo-devel \
         make \
+        meson \
         nasm \
         ncurses-devel \
+        ninja \
         ocaml \
         ocaml-findlib-devel \
         ocaml-ocamlbuild \
@@ -54,9 +58,10 @@ RUN zypper install -y --no-recommends \
         pandoc \
         patch \
         pkg-config \
-        python \
+        'pkgconfig(libpci)' \
+        'pkgconfig(sdl)' \
+        'pkgconfig(sdl2)' \
         python-devel \
-        python3 \
         python3-devel \
         systemd-devel \
         tar \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/ubuntu/bionic.dockerfile 4.16.1-1/automation/build/ubuntu/bionic.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/ubuntu/bionic.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/ubuntu/bionic.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -27,11 +27,13 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
         bcc \
         liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
         libc6-dev-i386 \
         libnl-3-dev \
         ocaml-nox \
@@ -43,6 +45,8 @@ RUN apt-get update && \
         wget \
         git \
         nasm \
+        # QEMU
+        ninja-build \
         && \
         apt-get autoremove -y && \
         apt-get clean && \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/ubuntu/focal.dockerfile 4.16.1-1/automation/build/ubuntu/focal.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/ubuntu/focal.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/build/ubuntu/focal.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,52 @@
+FROM ubuntu:20.04
+LABEL maintainer.name="The Xen Project " \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN apt-get update && \
+    apt-get --quiet --yes install \
+        build-essential \
+        zlib1g-dev \
+        libncurses5-dev \
+        libssl-dev \
+        python3-dev \
+        xorg-dev \
+        uuid-dev \
+        libyajl-dev \
+        libaio-dev \
+        libglib2.0-dev \
+        clang \
+        libpixman-1-dev \
+        pkg-config \
+        flex \
+        bison \
+        # gettext for Xen < 4.13
+        gettext \
+        acpica-tools \
+        bin86 \
+        bcc \
+        liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
+        libc6-dev-i386 \
+        libnl-3-dev \
+        ocaml-nox \
+        libfindlib-ocaml-dev \
+        libsystemd-dev \
+        transfig \
+        pandoc \
+        checkpolicy \
+        wget \
+        git \
+        nasm \
+        # QEMU
+        ninja-build \
+        && \
+        apt-get autoremove -y && \
+        apt-get clean && \
+        rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/ubuntu/trusty.dockerfile 4.16.1-1/automation/build/ubuntu/trusty.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/ubuntu/trusty.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/ubuntu/trusty.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -27,11 +27,13 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
         bcc \
         liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
         libc6-dev-i386 \
         libnl-3-dev \
         ocaml-nox \
diff -pruN 4.14.3+32-g9de3671772-1/automation/build/ubuntu/xenial.dockerfile 4.16.1-1/automation/build/ubuntu/xenial.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/build/ubuntu/xenial.dockerfile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/build/ubuntu/xenial.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -27,11 +27,13 @@ RUN apt-get update && \
         pkg-config \
         flex \
         bison \
+        # gettext for Xen < 4.13
         gettext \
         acpica-tools \
         bin86 \
         bcc \
         liblzma-dev \
+        # libc6-dev-i386 for Xen < 4.15
         libc6-dev-i386 \
         libnl-3-dev \
         ocaml-nox \
diff -pruN 4.14.3+32-g9de3671772-1/automation/gitlab-ci/build.yaml 4.16.1-1/automation/gitlab-ci/build.yaml
--- 4.14.3+32-g9de3671772-1/automation/gitlab-ci/build.yaml	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/gitlab-ci/build.yaml	2022-04-12 12:21:23.000000000 +0000
@@ -8,6 +8,7 @@
       - binaries/
       - xen-config
       - '*.log'
+      - '*/*.log'
     when: always
   except:
     - master
@@ -117,6 +118,33 @@
   variables:
     <<: *clang
 
+.arm32-cross-build-tmpl:
+  <<: *build
+  variables:
+    XEN_TARGET_ARCH: arm32
+  tags:
+    - x86_64
+
+.arm32-cross-build:
+  extends: .arm32-cross-build-tmpl
+  variables:
+    debug: n
+
+.arm32-cross-build-debug:
+  extends: .arm32-cross-build-tmpl
+  variables:
+    debug: y
+
+.gcc-arm32-cross-build:
+  extends: .arm32-cross-build
+  variables:
+    <<: *gcc
+
+.gcc-arm32-cross-build-debug:
+  extends: .arm32-cross-build-debug
+  variables:
+    <<: *gcc
+
 .arm64-build-tmpl:
   <<: *build
   variables:
@@ -176,16 +204,6 @@ centos-7-gcc-debug:
   variables:
     CONTAINER: centos:7
 
-centos-6-gcc:
-  extends: .gcc-x86-64-build
-  variables:
-    CONTAINER: centos:6
-
-centos-6-gcc-debug:
-  extends: .gcc-x86-64-build-debug
-  variables:
-    CONTAINER: centos:6
-
 debian-jessie-clang:
   extends: .clang-x86-64-build
   variables:
@@ -400,6 +418,26 @@ ubuntu-bionic-gcc-debug:
   variables:
     CONTAINER: ubuntu:bionic
 
+ubuntu-focal-gcc:
+  extends: .gcc-x86-64-build
+  variables:
+    CONTAINER: ubuntu:focal
+
+ubuntu-focal-gcc-debug:
+  extends: .gcc-x86-64-build-debug
+  variables:
+    CONTAINER: ubuntu:focal
+
+ubuntu-focal-clang:
+  extends: .clang-x86-64-build
+  variables:
+    CONTAINER: ubuntu:focal
+
+ubuntu-focal-clang-debug:
+  extends: .clang-x86-64-build-debug
+  variables:
+    CONTAINER: ubuntu:focal
+
 opensuse-leap-clang:
   extends: .clang-x86-64-build
   variables:
@@ -420,6 +458,74 @@ opensuse-leap-gcc-debug:
   variables:
     CONTAINER: suse:opensuse-leap
 
+opensuse-tumbleweed-clang:
+  extends: .clang-x86-64-build
+  variables:
+    CONTAINER: suse:opensuse-tumbleweed
+  allow_failure: true
+
+opensuse-tumbleweed-clang-debug:
+  extends: .clang-x86-64-build-debug
+  variables:
+    CONTAINER: suse:opensuse-tumbleweed
+  allow_failure: true
+
+opensuse-tumbleweed-gcc:
+  extends: .gcc-x86-64-build
+  variables:
+    CONTAINER: suse:opensuse-tumbleweed
+  allow_failure: true
+
+opensuse-tumbleweed-gcc-debug:
+  extends: .gcc-x86-64-build-debug
+  variables:
+    CONTAINER: suse:opensuse-tumbleweed
+  allow_failure: true
+
+alpine-3.12-gcc:
+  extends: .gcc-x86-64-build
+  variables:
+    CONTAINER: alpine:3.12
+
+alpine-3.12-gcc-debug:
+  extends: .gcc-x86-64-build-debug
+  variables:
+    CONTAINER: alpine:3.12
+
+alpine-3.12-clang:
+  extends: .clang-x86-64-build
+  variables:
+    CONTAINER: alpine:3.12
+
+alpine-3.12-clang-debug:
+  extends: .clang-x86-64-build-debug
+  variables:
+    CONTAINER: alpine:3.12
+
+# Arm32 cross-build
+
+debian-unstable-gcc-arm32:
+  extends: .gcc-arm32-cross-build
+  variables:
+    CONTAINER: debian:unstable-arm32-gcc
+
+debian-unstable-gcc-arm32-debug:
+  extends: .gcc-arm32-cross-build-debug
+  variables:
+    CONTAINER: debian:unstable-arm32-gcc
+
+debian-unstable-gcc-arm32-randconfig:
+  extends: .gcc-arm32-cross-build
+  variables:
+    CONTAINER: debian:unstable-arm32-gcc
+    RANDCONFIG: y
+
+debian-unstable-gcc-arm32-debug-randconfig:
+  extends: .gcc-arm32-cross-build-debug
+  variables:
+    CONTAINER: debian:unstable-arm32-gcc
+    RANDCONFIG: y
+
 # Arm builds
 
 debian-unstable-gcc-arm64:
@@ -444,3 +550,73 @@ debian-unstable-gcc-debug-arm64-randconf
     CONTAINER: debian:unstable-arm64v8
     RANDCONFIG: y
 
+alpine-3.12-gcc-arm64:
+  extends: .gcc-arm64-build
+  variables:
+    CONTAINER: alpine:3.12-arm64v8
+
+alpine-3.12-gcc-debug-arm64:
+  extends: .gcc-arm64-build-debug
+  variables:
+    CONTAINER: alpine:3.12-arm64v8
+
+
+# Arm test artifacts
+
+alpine-3.12-arm64-rootfs-export:
+  stage: build
+  image: registry.gitlab.com/xen-project/xen/tests-artifacts/alpine:3.12-arm64v8
+  script:
+    - mkdir binaries && cp /initrd.tar.gz binaries/initrd.tar.gz
+  artifacts:
+    paths:
+      - binaries/initrd.tar.gz
+  tags:
+    - arm64
+
+kernel-5.9.9-arm64-export:
+  stage: build
+  image: registry.gitlab.com/xen-project/xen/tests-artifacts/kernel:5.9.9-arm64v8
+  script:
+    - mkdir binaries && cp /Image binaries/Image
+  artifacts:
+    paths:
+      - binaries/Image
+  tags:
+    - arm64
+
+qemu-system-aarch64-5.2.0-arm64-export:
+  stage: build
+  image: registry.gitlab.com/xen-project/xen/tests-artifacts/qemu-system-aarch64:5.2.0-arm64v8
+  script:
+    - mkdir binaries && cp /qemu-system-aarch64 binaries/qemu-system-aarch64
+  artifacts:
+    paths:
+      - binaries/qemu-system-aarch64
+  tags:
+    - arm64
+
+
+# x86_64 test artifacts
+
+alpine-3.12-rootfs-export:
+  stage: build
+  image: registry.gitlab.com/xen-project/xen/tests-artifacts/alpine:3.12
+  script:
+    - mkdir binaries && cp /initrd.tar.gz binaries/initrd.tar.gz
+  artifacts:
+    paths:
+      - binaries/initrd.tar.gz
+  tags:
+    - x86_64
+
+kernel-5.10.74-export:
+  stage: build
+  image: registry.gitlab.com/xen-project/xen/tests-artifacts/kernel:5.10.74
+  script:
+    - mkdir binaries && cp /bzImage binaries/bzImage
+  artifacts:
+    paths:
+      - binaries/bzImage
+  tags:
+    - x86_64
diff -pruN 4.14.3+32-g9de3671772-1/automation/gitlab-ci/test.yaml 4.16.1-1/automation/gitlab-ci/test.yaml
--- 4.14.3+32-g9de3671772-1/automation/gitlab-ci/test.yaml	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/gitlab-ci/test.yaml	2022-04-12 12:21:23.000000000 +0000
@@ -22,6 +22,79 @@ build-each-commit-gcc:
     - /^coverity-tested\/.*/
     - /^stable-.*/
 
+qemu-alpine-arm64-gcc:
+  stage: test
+  image: registry.gitlab.com/xen-project/xen/${CONTAINER}
+  variables:
+    CONTAINER: debian:unstable-arm64v8
+  script:
+    - ./automation/scripts/qemu-alpine-arm64.sh 2>&1 | tee qemu-smoke-arm64.log
+  dependencies:
+    - alpine-3.12-gcc-arm64
+    - alpine-3.12-arm64-rootfs-export
+    - kernel-5.9.9-arm64-export
+    - qemu-system-aarch64-5.2.0-arm64-export
+  artifacts:
+    paths:
+      - smoke.serial
+      - '*.log'
+    when: always
+  tags:
+    - arm64
+  except:
+    - master
+    - smoke
+    - /^coverity-tested\/.*/
+    - /^stable-.*/
+
+qemu-alpine-x86_64-gcc:
+  stage: test
+  image: registry.gitlab.com/xen-project/xen/${CONTAINER}
+  variables:
+    CONTAINER: debian:stretch
+  script:
+    - ./automation/scripts/qemu-alpine-x86_64.sh 2>&1 | tee qemu-smoke-x86_64.log
+  dependencies:
+    - alpine-3.12-gcc
+    - alpine-3.12-rootfs-export
+    - kernel-5.10.74-export
+  artifacts:
+    paths:
+      - smoke.serial
+      - '*.log'
+    when: always
+  tags:
+    - x86_64
+  except:
+    - master
+    - smoke
+    - /^coverity-tested\/.*/
+    - /^stable-.*/
+
+qemu-smoke-arm64-gcc:
+  stage: test
+  image: registry.gitlab.com/xen-project/xen/${CONTAINER}
+  variables:
+    CONTAINER: debian:unstable-arm64v8
+  script:
+    - ./automation/scripts/qemu-smoke-arm64.sh 2>&1 | tee qemu-smoke-arm64.log
+  dependencies:
+    - debian-unstable-gcc-arm64
+    - kernel-5.9.9-arm64-export
+    - qemu-system-aarch64-5.2.0-arm64-export
+  artifacts:
+    paths:
+      - smoke.serial
+      - '*.log'
+    when: always
+  tags:
+    - arm64
+  except:
+    - master
+    - smoke
+    - /^coverity-tested\/.*/
+    - /^stable-.*/
+
 qemu-smoke-x86-64-gcc:
   stage: test
   image: registry.gitlab.com/xen-project/xen/${CONTAINER}
diff -pruN 4.14.3+32-g9de3671772-1/automation/scripts/build 4.16.1-1/automation/scripts/build
--- 4.14.3+32-g9de3671772-1/automation/scripts/build	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/scripts/build	2022-04-12 12:21:23.000000000 +0000
@@ -1,5 +1,7 @@
 #!/bin/bash -ex
 
+test -f /etc/os-release && cat "$_"
+
 $CC --version
 
 # Express the compiler version as an integer.  e.g. GCC 4.9.2 => 0x040902
@@ -10,9 +12,19 @@ cc-ver()
 
 # random config or default config
 if [[ "${RANDCONFIG}" == "y" ]]; then
-    make -C xen KCONFIG_ALLCONFIG=tools/kconfig/allrandom.config randconfig
+    make -j$(nproc) -C xen KCONFIG_ALLCONFIG=tools/kconfig/allrandom.config randconfig
+    hypervisor_only="y"
 else
-    make -C xen defconfig
+    make -j$(nproc) -C xen defconfig
+fi
+
+# Save the config file before building because build failure causes the script
+# to exit early -- bash is invoked with -e.
+cp xen/.config xen-config
+
+# arm32 only cross-compiles the hypervisor
+if [[ "${XEN_TARGET_ARCH}" = "arm32" ]]; then
+    hypervisor_only="y"
 fi
 
 # build up our configure options
@@ -28,8 +40,16 @@ if [[ "${CC}" == "clang"* ]]; then
     cfgargs+=("--disable-stubdom")
 fi
 
-# Qemu requires Python 3.5 or later
-if ! type python3 || python3 -c "import sys; res = sys.version_info < (3, 5); exit(not(res))"; then
+if ! test -z "$(ldd /bin/ls|grep musl|head -1)"; then
+    # disable --disable-werror for QEMUU when building with MUSL
+    cfgargs+=("--with-extra-qemuu-configure-args=\"--disable-werror\"")
+    # SeaBIOS doesn't build on MUSL systems
+    cfgargs+=("--with-system-seabios=/bin/false")
+fi
+
+# Qemu requires Python 3.5 or later, and ninja
+if ! type python3 || python3 -c "import sys; res = sys.version_info < (3, 5); exit(not(res))" \
+        || ! type ninja; then
     cfgargs+=("--with-system-qemu=/bin/false")
 fi
 
@@ -38,15 +58,26 @@ if [[ "${CC}" == "gcc" && `cc-ver` -lt 0
     cfgargs+=("--with-system-seabios=/bin/false")
 fi
 
-./configure "${cfgargs[@]}"
-
-make -j$(nproc) dist
+if [[ "${hypervisor_only}" == "y" ]]; then
+    make -j$(nproc) xen
+else
+    ./configure "${cfgargs[@]}"
+    make -j$(nproc) dist
+fi
 
 # Extract artifacts to avoid getting rewritten by customised builds
-cp xen/.config xen-config
 mkdir binaries
-if [[ "${XEN_TARGET_ARCH}" == "x86_64" ]]; then
+if [[ "${XEN_TARGET_ARCH}" != "x86_32" ]]; then
     cp xen/xen binaries/xen
+    if [[ "${hypervisor_only}" != "y" ]]; then
+        cp -r dist binaries/
+    fi
+fi
+
+if [[ "${hypervisor_only}" == "y" ]]; then
+    # If we are build testing a specific Kconfig exit now, there's no point in
+    # testing all the possible configs.
+    exit 0
 fi
 
 # Build all the configs we care about
diff -pruN 4.14.3+32-g9de3671772-1/automation/scripts/containerize 4.16.1-1/automation/scripts/containerize
--- 4.14.3+32-g9de3671772-1/automation/scripts/containerize	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/scripts/containerize	2022-04-12 12:21:23.000000000 +0000
@@ -7,7 +7,7 @@
 # and /etc/subgid.
 #
 docker_cmd=${DOCKER_CMD:-"docker"}
-[ "$DOCKER_CMD" = "podman" ] && userns_podman="--userns=keep-id"
+[ "$DOCKER_CMD" = "podman" ] && userns_podman="--userns=keep-id" selinux=",z"
 
 einfo() {
     echo "$*" >&2
@@ -24,11 +24,13 @@ die() {
 #
 BASE="registry.gitlab.com/xen-project/xen"
 case "_${CONTAINER}" in
+    _alpine) CONTAINER="${BASE}/alpine:3.12" ;;
     _archlinux|_arch) CONTAINER="${BASE}/archlinux:current" ;;
-    _centos6) CONTAINER="${BASE}/centos:6" ;;
+    _riscv64) CONTAINER="${BASE}/archlinux:riscv64" ;;
     _centos7) CONTAINER="${BASE}/centos:7" ;;
     _centos72) CONTAINER="${BASE}/centos:7.2" ;;
     _fedora) CONTAINER="${BASE}/fedora:29";;
+    _focal) CONTAINER="${BASE}/ubuntu:focal" ;;
     _jessie) CONTAINER="${BASE}/debian:jessie" ;;
     _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
     _unstable|_) CONTAINER="${BASE}/debian:unstable" ;;
@@ -45,10 +47,10 @@ case "_${CONTAINER_UID0}" in
 esac
 
 # Save the commands for future use
-cmd=$@
+cmd=("$@")
 
 # If no command was specified, just drop us into a shell if we're interactive
-[ $# -eq 0 ] && tty -s && cmd="/bin/bash"
+[ $# -eq 0 ] && tty -s && cmd=("/bin/bash")
 
 # Are we in an interactive terminal?
 tty -s && termint=t
@@ -95,11 +97,11 @@ einfo "*** Launching container ..."
 exec ${docker_cmd} run \
     ${userarg} \
     ${SSH_AUTH_SOCK:+-e SSH_AUTH_SOCK="/tmp/ssh-agent/${SSH_AUTH_NAME}"} \
-    -v "${CONTAINER_PATH}":/build:rw \
+    -v "${CONTAINER_PATH}":/build:rw${selinux} \
     -v "${HOME}/.ssh":/root/.ssh:ro \
-    ${SSH_AUTH_DIR:+-v "${SSH_AUTH_DIR}":/tmp/ssh-agent} \
+    ${SSH_AUTH_DIR:+-v "${SSH_AUTH_DIR}":/tmp/ssh-agent${selinux}} \
     ${XEN_CONFIG_EXPERT:+-e XEN_CONFIG_EXPERT=${XEN_CONFIG_EXPERT}} \
     ${CONTAINER_ARGS} \
     -${termint}i --rm -- \
     ${CONTAINER} \
-    ${cmd}
+    "${cmd[@]}"
diff -pruN 4.14.3+32-g9de3671772-1/automation/scripts/qemu-alpine-arm64.sh 4.16.1-1/automation/scripts/qemu-alpine-arm64.sh
--- 4.14.3+32-g9de3671772-1/automation/scripts/qemu-alpine-arm64.sh	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/scripts/qemu-alpine-arm64.sh	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+set -ex
+
+apt-get -qy update
+apt-get -qy install --no-install-recommends u-boot-qemu \
+                                            u-boot-tools \
+                                            device-tree-compiler \
+                                            cpio \
+                                            curl \
+                                            busybox-static
+
+# DomU Busybox
+cd binaries
+mkdir -p initrd
+mkdir -p initrd/bin
+mkdir -p initrd/sbin
+mkdir -p initrd/etc
+mkdir -p initrd/dev
+mkdir -p initrd/proc
+mkdir -p initrd/sys
+mkdir -p initrd/lib
+mkdir -p initrd/var
+mkdir -p initrd/mnt
+cp /bin/busybox initrd/bin/busybox
+initrd/bin/busybox --install initrd/bin
+echo "#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+mount -t devtmpfs devtmpfs /dev
+/bin/sh" > initrd/init
+chmod +x initrd/init
+cd initrd
+find . | cpio --create --format='newc' | gzip > ../initrd.cpio.gz
+cd ..
+
+mkdir -p rootfs
+cd rootfs
+tar xvzf ../initrd.tar.gz
+mkdir proc
+mkdir run
+mkdir srv
+mkdir sys
+rm var/run
+cp -ar ../dist/install/* .
+mv ../initrd.cpio.gz ./root
+cp ../Image ./root
+echo "name=\"test\"
+memory=512
+vcpus=1
+kernel=\"/root/Image\"
+ramdisk=\"/root/initrd.cpio.gz\"
+extra=\"console=hvc0 root=/dev/ram0 rdinit=/bin/sh\"
+" > root/test.cfg
+echo "#!/bin/bash
+
+export LD_LIBRARY_PATH=/usr/local/lib
+bash /etc/init.d/xencommons start
+
+xl list
+
+xl create -c /root/test.cfg
+
+" > etc/local.d/xen.start
+chmod +x etc/local.d/xen.start
+echo "rc_verbose=yes" >> etc/rc.conf
+find . |cpio -H newc -o|gzip > ../xen-rootfs.cpio.gz
+cd ../..
+
+# XXX QEMU looks for "efi-virtio.rom" even if it is unneeded
+curl -fsSLO https://github.com/qemu/qemu/raw/v5.2.0/pc-bios/efi-virtio.rom
+./binaries/qemu-system-aarch64 \
+   -machine virtualization=true \
+   -cpu cortex-a57 -machine type=virt \
+   -m 1024 -display none \
+   -machine dumpdtb=binaries/virt-gicv3.dtb
+# XXX disable pl061 to avoid Linux crash
+dtc -I dtb -O dts binaries/virt-gicv3.dtb > binaries/virt-gicv3.dts
+sed 's/compatible = "arm,pl061.*/status = "disabled";/g' binaries/virt-gicv3.dts > binaries/virt-gicv3-edited.dts
+dtc -I dts -O dtb binaries/virt-gicv3-edited.dts > binaries/virt-gicv3.dtb
+
+# ImageBuilder
+echo 'MEMORY_START="0x40000000"
+MEMORY_END="0x80000000"
+
+DEVICE_TREE="virt-gicv3.dtb"
+XEN="xen"
+DOM0_KERNEL="Image"
+DOM0_RAMDISK="xen-rootfs.cpio.gz"
+XEN_CMD="console=dtuart dom0_mem=1024M"
+
+NUM_DOMUS=0
+
+LOAD_CMD="tftpb"
+UBOOT_SOURCE="boot.source"
+UBOOT_SCRIPT="boot.scr"' > binaries/config
+rm -rf imagebuilder
+git clone https://gitlab.com/ViryaOS/imagebuilder
+bash imagebuilder/scripts/uboot-script-gen -t tftp -d binaries/ -c binaries/config
+
+
+# Run the test
+rm -f smoke.serial
+set +e
+echo "  virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
+timeout -k 1 720 \
+./binaries/qemu-system-aarch64 \
+    -machine virtualization=true \
+    -cpu cortex-a57 -machine type=virt \
+    -m 2048 -monitor none -serial stdio \
+    -smp 2 \
+    -no-reboot \
+    -device virtio-net-pci,netdev=n0 \
+    -netdev user,id=n0,tftp=binaries \
+    -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin |& tee smoke.serial
+
+set -e
+(grep -q "Domain-0" smoke.serial && grep -q "BusyBox" smoke.serial) || exit 1
+exit 0
diff -pruN 4.14.3+32-g9de3671772-1/automation/scripts/qemu-alpine-x86_64.sh 4.16.1-1/automation/scripts/qemu-alpine-x86_64.sh
--- 4.14.3+32-g9de3671772-1/automation/scripts/qemu-alpine-x86_64.sh	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/scripts/qemu-alpine-x86_64.sh	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+set -ex
+
+apt-get -qy update
+apt-get -qy install --no-install-recommends cpio \
+                                            busybox-static
+
+# DomU Busybox
+cd binaries
+mkdir -p initrd
+mkdir -p initrd/bin
+mkdir -p initrd/sbin
+mkdir -p initrd/etc
+mkdir -p initrd/dev
+mkdir -p initrd/proc
+mkdir -p initrd/sys
+mkdir -p initrd/lib
+mkdir -p initrd/var
+mkdir -p initrd/mnt
+cp /bin/busybox initrd/bin/busybox
+initrd/bin/busybox --install initrd/bin
+echo "#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+mount -t devtmpfs devtmpfs /dev
+/bin/sh" > initrd/init
+chmod +x initrd/init
+# DomU rootfs
+cd initrd
+find . | cpio --create --format='newc' | gzip > ../initrd.cpio.gz
+cd ..
+
+# initrd.tar.gz is Dom0 rootfs
+mkdir -p rootfs
+cd rootfs
+tar xvzf ../initrd.tar.gz
+mkdir proc
+mkdir run
+mkdir srv
+mkdir sys
+rm var/run
+cp -ar ../dist/install/* .
+mv ../initrd.cpio.gz ./root
+cp ../bzImage ./root
+echo "name=\"test\"
+memory=512
+vcpus=1
+kernel=\"/root/bzImage\"
+ramdisk=\"/root/initrd.cpio.gz\"
+extra=\"console=hvc0 root=/dev/ram0 rdinit=/bin/sh\"
+" > root/test.cfg
+echo "#!/bin/bash
+
+set -x
+
+export LD_LIBRARY_PATH=/usr/local/lib
+bash /etc/init.d/xencommons start
+
+xl list
+
+xl create -c /root/test.cfg
+
+" > etc/local.d/xen.start
+chmod +x etc/local.d/xen.start
+echo "rc_verbose=yes" >> etc/rc.conf
+# rebuild Dom0 rootfs
+find . |cpio -H newc -o|gzip > ../xen-rootfs.cpio.gz
+cd ../..
+
+cat >> binaries/pxelinux.0 << EOF
+#!ipxe
+
+kernel xen console=com1
+module bzImage console=hvc0
+module xen-rootfs.cpio.gz
+boot
+EOF
+
+# Run the test
+rm -f smoke.serial
+set +e
+timeout -k 1 720 \
+qemu-system-x86_64 \
+    -cpu qemu64,+svm \
+    -m 2G -smp 2 \
+    -monitor none -serial stdio \
+    -nographic \
+    -device virtio-net-pci,netdev=n0 \
+    -netdev user,id=n0,tftp=binaries,bootfile=/pxelinux.0 |& tee smoke.serial
+
+set -e
+(grep -q "Domain-0" smoke.serial && grep -q "BusyBox" smoke.serial) || exit 1
+exit 0
diff -pruN 4.14.3+32-g9de3671772-1/automation/scripts/qemu-smoke-arm64.sh 4.16.1-1/automation/scripts/qemu-smoke-arm64.sh
--- 4.14.3+32-g9de3671772-1/automation/scripts/qemu-smoke-arm64.sh	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/scripts/qemu-smoke-arm64.sh	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+set -ex
+
+# Install QEMU
+export DEBIAN_FRONTENT=noninteractive
+apt-get -qy update
+apt-get -qy install --no-install-recommends u-boot-qemu \
+                                            u-boot-tools \
+                                            device-tree-compiler \
+                                            busybox-static \
+                                            cpio \
+                                            curl
+
+# XXX QEMU looks for "efi-virtio.rom" even if it is unneeded
+curl -fsSLO https://github.com/qemu/qemu/raw/v5.2.0/pc-bios/efi-virtio.rom
+./binaries/qemu-system-aarch64 \
+   -machine virtualization=true \
+   -cpu cortex-a57 -machine type=virt \
+   -m 1024 -display none \
+   -machine dumpdtb=binaries/virt-gicv3.dtb
+# XXX disable pl061 to avoid Linux crash
+dtc -I dtb -O dts binaries/virt-gicv3.dtb > binaries/virt-gicv3.dts
+sed 's/compatible = "arm,pl061.*/status = "disabled";/g' binaries/virt-gicv3.dts > binaries/virt-gicv3-edited.dts
+dtc -I dts -O dtb binaries/virt-gicv3-edited.dts > binaries/virt-gicv3.dtb
+
+
+# Busybox Dom0
+mkdir -p initrd
+mkdir -p initrd/bin
+mkdir -p initrd/sbin
+mkdir -p initrd/etc
+mkdir -p initrd/dev
+mkdir -p initrd/proc
+mkdir -p initrd/sys
+mkdir -p initrd/lib
+mkdir -p initrd/var
+mkdir -p initrd/mnt
+cp /bin/busybox initrd/bin/busybox
+initrd/bin/busybox --install initrd/bin
+echo "#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+mount -t devtmpfs devtmpfs /dev
+/bin/sh" > initrd/init
+chmod +x initrd/init
+cd initrd
+find . | cpio --create --format='newc' | gzip > ../binaries/initrd
+cd ..
+
+
+# ImageBuilder
+echo 'MEMORY_START="0x40000000"
+MEMORY_END="0x80000000"
+
+DEVICE_TREE="virt-gicv3.dtb"
+XEN="xen"
+DOM0_KERNEL="Image"
+DOM0_RAMDISK="initrd"
+XEN_CMD="console=dtuart dom0_mem=512M"
+
+NUM_DOMUS=1
+DOMU_KERNEL[0]="Image"
+DOMU_RAMDISK[0]="initrd"
+DOMU_MEM[0]="256"
+
+LOAD_CMD="tftpb"
+UBOOT_SOURCE="boot.source"
+UBOOT_SCRIPT="boot.scr"' > binaries/config
+rm -rf imagebuilder
+git clone https://gitlab.com/ViryaOS/imagebuilder
+bash imagebuilder/scripts/uboot-script-gen -t tftp -d binaries/ -c binaries/config
+
+
+# Run the test
+rm -f smoke.serial
+set +e
+echo "  virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
+timeout -k 1 240 \
+./binaries/qemu-system-aarch64 \
+    -machine virtualization=true \
+    -cpu cortex-a57 -machine type=virt \
+    -m 1024 -monitor none -serial stdio \
+    -smp 2 \
+    -no-reboot \
+    -device virtio-net-pci,netdev=n0 \
+    -netdev user,id=n0,tftp=binaries \
+    -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin |& tee smoke.serial
+
+set -e
+(grep -q "^BusyBox" smoke.serial && grep -q "DOM1: BusyBox" smoke.serial) || exit 1
+exit 0
diff -pruN 4.14.3+32-g9de3671772-1/automation/scripts/qemu-smoke-x86-64.sh 4.16.1-1/automation/scripts/qemu-smoke-x86-64.sh
--- 4.14.3+32-g9de3671772-1/automation/scripts/qemu-smoke-x86-64.sh	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/automation/scripts/qemu-smoke-x86-64.sh	2022-04-12 12:21:23.000000000 +0000
@@ -5,18 +5,13 @@ set -ex
 # variant should be either pv or pvh
 variant=$1
 
-# Install QEMU
-export DEBIAN_FRONTENT=noninteractive
-apt-get -qy update
-apt-get -qy install qemu-system-x86
-
 # Clone and build XTF
 git clone https://xenbits.xen.org/git-http/xtf.git
 cd xtf && make -j$(nproc) && cd -
 
 case $variant in
-    pvh) k=test-hvm32pae-example extra="dom0-iommu=none dom0=pvh" ;;
-    *)   k=test-pv32pae-example  extra= ;;
+    pvh) k=test-hvm64-example    extra="dom0-iommu=none dom0=pvh" ;;
+    *)   k=test-pv64-example     extra= ;;
 esac
 
 rm -f smoke.serial
diff -pruN 4.14.3+32-g9de3671772-1/automation/tests-artifacts/alpine/3.12-arm64v8.dockerfile 4.16.1-1/automation/tests-artifacts/alpine/3.12-arm64v8.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/tests-artifacts/alpine/3.12-arm64v8.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/tests-artifacts/alpine/3.12-arm64v8.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,68 @@
+FROM arm64v8/alpine:3.12
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+RUN \
+  # apk
+  apk update && \
+  \
+  # xen runtime deps
+  apk add musl && \
+  apk add openrc && \
+  apk add busybox && \
+  apk add sudo && \
+  apk add dbus && \
+  apk add bash && \
+  apk add python2 && \
+  # gettext for Xen < 4.13
+  apk add gettext && \
+  apk add zlib && \
+  apk add ncurses && \
+  apk add texinfo && \
+  apk add yajl && \
+  apk add libaio && \
+  apk add xz-dev && \
+  apk add util-linux && \
+  apk add argp-standalone && \
+  apk add libfdt && \
+  apk add glib && \
+  apk add pixman && \
+  apk add curl && \
+  apk add udev && \
+  \
+  # Xen
+  cd / && \
+  # Minimal ramdisk environment in case of cpio output
+  rc-update add udev && \
+  rc-update add udev-trigger && \
+  rc-update add udev-settle && \
+  rc-update add networking sysinit && \
+  rc-update add loopback sysinit && \
+  rc-update add bootmisc boot && \
+  rc-update add devfs sysinit && \
+  rc-update add dmesg sysinit && \
+  rc-update add hostname boot && \
+  rc-update add hwclock boot && \
+  rc-update add hwdrivers sysinit && \
+  rc-update add killprocs shutdown && \
+  rc-update add modloop sysinit && \
+  rc-update add modules boot && \
+  rc-update add mount-ro shutdown && \
+  rc-update add savecache shutdown && \
+  rc-update add sysctl boot && \
+  rc-update add local default && \
+  cp -a /sbin/init /init && \
+  echo "ttyS0" >> /etc/securetty && \
+  echo "hvc0" >> /etc/securetty && \
+  echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab && \
+  echo "hvc0::respawn:/sbin/getty -L hvc0 115200 vt100" >> /etc/inittab && \
+  passwd -d "root" root && \
+  \
+  # Create rootfs
+  cd / && \
+  tar cvzf /initrd.tar.gz bin dev etc home init lib mnt opt root sbin usr var
diff -pruN 4.14.3+32-g9de3671772-1/automation/tests-artifacts/alpine/3.12.dockerfile 4.16.1-1/automation/tests-artifacts/alpine/3.12.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/tests-artifacts/alpine/3.12.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/tests-artifacts/alpine/3.12.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,66 @@
+FROM alpine:3.12
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+RUN \
+  # apk
+  apk update && \
+  \
+  # xen runtime deps
+  apk add musl && \
+  apk add openrc && \
+  apk add busybox && \
+  apk add sudo && \
+  apk add dbus && \
+  apk add bash && \
+  apk add python2 && \
+  apk add zlib && \
+  apk add ncurses && \
+  apk add texinfo && \
+  apk add yajl && \
+  apk add libaio && \
+  apk add xz-dev && \
+  apk add util-linux && \
+  apk add argp-standalone && \
+  apk add libfdt && \
+  apk add glib && \
+  apk add pixman && \
+  apk add curl && \
+  apk add udev && \
+  \
+  # Xen
+  cd / && \
+  # Minimal ramdisk environment in case of cpio output
+  rc-update add udev && \
+  rc-update add udev-trigger && \
+  rc-update add udev-settle && \
+  rc-update add networking sysinit && \
+  rc-update add loopback sysinit && \
+  rc-update add bootmisc boot && \
+  rc-update add devfs sysinit && \
+  rc-update add dmesg sysinit && \
+  rc-update add hostname boot && \
+  rc-update add hwclock boot && \
+  rc-update add hwdrivers sysinit && \
+  rc-update add killprocs shutdown && \
+  rc-update add modloop sysinit && \
+  rc-update add modules boot && \
+  rc-update add mount-ro shutdown && \
+  rc-update add savecache shutdown && \
+  rc-update add sysctl boot && \
+  rc-update add local default && \
+  cp -a /sbin/init /init && \
+  echo "ttyS0" >> /etc/securetty && \
+  echo "hvc0" >> /etc/securetty && \
+  echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab && \
+  echo "hvc0::respawn:/sbin/getty -L hvc0 115200 vt100" >> /etc/inittab && \
+  passwd -d "root" root && \
+  \
+  # Create rootfs
+  cd / && \
+  tar cvzf /initrd.tar.gz bin dev etc home init lib mnt opt root sbin usr var
diff -pruN 4.14.3+32-g9de3671772-1/automation/tests-artifacts/kernel/5.10.74.dockerfile 4.16.1-1/automation/tests-artifacts/kernel/5.10.74.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/tests-artifacts/kernel/5.10.74.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/tests-artifacts/kernel/5.10.74.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,38 @@
+FROM debian:unstable
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV LINUX_VERSION=5.10.74
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN apt-get update && \
+    apt-get --quiet --yes install \
+        build-essential \
+        libssl-dev \
+        bc \
+        curl \
+        flex \
+        bison \
+        libelf-dev \
+        && \
+    apt-get autoremove -y && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
+
+# Build the kernel
+RUN curl -fsSLO https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-"$LINUX_VERSION".tar.xz && \
+    tar xvJf linux-"$LINUX_VERSION".tar.xz && \
+    cd linux-"$LINUX_VERSION" && \
+    make defconfig && \
+    make xen.config && \
+    cp .config .config.orig && \
+    cat .config.orig | grep XEN | grep =m |sed 's/=m/=y/g' >> .config && \
+    make -j$(nproc) bzImage && \
+    cp arch/x86/boot/bzImage / && \
+    cd /build && \
+    rm -rf linux-"$LINUX_VERSION"*
diff -pruN 4.14.3+32-g9de3671772-1/automation/tests-artifacts/kernel/5.9.9-arm64v8.dockerfile 4.16.1-1/automation/tests-artifacts/kernel/5.9.9-arm64v8.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/tests-artifacts/kernel/5.9.9-arm64v8.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/tests-artifacts/kernel/5.9.9-arm64v8.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,34 @@
+FROM arm64v8/debian:unstable
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV LINUX_VERSION=5.9.9
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN apt-get update && \
+    apt-get --quiet --yes install \
+        build-essential \
+        libssl-dev \
+        bc \
+        curl \
+        flex \
+        bison \
+        && \
+    \
+    # Build the kernel
+    curl -fsSLO https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-"$LINUX_VERSION".tar.xz && \
+    tar xvJf linux-"$LINUX_VERSION".tar.xz && \
+    cd linux-"$LINUX_VERSION" && \
+    make defconfig && \
+    make -j$(nproc) Image.gz && \
+    cp arch/arm64/boot/Image / && \
+    cd /build && \
+    rm -rf linux-"$LINUX_VERSION"* && \
+    apt-get autoremove -y && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
diff -pruN 4.14.3+32-g9de3671772-1/automation/tests-artifacts/Makefile 4.16.1-1/automation/tests-artifacts/Makefile
--- 4.14.3+32-g9de3671772-1/automation/tests-artifacts/Makefile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/tests-artifacts/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,19 @@
+
+# the base of where these containers will appear
+REGISTRY := registry.gitlab.com/xen-project/xen/tests-artifacts
+CONTAINERS = $(subst .dockerfile,,$(wildcard */*.dockerfile))
+
+help:
+	@echo "Containers to build and export tests artifacts."
+	@echo "To build one run 'make ARTIFACT/VERSION'. Available containers:"
+	@$(foreach file,$(sort $(CONTAINERS)),echo ${file};)
+	@echo "To push container builds, set the env var PUSH"
+
+%: %.dockerfile ## Builds containers
+	docker build -t $(REGISTRY)/$(@D):$(@F) -f $< $(<D)
+	@if [ ! -z $${PUSH+x} ]; then \
+		docker push $(REGISTRY)/$(@D):$(@F); \
+	fi
+
+.PHONY: all
+all: $(CONTAINERS)
diff -pruN 4.14.3+32-g9de3671772-1/automation/tests-artifacts/qemu-system-aarch64/5.2.0-arm64v8.dockerfile 4.16.1-1/automation/tests-artifacts/qemu-system-aarch64/5.2.0-arm64v8.dockerfile
--- 4.14.3+32-g9de3671772-1/automation/tests-artifacts/qemu-system-aarch64/5.2.0-arm64v8.dockerfile	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/automation/tests-artifacts/qemu-system-aarch64/5.2.0-arm64v8.dockerfile	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,75 @@
+FROM arm64v8/debian:unstable
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="xen-devel@lists.xenproject.org"
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV QEMU_VERSION=5.2.0
+ENV USER root
+
+RUN mkdir /build
+WORKDIR /build
+
+# build depends
+RUN apt-get update && \
+    apt-get --quiet --yes install \
+        build-essential \
+        curl \
+        python3 \
+        ninja-build \
+        pkg-config \
+        libglib2.0-dev \
+        libpixman-1-dev \
+        && \
+    \
+    curl -fsSLO https://download.qemu.org/qemu-"$QEMU_VERSION".tar.xz && \
+    tar xvJf qemu-"$QEMU_VERSION".tar.xz && \
+    cd qemu-"$QEMU_VERSION" && \
+    ./configure                \
+        --target-list=aarch64-softmmu \
+        --enable-system        \
+        --disable-blobs        \
+        --disable-bsd-user     \
+        --disable-debug-info   \
+        --disable-glusterfs    \
+        --disable-gtk          \
+        --disable-guest-agent  \
+        --disable-linux-user   \
+        --disable-sdl          \
+        --disable-spice        \
+        --disable-tpm          \
+        --disable-vhost-net    \
+        --disable-vhost-scsi   \
+        --disable-vhost-user   \
+        --disable-vhost-vsock  \
+        --disable-virtfs       \
+        --disable-vnc          \
+        --disable-werror       \
+        --disable-xen          \
+        --disable-safe-stack   \
+        --disable-libssh       \
+        --disable-opengl       \
+        --disable-tools        \
+        --disable-virglrenderer  \
+        --disable-stack-protector  \
+        --disable-containers   \
+        --disable-replication  \
+        --disable-cloop        \
+        --disable-dmg          \
+        --disable-vvfat        \
+        --disable-vdi          \
+        --disable-parallels    \
+        --disable-qed          \
+        --disable-bochs        \
+        --disable-qom-cast-debug  \
+        --disable-vhost-vdpa   \
+        --disable-vhost-kernel \
+        --disable-qcow1        \
+        --disable-live-block-migration \
+    && \
+    make -j$(nproc) && \
+    cp ./build/qemu-system-aarch64 / && \
+    cd /build && \
+    rm -rf qemu-"$QEMU_VERSION"* && \
+    apt-get autoremove -y && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
diff -pruN 4.14.3+32-g9de3671772-1/CHANGELOG.md 4.16.1-1/CHANGELOG.md
--- 4.14.3+32-g9de3671772-1/CHANGELOG.md	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/CHANGELOG.md	2022-04-12 12:21:23.000000000 +0000
@@ -4,7 +4,84 @@ Notable changes to Xen will be documente
 
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 
-## [Unreleased](https://xenbits.xen.org/gitweb/?p=xen.git;a=shortlog)
+## [4.16.0](https://xenbits.xen.org/gitweb/?p=xen.git;a=shortlog;h=staging) - 2021-12-02
+
+### Removed
+ - XENSTORED_ROOTDIR environment variable from configuartion files and
+   initscripts, due to being unused.
+
+### Changed
+ - Quarantining of passed-through PCI devices no longer defaults to directing I/O to a scratch
+   page, matching original post-XSA-302 behavior (albeit the change was also backported, first
+   appearing in 4.12.2 and 4.11.4). Prior (4.13...4.15-like) behavior can be arranged for
+   either by enabling the IOMMU_QUARANTINE_SCRATCH_PAGE setting at build (configuration) time
+   or by passing "iommu=quarantine=scratch-page" on the hypervisor command line.
+ - pv-grub stubdoms will no longer be built per default. In order to be able to use pv-grub
+   configure needs to be called with "--enable-pv-grub" as parameter.
+ - qemu-traditional based device models (both, qemu-traditional and ioemu-stubdom) will
+   no longer be built per default. In order to be able to use those, configure needs to
+   be called with "--enable-qemu-traditional" as parameter.
+ - Fixes for credit2 scheduler stability in corner case conditions.
+ - Ongoing improvements in the hypervisor build system.
+ - vtpmmgr miscellaneous fixes in preparation for TPM 2.0 support.
+ - 32bit PV guests only supported in shim mode.
+ - Improved PVH dom0 debug key handling.
+ - Fix booting on some Intel systems without a PIT (i8254).
+ - Cleanup of the xenstore library interface.
+ - Fix truncation of return value from xencall2 by introducing a new helper
+   that returns a long instead.
+ - Fix system register accesses on Arm to use the proper 32/64bit access size.
+ - Various fixes for Arm OP-TEE mediator.
+ - Switch to domheap for Xen page tables.
+
+### Added
+ - 32bit Arm builds to the gitlab-ci automated tests.
+ - x86 full system tests to the gitlab-ci automated tests.
+ - Arm limited vPMU support for guests.
+ - Static physical memory allocation for dom0less on arm64.
+ - dom0less EFI support on arm64.
+ - GICD_ICPENDR register handling in vGIC emulation to support Zephyr OS.
+ - CPU feature leveling on arm64 platform with heterogeneous cores.
+ - Report unpopulated memory regions safe to use for external mappings, Arm and
+   device tree only.
+ - Support of generic DT IOMMU bindings for Arm SMMU v2.
+ - Limit grant table version on a per-domain basis.
+
+## [4.15.0](https://xenbits.xen.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.15.0) - 2021-04-08
+
+### Added / support upgraded
+ - ARM IOREQ servers (device emulation etc.) (Tech Preview)
+ - Renesas IPMMU-VMSA (Supported, not security supported; was Tech Preview)
+ - ARM SMMUv3 (Tech Preview)
+ - Switched MSR accesses to deny by default policy.
+ - Intel Processor Trace support (Tech Preview)
+ - Named PCI devices for xl/libxl
+ - Improved documentation for xl PCI configuration format
+ - Support for zstd-compressed dom0 (x86) and domU kernels
+ - EFI: Enable booting unified hypervisor/kernel/initrd/DT images
+ - Reduce ACPI verbosity by default
+ - Add ucode=allow-same option to test late microcode loading path
+ - Library improvements from NetBSD ports upstreamed
+ - CI loop: Add Alpine Linux, Ubuntu Focal targets; drop CentOS 6
+ - CI loop: Add qemu-based dom0 / domU test for ARM
+ - CI loop: Add dom0less aarch64 smoke test
+ - x86: Allow domains to use AVX-VNNI instructions
+ - Factored out HVM-specific shadow code, improving code clarity and reducing the size of PV-only hypervisor builds
+ - Added XEN_SCRIPT_DIR configuration option to specify location for Xen scripts, rather than hard-coding /etc/xen/scripts
+ - xennet: Documented a way for the backend (or toolstack) to specify MTU to the frontend
+ - xenstore can now be live-updated on a running system. (Tech preview)
+ - Some additional affordances in various xl subcommands.
+ - Added workarounds for the following ARM errata: Cortex A53 #843419, Cortex A55 #1530923, Cortex A72 #853709, Cortex A73 #858921, Cortex A76 #1286807, Neoverse-N1 #1165522
+ - On detecting a host crash, some debug key handlers can automatically triggered to aid in debugging
+ - Increase the maximum number of guests which can share a single IRQ from 7 to 16, and make this configurable with irq-max-guests
+
+### Removed / support downgraded
+
+ - qemu-xen-traditional as host process device model, now "No security
+   support, not recommended".  (Use as stub domain device model is still
+   supported - see SUPPORT.md.)
+
+## [4.14.0](https://xenbits.xen.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.14.0) - 2020-07-23
 
 ### Added
  - This file and MAINTAINERS entry.
diff -pruN 4.14.3+32-g9de3671772-1/.cirrus.yml 4.16.1-1/.cirrus.yml
--- 4.14.3+32-g9de3671772-1/.cirrus.yml	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/.cirrus.yml	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,26 @@
+# https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
+freebsd_template: &FREEBSD_TEMPLATE
+  environment:
+    APPEND_LIB: /usr/local/lib
+    APPEND_INCLUDES: /usr/local/include
+
+  install_script: pkg install -y seabios gmake ninja bash
+                                 pkgconf python libiconv bison perl5
+                                 yajl lzo2 pixman argp-standalone
+                                 libxml2 glib git
+
+  build_script:
+    - ./configure --with-system-seabios=/usr/local/share/seabios/bios.bin
+    - gmake -j`sysctl -n hw.ncpu` clang=y
+
+task:
+  name: 'FreeBSD 12'
+  freebsd_instance:
+    image_family: freebsd-12-2
+  << : *FREEBSD_TEMPLATE
+
+task:
+  name: 'FreeBSD 13'
+  freebsd_instance:
+    image_family: freebsd-13-0
+  << : *FREEBSD_TEMPLATE
diff -pruN 4.14.3+32-g9de3671772-1/config/riscv64.mk 4.16.1-1/config/riscv64.mk
--- 4.14.3+32-g9de3671772-1/config/riscv64.mk	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/config/riscv64.mk	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,5 @@
+CONFIG_RISCV := y
+CONFIG_RISCV_64 := y
+CONFIG_RISCV_$(XEN_OS) := y
+
+CONFIG_XEN_INSTALL_SUFFIX :=
diff -pruN 4.14.3+32-g9de3671772-1/config/Tools.mk.in 4.16.1-1/config/Tools.mk.in
--- 4.14.3+32-g9de3671772-1/config/Tools.mk.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/config/Tools.mk.in	2022-04-12 12:21:23.000000000 +0000
@@ -12,14 +12,13 @@ PYTHON              := @PYTHON@
 PYTHON_PATH         := @PYTHONPATH@
 PY_NOOPT_CFLAGS     := @PY_NOOPT_CFLAGS@
 PERL                := @PERL@
-BASH                := @BASH@
-XGETTTEXT           := @XGETTEXT@
 AS86                := @AS86@
 LD86                := @LD86@
 BCC                 := @BCC@
 IASL                := @IASL@
 AWK                 := @AWK@
 FETCHER             := @FETCHER@
+ABI_DUMPER          := @ABI_DUMPER@
 
 # Extra folder for libs/includes
 PREPEND_INCLUDES    := @PREPEND_INCLUDES@
diff -pruN 4.14.3+32-g9de3671772-1/Config.mk 4.16.1-1/Config.mk
--- 4.14.3+32-g9de3671772-1/Config.mk	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/Config.mk	2022-04-12 12:21:23.000000000 +0000
@@ -63,7 +63,7 @@ DEPS_INCLUDE = $(addsuffix .d2, $(basena
 DEPS_RM = $(DEPS) $(DEPS_INCLUDE)
 
 %.d2: %.d
-	sed "s! $$PWD/! !" $^ >$@.tmp && mv -f $@.tmp $@
+	sed "s!\(^\| \)$$PWD/! !" $^ >$@.tmp && mv -f $@.tmp $@
 
 include $(XEN_ROOT)/config/$(XEN_OS).mk
 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
@@ -91,7 +91,7 @@ PYTHON_PREFIX_ARG ?= --prefix="$(prefix)
 #
 # Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
 cc-option = $(shell if test -z "`echo 'void*p=1;' | \
-              $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) -`"; \
+              $(1) $(2) -c -o /dev/null -x c - 2>&1 | grep -- $(2:-Wa$(comma)%=%) -`"; \
               then echo "$(2)"; else echo "$(3)"; fi ;)
 
 # cc-option-add: Add an option to compilation flags, but only if supported.
@@ -137,12 +137,6 @@ export XEN_HAS_BUILD_ID=y
 build_id_linker := --build-id=sha1
 endif
 
-ifndef XEN_HAS_CHECKPOLICY
-    CHECKPOLICY ?= checkpolicy
-    XEN_HAS_CHECKPOLICY := $(shell $(CHECKPOLICY) -h 2>&1 | grep -q xen && echo y || echo n)
-    export XEN_HAS_CHECKPOLICY
-endif
-
 define buildmakevars2shellvars
     export PREFIX="$(prefix)";                                            \
     export XEN_SCRIPT_DIR="$(XEN_SCRIPT_DIR)";                            \
@@ -205,7 +199,6 @@ APPEND_CFLAGS += $(foreach i, $(APPEND_I
 
 EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all
 EMBEDDED_EXTRA_CFLAGS += -fno-exceptions -fno-asynchronous-unwind-tables
-EMBEDDED_EXTRA_CFLAGS += -fcf-protection=none
 
 XEN_EXTFILES_URL ?= http://xenbits.xen.org/xen-extfiles
 # All the files at that location were downloaded from elsewhere on
@@ -244,16 +237,16 @@ QEMU_TRADITIONAL_URL ?= git://xenbits.xe
 SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
 MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git
 endif
-OVMF_UPSTREAM_REVISION ?= 20d2e5a125e34fc8501026613a71549b2a1a3e54
-QEMU_UPSTREAM_REVISION ?= qemu-xen-4.14.3
-MINIOS_UPSTREAM_REVISION ?= xen-RELEASE-4.14.3
+OVMF_UPSTREAM_REVISION ?= 7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5
+QEMU_UPSTREAM_REVISION ?= qemu-xen-4.16.1
+MINIOS_UPSTREAM_REVISION ?= xen-RELEASE-4.16.1
 
-SEABIOS_UPSTREAM_REVISION ?= rel-1.13.0
+SEABIOS_UPSTREAM_REVISION ?= rel-1.14.0
 
 ETHERBOOT_NICS ?= rtl8139 8086100e
 
 
-QEMU_TRADITIONAL_REVISION ?= xen-4.14.3
+QEMU_TRADITIONAL_REVISION ?= xen-4.16.1
 
 # Specify which qemu-dm to use. This may be `ioemu' to use the old
 # Mercurial in-tree version, or a local directory, or a git URL.
diff -pruN 4.14.3+32-g9de3671772-1/configure 4.16.1-1/configure
--- 4.14.3+32-g9de3671772-1/configure	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/configure	2022-04-12 12:21:23.000000000 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Xen Hypervisor 4.14.
+# Generated by GNU Autoconf 2.69 for Xen Hypervisor 4.16.
 #
 # Report bugs to <xen-devel@lists.xen.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Xen Hypervisor'
 PACKAGE_TARNAME='xen'
-PACKAGE_VERSION='4.14'
-PACKAGE_STRING='Xen Hypervisor 4.14'
+PACKAGE_VERSION='4.16'
+PACKAGE_STRING='Xen Hypervisor 4.16'
 PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 PACKAGE_URL='https://www.xen.org/'
 
@@ -599,10 +599,7 @@ DEBUG_DIR
 XEN_DUMP_DIR
 XEN_PAGING_DIR
 XEN_LOCK_DIR
-XEN_SCRIPT_DIR
-XEN_CONFIG_DIR
 INITD_DIR
-CONFIG_DIR
 SHAREDIR
 XEN_LIB_DIR
 XEN_RUN_STORED
@@ -614,7 +611,10 @@ LIBEXEC_INC
 LIBEXEC_LIB
 LIBEXEC_BIN
 LIBEXEC
+XEN_SCRIPT_DIR
 CONFIG_LEAF_DIR
+XEN_CONFIG_DIR
+CONFIG_DIR
 XENSTORED_PORT
 XENSTORED_KVA
 host_os
@@ -670,6 +670,7 @@ enable_option_checking
 with_initddir
 with_sysconfig_leaf_dir
 with_libexec_leaf_dir
+with_xen_scriptdir
 with_xen_dumpdir
 with_rundir
 with_debugdir
@@ -1235,7 +1236,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Xen Hypervisor 4.14 to adapt to many kinds of systems.
+\`configure' configures Xen Hypervisor 4.16 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1301,7 +1302,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Xen Hypervisor 4.14:";;
+     short | recursive ) echo "Configuration of Xen Hypervisor 4.16:";;
    esac
   cat <<\_ACEOF
 
@@ -1328,6 +1329,9 @@ Optional Packages:
                           "default". [sysconfig]
   --with-libexec-leaf-dir=SUBDIR
                           Name of subdirectory in libexecdir to use.
+  --with-xen-scriptdir=DIR
+                          Path to directory for dom0 hotplug scripts.
+                          [SYSCONFDIR/xen/scripts]
   --with-xen-dumpdir=DIR  Path to directory for domU crash dumps.
                           [LOCALSTATEDIR/lib/xen/dump]
   --with-rundir=DIR       Path to directory for runtime data.
@@ -1399,7 +1403,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Xen Hypervisor configure 4.14
+Xen Hypervisor configure 4.16
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1416,7 +1420,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Xen Hypervisor $as_me 4.14, which was
+It was created by Xen Hypervisor $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -1936,6 +1940,12 @@ if test "x$sysconfdir" = 'x${prefix}/etc
     esac
 fi
 
+CONFIG_DIR=$sysconfdir
+
+
+XEN_CONFIG_DIR=$CONFIG_DIR/xen
+
+
 
 # Check whether --with-initddir was given.
 if test "${with_initddir+set}" = set; then :
@@ -1978,6 +1988,17 @@ fi
 
 
 
+# Check whether --with-xen-scriptdir was given.
+if test "${with_xen_scriptdir+set}" = set; then :
+  withval=$with_xen_scriptdir; xen_scriptdir_path=$withval
+else
+  xen_scriptdir_path=$XEN_CONFIG_DIR/scripts
+fi
+
+XEN_SCRIPT_DIR=$xen_scriptdir_path
+
+
+
 # Check whether --with-xen-dumpdir was given.
 if test "${with_xen_dumpdir+set}" = set; then :
   withval=$with_xen_dumpdir; xen_dumpdir_path=$withval
@@ -2042,21 +2063,12 @@ XEN_LIB_DIR=$localstatedir/lib/xen
 SHAREDIR=$prefix/share
 
 
-CONFIG_DIR=$sysconfdir
-
-
 INITD_DIR=$initddir_path
 
 
-XEN_CONFIG_DIR=$CONFIG_DIR/xen
-
-
-XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
-
-
 case "$host_os" in
 *freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
-*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 *) XEN_LOCK_DIR=$localstatedir/lock ;;
 esac
 
@@ -2856,7 +2868,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Xen Hypervisor $as_me 4.14, which was
+This file was extended by Xen Hypervisor $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -2910,7 +2922,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Xen Hypervisor config.status 4.14
+Xen Hypervisor config.status 4.16
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -pruN 4.14.3+32-g9de3671772-1/debian/changelog 4.16.1-1/debian/changelog
--- 4.14.3+32-g9de3671772-1/debian/changelog	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/changelog	2022-05-09 20:29:23.000000000 +0000
@@ -1,3 +1,127 @@
+xen (4.16.1-1) unstable; urgency=medium
+
+  * Update to new upstream version 4.16.1, which also contains security fixes
+    for the following issues:
+    - Racy interactions between dirty vram tracking and paging log dirty
+      hypercalls
+      XSA-397 CVE-2022-26356
+    - Multiple speculative security issues
+      XSA-398 (no CVE yet)
+    - race in VT-d domain ID cleanup
+      XSA-399 CVE-2022-26357
+    - IOMMU: RMRR (VT-d) and unity map (AMD-Vi) handling issues
+      XSA-400 CVE-2022-26358 CVE-2022-26359 CVE-2022-26360 CVE-2022-26361
+  * Note that the following XSA are not listed, because...
+    - XSA-396 has patches for the Linux kernel.
+  * Don't ship NEWS in libxen* packages. Instead, only ship relevant NEWS
+    items for actual hypervisor and/or utils packages they belong to.
+    (Closes: #962267)
+  * d/control: make xen-hypervisor-common arch specific, just like
+    xen-utils-common.
+  * d/control: stop recommending qemu-system-x86 on arm, because qemu is not
+    being built with xen support on arm...
+  * Add a patch for tools/libs/light/Makefile which prevents build.o and
+    build.opic to be rebuilt unneededly during the package install phase,
+    causing a FTBFS because it triggers the use of ccache, which is not
+    allowed in the install phase of building the Debian packages.
+
+  Improvements related to Qemu integration:  [Michael Tokarev]
+  * d/xen-utils-common.xen.init: properly disable qemu monitor/serial/parallel
+    devices for qemu started at boot.
+  * debian: switch from recommending qemu-system-x86 to qemu-system-xen and
+    mention this change in the NEWS file.
+  * Add patch "give meaningful error message if qemu device model is
+    unavailable" to give a useful error message only in case the domU needs
+    the qemu device model which is not installed, instead of giving a warning
+    about missing qemu even if it is not used by this domain.
+
+  Documentation, grammar and spelling fixes and improvements:
+  * d/control: drop obsolete paragraph about separate xen linux kernel package
+  * d/control: Harmonize the capitalization of the 'Xen' word  [Diederik de Haas]
+  * d/control: Improve spelling and grammar  [Diederik de Haas]`
+
+ -- Hans van Kranenburg <hans@knorrie.org>  Mon, 09 May 2022 22:29:23 +0200
+
+xen (4.16.0+51-g0941d6cb-1) unstable; urgency=medium
+
+  * Update to new upstream version 4.16.0+51-g0941d6cb, which also contains
+    security fixes for the following issues:
+    - arm: guest_physmap_remove_page not removing the p2m mappings
+      XSA-393 CVE-2022-23033
+    - A PV guest could DoS Xen while unmapping a grant
+      XSA-394 CVE-2022-23034
+    - Insufficient cleanup of passed-through device IRQs
+      XSA-395 CVE-2022-23035
+  * Note that the following XSA are not listed, because...
+    - XSA-391 and XSA-392 have patches for the Linux kernel.
+  * Upload to unstable now, which obsoletes the Xen 4.14 FTBFS issue.
+    (Closes: #1002658)
+
+ -- Hans van Kranenburg <hans@knorrie.org>  Sat, 19 Feb 2022 20:29:32 +0100
+
+xen (4.16.0-1~exp1) experimental; urgency=medium
+
+  Significant changes:
+  * Update to new upstream version 4.16.0. This also includes a security fix
+    for the following issue, which was not applicable to Xen 4.14 yet:
+    - certain VT-d IOMMUs may not work in shared page table mode
+      XSA-390 CVE-2021-28710
+  * No longer build any package for the i386 architecture. It was already not
+    possible to use x86_32 hardware because the i386 packages already
+    shipped a 64-bit hypervisor and PV shim. Running 32-bit utils with a
+    64-bit hypervisor requires using a compatibility layer that is fragile and
+    becomes harder to maintain and test upstream. This change ends the 'grace
+    period' in which users should have moved to using a fully 64-bit dom0.
+    - debian/{control,rules,salsa-ci.yml,xen-utils-V.install.vsn-in}: make the
+      necessary changes
+    - Remove the Recommends on libc6-xen, which already actually does not
+      exist any more. (Closes: #992909)
+    - Drop patch "tools/tests/x86_emulator: Pass -no-pie -fno-pic to gcc on
+      x86_32" because it is not relevant any more.
+
+  Changes related to upgrading to Xen 4.16:
+  * debian/control: adjust to 4.16  [Maximilian Engelhardt]
+  * Drop patches that have been applied upstream
+  * Refresh remaining patches if needed
+  * debian: follow upstream removal of '.sh' suffix in xl bash_completion file
+    [Maximilian Engelhardt]
+  * debian/control, debian/libxenstore*: ship a libxenstore4 package instead
+    of libxenstore3.0, since upstream bumped the soname
+    [Maximilian Engelhardt]
+
+  Packaging minor fixes and improvements  [Maximilian Engelhardt]:
+  * debian/rules: set SOURCE_BASE_DIR to the top level build dir so that the
+    "Display Debian package version in hypervisor log" patch can use it.
+  * Add patch "xen/arch/x86: make objdump output user locale agnostic" to fix
+    reproducable builds. This patch will also be sent upstream.
+  * d/rules: remove reproducible=+fixfilepath from DEB_BUILD_MAINT_OPTIONS
+  * d/salsa-ci.yml: Explicitly set RELEASE variable to unstable
+  * d/salsa-ci.yml: disable cross building as it's currently not working
+  * debian: call update-grub when installing/removing xen-hypervisor-common
+    (Closes: #988901)
+  * debian: fix dependency generation for python after dh-python was fixed
+    first. (Closes: #976597)
+  * debian/rules: remove unused pybuild settings
+
+  Packaging minor fixes and improvements:
+  * Improve patches for building the PV shim separately. This enables to
+    drop the extra Revert of an upstream commit that was done in
+    4.14.0+80-gd101b417b7-1~exp1:
+    - Drop patch: Revert "pvshim: make PV shim build selectable from
+      configure"
+    - Update patch "[...] Respect caller's CONFIG_PV_SHIM" to follow moving
+      of a line to a different file
+    - Drop patch: "tools/firmware/Makefile: CONFIG_PV_SHIM: enable only on
+      x86_64" because that's now already the default upstream
+  * debian/control.md5sum: remove this obsolete file
+  * Merge patches "vif-common: disable handle_iptable" and
+    "t/h/L/vif-common.sh: fix handle_iptable return value" into a single
+    patch, since the latter was a fix for the first.
+  * debian/control: change the Uploaders email address for Ian Jackson,
+    since he does not work at Citrix any more now
+
+ -- Hans van Kranenburg <hans@knorrie.org>  Mon, 17 Jan 2022 18:36:02 +0100
+
 xen (4.14.3+32-g9de3671772-1) unstable; urgency=medium
 
   * Update to new upstream version 4.14.3+32-g9de3671772, which also contains
diff -pruN 4.14.3+32-g9de3671772-1/debian/control 4.16.1-1/debian/control
--- 4.14.3+32-g9de3671772-1/debian/control	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/control	2022-05-09 20:29:23.000000000 +0000
@@ -1,7 +1,7 @@
 Source: xen
 Priority: optional
 Maintainer: Debian Xen Team <pkg-xen-devel@lists.alioth.debian.org>
-Uploaders: Ian Jackson <ian.jackson@eu.citrix.com>, Hans van Kranenburg <hans@knorrie.org>
+Uploaders: Ian Jackson <iwj@xenproject.org>, Hans van Kranenburg <hans@knorrie.org>
 Section: admin
 Standards-Version: 4.5.0
 Build-Depends:
@@ -15,11 +15,11 @@ Build-Depends:
    python3-dev:any,
    libpython3-dev,
    dh-python,
-   bcc [i386 amd64],
-   gcc-multilib [i386 amd64],
+   bcc [amd64],
+   gcc-multilib [amd64],
    e2fslibs-dev,
    iasl,
-   seabios (>= 1.7.4-2~) [i386 amd64],
+   seabios (>= 1.7.4-2~) [amd64],
    libaio-dev,
    libfdt-dev [armhf arm64],
    libglib2.0-dev,
@@ -39,7 +39,7 @@ Vcs-Browser: https://salsa.debian.org/xe
 Vcs-Git: https://salsa.debian.org/xen-team/debian-xen.git
 
 Package: xenstore-utils
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Section: admin
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Replaces: xen-utils-common (<= 4.11.1~pre+1.733450b39b-1~)
@@ -60,7 +60,7 @@ Description: Xenstore command line utili
 
 Package: xen-utils-common
 Section: admin
-Architecture: amd64 i386 armhf arm64
+Architecture: amd64 armhf arm64
 Depends: lsb-base, udev, xenstore-utils,
     ${shlibs:Depends}, ${python3:Depends}, ${misc:Depends}
 Suggests: xen-doc
@@ -73,7 +73,7 @@ Description: Xen administrative tools -
 
 Package: xen-hypervisor-common
 Section: kernel
-Architecture: all
+Architecture: amd64 armhf arm64
 Depends: ${misc:Depends}
 Replaces: xen-hypervisor-4.8-amd64, xen-hypervisor-4.8-arm64, xen-hypervisor-4.8-armhf
 Description: Xen Hypervisor - common files
@@ -86,9 +86,9 @@ Description: Xen Hypervisor - common fil
 
 Package: xen-doc
 Section: doc
-Architecture: amd64 i386 armhf arm64
+Architecture: amd64 armhf arm64
 Depends: ${misc:Depends}
-Description: XEN documentation
+Description: Xen documentation
  Documentation for the Xen hypervisor and surrounding software,
  including descriptions of the hypercall interfaces and of some
  of the library APIs.
@@ -97,103 +97,91 @@ Description: XEN documentation
  Xen control utilities, as those are in the xen-utils-common package.
 # Yes, arch-specific.  See xen-doc.lintian-overrides.
 
-Package: xen-utils-4.14
+Package: xen-utils-4.16
 Section: admin
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Provides: xen-utils
-Depends: ${shlibs:Depends}, ${misc:Depends}, python3, xen-utils-common (>= ${source:Version})
-Recommends: bridge-utils, libc6-xen [i386], xen-hypervisor-4.14, qemu-system-x86, grub-xen-host [i386 amd64]
-Suggests: qemu-utils [i386 amd64], seabios [i386 amd64], ovmf
-Description: XEN administrative tools
- The userspace tools to manage a system virtualized through the XEN virtual
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, xen-utils-common (>= ${source:Version})
+Recommends: bridge-utils, xen-hypervisor-4.16, qemu-system-xen (>> 1:7.0+dfsg-6~) [amd64], grub-xen-host [amd64]
+Suggests: qemu-utils [amd64], seabios [amd64], ovmf
+Description: Xen administrative tools
+ The userspace tools to manage a system virtualized through the Xen virtual
  machine monitor.
  .
- qemu-utils and seabios are neded for "Xen HVM" (amd64 and i386)
+ qemu-utils and seabios are needed for "Xen HVM" (amd64)
 Built-Using: ${misc:Built-Using}
 
-Package: xen-hypervisor-4.14-amd64
+Package: xen-hypervisor-4.16-amd64
 Section: kernel
-Architecture: amd64 i386
-Provides: xen-hypervisor, xen-hypervisor-4.14, xen-hypervisor-amd64
+Architecture: amd64
+Provides: xen-hypervisor, xen-hypervisor-4.16, xen-hypervisor-amd64
 Depends: ${misc:Depends}
-Recommends: xen-utils-4.14, xen-hypervisor-common
+Recommends: xen-utils-4.16, xen-hypervisor-common
 Description: Xen Hypervisor on AMD64
- The hypervisor is the "core" for XEN itself.  It gets booted by the boot
+ The hypervisor is the "core" for Xen itself.  It gets started by the boot
  loader and controls cpu and memory, sharing them between your
  administrative domain (Domain 0) and the virtual guest systems.
- .
- In order to boot a XEN system along with this package you also need a
- kernel specifically crafted to work as the Domain 0, mediating hardware
- access for XEN itself.
 
 Package: xen-system-amd64
 Section: admin
-Architecture: amd64 i386
+Architecture: amd64
 Provides: xen-system
-Depends: xen-hypervisor-4.14-amd64, xen-hypervisor-common, xen-utils-4.14, ${misc:Depends}
+Depends: xen-hypervisor-4.16-amd64, xen-hypervisor-common, xen-utils-4.16, ${misc:Depends}
 Description: Xen System on AMD64 (metapackage)
  This package depends on the latest Xen hypervisor for use on AMD64 and the
  Xen utils.
 
-Package: xen-hypervisor-4.14-arm64
+Package: xen-hypervisor-4.16-arm64
 Section: kernel
 Architecture: arm64
-Provides: xen-hypervisor, xen-hypervisor-4.14, xen-hypervisor-arm64
+Provides: xen-hypervisor, xen-hypervisor-4.16, xen-hypervisor-arm64
 Depends: ${misc:Depends}
-Recommends: xen-utils-4.14, xen-hypervisor-common
+Recommends: xen-utils-4.16, xen-hypervisor-common
 Description: Xen Hypervisor on ARM64
- The hypervisor is the "core" for XEN itself.  It gets booted by the boot
+ The hypervisor is the "core" for Xen itself.  It gets started by the boot
  loader and controls cpu and memory, sharing them between your
  administrative domain (Domain 0) and the virtual guest systems.
- .
- In order to boot a XEN system along with this package you also need a
- kernel specifically crafted to work as the Domain 0, mediating hardware
- access for XEN itself.
 
 Package: xen-system-arm64
 Section: admin
 Architecture: arm64
 Provides: xen-system
-Depends: xen-hypervisor-4.14-arm64, xen-hypervisor-common, xen-utils-4.14, ${misc:Depends}
+Depends: xen-hypervisor-4.16-arm64, xen-hypervisor-common, xen-utils-4.16, ${misc:Depends}
 Description: Xen System on ARM64 (metapackage)
  This package depends on the latest Xen hypervisor for use on ARM64 and the
  Xen utils.
 
-Package: xen-hypervisor-4.14-armhf
+Package: xen-hypervisor-4.16-armhf
 Section: kernel
 Architecture: armhf
-Provides: xen-hypervisor, xen-hypervisor-4.14, xen-hypervisor-armhf
+Provides: xen-hypervisor, xen-hypervisor-4.16, xen-hypervisor-armhf
 Depends: ${misc:Depends}
-Recommends: xen-utils-4.14, xen-hypervisor-common
+Recommends: xen-utils-4.16, xen-hypervisor-common
 Description: Xen Hypervisor on ARMHF
- The hypervisor is the "core" for XEN itself.  It gets booted by the boot
+ The hypervisor is the "core" for Xen itself.  It gets started by the boot
  loader and controls cpu and memory, sharing them between your
  administrative domain (Domain 0) and the virtual guest systems.
- .
- In order to boot a XEN system along with this package you also need a
- kernel specifically crafted to work as the Domain 0, mediating hardware
- access for XEN itself.
 
 Package: xen-system-armhf
 Section: admin
 Architecture: armhf
 Provides: xen-system
-Depends: xen-hypervisor-4.14-armhf, xen-hypervisor-common, xen-utils-4.14, ${misc:Depends}
+Depends: xen-hypervisor-4.16-armhf, xen-hypervisor-common, xen-utils-4.16, ${misc:Depends}
 Description: Xen System on ARMHF (metapackage)
  This package depends on the latest Xen hypervisor for use on ARMHF and the
  Xen utils.
 
 Package: libxen-dev
 Section: libdevel
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends},
-	 libxenmisc4.14 (= ${binary:Version}),
+	 libxenmisc4.16 (= ${binary:Version}),
 	 libxencall1 (= ${binary:Version}),
 	 libxendevicemodel1 (= ${binary:Version}),
 	 libxenevtchn1 (= ${binary:Version}),
 	 libxenforeignmemory1 (= ${binary:Version}),
 	 libxengnttab1 (= ${binary:Version}),
-	 libxenstore3.0 (= ${binary:Version}),
+	 libxenstore4 (= ${binary:Version}),
 	 libxentoolcore1 (= ${binary:Version}),
 	 libxentoollog1 (= ${binary:Version}),
 	 libxenhypfs1 (= ${binary:Version}),
@@ -211,9 +199,9 @@ Description: Public headers and libs for
  Most of the other included libraries are internal, and intended for
  use by the Xen toolstack, rather than directly.
 
-Package: libxenmisc4.14
+Package: libxenmisc4.16
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - miscellaneous, versioned ABI
  Shared libraries for Xen utilities.
@@ -224,7 +212,7 @@ Multi-Arch: same
 
 Package: libxencall1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime library - libxencall
  Shared library for Xen utilities.
@@ -232,7 +220,7 @@ Multi-Arch: same
 
 Package: libxendevicemodel1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxendevicemodel
  Shared library for Xen utilities.
@@ -240,7 +228,7 @@ Multi-Arch: same
 
 Package: libxenevtchn1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxenevtchn
  Shared library for Xen utilities.
@@ -248,7 +236,7 @@ Multi-Arch: same
 
 Package: libxenforeignmemory1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxenforeignmemory
  Shared library for Xen utilities.
@@ -256,15 +244,15 @@ Multi-Arch: same
 
 Package: libxengnttab1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxengnttab
  Shared library for Xen utilities.
 Multi-Arch: same
 
-Package: libxenstore3.0
+Package: libxenstore4
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxenstore
  Shared library for Xen utilities.
@@ -272,7 +260,7 @@ Multi-Arch: same
 
 Package: libxentoolcore1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxentoolcore
  Shared library for Xen utilities.
@@ -280,7 +268,7 @@ Multi-Arch: same
 
 Package: libxentoollog1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime libraries - libxentoollog
  Shared library for Xen utilities.
@@ -288,7 +276,7 @@ Multi-Arch: same
 
 Package: libxenhypfs1
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Xen runtime library - libxenhypfs
  Shared library for Xen utilities.
diff -pruN 4.14.3+32-g9de3671772-1/debian/control.md5sum 4.16.1-1/debian/control.md5sum
--- 4.14.3+32-g9de3671772-1/debian/control.md5sum	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/control.md5sum	1970-01-01 00:00:00.000000000 +0000
@@ -1,17 +0,0 @@
-90846bd8cd1227c290d02071e1f3b141  debian/changelog
-dc7b5d9f0538e3180af4e9aff9b0bd57  debian/bin/gencontrol.py
-9e089bdfb9c848da38da7f50e37a5502  debian/templates/control.main.in
-a15fa64ce6deead28d33c1581b14dba7  debian/templates/xen-hypervisor.postinst.in
-28356e01cce3f5f226bacec4c49a7f1e  debian/templates/control.system.latest.in
-03f63e67cf2d915bfbb535f8c9d9e2e4  debian/templates/xen-utils.postinst.in
-63ad8a975156f7bf2327f0e1dc7fc9e2  debian/templates/control.source.in
-22492e0565a4754b5e008ca7cac871da  debian/templates/xen-hypervisor.postrm.in
-02ec00ee85d07ab4eb277a91df014e0c  debian/templates/control.hypervisor.in
-4974334083116945da78ec656b4371f5  debian/templates/control.utils.in
-dcabf82578122540e0534f72750698d5  debian/templates/xen-utils.lintian-overrides.in
-b6acd21c3924e6ec6f9c547afbbc7d9e  debian/templates/xen-utils.prerm.in
-9851cdcecfae45a8c4f95ef676e26973  debian/arch/defines
-bda767ffd62b57de88b50731794f1374  debian/arch/i386/defines
-06efb201e83233c4607b13c8dad5c031  debian/arch/armhf/defines
-afd11afd204a8929340d194894572353  debian/arch/amd64/defines
-b6a35272efc8545fafab547e1cf492cb  debian/arch/arm64/defines
diff -pruN 4.14.3+32-g9de3671772-1/debian/libxenstore3.0.install 4.16.1-1/debian/libxenstore3.0.install
--- 4.14.3+32-g9de3671772-1/debian/libxenstore3.0.install	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/libxenstore3.0.install	1970-01-01 00:00:00.000000000 +0000
@@ -1 +0,0 @@
-usr/lib/*/libxenstore.so.*
diff -pruN 4.14.3+32-g9de3671772-1/debian/libxenstore3.0.symbols 4.16.1-1/debian/libxenstore3.0.symbols
--- 4.14.3+32-g9de3671772-1/debian/libxenstore3.0.symbols	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/libxenstore3.0.symbols	1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-libxenstore.so.3.0 libxenstore3.0 #MINVER#
- expanding_buffer_ensure@Base 3.2.0
- sanitise_value@Base 3.2.0
- unsanitise_value@Base 3.2.0
- xs_check_watch@Base 4.2~
- xs_close@Base 4.1.0~rc6
- xs_control_command@Base 4.9.0
- xs_count_strings@Base 3.2.0
- xs_daemon_close@Base 3.2.0
- xs_daemon_destroy_postfork@Base 4.0.1~rc4
- xs_daemon_open@Base 3.2.0
- xs_daemon_open_readonly@Base 3.2.0
- xs_daemon_rootdir@Base 3.2.0
- xs_daemon_rundir@Base 3.2.0
- xs_daemon_socket@Base 3.2.0
- xs_daemon_socket_ro@Base 3.2.0
- xs_daemon_tdb@Base 3.2.0
- xs_debug_command@Base 3.2.0
- xs_directory@Base 3.2.0
- xs_domain_dev@Base 3.2.0
- xs_domain_open@Base 3.2.0
- xs_fileno@Base 3.2.0
- xs_get_domain_path@Base 3.2.0
- xs_get_permissions@Base 3.2.0
- xs_introduce_domain@Base 3.2.0
- xs_is_domain_introduced@Base 3.2.0
- xs_mkdir@Base 3.2.0
- xs_open@Base 4.1.0~rc6
- xs_path_is_subpath@Base 4.2~
- xs_perm_to_string@Base 3.2.0
- xs_read@Base 3.2.0
- xs_read_watch@Base 3.2.0
- xs_release_domain@Base 3.2.0
- xs_restrict@Base 4.1.0~rc6
- xs_resume_domain@Base 3.2.0
- xs_rm@Base 3.2.0
- xs_set_permissions@Base 3.2.0
- xs_set_target@Base 3.4.0
- xs_strings_to_perms@Base 3.2.0
- xs_suspend_evtchn_port@Base 3.4.0
- xs_transaction_end@Base 3.2.0
- xs_transaction_start@Base 3.2.0
- xs_unwatch@Base 3.2.0
- xs_watch@Base 3.2.0
- xs_write@Base 3.2.0
- xs_write_all@Base 3.2.0
diff -pruN 4.14.3+32-g9de3671772-1/debian/libxenstore4.install 4.16.1-1/debian/libxenstore4.install
--- 4.14.3+32-g9de3671772-1/debian/libxenstore4.install	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/libxenstore4.install	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1 @@
+usr/lib/*/libxenstore.so.*
diff -pruN 4.14.3+32-g9de3671772-1/debian/libxenstore4.symbols 4.16.1-1/debian/libxenstore4.symbols
--- 4.14.3+32-g9de3671772-1/debian/libxenstore4.symbols	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/libxenstore4.symbols	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,39 @@
+libxenstore.so.4 libxenstore4 #MINVER#
+ VERS_4.0@VERS_4.0 4.16.0
+ xs_check_watch@VERS_4.0 4.16.0
+ xs_close@VERS_4.0 4.16.0
+ xs_control_command@VERS_4.0 4.16.0
+ xs_daemon_close@VERS_4.0 4.16.0
+ xs_daemon_destroy_postfork@VERS_4.0 4.16.0
+ xs_daemon_open@VERS_4.0 4.16.0
+ xs_daemon_open_readonly@VERS_4.0 4.16.0
+ xs_daemon_rundir@VERS_4.0 4.16.0
+ xs_daemon_socket@VERS_4.0 4.16.0
+ xs_daemon_socket_ro@VERS_4.0 4.16.0
+ xs_debug_command@VERS_4.0 4.16.0
+ xs_directory@VERS_4.0 4.16.0
+ xs_domain_open@VERS_4.0 4.16.0
+ xs_fileno@VERS_4.0 4.16.0
+ xs_get_domain_path@VERS_4.0 4.16.0
+ xs_get_permissions@VERS_4.0 4.16.0
+ xs_introduce_domain@VERS_4.0 4.16.0
+ xs_is_domain_introduced@VERS_4.0 4.16.0
+ xs_mkdir@VERS_4.0 4.16.0
+ xs_open@VERS_4.0 4.16.0
+ xs_path_is_subpath@VERS_4.0 4.16.0
+ xs_read@VERS_4.0 4.16.0
+ xs_read_watch@VERS_4.0 4.16.0
+ xs_release_domain@VERS_4.0 4.16.0
+ xs_restrict@VERS_4.0 4.16.0
+ xs_resume_domain@VERS_4.0 4.16.0
+ xs_rm@VERS_4.0 4.16.0
+ xs_set_permissions@VERS_4.0 4.16.0
+ xs_set_target@VERS_4.0 4.16.0
+ xs_strings_to_perms@VERS_4.0 4.16.0
+ xs_suspend_evtchn_port@VERS_4.0 4.16.0
+ xs_transaction_end@VERS_4.0 4.16.0
+ xs_transaction_start@VERS_4.0 4.16.0
+ xs_unwatch@VERS_4.0 4.16.0
+ xs_watch@VERS_4.0 4.16.0
+ xs_write@VERS_4.0 4.16.0
+ xs_write_all@VERS_4.0 4.16.0
diff -pruN 4.14.3+32-g9de3671772-1/debian/NEWS 4.16.1-1/debian/NEWS
--- 4.14.3+32-g9de3671772-1/debian/NEWS	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/NEWS	1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-xen (4.11.4-1) unstable; urgency=medium
-
-    This package version fixes a bug that would call the stop action on the
-    xen init script when removing an obsolete xen-utils-V package for a Xen
-    version V other than the currently running one. This results in stopping
-    the xenconsoled process.
-
-    If you just upgraded from Xen 4.8 (Stretch), this will happen when
-    removing the xen-utils-4.8 package afterwards.
-
-    The resulting situation can safely be repaired by calling the start action
-    on the xen script again manually once to bring back the xenconsoled
-    process. There will be no damage to running domUs.
-
-    If you're upgrading from previous Xen 4.11 packages, no action is needed.
-
-    Having these (or later) Xen 4.11 packages installed means that the bug
-    will not trigger any more when removing xen-utils-4.11 after upgrading to
-    a newer Xen version (e.g. 4.13) in the future.
-
- -- Hans van Kranenburg <hans@knorrie.org>  Tue, 26 May 2020 13:33:17 +0200
-
-xen (4.11.1+92-g6c33308a8d-1) unstable; urgency=high
-
-    This update contains the mitigations for the Microarchitectural Data
-    Sampling speculative side channel attacks. Only Intel based processors are
-    affected.
-
-    Note that these fixes will only have effect when also loading updated cpu
-    microcode with MD_CLEAR functionality. When using the intel-microcode
-    package to include microcode in the dom0 initrd, it has to be loaded by
-    Xen. Please refer to the hypervisor command line documentation about the
-    'ucode=scan' option.
-
-    For the fixes to be fully effective, it is currently also needed to disable
-    hyper-threading, which can be done in BIOS settings, or by using smt=no on
-    the hypervisor command line.
-
-    Additional information is available in the upstream Xen security advisory:
-    https://xenbits.xen.org/xsa/advisory-297.html
-
- -- Hans van Kranenburg <hans@knorrie.org>  Tue, 18 Jun 2019 09:50:19 +0200
diff -pruN 4.14.3+32-g9de3671772-1/debian/not-installed 4.16.1-1/debian/not-installed
--- 4.14.3+32-g9de3671772-1/debian/not-installed	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/not-installed	2022-05-09 20:29:23.000000000 +0000
@@ -13,7 +13,7 @@ etc/init.d/xendomains
 # as installed. See bug #831786. Fool dh_missing by pretending
 # they're not installed at all, for now.
 etc/default/xencommons
-etc/bash_completion.d/xl.sh
+etc/bash_completion.d/xl
 
 # This is all handled by debian/shuffle-boot-files,
 # which dh_missing does not know about.
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0002-Delete-configure-output.patch 4.16.1-1/debian/patches/0002-Delete-configure-output.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0002-Delete-configure-output.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0002-Delete-configure-output.patch	2022-05-09 20:29:23.000000000 +0000
@@ -10,23 +10,23 @@ files again.
 
 Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
 ---
- configure       |  3618 -----------------
- docs/configure  |  3427 -----------------
- tools/configure | 11329 ------------------------------------------------------
- 3 files changed, 18374 deletions(-)
+ configure       |  3630 -----------------
+ docs/configure  |  3442 ----------------
+ tools/configure | 11485 ------------------------------------------------------
+ 3 files changed, 18557 deletions(-)
  delete mode 100755 configure
  delete mode 100755 docs/configure
  delete mode 100755 tools/configure
 
 diff --git a/configure b/configure
 deleted file mode 100755
-index 9da3970..0000000
+index 62f6c2d..0000000
 --- a/configure
 +++ /dev/null
-@@ -1,3618 +0,0 @@
+@@ -1,3630 +0,0 @@
 -#! /bin/sh
 -# Guess values for system-dependent variables and create Makefiles.
--# Generated by GNU Autoconf 2.69 for Xen Hypervisor 4.14.
+-# Generated by GNU Autoconf 2.69 for Xen Hypervisor 4.16.
 -#
 -# Report bugs to <xen-devel@lists.xen.org>.
 -#
@@ -605,8 +605,8 @@ index 9da3970..0000000
 -# Identity of this package.
 -PACKAGE_NAME='Xen Hypervisor'
 -PACKAGE_TARNAME='xen'
--PACKAGE_VERSION='4.14'
--PACKAGE_STRING='Xen Hypervisor 4.14'
+-PACKAGE_VERSION='4.16'
+-PACKAGE_STRING='Xen Hypervisor 4.16'
 -PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 -PACKAGE_URL='https://www.xen.org/'
 -
@@ -625,10 +625,7 @@ index 9da3970..0000000
 -XEN_DUMP_DIR
 -XEN_PAGING_DIR
 -XEN_LOCK_DIR
--XEN_SCRIPT_DIR
--XEN_CONFIG_DIR
 -INITD_DIR
--CONFIG_DIR
 -SHAREDIR
 -XEN_LIB_DIR
 -XEN_RUN_STORED
@@ -640,7 +637,10 @@ index 9da3970..0000000
 -LIBEXEC_LIB
 -LIBEXEC_BIN
 -LIBEXEC
+-XEN_SCRIPT_DIR
 -CONFIG_LEAF_DIR
+-XEN_CONFIG_DIR
+-CONFIG_DIR
 -XENSTORED_PORT
 -XENSTORED_KVA
 -host_os
@@ -696,6 +696,7 @@ index 9da3970..0000000
 -with_initddir
 -with_sysconfig_leaf_dir
 -with_libexec_leaf_dir
+-with_xen_scriptdir
 -with_xen_dumpdir
 -with_rundir
 -with_debugdir
@@ -1261,7 +1262,7 @@ index 9da3970..0000000
 -  # Omit some internal or obsolete options to make the list less imposing.
 -  # This message is too long to be a string in the A/UX 3.1 sh.
 -  cat <<_ACEOF
--\`configure' configures Xen Hypervisor 4.14 to adapt to many kinds of systems.
+-\`configure' configures Xen Hypervisor 4.16 to adapt to many kinds of systems.
 -
 -Usage: $0 [OPTION]... [VAR=VALUE]...
 -
@@ -1327,7 +1328,7 @@ index 9da3970..0000000
 -
 -if test -n "$ac_init_help"; then
 -  case $ac_init_help in
--     short | recursive ) echo "Configuration of Xen Hypervisor 4.14:";;
+-     short | recursive ) echo "Configuration of Xen Hypervisor 4.16:";;
 -   esac
 -  cat <<\_ACEOF
 -
@@ -1354,6 +1355,9 @@ index 9da3970..0000000
 -                          "default". [sysconfig]
 -  --with-libexec-leaf-dir=SUBDIR
 -                          Name of subdirectory in libexecdir to use.
+-  --with-xen-scriptdir=DIR
+-                          Path to directory for dom0 hotplug scripts.
+-                          [SYSCONFDIR/xen/scripts]
 -  --with-xen-dumpdir=DIR  Path to directory for domU crash dumps.
 -                          [LOCALSTATEDIR/lib/xen/dump]
 -  --with-rundir=DIR       Path to directory for runtime data.
@@ -1425,7 +1429,7 @@ index 9da3970..0000000
 -test -n "$ac_init_help" && exit $ac_status
 -if $ac_init_version; then
 -  cat <<\_ACEOF
--Xen Hypervisor configure 4.14
+-Xen Hypervisor configure 4.16
 -generated by GNU Autoconf 2.69
 -
 -Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1442,7 +1446,7 @@ index 9da3970..0000000
 -This file contains any messages produced by compilers while
 -running configure, to aid debugging if configure makes a mistake.
 -
--It was created by Xen Hypervisor $as_me 4.14, which was
+-It was created by Xen Hypervisor $as_me 4.16, which was
 -generated by GNU Autoconf 2.69.  Invocation command line was
 -
 -  $ $0 $@
@@ -1962,6 +1966,12 @@ index 9da3970..0000000
 -    esac
 -fi
 -
+-CONFIG_DIR=$sysconfdir
+-
+-
+-XEN_CONFIG_DIR=$CONFIG_DIR/xen
+-
+-
 -
 -# Check whether --with-initddir was given.
 -if test "${with_initddir+set}" = set; then :
@@ -2004,6 +2014,17 @@ index 9da3970..0000000
 -
 -
 -
+-# Check whether --with-xen-scriptdir was given.
+-if test "${with_xen_scriptdir+set}" = set; then :
+-  withval=$with_xen_scriptdir; xen_scriptdir_path=$withval
+-else
+-  xen_scriptdir_path=$XEN_CONFIG_DIR/scripts
+-fi
+-
+-XEN_SCRIPT_DIR=$xen_scriptdir_path
+-
+-
+-
 -# Check whether --with-xen-dumpdir was given.
 -if test "${with_xen_dumpdir+set}" = set; then :
 -  withval=$with_xen_dumpdir; xen_dumpdir_path=$withval
@@ -2068,21 +2089,12 @@ index 9da3970..0000000
 -SHAREDIR=$prefix/share
 -
 -
--CONFIG_DIR=$sysconfdir
--
--
 -INITD_DIR=$initddir_path
 -
 -
--XEN_CONFIG_DIR=$CONFIG_DIR/xen
--
--
--XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
--
--
 -case "$host_os" in
 -*freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
--*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+-*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 -*) XEN_LOCK_DIR=$localstatedir/lock ;;
 -esac
 -
@@ -2882,7 +2894,7 @@ index 9da3970..0000000
 -# report actual input values of CONFIG_FILES etc. instead of their
 -# values after options handling.
 -ac_log="
--This file was extended by Xen Hypervisor $as_me 4.14, which was
+-This file was extended by Xen Hypervisor $as_me 4.16, which was
 -generated by GNU Autoconf 2.69.  Invocation command line was
 -
 -  CONFIG_FILES    = $CONFIG_FILES
@@ -2936,7 +2948,7 @@ index 9da3970..0000000
 -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 -ac_cs_version="\\
--Xen Hypervisor config.status 4.14
+-Xen Hypervisor config.status 4.16
 -configured by $0, generated by GNU Autoconf 2.69,
 -  with options \\"\$ac_cs_config\\"
 -
@@ -3644,13 +3656,13 @@ index 9da3970..0000000
 -
 diff --git a/docs/configure b/docs/configure
 deleted file mode 100755
-index 9e3ed60..0000000
+index 569bd4c..0000000
 --- a/docs/configure
 +++ /dev/null
-@@ -1,3427 +0,0 @@
+@@ -1,3442 +0,0 @@
 -#! /bin/sh
 -# Guess values for system-dependent variables and create Makefiles.
--# Generated by GNU Autoconf 2.69 for Xen Hypervisor Documentation 4.14.
+-# Generated by GNU Autoconf 2.69 for Xen Hypervisor Documentation 4.16.
 -#
 -# Report bugs to <xen-devel@lists.xen.org>.
 -#
@@ -4229,8 +4241,8 @@ index 9e3ed60..0000000
 -# Identity of this package.
 -PACKAGE_NAME='Xen Hypervisor Documentation'
 -PACKAGE_TARNAME='xen'
--PACKAGE_VERSION='4.14'
--PACKAGE_STRING='Xen Hypervisor Documentation 4.14'
+-PACKAGE_VERSION='4.16'
+-PACKAGE_STRING='Xen Hypervisor Documentation 4.16'
 -PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 -PACKAGE_URL='https://www.xen.org/'
 -
@@ -4247,10 +4259,7 @@ index 9e3ed60..0000000
 -XEN_DUMP_DIR
 -XEN_PAGING_DIR
 -XEN_LOCK_DIR
--XEN_SCRIPT_DIR
--XEN_CONFIG_DIR
 -INITD_DIR
--CONFIG_DIR
 -SHAREDIR
 -XEN_LIB_DIR
 -XEN_RUN_STORED
@@ -4262,7 +4271,10 @@ index 9e3ed60..0000000
 -LIBEXEC_LIB
 -LIBEXEC_BIN
 -LIBEXEC
+-XEN_SCRIPT_DIR
 -CONFIG_LEAF_DIR
+-XEN_CONFIG_DIR
+-CONFIG_DIR
 -XENSTORED_PORT
 -XENSTORED_KVA
 -target_alias
@@ -4310,6 +4322,7 @@ index 9e3ed60..0000000
 -with_initddir
 -with_sysconfig_leaf_dir
 -with_libexec_leaf_dir
+-with_xen_scriptdir
 -with_xen_dumpdir
 -with_rundir
 -with_debugdir
@@ -4873,7 +4886,7 @@ index 9e3ed60..0000000
 -  # Omit some internal or obsolete options to make the list less imposing.
 -  # This message is too long to be a string in the A/UX 3.1 sh.
 -  cat <<_ACEOF
--\`configure' configures Xen Hypervisor Documentation 4.14 to adapt to many kinds of systems.
+-\`configure' configures Xen Hypervisor Documentation 4.16 to adapt to many kinds of systems.
 -
 -Usage: $0 [OPTION]... [VAR=VALUE]...
 -
@@ -4935,7 +4948,7 @@ index 9e3ed60..0000000
 -
 -if test -n "$ac_init_help"; then
 -  case $ac_init_help in
--     short | recursive ) echo "Configuration of Xen Hypervisor Documentation 4.14:";;
+-     short | recursive ) echo "Configuration of Xen Hypervisor Documentation 4.16:";;
 -   esac
 -  cat <<\_ACEOF
 -
@@ -4951,6 +4964,9 @@ index 9e3ed60..0000000
 -                          "default". [sysconfig]
 -  --with-libexec-leaf-dir=SUBDIR
 -                          Name of subdirectory in libexecdir to use.
+-  --with-xen-scriptdir=DIR
+-                          Path to directory for dom0 hotplug scripts.
+-                          [SYSCONFDIR/xen/scripts]
 -  --with-xen-dumpdir=DIR  Path to directory for domU crash dumps.
 -                          [LOCALSTATEDIR/lib/xen/dump]
 -  --with-rundir=DIR       Path to directory for runtime data.
@@ -5033,7 +5049,7 @@ index 9e3ed60..0000000
 -test -n "$ac_init_help" && exit $ac_status
 -if $ac_init_version; then
 -  cat <<\_ACEOF
--Xen Hypervisor Documentation configure 4.14
+-Xen Hypervisor Documentation configure 4.16
 -generated by GNU Autoconf 2.69
 -
 -Copyright (C) 2012 Free Software Foundation, Inc.
@@ -5050,7 +5066,7 @@ index 9e3ed60..0000000
 -This file contains any messages produced by compilers while
 -running configure, to aid debugging if configure makes a mistake.
 -
--It was created by Xen Hypervisor Documentation $as_me 4.14, which was
+-It was created by Xen Hypervisor Documentation $as_me 4.16, which was
 -generated by GNU Autoconf 2.69.  Invocation command line was
 -
 -  $ $0 $@
@@ -5399,7 +5415,7 @@ index 9e3ed60..0000000
 -
 -
 -
--ac_config_files="$ac_config_files ../config/Docs.mk man/xl.cfg.5.pod man/xl.1.pod"
+-ac_config_files="$ac_config_files ../config/Docs.mk man/xl.cfg.5.pod man/xl.1.pod man/xl-disk-configuration.5.pod man/xl-network-configuration.5.pod man/xl.conf.5.pod"
 -
 -ac_aux_dir=
 -for ac_dir in ../ "$srcdir"/../; do
@@ -5489,6 +5505,12 @@ index 9e3ed60..0000000
 -    esac
 -fi
 -
+-CONFIG_DIR=$sysconfdir
+-
+-
+-XEN_CONFIG_DIR=$CONFIG_DIR/xen
+-
+-
 -
 -# Check whether --with-initddir was given.
 -if test "${with_initddir+set}" = set; then :
@@ -5531,6 +5553,17 @@ index 9e3ed60..0000000
 -
 -
 -
+-# Check whether --with-xen-scriptdir was given.
+-if test "${with_xen_scriptdir+set}" = set; then :
+-  withval=$with_xen_scriptdir; xen_scriptdir_path=$withval
+-else
+-  xen_scriptdir_path=$XEN_CONFIG_DIR/scripts
+-fi
+-
+-XEN_SCRIPT_DIR=$xen_scriptdir_path
+-
+-
+-
 -# Check whether --with-xen-dumpdir was given.
 -if test "${with_xen_dumpdir+set}" = set; then :
 -  withval=$with_xen_dumpdir; xen_dumpdir_path=$withval
@@ -5595,21 +5628,12 @@ index 9e3ed60..0000000
 -SHAREDIR=$prefix/share
 -
 -
--CONFIG_DIR=$sysconfdir
--
--
 -INITD_DIR=$initddir_path
 -
 -
--XEN_CONFIG_DIR=$CONFIG_DIR/xen
--
--
--XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
--
--
 -case "$host_os" in
 -*freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
--*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+-*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 -*) XEN_LOCK_DIR=$localstatedir/lock ;;
 -esac
 -
@@ -6459,7 +6483,7 @@ index 9e3ed60..0000000
 -# report actual input values of CONFIG_FILES etc. instead of their
 -# values after options handling.
 -ac_log="
--This file was extended by Xen Hypervisor Documentation $as_me 4.14, which was
+-This file was extended by Xen Hypervisor Documentation $as_me 4.16, which was
 -generated by GNU Autoconf 2.69.  Invocation command line was
 -
 -  CONFIG_FILES    = $CONFIG_FILES
@@ -6513,7 +6537,7 @@ index 9e3ed60..0000000
 -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 -ac_cs_version="\\
--Xen Hypervisor Documentation config.status 4.14
+-Xen Hypervisor Documentation config.status 4.16
 -configured by $0, generated by GNU Autoconf 2.69,
 -  with options \\"\$ac_cs_config\\"
 -
@@ -6626,6 +6650,9 @@ index 9e3ed60..0000000
 -    "../config/Docs.mk") CONFIG_FILES="$CONFIG_FILES ../config/Docs.mk" ;;
 -    "man/xl.cfg.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl.cfg.5.pod" ;;
 -    "man/xl.1.pod") CONFIG_FILES="$CONFIG_FILES man/xl.1.pod" ;;
+-    "man/xl-disk-configuration.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl-disk-configuration.5.pod" ;;
+-    "man/xl-network-configuration.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl-network-configuration.5.pod" ;;
+-    "man/xl.conf.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl.conf.5.pod" ;;
 -
 -  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
 -  esac
@@ -7077,13 +7104,13 @@ index 9e3ed60..0000000
 -
 diff --git a/tools/configure b/tools/configure
 deleted file mode 100755
-index f3f19c1..0000000
+index 40f970b..0000000
 --- a/tools/configure
 +++ /dev/null
-@@ -1,11329 +0,0 @@
+@@ -1,11485 +0,0 @@
 -#! /bin/sh
 -# Guess values for system-dependent variables and create Makefiles.
--# Generated by GNU Autoconf 2.69 for Xen Hypervisor Tools 4.14.
+-# Generated by GNU Autoconf 2.69 for Xen Hypervisor Tools 4.16.
 -#
 -# Report bugs to <xen-devel@lists.xen.org>.
 -#
@@ -7663,12 +7690,12 @@ index f3f19c1..0000000
 -# Identity of this package.
 -PACKAGE_NAME='Xen Hypervisor Tools'
 -PACKAGE_TARNAME='xen'
--PACKAGE_VERSION='4.14'
--PACKAGE_STRING='Xen Hypervisor Tools 4.14'
+-PACKAGE_VERSION='4.16'
+-PACKAGE_STRING='Xen Hypervisor Tools 4.16'
 -PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 -PACKAGE_URL='https://www.xen.org/'
 -
--ac_unique_file="libxl/libxl.c"
+-ac_unique_file="libs/light/libxl.c"
 -# Factoring default headers for most tests.
 -ac_includes_default="\
 -#include <stdio.h>
@@ -7726,6 +7753,8 @@ index f3f19c1..0000000
 -EXTFS_LIBS
 -system_aio
 -zlib
+-libzstd_LIBS
+-libzstd_CFLAGS
 -FETCHER
 -FTP
 -FALSE
@@ -7745,6 +7774,7 @@ index f3f19c1..0000000
 -CPP
 -pyconfig
 -PYTHONPATH
+-BASH
 -CHECKPOLICY
 -XENSTORED
 -GO
@@ -7762,14 +7792,13 @@ index f3f19c1..0000000
 -OCAMLLIB
 -OCAMLVERSION
 -OCAMLC
+-ABI_DUMPER
 -INSTALL_DATA
 -INSTALL_SCRIPT
 -INSTALL_PROGRAM
 -SET_MAKE
 -AWK
 -IASL
--XGETTEXT
--BASH
 -FLEX
 -BISON
 -PERL
@@ -7779,7 +7808,6 @@ index f3f19c1..0000000
 -PREPEND_LIB
 -PREPEND_INCLUDES
 -EXTRA_QEMUU_CONFIGURE_ARGS
--ipxe
 -qemu_xen_systemd
 -qemu_xen_path
 -qemu_xen
@@ -7787,6 +7815,7 @@ index f3f19c1..0000000
 -BCC
 -LD86
 -AS86
+-ipxe
 -qemu_traditional
 -LINUX_BACKEND_MODULES
 -golang
@@ -7801,10 +7830,7 @@ index f3f19c1..0000000
 -XEN_DUMP_DIR
 -XEN_PAGING_DIR
 -XEN_LOCK_DIR
--XEN_SCRIPT_DIR
--XEN_CONFIG_DIR
 -INITD_DIR
--CONFIG_DIR
 -SHAREDIR
 -XEN_LIB_DIR
 -XEN_RUN_STORED
@@ -7816,7 +7842,10 @@ index f3f19c1..0000000
 -LIBEXEC_LIB
 -LIBEXEC_BIN
 -LIBEXEC
+-XEN_SCRIPT_DIR
 -CONFIG_LEAF_DIR
+-XEN_CONFIG_DIR
+-CONFIG_DIR
 -XENSTORED_PORT
 -XENSTORED_KVA
 -FILE_OFFSET_BITS
@@ -7882,6 +7911,7 @@ index f3f19c1..0000000
 -with_initddir
 -with_sysconfig_leaf_dir
 -with_libexec_leaf_dir
+-with_xen_scriptdir
 -with_xen_dumpdir
 -with_rundir
 -with_debugdir
@@ -7895,13 +7925,13 @@ index f3f19c1..0000000
 -enable_golang
 -with_linux_backend_modules
 -enable_qemu_traditional
+-enable_ipxe
+-with_system_ipxe
 -enable_rombios
 -with_system_qemu
 -with_stubdom_qmp_proxy
 -with_system_seabios
 -with_system_ovmf
--enable_ipxe
--with_system_ipxe
 -with_extra_qemuu_configure_args
 -with_xenstored
 -enable_systemd
@@ -7926,8 +7956,6 @@ index f3f19c1..0000000
 -PERL
 -BISON
 -FLEX
--BASH
--XGETTEXT
 -AS86
 -LD86
 -BCC
@@ -7941,6 +7969,8 @@ index f3f19c1..0000000
 -glib_LIBS
 -pixman_CFLAGS
 -pixman_LIBS
+-libzstd_CFLAGS
+-libzstd_LIBS
 -LIBNL3_CFLAGS
 -LIBNL3_LIBS
 -SYSTEMD_CFLAGS
@@ -8495,7 +8525,7 @@ index f3f19c1..0000000
 -  # Omit some internal or obsolete options to make the list less imposing.
 -  # This message is too long to be a string in the A/UX 3.1 sh.
 -  cat <<_ACEOF
--\`configure' configures Xen Hypervisor Tools 4.14 to adapt to many kinds of systems.
+-\`configure' configures Xen Hypervisor Tools 4.16 to adapt to many kinds of systems.
 -
 -Usage: $0 [OPTION]... [VAR=VALUE]...
 -
@@ -8561,7 +8591,7 @@ index f3f19c1..0000000
 -
 -if test -n "$ac_init_help"; then
 -  case $ac_init_help in
--     short | recursive ) echo "Configuration of Xen Hypervisor Tools 4.14:";;
+-     short | recursive ) echo "Configuration of Xen Hypervisor Tools 4.16:";;
 -   esac
 -  cat <<\_ACEOF
 -
@@ -8582,12 +8612,12 @@ index f3f19c1..0000000
 -  --disable-seabios       Disable SeaBIOS (default is ENABLED)
 -  --disable-golang        Disable Go tools (default is ENABLED)
 -  --enable-qemu-traditional
--                          Enable qemu traditional device model, (DEFAULT is on
--                          for Linux or NetBSD x86, otherwise off)
+-                          Enable qemu traditional device model, (DEFAULT is
+-                          off)
+-  --enable-ipxe           Enable in-tree IPXE, (DEFAULT is off, see also
+-                          --with-system-ipxe)
 -  --enable-rombios        Enable ROMBIOS, (DEFAULT is on if qemu-traditional
--                          is enabled, otherwise off)
--  --disable-ipxe          Enable in-tree IPXE, (DEFAULT is on if rombios is
--                          enabled, otherwise off, see also --with-system-ipxe)
+-                          or ipxe is enabled, otherwise off)
 -  --enable-systemd        Enable systemd support (default is DISABLED)
 -  --enable-9pfs           Explicitly enable 9pfs support in QEMU build
 -                          (default is to defer to QEMU configure default)
@@ -8606,6 +8636,9 @@ index f3f19c1..0000000
 -                          "default". [sysconfig]
 -  --with-libexec-leaf-dir=SUBDIR
 -                          Name of subdirectory in libexecdir to use.
+-  --with-xen-scriptdir=DIR
+-                          Path to directory for dom0 hotplug scripts.
+-                          [SYSCONFDIR/xen/scripts]
 -  --with-xen-dumpdir=DIR  Path to directory for domU crash dumps.
 -                          [LOCALSTATEDIR/lib/xen/dump]
 -  --with-rundir=DIR       Path to directory for runtime data.
@@ -8615,6 +8648,11 @@ index f3f19c1..0000000
 -  --with-linux-backend-modules="mod1 mod2"
 -                          List of Linux backend module or modalias names to be
 -                          autoloaded on startup.
+-  --with-system-ipxe[=PATH]
+-                          Use system supplied IPXE PATH instead of building
+-                          and installing our own version, it takes precedence
+-                          over --{en,dis}able-ipxe, --without-system-ipxe is
+-                          an error
 -  --with-system-qemu[=PATH]
 -                          Use system supplied qemu PATH or qemu (taken from
 -                          $PATH) as qemu-xen device model instead of building
@@ -8628,12 +8666,6 @@ index f3f19c1..0000000
 -  --with-system-ovmf[=PATH]
 -                          Use system supplied OVMF PATH instead of building
 -                          and installing our own version
--  --with-system-ipxe[=PATH]
--                          Use system supplied IPXE PATH instead of building
--                          and installing our own version, it takes precedence
--                          over --{en,dis}able-ipxe and is bound by the
--                          presence of rombios, --without-system-ipxe is an
--                          error
 -  --with-extra-qemuu-configure-args[="--ARG1 ..."]
 -                          List of additional configure options for upstream
 -                          qemu
@@ -8672,8 +8704,6 @@ index f3f19c1..0000000
 -  PERL        Path to Perl parser
 -  BISON       Path to Bison parser generator
 -  FLEX        Path to Flex lexical analyser generator
--  BASH        Path to bash shell
--  XGETTEXT    Path to xgetttext tool
 -  AS86        Path to as86 tool
 -  LD86        Path to ld86 tool
 -  BCC         Path to bcc tool
@@ -8690,6 +8720,10 @@ index f3f19c1..0000000
 -  pixman_CFLAGS
 -              C compiler flags for pixman, overriding pkg-config
 -  pixman_LIBS linker flags for pixman, overriding pkg-config
+-  libzstd_CFLAGS
+-              C compiler flags for libzstd, overriding pkg-config
+-  libzstd_LIBS
+-              linker flags for libzstd, overriding pkg-config
 -  LIBNL3_CFLAGS
 -              C compiler flags for LIBNL3, overriding pkg-config
 -  LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config
@@ -8765,7 +8799,7 @@ index f3f19c1..0000000
 -test -n "$ac_init_help" && exit $ac_status
 -if $ac_init_version; then
 -  cat <<\_ACEOF
--Xen Hypervisor Tools configure 4.14
+-Xen Hypervisor Tools configure 4.16
 -generated by GNU Autoconf 2.69
 -
 -Copyright (C) 2012 Free Software Foundation, Inc.
@@ -9180,7 +9214,7 @@ index f3f19c1..0000000
 -This file contains any messages produced by compilers while
 -running configure, to aid debugging if configure makes a mistake.
 -
--It was created by Xen Hypervisor Tools $as_me 4.14, which was
+-It was created by Xen Hypervisor Tools $as_me 4.16, which was
 -generated by GNU Autoconf 2.69.  Invocation command line was
 -
 -  $ $0 $@
@@ -10966,6 +11000,8 @@ index f3f19c1..0000000
 -
 -
 -
+-
+-
 -test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
 -test "x$exec_prefix" = "xNONE" && exec_prefix=${prefix}
 -
@@ -10995,6 +11031,12 @@ index f3f19c1..0000000
 -    esac
 -fi
 -
+-CONFIG_DIR=$sysconfdir
+-
+-
+-XEN_CONFIG_DIR=$CONFIG_DIR/xen
+-
+-
 -
 -# Check whether --with-initddir was given.
 -if test "${with_initddir+set}" = set; then :
@@ -11037,6 +11079,17 @@ index f3f19c1..0000000
 -
 -
 -
+-# Check whether --with-xen-scriptdir was given.
+-if test "${with_xen_scriptdir+set}" = set; then :
+-  withval=$with_xen_scriptdir; xen_scriptdir_path=$withval
+-else
+-  xen_scriptdir_path=$XEN_CONFIG_DIR/scripts
+-fi
+-
+-XEN_SCRIPT_DIR=$xen_scriptdir_path
+-
+-
+-
 -# Check whether --with-xen-dumpdir was given.
 -if test "${with_xen_dumpdir+set}" = set; then :
 -  withval=$with_xen_dumpdir; xen_dumpdir_path=$withval
@@ -11101,21 +11154,12 @@ index f3f19c1..0000000
 -SHAREDIR=$prefix/share
 -
 -
--CONFIG_DIR=$sysconfdir
--
--
 -INITD_DIR=$initddir_path
 -
 -
--XEN_CONFIG_DIR=$CONFIG_DIR/xen
--
--
--XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
--
--
 -case "$host_os" in
 -*freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
--*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+-*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 -*) XEN_LOCK_DIR=$localstatedir/lock ;;
 -esac
 -
@@ -11352,19 +11396,6 @@ index f3f19c1..0000000
 -# Check whether --enable-qemu-traditional was given.
 -if test "${enable_qemu_traditional+set}" = set; then :
 -  enableval=$enable_qemu_traditional;
--else
--
--    case "$host_cpu" in
--        i[3456]86|x86_64)
--           enable_qemu_traditional="yes";;
--        *) enable_qemu_traditional="no";;
--    esac
--    case "$host_os" in
--        freebsd*)
--           enable_qemu_traditional="no";;
--    esac
--
--
 -fi
 -
 -if test "x$enable_qemu_traditional" = "xyes"; then :
@@ -11380,12 +11411,57 @@ index f3f19c1..0000000
 -fi
 -
 -
+-# Check whether --enable-ipxe was given.
+-if test "${enable_ipxe+set}" = set; then :
+-  enableval=$enable_ipxe;
+-else
+-
+-    if test "x$enable_qemu_traditional" = "xyes"; then :
+-
+-        enable_ipxe="yes"
+-
+-else
+-
+-        enable_ipxe="no"
+-
+-fi
+-
+-fi
+-
+-if test "x$enable_ipxe" = "xno"; then :
+-  ipxe=n
+-else
+-  ipxe=y
+-fi
+-
+-# Check whether --with-system-ipxe was given.
+-if test "${with_system_ipxe+set}" = set; then :
+-  withval=$with_system_ipxe;
+-    case $withval in
+-        no) as_fn_error $? "--without-system-ipxe has no effect" "$LINENO" 5 ;;
+-        /*)  ipxe_path=$withval; ipxe=n ;;
+-        *) as_fn_error $? "IPXE specified, but is not an absolute path" "$LINENO" 5 ;;
+-    esac
+-
+-fi
+-
+-if test "x$ipxe" = "xy" -o -n "$ipxe_path" ; then :
+-
+-
+-cat >>confdefs.h <<_ACEOF
+-#define IPXE_PATH "${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"
+-_ACEOF
+-
+-
+-fi
+-
+-
 -# Check whether --enable-rombios was given.
 -if test "${enable_rombios+set}" = set; then :
 -  enableval=$enable_rombios;
 -else
 -
--    if test "x$enable_qemu_traditional" = "xyes"; then :
+-    if test "x$enable_qemu_traditional" = "xyes" -o "x$enable_ipxe" = "xyes"; then :
 -
 -        enable_rombios="yes"
 -
@@ -11700,55 +11776,6 @@ index f3f19c1..0000000
 -
 -fi
 -
--# Check whether --enable-ipxe was given.
--if test "${enable_ipxe+set}" = set; then :
--  enableval=$enable_ipxe;
--     if test "x$enable_ipxe" = "xno"; then :
--  ipxe=n
--else
--  ipxe=y
--fi
--
--else
--
--    if test "x$enable_rombios" = "xno"; then :
--  ipxe=n
--else
--  ipxe=y
--fi
--
--fi
--
--
--# Check whether --with-system-ipxe was given.
--if test "${with_system_ipxe+set}" = set; then :
--  withval=$with_system_ipxe;
--    case $withval in
--        no) as_fn_error $? "--without-system-ipxe has no effect" "$LINENO" 5 ;;
--        /*)  ipxe_path=$withval; ipxe=n ;;
--        *) as_fn_error $? "IPXE specified, but is not an absolute path" "$LINENO" 5 ;;
--    esac
--
--fi
--
--if test "x$ipxe" = "xy" -o -n "$ipxe_path" ; then :
--
--
--    if test "x$enable_rombios" = "xno"; then :
--
--        as_fn_error $? "Rombios is required to use IPXE" "$LINENO" 5
--
--fi
--
--
--cat >>confdefs.h <<_ACEOF
--#define IPXE_PATH "${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"
--_ACEOF
--
--
--fi
--
--
 -
 -# Check whether --with-extra-qemuu-configure-args was given.
 -if test "${with_extra_qemuu_configure_args+set}" = set; then :
@@ -11800,8 +11827,6 @@ index f3f19c1..0000000
 -
 -
 -
--
--
 -# Checks for programs.
 -ac_ext=c
 -ac_cpp='$CPP $CPPFLAGS'
@@ -12466,16 +12491,16 @@ index f3f19c1..0000000
 -
 -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 -
--# Extract the first word of "bison", so it can be a program name with args.
--set dummy bison; ac_word=$2
+-# Extract the first word of "flex", so it can be a program name with args.
+-set dummy flex; ac_word=$2
 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 -$as_echo_n "checking for $ac_word... " >&6; }
--if ${ac_cv_path_BISON+:} false; then :
+-if ${ac_cv_path_FLEX+:} false; then :
 -  $as_echo_n "(cached) " >&6
 -else
--  case $BISON in
+-  case $FLEX in
 -  [\\/]* | ?:[\\/]*)
--  ac_cv_path_BISON="$BISON" # Let the user override the test with a path.
+-  ac_cv_path_FLEX="$FLEX" # Let the user override the test with a path.
 -  ;;
 -  *)
 -  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -12485,7 +12510,7 @@ index f3f19c1..0000000
 -  test -z "$as_dir" && as_dir=.
 -    for ac_exec_ext in '' $ac_executable_extensions; do
 -  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--    ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
+-    ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext"
 -    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 -    break 2
 -  fi
@@ -12496,26 +12521,26 @@ index f3f19c1..0000000
 -  ;;
 -esac
 -fi
--BISON=$ac_cv_path_BISON
--if test -n "$BISON"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5
--$as_echo "$BISON" >&6; }
+-FLEX=$ac_cv_path_FLEX
+-if test -n "$FLEX"; then
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5
+-$as_echo "$FLEX" >&6; }
 -else
 -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 -$as_echo "no" >&6; }
 -fi
 -
 -
--# Extract the first word of "flex", so it can be a program name with args.
--set dummy flex; ac_word=$2
+-# Extract the first word of "abi-dumper", so it can be a program name with args.
+-set dummy abi-dumper; ac_word=$2
 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 -$as_echo_n "checking for $ac_word... " >&6; }
--if ${ac_cv_path_FLEX+:} false; then :
+-if ${ac_cv_path_ABI_DUMPER+:} false; then :
 -  $as_echo_n "(cached) " >&6
 -else
--  case $FLEX in
+-  case $ABI_DUMPER in
 -  [\\/]* | ?:[\\/]*)
--  ac_cv_path_FLEX="$FLEX" # Let the user override the test with a path.
+-  ac_cv_path_ABI_DUMPER="$ABI_DUMPER" # Let the user override the test with a path.
 -  ;;
 -  *)
 -  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -12525,7 +12550,7 @@ index f3f19c1..0000000
 -  test -z "$as_dir" && as_dir=.
 -    for ac_exec_ext in '' $ac_executable_extensions; do
 -  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--    ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext"
+-    ac_cv_path_ABI_DUMPER="$as_dir/$ac_word$ac_exec_ext"
 -    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
 -    break 2
 -  fi
@@ -12536,10 +12561,10 @@ index f3f19c1..0000000
 -  ;;
 -esac
 -fi
--FLEX=$ac_cv_path_FLEX
--if test -n "$FLEX"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5
--$as_echo "$FLEX" >&6; }
+-ABI_DUMPER=$ac_cv_path_ABI_DUMPER
+-if test -n "$ABI_DUMPER"; then
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ABI_DUMPER" >&5
+-$as_echo "$ABI_DUMPER" >&6; }
 -else
 -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 -$as_echo "no" >&6; }
@@ -14909,51 +14934,6 @@ index f3f19c1..0000000
 -
 -if ! $rump; then
 -
--# Extract the first word of "xgettext", so it can be a program name with args.
--set dummy xgettext; ac_word=$2
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
--$as_echo_n "checking for $ac_word... " >&6; }
--if ${ac_cv_path_XGETTEXT+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--  case $XGETTEXT in
--  [\\/]* | ?:[\\/]*)
--  ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
--  ;;
--  *)
--  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
--for as_dir in $PATH
--do
--  IFS=$as_save_IFS
--  test -z "$as_dir" && as_dir=.
--    for ac_exec_ext in '' $ac_executable_extensions; do
--  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--    ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext"
--    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--    break 2
--  fi
--done
--  done
--IFS=$as_save_IFS
--
--  test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT="no"
--  ;;
--esac
--fi
--XGETTEXT=$ac_cv_path_XGETTEXT
--if test -n "$XGETTEXT"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5
--$as_echo "$XGETTEXT" >&6; }
--else
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--$as_echo "no" >&6; }
--fi
--
--
--if test x"${XGETTEXT}" = x"no"
--then
--    as_fn_error $? "Unable to find xgettext, please install xgettext" "$LINENO" 5
--fi
 -case "$host_cpu" in
 -i[3456]86|x86_64|aarch64)
 -    # Extract the first word of "iasl", so it can be a program name with args.
@@ -15830,6 +15810,77 @@ index f3f19c1..0000000
 -
 -
 -
+-pkg_failed=no
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd" >&5
+-$as_echo_n "checking for libzstd... " >&6; }
+-
+-if test -n "$libzstd_CFLAGS"; then
+-    pkg_cv_libzstd_CFLAGS="$libzstd_CFLAGS"
+- elif test -n "$PKG_CONFIG"; then
+-    if test -n "$PKG_CONFIG" && \
+-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+-  ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+-  ac_status=$?
+-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+-  test $ac_status = 0; }; then
+-  pkg_cv_libzstd_CFLAGS=`$PKG_CONFIG --cflags "libzstd" 2>/dev/null`
+-		      test "x$?" != "x0" && pkg_failed=yes
+-else
+-  pkg_failed=yes
+-fi
+- else
+-    pkg_failed=untried
+-fi
+-if test -n "$libzstd_LIBS"; then
+-    pkg_cv_libzstd_LIBS="$libzstd_LIBS"
+- elif test -n "$PKG_CONFIG"; then
+-    if test -n "$PKG_CONFIG" && \
+-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+-  ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+-  ac_status=$?
+-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+-  test $ac_status = 0; }; then
+-  pkg_cv_libzstd_LIBS=`$PKG_CONFIG --libs "libzstd" 2>/dev/null`
+-		      test "x$?" != "x0" && pkg_failed=yes
+-else
+-  pkg_failed=yes
+-fi
+- else
+-    pkg_failed=untried
+-fi
+-
+-
+-
+-if test $pkg_failed = yes; then
+-   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-
+-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+-        _pkg_short_errors_supported=yes
+-else
+-        _pkg_short_errors_supported=no
+-fi
+-        if test $_pkg_short_errors_supported = yes; then
+-	        libzstd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd" 2>&1`
+-        else
+-	        libzstd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd" 2>&1`
+-        fi
+-	# Put the nasty error message in config.log where it belongs
+-	echo "$libzstd_PKG_ERRORS" >&5
+-
+-	true
+-elif test $pkg_failed = untried; then
+-     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-	true
+-else
+-	libzstd_CFLAGS=$pkg_cv_libzstd_CFLAGS
+-	libzstd_LIBS=$pkg_cv_libzstd_LIBS
+-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+-$as_echo "yes" >&6; }
+-	zlib="$zlib -DHAVE_ZSTD $libzstd_CFLAGS $libzstd_LIBS"
+-fi
+-
 -
 -
 -ac_fn_c_check_header_mongrel "$LINENO" "ext2fs/ext2fs.h" "ac_cv_header_ext2fs_ext2fs_h" "$ac_includes_default"
@@ -17105,6 +17156,138 @@ index f3f19c1..0000000
 -fi
 -
 -
+-if test "x$pvshim" = "xy"; then :
+-
+-    # Extract the first word of "bison", so it can be a program name with args.
+-set dummy bison; ac_word=$2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+-$as_echo_n "checking for $ac_word... " >&6; }
+-if ${ac_cv_path_BISON+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  case $BISON in
+-  [\\/]* | ?:[\\/]*)
+-  ac_cv_path_BISON="$BISON" # Let the user override the test with a path.
+-  ;;
+-  *)
+-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+-  IFS=$as_save_IFS
+-  test -z "$as_dir" && as_dir=.
+-    for ac_exec_ext in '' $ac_executable_extensions; do
+-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+-    ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
+-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+-    break 2
+-  fi
+-done
+-  done
+-IFS=$as_save_IFS
+-
+-  test -z "$ac_cv_path_BISON" && ac_cv_path_BISON="no"
+-  ;;
+-esac
+-fi
+-BISON=$ac_cv_path_BISON
+-if test -n "$BISON"; then
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5
+-$as_echo "$BISON" >&6; }
+-else
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-fi
+-
+-
+-if test x"${BISON}" = x"no"
+-then
+-    as_fn_error $? "Unable to find bison, please install bison" "$LINENO" 5
+-fi
+-
+-else
+-
+-    # Extract the first word of "bison", so it can be a program name with args.
+-set dummy bison; ac_word=$2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+-$as_echo_n "checking for $ac_word... " >&6; }
+-if ${ac_cv_path_BISON+:} false; then :
+-  $as_echo_n "(cached) " >&6
+-else
+-  case $BISON in
+-  [\\/]* | ?:[\\/]*)
+-  ac_cv_path_BISON="$BISON" # Let the user override the test with a path.
+-  ;;
+-  *)
+-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+-  IFS=$as_save_IFS
+-  test -z "$as_dir" && as_dir=.
+-    for ac_exec_ext in '' $ac_executable_extensions; do
+-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+-    ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
+-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+-    break 2
+-  fi
+-done
+-  done
+-IFS=$as_save_IFS
+-
+-  ;;
+-esac
+-fi
+-BISON=$ac_cv_path_BISON
+-if test -n "$BISON"; then
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5
+-$as_echo "$BISON" >&6; }
+-else
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-fi
+-
+-
+-
+-fi
+-
+-
+-ax_found=0
+-
+-    if test "$ax_found" = "0"; then :
+-
+-        ac_fn_c_check_header_mongrel "$LINENO" "endian.h" "ac_cv_header_endian_h" "$ac_includes_default"
+-if test "x$ac_cv_header_endian_h" = xyes; then :
+-
+-
+-$as_echo "#define INCLUDE_ENDIAN_H <endian.h>" >>confdefs.h
+-
+-            ax_found=1
+-fi
+-
+-
+-
+-fi
+-
+-    if test "$ax_found" = "0"; then :
+-
+-        ac_fn_c_check_header_mongrel "$LINENO" "sys/endian.h" "ac_cv_header_sys_endian_h" "$ac_includes_default"
+-if test "x$ac_cv_header_sys_endian_h" = xyes; then :
+-
+-
+-$as_echo "#define INCLUDE_ENDIAN_H <sys/endian.h>" >>confdefs.h
+-
+-            ax_found=1
+-fi
+-
+-
+-
+-fi
+-
+-if test "$ax_found" = "0"; then :
+-
+-    as_fn_error $? "No header found from list endian.h sys/endian.h" "$LINENO" 5
+-
+-fi
+-
 -
 -cat >confcache <<\_ACEOF
 -# This file is a shell script that caches the results of configure
@@ -17612,7 +17795,7 @@ index f3f19c1..0000000
 -# report actual input values of CONFIG_FILES etc. instead of their
 -# values after options handling.
 -ac_log="
--This file was extended by Xen Hypervisor Tools $as_me 4.14, which was
+-This file was extended by Xen Hypervisor Tools $as_me 4.16, which was
 -generated by GNU Autoconf 2.69.  Invocation command line was
 -
 -  CONFIG_FILES    = $CONFIG_FILES
@@ -17675,7 +17858,7 @@ index f3f19c1..0000000
 -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 -ac_cs_version="\\
--Xen Hypervisor Tools config.status 4.14
+-Xen Hypervisor Tools config.status 4.16
 -configured by $0, generated by GNU Autoconf 2.69,
 -  with options \\"\$ac_cs_config\\"
 -
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0003-Display-Debian-package-version-in-hypervisor-log.patch 4.16.1-1/debian/patches/0003-Display-Debian-package-version-in-hypervisor-log.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0003-Display-Debian-package-version-in-hypervisor-log.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0003-Display-Debian-package-version-in-hypervisor-log.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,187 @@
+From: Bastian Blank <waldi@debian.org>
+Date: Sat, 5 Jul 2014 11:46:43 +0200
+Subject: Display Debian package version in hypervisor log
+
+During hypervisor boot, disable the banner and nicely display the xen
+version as well as the Maintainer address from debian/control.
+
+For this to work the SOURCE_BASE_DIR variable needs to be set by the
+build system to the top directory, i.e. where the debian folder is.
+
+Original patch by Bastian Blank <waldi@debian.org>
+Modified by
+Hans van Kranenburg <hans@knorrie.org>
+Maximilian Engelhardt <maxi@daemonizer.de>
+---
+ xen/Makefile                 |  8 +++++---
+ xen/common/kernel.c          |  8 ++++----
+ xen/common/version.c         | 22 +++++++++++-----------
+ xen/drivers/char/console.c   | 11 ++++-------
+ xen/include/xen/compile.h.in |  8 ++++----
+ xen/include/xen/version.h    |  7 ++++---
+ 6 files changed, 32 insertions(+), 32 deletions(-)
+
+diff --git a/xen/Makefile b/xen/Makefile
+index 8abc71c..503104f 100644
+--- a/xen/Makefile
++++ b/xen/Makefile
+@@ -430,7 +430,7 @@ endef
+ targets += .banner
+ 
+ # compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
+-include/xen/compile.h: include/xen/compile.h.in .banner
++include/xen/compile.h: include/xen/compile.h.in
+ 	@sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \
+ 	    -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \
+ 	    -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \
+@@ -441,9 +441,11 @@ include/xen/compile.h: include/xen/compile.h.in .banner
+ 	    -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
+ 	    -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
+ 	    -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")!g' \
++	    -e 's/@@system_distribution@@/$(shell lsb_release -is)/g' \
++	    -e 's/@@system_maintainer_domain@@/$(shell grep Maintainer ${SOURCE_BASE_DIR}/debian/control | sed -ne 's,^Maintainer: .[^<]*<[^@>]*@\([^>]*\)>,\1,p')/g' \
++	    -e 's/@@system_maintainer_local@@/$(shell grep Maintainer ${SOURCE_BASE_DIR}/debian/control | sed -ne 's,^Maintainer: .[^<]*<\([^@>]*\)@.*>,\1,p')/g' \
++	    -e 's/@@system_version@@/$(shell cd ${SOURCE_BASE_DIR}; dpkg-parsechangelog | awk '/^Version:/ {print $$2}')/g' \
+ 	    < include/xen/compile.h.in > $@.new
+-	@cat .banner
+-	@sed -rf tools/process-banner.sed < .banner >> $@.new
+ 	@mv -f $@.new $@
+ 
+ asm-offsets.s: arch/$(TARGET_ARCH)/$(TARGET_SUBARCH)/asm-offsets.c
+diff --git a/xen/common/kernel.c b/xen/common/kernel.c
+index e119e54..a31e617 100644
+--- a/xen/common/kernel.c
++++ b/xen/common/kernel.c
+@@ -402,9 +402,9 @@ static int __init buildinfo_init(void)
+ 
+     hypfs_add_dir(&buildinfo, &compileinfo, true);
+     hypfs_string_set_reference(&compiler, xen_compiler());
+-    hypfs_string_set_reference(&compile_by, xen_compile_by());
++    hypfs_string_set_reference(&compile_by, xen_compile_system_maintainer_local());
+     hypfs_string_set_reference(&compile_date, xen_compile_date());
+-    hypfs_string_set_reference(&compile_domain, xen_compile_domain());
++    hypfs_string_set_reference(&compile_domain, xen_compile_system_maintainer_domain());
+     hypfs_add_leaf(&compileinfo, &compiler, true);
+     hypfs_add_leaf(&compileinfo, &compile_by, true);
+     hypfs_add_leaf(&compileinfo, &compile_date, true);
+@@ -485,8 +485,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
+ 
+         memset(&info, 0, sizeof(info));
+         safe_strcpy(info.compiler,       deny ? xen_deny() : xen_compiler());
+-        safe_strcpy(info.compile_by,     deny ? xen_deny() : xen_compile_by());
+-        safe_strcpy(info.compile_domain, deny ? xen_deny() : xen_compile_domain());
++        safe_strcpy(info.compile_by,     deny ? xen_deny() : xen_compile_system_maintainer_local());
++        safe_strcpy(info.compile_domain, deny ? xen_deny() : xen_compile_system_maintainer_domain());
+         safe_strcpy(info.compile_date,   deny ? xen_deny() : xen_compile_date());
+         if ( copy_to_guest(arg, &info, 1) )
+             return -EFAULT;
+diff --git a/xen/common/version.c b/xen/common/version.c
+index d320135..b44d411 100644
+--- a/xen/common/version.c
++++ b/xen/common/version.c
+@@ -20,19 +20,24 @@ const char *xen_compile_time(void)
+     return XEN_COMPILE_TIME;
+ }
+ 
+-const char *xen_compile_by(void)
++const char *xen_compile_system_distribution(void)
+ {
+-    return XEN_COMPILE_BY;
++    return XEN_COMPILE_SYSTEM_DISTRIBUTION;
+ }
+ 
+-const char *xen_compile_domain(void)
++const char *xen_compile_system_maintainer_local(void)
+ {
+-    return XEN_COMPILE_DOMAIN;
++    return XEN_COMPILE_SYSTEM_MAINTAINER_LOCAL;
+ }
+ 
+-const char *xen_compile_host(void)
++const char *xen_compile_system_maintainer_domain(void)
+ {
+-    return XEN_COMPILE_HOST;
++    return XEN_COMPILE_SYSTEM_MAINTAINER_DOMAIN;
++}
++
++const char *xen_compile_system_version(void)
++{
++    return XEN_COMPILE_SYSTEM_VERSION;
+ }
+ 
+ const char *xen_compiler(void)
+@@ -60,11 +65,6 @@ const char *xen_changeset(void)
+     return XEN_CHANGESET;
+ }
+ 
+-const char *xen_banner(void)
+-{
+-    return XEN_BANNER;
+-}
+-
+ const char *xen_deny(void)
+ {
+     return "<denied>";
+diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
+index 7d0a603..f1ec810 100644
+--- a/xen/drivers/char/console.c
++++ b/xen/drivers/char/console.c
+@@ -1000,14 +1000,11 @@ void __init console_init_preirq(void)
+     pv_console_set_rx_handler(serial_rx);
+ 
+     /* HELLO WORLD --- start-of-day banner text. */
+-    spin_lock(&console_lock);
+-    __putstr(xen_banner());
+-    spin_unlock(&console_lock);
+-    printk("Xen version %d.%d%s (%s@%s) (%s) %s %s\n",
++    printk("Xen version %d.%d%s (%s %s) (%s@%s) (%s) %s %s\n",
+            xen_major_version(), xen_minor_version(), xen_extra_version(),
+-           xen_compile_by(), xen_compile_domain(), xen_compiler(),
+-           xen_build_info(), xen_compile_date());
+-    printk("Latest ChangeSet: %s\n", xen_changeset());
++           xen_compile_system_distribution(), xen_compile_system_version(),
++           xen_compile_system_maintainer_local(), xen_compile_system_maintainer_domain(),
++           xen_compiler(), xen_build_info(), xen_compile_date());
+ 
+     /* Locate and print the buildid, if applicable. */
+     xen_build_init();
+diff --git a/xen/include/xen/compile.h.in b/xen/include/xen/compile.h.in
+index 440ecb2..0c3ca58 100644
+--- a/xen/include/xen/compile.h.in
++++ b/xen/include/xen/compile.h.in
+@@ -1,8 +1,9 @@
+ #define XEN_COMPILE_DATE	"@@date@@"
+ #define XEN_COMPILE_TIME	"@@time@@"
+-#define XEN_COMPILE_BY		"@@whoami@@"
+-#define XEN_COMPILE_DOMAIN	"@@domain@@"
+-#define XEN_COMPILE_HOST	"@@hostname@@"
++#define XEN_COMPILE_SYSTEM_DISTRIBUTION		"@@system_distribution@@"
++#define XEN_COMPILE_SYSTEM_MAINTAINER_DOMAIN	"@@system_maintainer_domain@@"
++#define XEN_COMPILE_SYSTEM_MAINTAINER_LOCAL	"@@system_maintainer_local@@"
++#define XEN_COMPILE_SYSTEM_VERSION		"@@system_version@@"
+ #define XEN_COMPILER		"@@compiler@@"
+ 
+ #define XEN_VERSION		@@version@@
+@@ -10,4 +11,3 @@
+ #define XEN_EXTRAVERSION	"@@extraversion@@"
+ 
+ #define XEN_CHANGESET		"@@changeset@@"
+-#define XEN_BANNER		\
+diff --git a/xen/include/xen/version.h b/xen/include/xen/version.h
+index 93c5877..9d98d6e 100644
+--- a/xen/include/xen/version.h
++++ b/xen/include/xen/version.h
+@@ -6,9 +6,10 @@
+ 
+ const char *xen_compile_date(void);
+ const char *xen_compile_time(void);
+-const char *xen_compile_by(void);
+-const char *xen_compile_domain(void);
+-const char *xen_compile_host(void);
++const char *xen_compile_system_distribution(void);
++const char *xen_compile_system_maintainer_domain(void);
++const char *xen_compile_system_maintainer_local(void);
++const char *xen_compile_system_version(void);
+ const char *xen_compiler(void);
+ unsigned int xen_major_version(void);
+ unsigned int xen_minor_version(void);
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0003-version.patch 4.16.1-1/debian/patches/0003-version.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0003-version.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0003-version.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,176 +0,0 @@
-From: Bastian Blank <waldi@debian.org>
-Date: Sat, 5 Jul 2014 11:46:43 +0200
-Subject: version
-
----
- xen/Makefile                 |  8 +++++---
- xen/common/kernel.c          |  8 ++++----
- xen/common/version.c         | 22 +++++++++++-----------
- xen/drivers/char/console.c   |  9 +++------
- xen/include/xen/compile.h.in |  8 ++++----
- xen/include/xen/version.h    |  7 ++++---
- 6 files changed, 31 insertions(+), 31 deletions(-)
-
-diff --git a/xen/Makefile b/xen/Makefile
-index e20d61b..b211dbe 100644
---- a/xen/Makefile
-+++ b/xen/Makefile
-@@ -382,7 +382,7 @@ delete-unfresh-files:
- 	@mv -f $@.tmp $@
- 
- # compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
--include/xen/compile.h: include/xen/compile.h.in .banner
-+include/xen/compile.h: include/xen/compile.h.in
- 	@sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \
- 	    -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \
- 	    -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \
-@@ -393,9 +393,11 @@ include/xen/compile.h: include/xen/compile.h.in .banner
- 	    -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
- 	    -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
- 	    -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")!g' \
-+	    -e 's/@@system_distribution@@/$(shell lsb_release -is)/g' \
-+	    -e 's/@@system_maintainer_domain@@/$(shell cd ../../../..; dpkg-parsechangelog | sed -ne 's,^Maintainer: .[^<]*<[^@>]*@\([^>]*\)>,\1,p')/g' \
-+	    -e 's/@@system_maintainer_local@@/$(shell cd ../../../..; dpkg-parsechangelog | sed -ne 's,^Maintainer: .[^<]*<\([^@>]*\)@.*>,\1,p')/g' \
-+	    -e 's/@@system_version@@/$(shell cd ../../../..; dpkg-parsechangelog | awk '/^Version:/ {print $$2}')/g' \
- 	    < include/xen/compile.h.in > $@.new
--	@cat .banner
--	@sed -rf tools/process-banner.sed < .banner >> $@.new
- 	@mv -f $@.new $@
- 
- include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
-diff --git a/xen/common/kernel.c b/xen/common/kernel.c
-index c3a943f..12bdf9d 100644
---- a/xen/common/kernel.c
-+++ b/xen/common/kernel.c
-@@ -398,9 +398,9 @@ static int __init buildinfo_init(void)
- 
-     hypfs_add_dir(&buildinfo, &compileinfo, true);
-     hypfs_string_set_reference(&compiler, xen_compiler());
--    hypfs_string_set_reference(&compile_by, xen_compile_by());
-+    hypfs_string_set_reference(&compile_by, xen_compile_system_maintainer_local());
-     hypfs_string_set_reference(&compile_date, xen_compile_date());
--    hypfs_string_set_reference(&compile_domain, xen_compile_domain());
-+    hypfs_string_set_reference(&compile_domain, xen_compile_system_maintainer_domain());
-     hypfs_add_leaf(&compileinfo, &compiler, true);
-     hypfs_add_leaf(&compileinfo, &compile_by, true);
-     hypfs_add_leaf(&compileinfo, &compile_date, true);
-@@ -481,8 +481,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
- 
-         memset(&info, 0, sizeof(info));
-         safe_strcpy(info.compiler,       deny ? xen_deny() : xen_compiler());
--        safe_strcpy(info.compile_by,     deny ? xen_deny() : xen_compile_by());
--        safe_strcpy(info.compile_domain, deny ? xen_deny() : xen_compile_domain());
-+        safe_strcpy(info.compile_by,     deny ? xen_deny() : xen_compile_system_maintainer_local());
-+        safe_strcpy(info.compile_domain, deny ? xen_deny() : xen_compile_system_maintainer_domain());
-         safe_strcpy(info.compile_date,   deny ? xen_deny() : xen_compile_date());
-         if ( copy_to_guest(arg, &info, 1) )
-             return -EFAULT;
-diff --git a/xen/common/version.c b/xen/common/version.c
-index 937eb12..781cd03 100644
---- a/xen/common/version.c
-+++ b/xen/common/version.c
-@@ -20,19 +20,24 @@ const char *xen_compile_time(void)
-     return XEN_COMPILE_TIME;
- }
- 
--const char *xen_compile_by(void)
-+const char *xen_compile_system_distribution(void)
- {
--    return XEN_COMPILE_BY;
-+    return XEN_COMPILE_SYSTEM_DISTRIBUTION;
- }
- 
--const char *xen_compile_domain(void)
-+const char *xen_compile_system_maintainer_local(void)
- {
--    return XEN_COMPILE_DOMAIN;
-+    return XEN_COMPILE_SYSTEM_MAINTAINER_LOCAL;
- }
- 
--const char *xen_compile_host(void)
-+const char *xen_compile_system_maintainer_domain(void)
- {
--    return XEN_COMPILE_HOST;
-+    return XEN_COMPILE_SYSTEM_MAINTAINER_DOMAIN;
-+}
-+
-+const char *xen_compile_system_version(void)
-+{
-+    return XEN_COMPILE_SYSTEM_VERSION;
- }
- 
- const char *xen_compiler(void)
-@@ -60,11 +65,6 @@ const char *xen_changeset(void)
-     return XEN_CHANGESET;
- }
- 
--const char *xen_banner(void)
--{
--    return XEN_BANNER;
--}
--
- const char *xen_deny(void)
- {
-     return "<denied>";
-diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
-index 861ad53..501362e 100644
---- a/xen/drivers/char/console.c
-+++ b/xen/drivers/char/console.c
-@@ -999,14 +999,11 @@ void __init console_init_preirq(void)
-     pv_console_set_rx_handler(serial_rx);
- 
-     /* HELLO WORLD --- start-of-day banner text. */
--    spin_lock(&console_lock);
--    __putstr(xen_banner());
--    spin_unlock(&console_lock);
--    printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string " %s\n",
-+    printk("Xen version %d.%d%s (%s %s) (%s@%s) (%s) debug=%c " gcov_string " %s\n",
-            xen_major_version(), xen_minor_version(), xen_extra_version(),
--           xen_compile_by(), xen_compile_domain(),
-+           xen_compile_system_distribution(), xen_compile_system_version(),
-+           xen_compile_system_maintainer_local(), xen_compile_system_maintainer_domain(),
-            xen_compiler(), debug_build() ? 'y' : 'n', xen_compile_date());
--    printk("Latest ChangeSet: %s\n", xen_changeset());
- 
-     /* Locate and print the buildid, if applicable. */
-     xen_build_init();
-diff --git a/xen/include/xen/compile.h.in b/xen/include/xen/compile.h.in
-index 440ecb2..0c3ca58 100644
---- a/xen/include/xen/compile.h.in
-+++ b/xen/include/xen/compile.h.in
-@@ -1,8 +1,9 @@
- #define XEN_COMPILE_DATE	"@@date@@"
- #define XEN_COMPILE_TIME	"@@time@@"
--#define XEN_COMPILE_BY		"@@whoami@@"
--#define XEN_COMPILE_DOMAIN	"@@domain@@"
--#define XEN_COMPILE_HOST	"@@hostname@@"
-+#define XEN_COMPILE_SYSTEM_DISTRIBUTION		"@@system_distribution@@"
-+#define XEN_COMPILE_SYSTEM_MAINTAINER_DOMAIN	"@@system_maintainer_domain@@"
-+#define XEN_COMPILE_SYSTEM_MAINTAINER_LOCAL	"@@system_maintainer_local@@"
-+#define XEN_COMPILE_SYSTEM_VERSION		"@@system_version@@"
- #define XEN_COMPILER		"@@compiler@@"
- 
- #define XEN_VERSION		@@version@@
-@@ -10,4 +11,3 @@
- #define XEN_EXTRAVERSION	"@@extraversion@@"
- 
- #define XEN_CHANGESET		"@@changeset@@"
--#define XEN_BANNER		\
-diff --git a/xen/include/xen/version.h b/xen/include/xen/version.h
-index 9ac926d..1553f22 100644
---- a/xen/include/xen/version.h
-+++ b/xen/include/xen/version.h
-@@ -6,9 +6,10 @@
- 
- const char *xen_compile_date(void);
- const char *xen_compile_time(void);
--const char *xen_compile_by(void);
--const char *xen_compile_domain(void);
--const char *xen_compile_host(void);
-+const char *xen_compile_system_distribution(void);
-+const char *xen_compile_system_maintainer_domain(void);
-+const char *xen_compile_system_maintainer_local(void);
-+const char *xen_compile_system_version(void);
- const char *xen_compiler(void);
- unsigned int xen_major_version(void);
- unsigned int xen_minor_version(void);
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0005-Do-not-ship-COPYING-into-usr-include.patch 4.16.1-1/debian/patches/0005-Do-not-ship-COPYING-into-usr-include.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0005-Do-not-ship-COPYING-into-usr-include.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0005-Do-not-ship-COPYING-into-usr-include.patch	2022-05-09 20:29:23.000000000 +0000
@@ -13,18 +13,18 @@ Signed-off-by: Ian Jackson <ian.jackson@
  1 file changed, 2 deletions(-)
 
 diff --git a/tools/include/Makefile b/tools/include/Makefile
-index 3d0192f..edfb35e 100644
+index 42605d4..39c0ad3 100644
 --- a/tools/include/Makefile
 +++ b/tools/include/Makefile
-@@ -18,7 +18,6 @@ XEN_LIB_X86_INCLUDES = $(filter-out %autogen.h, $(XEN_ROOT)/xen/include/xen/lib/
- xen/.dir: $(XEN_PUBLIC_INCLUDES) $(XEN_LIB_X86_INCLUDES)
- 	@rm -rf xen
- 	mkdir -p xen/libelf
--	ln -sf $(XEN_ROOT)/xen/include/public/COPYING xen
- 	ln -sf $(XEN_PUBLIC_INCLUDES) xen
- 	ln -sf $(addprefix $(XEN_ROOT)/xen/include/public/,arch-x86 arch-arm hvm io xsm) xen
- 	ln -sf ../xen-sys/$(XEN_OS) xen/sys
-@@ -57,7 +56,6 @@ install: all
+@@ -21,7 +21,6 @@ xen-foreign:
+ xen-dir:
+ 	mkdir -p xen/libelf acpi
+ 	find xen/ acpi/ -type l -exec rm '{}' +
+-	ln -s $(XEN_ROOT)/xen/include/public/COPYING xen/
+ 	ln -s $(XEN_ROOT)/xen/include/public/*.h xen/
+ 	ln -s $(XEN_ROOT)/xen/include/public/*/ xen/
+ 	ln -s ../xen-sys/$(XEN_OS) xen/sys
+@@ -59,7 +58,6 @@ install: all
  	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/io
  	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/sys
  	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/xsm
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0007-Do-not-build-the-instruction-emulator.patch 4.16.1-1/debian/patches/0007-Do-not-build-the-instruction-emulator.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0007-Do-not-build-the-instruction-emulator.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0007-Do-not-build-the-instruction-emulator.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,25 @@
+From: Ian Jackson <ian.jackson@citrix.com>
+Date: Thu, 20 Sep 2018 18:10:14 +0100
+Subject: Do not build the instruction emulator
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+---
+ tools/fuzz/Makefile | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/tools/fuzz/Makefile b/tools/fuzz/Makefile
+index 85213dc..6b7970b 100644
+--- a/tools/fuzz/Makefile
++++ b/tools/fuzz/Makefile
+@@ -3,7 +3,10 @@ include $(XEN_ROOT)/tools/Rules.mk
+ 
+ SUBDIRS-y :=
+ SUBDIRS-y += libelf
+-SUBDIRS-y += x86_instruction_emulator
++
++#SUBDIRS-y += x86_instruction_emulator
++# This does not compile with Debian's userland compile options,
++# which include fortify etc.
+ 
+ .PHONY: all clean distclean install uninstall
+ all clean distclean install uninstall: %: subdirs-%
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0008-Do-not-build-the-instruction-emulator.patch 4.16.1-1/debian/patches/0008-Do-not-build-the-instruction-emulator.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0008-Do-not-build-the-instruction-emulator.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0008-Do-not-build-the-instruction-emulator.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,25 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Thu, 20 Sep 2018 18:10:14 +0100
-Subject: Do not build the instruction emulator
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
----
- tools/fuzz/Makefile | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/tools/fuzz/Makefile b/tools/fuzz/Makefile
-index 85213dc..6b7970b 100644
---- a/tools/fuzz/Makefile
-+++ b/tools/fuzz/Makefile
-@@ -3,7 +3,10 @@ include $(XEN_ROOT)/tools/Rules.mk
- 
- SUBDIRS-y :=
- SUBDIRS-y += libelf
--SUBDIRS-y += x86_instruction_emulator
-+
-+#SUBDIRS-y += x86_instruction_emulator
-+# This does not compile with Debian's userland compile options,
-+# which include fortify etc.
- 
- .PHONY: all clean distclean install uninstall
- all clean distclean install uninstall: %: subdirs-%
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0008-tools-libfsimage-prefix.diff.patch 4.16.1-1/debian/patches/0008-tools-libfsimage-prefix.diff.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0008-tools-libfsimage-prefix.diff.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0008-tools-libfsimage-prefix.diff.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,83 @@
+From: Hans van Kranenburg <hans@knorrie.org>
+Date: Mon, 25 May 2020 17:08:18 +0200
+Subject: tools-libfsimage-prefix.diff
+
+\o/
+---
+ tools/Rules.mk                   |  2 ++
+ tools/libfsimage/Rules.mk        |  3 ++-
+ tools/libfsimage/common/Makefile | 16 +++++++++-------
+ 3 files changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/tools/Rules.mk b/tools/Rules.mk
+index 051a5d3..ccde2d4 100644
+--- a/tools/Rules.mk
++++ b/tools/Rules.mk
+@@ -16,6 +16,8 @@ INSTALL = $(XEN_ROOT)/tools/cross-install
+ 
+ LDFLAGS += $(PREPEND_LDFLAGS_XEN_TOOLS)
+ 
++LDFLAGS_RPATH = -Wl,-rpath,'$${ORIGIN}$(if $(1),/$(1))'
++
+ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
+ 
+ include $(XEN_ROOT)/tools/libs/uselibs.mk
+diff --git a/tools/libfsimage/Rules.mk b/tools/libfsimage/Rules.mk
+index bb6d42a..38cc539 100644
+--- a/tools/libfsimage/Rules.mk
++++ b/tools/libfsimage/Rules.mk
+@@ -3,10 +3,11 @@ include $(XEN_ROOT)/tools/Rules.mk
+ CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
+ CFLAGS += -Werror -D_GNU_SOURCE
+ LDFLAGS += -L../common/
++LDFLAGS += $(call LDFLAGS_RPATH,../..)
+ 
+ PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
+ 
+-FSDIR = $(libdir)/xenfsimage
++FSDIR = $(LIBEXEC_LIB)/xenfsimage
+ 
+ FSLIB = fsimage.so
+ 
+diff --git a/tools/libfsimage/common/Makefile b/tools/libfsimage/common/Makefile
+index 24bc90e..88d964a 100644
+--- a/tools/libfsimage/common/Makefile
++++ b/tools/libfsimage/common/Makefile
+@@ -4,6 +4,8 @@ include $(XEN_ROOT)/tools/libfsimage/Rules.mk
+ MAJOR = 4.16
+ MINOR = 0
+ 
++CFLAGS += -DFSDIR="\"$(LIBEXEC_LIB)/fs\""
++
+ LDFLAGS-$(CONFIG_SunOS) = -Wl,-M -Wl,mapfile-SunOS
+ LDFLAGS-$(CONFIG_Linux) = -Wl,mapfile-GNU
+ LDFLAGS += $(LDFLAGS-y)
+@@ -22,11 +24,11 @@ all: $(LIB)
+ 
+ .PHONY: install
+ install: all
+-	$(INSTALL_DIR) $(DESTDIR)$(libdir)
++	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_LIB)
+ 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
+-	$(INSTALL_PROG) libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
+-	ln -sf libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR)
+-	ln -sf libxenfsimage.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenfsimage.so
++	$(INSTALL_PROG) libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBEXEC_LIB)
++	ln -sf libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so.$(MAJOR)
++	ln -sf libxenfsimage.so.$(MAJOR) $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so
+ 	$(INSTALL_DATA) xenfsimage.h $(DESTDIR)$(includedir)
+ 	$(INSTALL_DATA) xenfsimage_plugin.h $(DESTDIR)$(includedir)
+ 	$(INSTALL_DATA) xenfsimage_grub.h $(DESTDIR)$(includedir)
+@@ -36,9 +38,9 @@ uninstall:
+ 	rm -f $(DESTDIR)$(includedir)/xenfsimage_grub.h
+ 	rm -f $(DESTDIR)$(includedir)/xenfsimage_plugin.h
+ 	rm -f $(DESTDIR)$(includedir)/xenfsimage.h
+-	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so
+-	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR)
+-	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR).$(MINOR)
++	rm -f $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so
++	rm -f $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so.$(MAJOR)
++	rm -f $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so.$(MAJOR).$(MINOR)
+ 
+ clean distclean::
+ 	rm -f $(LIB)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0009-autoconf-Provide-libexec_libdir_suffix.patch 4.16.1-1/debian/patches/0009-autoconf-Provide-libexec_libdir_suffix.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0009-autoconf-Provide-libexec_libdir_suffix.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0009-autoconf-Provide-libexec_libdir_suffix.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,39 @@
+From: Ian Jackson <ian.jackson@citrix.com>
+Date: Wed, 3 Oct 2018 16:25:58 +0100
+Subject: autoconf: Provide libexec_libdir_suffix
+
+This is going to be used to put libfsimage.so into a path containing
+the multiarch triplet.
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+---
+ m4/paths.m4 | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/m4/paths.m4 b/m4/paths.m4
+index 7be314a..9cf906e 100644
+--- a/m4/paths.m4
++++ b/m4/paths.m4
+@@ -84,6 +84,13 @@ AC_ARG_WITH([xen-scriptdir],
+ XEN_SCRIPT_DIR=$xen_scriptdir_path
+ AC_SUBST(XEN_SCRIPT_DIR)
+ 
++dnl Allows .../libexec/lib (used for libfsimage) to have a multiarch path
++AC_ARG_WITH([libexec-libdir-suffix],
++    AS_HELP_STRING([--with-libexec-libdir-suffix=/SUFFIX],
++    [Name of subdirectory or suffix to use after ...LIBEXEC/lib.]),
++    [libexec_libdir_suffix=$withval],
++    [libexec_libdir_suffix=''])
++
+ AC_ARG_WITH([xen-dumpdir],
+     AS_HELP_STRING([--with-xen-dumpdir=DIR],
+     [Path to directory for domU crash dumps. [LOCALSTATEDIR/lib/xen/dump]]),
+@@ -117,7 +124,7 @@ AC_SUBST(LIBEXEC)
+ dnl These variables will be substituted in various .in files
+ LIBEXEC_BIN=${LIBEXEC}/bin
+ AC_SUBST(LIBEXEC_BIN)
+-LIBEXEC_LIB=${LIBEXEC}/lib
++LIBEXEC_LIB=${LIBEXEC}/lib${libexec_libdir_suffix}
+ AC_SUBST(LIBEXEC_LIB)
+ LIBEXEC_INC=${LIBEXEC}/include
+ AC_SUBST(LIBEXEC_INC)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0009-tools-libfsimage-prefix.diff.patch 4.16.1-1/debian/patches/0009-tools-libfsimage-prefix.diff.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0009-tools-libfsimage-prefix.diff.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0009-tools-libfsimage-prefix.diff.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,83 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Mon, 25 May 2020 17:08:18 +0200
-Subject: tools-libfsimage-prefix.diff
-
-\o/
----
- tools/Rules.mk                   |  2 ++
- tools/libfsimage/Rules.mk        |  3 ++-
- tools/libfsimage/common/Makefile | 16 +++++++++-------
- 3 files changed, 13 insertions(+), 8 deletions(-)
-
-diff --git a/tools/Rules.mk b/tools/Rules.mk
-index 6774711..96dfe65 100644
---- a/tools/Rules.mk
-+++ b/tools/Rules.mk
-@@ -11,6 +11,8 @@ INSTALL = $(XEN_ROOT)/tools/cross-install
- 
- LDFLAGS += $(PREPEND_LDFLAGS_XEN_TOOLS)
- 
-+LDFLAGS_RPATH = -Wl,-rpath,'$${ORIGIN}$(if $(1),/$(1))'
-+
- XEN_INCLUDE        = $(XEN_ROOT)/tools/include
- XEN_LIBXENTOOLCORE  = $(XEN_ROOT)/tools/libs/toolcore
- XEN_LIBXENTOOLLOG  = $(XEN_ROOT)/tools/libs/toollog
-diff --git a/tools/libfsimage/Rules.mk b/tools/libfsimage/Rules.mk
-index bb6d42a..38cc539 100644
---- a/tools/libfsimage/Rules.mk
-+++ b/tools/libfsimage/Rules.mk
-@@ -3,10 +3,11 @@ include $(XEN_ROOT)/tools/Rules.mk
- CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
- CFLAGS += -Werror -D_GNU_SOURCE
- LDFLAGS += -L../common/
-+LDFLAGS += $(call LDFLAGS_RPATH,../..)
- 
- PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
- 
--FSDIR = $(libdir)/xenfsimage
-+FSDIR = $(LIBEXEC_LIB)/xenfsimage
- 
- FSLIB = fsimage.so
- 
-diff --git a/tools/libfsimage/common/Makefile b/tools/libfsimage/common/Makefile
-index 8c8ba09..cb5fe56 100644
---- a/tools/libfsimage/common/Makefile
-+++ b/tools/libfsimage/common/Makefile
-@@ -4,6 +4,8 @@ include $(XEN_ROOT)/tools/libfsimage/Rules.mk
- MAJOR = 4.14
- MINOR = 0
- 
-+CFLAGS += -DFSDIR="\"$(LIBEXEC_LIB)/fs\""
-+
- LDFLAGS-$(CONFIG_SunOS) = -Wl,-M -Wl,mapfile-SunOS
- LDFLAGS-$(CONFIG_Linux) = -Wl,mapfile-GNU
- LDFLAGS += $(LDFLAGS-y)
-@@ -22,11 +24,11 @@ all: $(LIB)
- 
- .PHONY: install
- install: all
--	$(INSTALL_DIR) $(DESTDIR)$(libdir)
-+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_LIB)
- 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
--	$(INSTALL_PROG) libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
--	ln -sf libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR)
--	ln -sf libxenfsimage.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenfsimage.so
-+	$(INSTALL_PROG) libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBEXEC_LIB)
-+	ln -sf libxenfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so.$(MAJOR)
-+	ln -sf libxenfsimage.so.$(MAJOR) $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so
- 	$(INSTALL_DATA) xenfsimage.h $(DESTDIR)$(includedir)
- 	$(INSTALL_DATA) xenfsimage_plugin.h $(DESTDIR)$(includedir)
- 	$(INSTALL_DATA) xenfsimage_grub.h $(DESTDIR)$(includedir)
-@@ -36,9 +38,9 @@ uninstall:
- 	rm -f $(DESTDIR)$(includedir)/xenfsimage_grub.h
- 	rm -f $(DESTDIR)$(includedir)/xenfsimage_plugin.h
- 	rm -f $(DESTDIR)$(includedir)/xenfsimage.h
--	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so
--	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR)
--	rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR).$(MINOR)
-+	rm -f $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so
-+	rm -f $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so.$(MAJOR)
-+	rm -f $(DESTDIR)$(LIBEXEC_LIB)/libxenfsimage.so.$(MAJOR).$(MINOR)
- 
- clean distclean::
- 	rm -f $(LIB)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0010-autoconf-Provide-libexec_libdir_suffix.patch 4.16.1-1/debian/patches/0010-autoconf-Provide-libexec_libdir_suffix.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0010-autoconf-Provide-libexec_libdir_suffix.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0010-autoconf-Provide-libexec_libdir_suffix.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,39 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Wed, 3 Oct 2018 16:25:58 +0100
-Subject: autoconf: Provide libexec_libdir_suffix
-
-This is going to be used to put libfsimage.so into a path containing
-the multiarch triplet.
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
----
- m4/paths.m4 | 9 ++++++++-
- 1 file changed, 8 insertions(+), 1 deletion(-)
-
-diff --git a/m4/paths.m4 b/m4/paths.m4
-index 89d3bb8..42b4970 100644
---- a/m4/paths.m4
-+++ b/m4/paths.m4
-@@ -70,6 +70,13 @@ AC_ARG_WITH([libexec-leaf-dir],
-     [libexec_subdir=$withval],
-     [libexec_subdir=$PACKAGE_TARNAME])
- 
-+dnl Allows .../libexec/lib (used for libfsimage) to have a multiarch path
-+AC_ARG_WITH([libexec-libdir-suffix],
-+    AS_HELP_STRING([--with-libexec-libdir-suffix=/SUFFIX],
-+    [Name of subdirectory or suffix to use after ...LIBEXEC/lib.]),
-+    [libexec_libdir_suffix=$withval],
-+    [libexec_libdir_suffix=''])
-+
- AC_ARG_WITH([xen-dumpdir],
-     AS_HELP_STRING([--with-xen-dumpdir=DIR],
-     [Path to directory for domU crash dumps. [LOCALSTATEDIR/lib/xen/dump]]),
-@@ -103,7 +110,7 @@ AC_SUBST(LIBEXEC)
- dnl These variables will be substituted in various .in files
- LIBEXEC_BIN=${LIBEXEC}/bin
- AC_SUBST(LIBEXEC_BIN)
--LIBEXEC_LIB=${LIBEXEC}/lib
-+LIBEXEC_LIB=${LIBEXEC}/lib${libexec_libdir_suffix}
- AC_SUBST(LIBEXEC_LIB)
- LIBEXEC_INC=${LIBEXEC}/include
- AC_SUBST(LIBEXEC_INC)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0010-.gitignore-Add-configure-output-which-we-always-dele.patch 4.16.1-1/debian/patches/0010-.gitignore-Add-configure-output-which-we-always-dele.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0010-.gitignore-Add-configure-output-which-we-always-dele.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0010-.gitignore-Add-configure-output-which-we-always-dele.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,24 @@
+From: Ian Jackson <ian.jackson@citrix.com>
+Date: Fri, 5 Oct 2018 18:05:48 +0100
+Subject: .gitignore: Add configure output which we always delete and
+ regenerate
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+---
+ .gitignore | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/.gitignore b/.gitignore
+index 8ebb51b..aa68745 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -432,3 +432,9 @@ tools/xl/xl
+ docs/txt/misc/*.txt
+ docs/txt/man/*.txt
+ docs/figs/*.png
++
++configure
++docs/configure
++tools/configure
++config.sub
++config.guess
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0011-config-Tools.mk.in-Respect-caller-s-CONFIG_PV_SHIM.patch 4.16.1-1/debian/patches/0011-config-Tools.mk.in-Respect-caller-s-CONFIG_PV_SHIM.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0011-config-Tools.mk.in-Respect-caller-s-CONFIG_PV_SHIM.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0011-config-Tools.mk.in-Respect-caller-s-CONFIG_PV_SHIM.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,26 @@
+From: Ian Jackson <iwj@barriere.debian.org>
+Date: Fri, 12 Oct 2018 16:00:16 +0000
+Subject: config/Tools.mk.in: Respect caller's CONFIG_PV_SHIM
+
+This makes it easier to disable the shim build.  (In Debian we need to
+build the shim separately because it needs different compiler flags).
+
+Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
+[ Hans: adjust from tools/firmware/Makefile to config/Tools.mk.in to
+follow changes that happened in 8845155c83 ("pvshim: make PV shim build
+selectable from configure") ]
+Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
+---
+ config/Tools.mk.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/config/Tools.mk.in b/config/Tools.mk.in
+index 934d899..03313b3 100644
+--- a/config/Tools.mk.in
++++ b/config/Tools.mk.in
+@@ -75,4 +75,4 @@ ARGP_LDFLAGS        := @argp_ldflags@
+ 
+ FILE_OFFSET_BITS    := @FILE_OFFSET_BITS@
+ 
+-CONFIG_PV_SHIM      := @pvshim@
++CONFIG_PV_SHIM      ?= @pvshim@
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0011-.gitignore-Add-configure-output-which-we-always-dele.patch 4.16.1-1/debian/patches/0011-.gitignore-Add-configure-output-which-we-always-dele.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0011-.gitignore-Add-configure-output-which-we-always-dele.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0011-.gitignore-Add-configure-output-which-we-always-dele.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,24 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Fri, 5 Oct 2018 18:05:48 +0100
-Subject: .gitignore: Add configure output which we always delete and
- regenerate
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
----
- .gitignore | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/.gitignore b/.gitignore
-index 36ce2ea..98cb39e 100644
---- a/.gitignore
-+++ b/.gitignore
-@@ -416,3 +416,9 @@ tools/xl/xl
- docs/txt/misc/*.txt
- docs/txt/man/*.txt
- docs/figs/*.png
-+
-+configure
-+docs/configure
-+tools/configure
-+config.sub
-+config.guess
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0012-Revert-pvshim-make-PV-shim-build-selectable-from-con.patch 4.16.1-1/debian/patches/0012-Revert-pvshim-make-PV-shim-build-selectable-from-con.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0012-Revert-pvshim-make-PV-shim-build-selectable-from-con.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0012-Revert-pvshim-make-PV-shim-build-selectable-from-con.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,70 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Sun, 22 Nov 2020 00:40:58 +0100
-Subject: Revert "pvshim: make PV shim build selectable from configure"
-
-This reverts commit 8845155c831c59e867ee3dd31ee63e0cc6c7dcf2.
-
-This upstream change changes stuff that breaks our very fragile mess
-that builds the shim when it needs to, and doesn't when it should not.
-
-The result is that it's missing in the end for the i386 build... :|
-
-    dh_install: warning: Cannot find (any matches for)
-    "usr/lib/debug/usr/lib/xen-*/boot/*" (tried in ., debian/tmp)
-
-    dh_install: warning: xen-utils-4.14 missing files:
-    usr/lib/debug/usr/lib/xen-*/boot/*
-    dh_install: error: missing files, aborting
----
- config/Tools.mk.in      |  2 --
- tools/configure.ac      | 13 -------------
- tools/firmware/Makefile |  4 ++++
- 3 files changed, 4 insertions(+), 15 deletions(-)
-
-diff --git a/config/Tools.mk.in b/config/Tools.mk.in
-index 23df47a..6408e42 100644
---- a/config/Tools.mk.in
-+++ b/config/Tools.mk.in
-@@ -75,5 +75,3 @@ TINFO_LIBS          := @TINFO_LIBS@
- ARGP_LDFLAGS        := @argp_ldflags@
- 
- FILE_OFFSET_BITS    := @FILE_OFFSET_BITS@
--
--CONFIG_PV_SHIM      := @pvshim@
-diff --git a/tools/configure.ac b/tools/configure.ac
-index 9d126b7..88e66d1 100644
---- a/tools/configure.ac
-+++ b/tools/configure.ac
-@@ -503,17 +503,4 @@ AC_ARG_ENABLE([9pfs],
- 
- AC_SUBST(ninepfs)
- 
--AC_ARG_ENABLE([pvshim],
--    AS_HELP_STRING([--disable-pvshim],
--                   [Disable pvshim build (enabled by default on 64bit x86)]),
--    [AS_IF([test "x$enable_pvshim" = "xno"], [pvshim=n], [pvshim=y])], [
--    cpu=`test -z "$target_cpu" && echo "$host_cpu" || echo "$target_cpu"`
--    case "${XEN_COMPILE_ARCH-${XEN_TARGET_ARCH-$cpu}}" in
--        x86_64)
--           pvshim="y";;
--        *) pvshim="n";;
--    esac
--])
--AC_SUBST(pvshim)
--
- AC_OUTPUT()
-diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
-index 809a5fd..cf304fc 100644
---- a/tools/firmware/Makefile
-+++ b/tools/firmware/Makefile
-@@ -1,6 +1,10 @@
- XEN_ROOT = $(CURDIR)/../..
- include $(XEN_ROOT)/tools/Rules.mk
- 
-+ifneq ($(XEN_TARGET_ARCH),x86_32)
-+CONFIG_PV_SHIM := y
-+endif
-+
- # hvmloader is a 32-bit protected mode binary.
- TARGET      := hvmloader/hvmloader
- INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0012-shim-Provide-separate-install-shim-target.patch 4.16.1-1/debian/patches/0012-shim-Provide-separate-install-shim-target.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0012-shim-Provide-separate-install-shim-target.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0012-shim-Provide-separate-install-shim-target.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,78 @@
+From: Ian Jackson <iwj@barriere.debian.org>
+Date: Fri, 12 Oct 2018 17:17:10 +0000
+Subject: shim: Provide separate install-shim target
+
+When building on a 32-bit userland, the user wants to build 32-bit
+tools and a 64-bit hypervisor.  This involves setting XEN_TARGET_ARCH
+to different values for the tools build and the hypervisor build.
+
+So the user must invoke the tools build and the hypervisor build
+separately.
+
+However, although the shim is done by the tools/firmware Makefile, its
+bitness needs to be the same as the hypervisor, not the same as the
+tools.  When run with XEN_TARGET_ARCH=x86_32, it it skipped, which is
+wrong.
+
+So the user must invoke the shim build separately.  This can be done
+with
+   make -C tools/firmware/xen-dir XEN_TARGET_ARCH=x86_64
+
+However, tools/firmware/xen-dir has no `install' target.  The
+installation of all `firmware' is done in tools/firmware/Makefile.  It
+might be possible to fix this, but it is not trivial.  For example,
+the definitions of INST_DIR and DEBG_DIR would need to be copied, as
+would an appropriate $(INSTALL_DIR) call.
+
+For now, provide an `install-shim' target in tools/firmware/Makefile.
+
+This has to be called from `install' of course.  We can't make it
+a dependency of `install' because it might be run before `all' has
+completed.  We could make it depend on a `shim' target but such
+a target is nearly impossible to write because everything is done by
+the inflexible subdir-$@ machinery.
+
+The overally result of this patch is that existing make invocations
+work as before.  But additionally, the user can say
+  make -C tools/firmware install-shim XEN_TARGET_ARCH=x86_64
+to install the shim.  The user must have built it already.
+Unlike the build rune, this install-rune is properly conditional
+so it is OK to call on ARM.
+
+What a mess.
+
+Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
+---
+ tools/firmware/Makefile | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
+index 1f27117..bbfd141 100644
+--- a/tools/firmware/Makefile
++++ b/tools/firmware/Makefile
+@@ -43,6 +43,13 @@ ifeq ($(CONFIG_ROMBIOS),y)
+ endif
+ 	$(MAKE) CC=$(CC) PYTHON=$(PYTHON) subdirs-$@
+ 
++.PHONY: install-shim
++install-shim:
++ifeq ($(CONFIG_PV_SHIM),y)
++	$(INSTALL_DATA) xen-dir/xen-shim $(INST_DIR)/xen-shim
++	$(INSTALL_DATA) xen-dir/xen-shim-syms $(DEBG_DIR)/xen-shim-syms
++endif
++
+ .PHONY: install
+ install: all
+ 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
+@@ -57,10 +64,7 @@ endif
+ ifeq ($(CONFIG_IPXE),y)
+ 	$(INSTALL_DATA) etherboot/ipxe/src/bin/ipxe.bin $(INST_DIR)/ipxe.bin
+ endif
+-ifeq ($(CONFIG_PV_SHIM),y)
+-	$(INSTALL_DATA) xen-dir/xen-shim $(INST_DIR)/xen-shim
+-	$(INSTALL_DATA) xen-dir/xen-shim-syms $(DEBG_DIR)/xen-shim-syms
+-endif
++	$(MAKE) install-shim
+ 
+ .PHONY: uninstall
+ uninstall:
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0013-docs-man-xen-vbd-interface.7-Provide-properly-format.patch 4.16.1-1/debian/patches/0013-docs-man-xen-vbd-interface.7-Provide-properly-format.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0013-docs-man-xen-vbd-interface.7-Provide-properly-format.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0013-docs-man-xen-vbd-interface.7-Provide-properly-format.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,27 @@
+From: Ian Jackson <ian.jackson@citrix.com>
+Date: Fri, 12 Oct 2018 17:56:56 +0100
+Subject: docs/man/xen-vbd-interface.7: Provide properly-formatted NAME
+ section
+
+This manpage was omitted from
+   docs/man: Provide properly-formatted NAME sections
+because I was previously building with markdown not installed.
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+---
+ docs/man/xen-vbd-interface.7.pandoc | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/docs/man/xen-vbd-interface.7.pandoc b/docs/man/xen-vbd-interface.7.pandoc
+index ba0d159..2f18d5b 100644
+--- a/docs/man/xen-vbd-interface.7.pandoc
++++ b/docs/man/xen-vbd-interface.7.pandoc
+@@ -1,3 +1,8 @@
++Name
++----
++
++xen-vbd-interface - Xen paravirtualised block device protocol
++
+ Xen guest interface
+ -------------------
+ 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0013-tools-firmware-Makfile-Respect-caller-s-CONFIG_PV_SH.patch 4.16.1-1/debian/patches/0013-tools-firmware-Makfile-Respect-caller-s-CONFIG_PV_SH.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0013-tools-firmware-Makfile-Respect-caller-s-CONFIG_PV_SH.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0013-tools-firmware-Makfile-Respect-caller-s-CONFIG_PV_SH.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,26 +0,0 @@
-From: Ian Jackson <iwj@barriere.debian.org>
-Date: Fri, 12 Oct 2018 16:00:16 +0000
-Subject: tools/firmware/Makfile: Respect caller's CONFIG_PV_SHIM
-
-This makes it easier to disable the shim build.  (In Debian we need to
-build the shim separately because it needs different compiler flags
-and a different XEN_COMPILE_ARCH.
-
-Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
----
- tools/firmware/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
-index cf304fc..69f63b1 100644
---- a/tools/firmware/Makefile
-+++ b/tools/firmware/Makefile
-@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../..
- include $(XEN_ROOT)/tools/Rules.mk
- 
- ifneq ($(XEN_TARGET_ARCH),x86_32)
--CONFIG_PV_SHIM := y
-+CONFIG_PV_SHIM ?= y
- endif
- 
- # hvmloader is a 32-bit protected mode binary.
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0014-t-h-L-vif-common.sh-disable-handle_iptable.patch 4.16.1-1/debian/patches/0014-t-h-L-vif-common.sh-disable-handle_iptable.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0014-t-h-L-vif-common.sh-disable-handle_iptable.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0014-t-h-L-vif-common.sh-disable-handle_iptable.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,40 @@
+From: Hans van Kranenburg <hans@knorrie.org>
+Date: Fri, 4 Jan 2019 00:35:45 +0100
+Subject: t/h/L/vif-common.sh: disable handle_iptable
+
+Also see Debian bug #894013. The current attempt at providing
+anti-spoofing rules results in a situation that does not have any
+effect. Also note that forwarding bridged traffic to iptables is not
+enabled by default, and that for openvswitch users it does not make any
+sense.
+
+So, stop cluttering the live iptables ruleset.
+
+This functionality seems to be introduced before 2004 and since then it
+has never got some additional love.
+
+It would be nice to have a proper discussion upstream about how Xen
+could provide some anti mac/ip spoofing in the dom0. It does not seem to
+be a trivial thing to do, since it requires having quite some knowledge
+about what the domU is allowed to do or not (e.g. a domU can be a
+router...).
+
+Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
+---
+ tools/hotplug/Linux/vif-common.sh | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/tools/hotplug/Linux/vif-common.sh b/tools/hotplug/Linux/vif-common.sh
+index a8e6517..99ff1ba 100644
+--- a/tools/hotplug/Linux/vif-common.sh
++++ b/tools/hotplug/Linux/vif-common.sh
+@@ -182,6 +182,9 @@ frob_iptable()
+ #
+ handle_iptable()
+ {
++  # This function is disabled in Debian packaging. See Debian bug #894013.
++  return 0
++
+   # Check for a working iptables installation.  Checking for the iptables
+   # binary is not sufficient, because the user may not have the appropriate
+   # modules installed.  If iptables is not working, then there's no need to do
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0014-tools-firmware-Makefile-CONFIG_PV_SHIM-enable-only-o.patch 4.16.1-1/debian/patches/0014-tools-firmware-Makefile-CONFIG_PV_SHIM-enable-only-o.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0014-tools-firmware-Makefile-CONFIG_PV_SHIM-enable-only-o.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0014-tools-firmware-Makefile-CONFIG_PV_SHIM-enable-only-o.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,26 +0,0 @@
-From: Ian Jackson <iwj@amdahl.debian.org>
-Date: Fri, 12 Oct 2018 17:56:04 +0000
-Subject: tools/firmware/Makefile: CONFIG_PV_SHIM: enable only on x86_64
-
-Previously this was *dis*abled for x86_*32*.  But if someone should
-run some of this Makefile on ARM, say, it ought not to be built
-either.
-
-Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
----
- tools/firmware/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
-index 69f63b1..6f9034f 100644
---- a/tools/firmware/Makefile
-+++ b/tools/firmware/Makefile
-@@ -1,7 +1,7 @@
- XEN_ROOT = $(CURDIR)/../..
- include $(XEN_ROOT)/tools/Rules.mk
- 
--ifneq ($(XEN_TARGET_ARCH),x86_32)
-+ifeq ($(XEN_TARGET_ARCH),x86_64)
- CONFIG_PV_SHIM ?= y
- endif
- 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0015-shim-Provide-separate-install-shim-target.patch 4.16.1-1/debian/patches/0015-shim-Provide-separate-install-shim-target.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0015-shim-Provide-separate-install-shim-target.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0015-shim-Provide-separate-install-shim-target.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,78 +0,0 @@
-From: Ian Jackson <iwj@barriere.debian.org>
-Date: Fri, 12 Oct 2018 17:17:10 +0000
-Subject: shim: Provide separate install-shim target
-
-When building on a 32-bit userland, the user wants to build 32-bit
-tools and a 64-bit hypervisor.  This involves setting XEN_TARGET_ARCH
-to different values for the tools build and the hypervisor build.
-
-So the user must invoke the tools build and the hypervisor build
-separately.
-
-However, although the shim is done by the tools/firmware Makefile, its
-bitness needs to be the same as the hypervisor, not the same as the
-tools.  When run with XEN_TARGET_ARCH=x86_32, it it skipped, which is
-wrong.
-
-So the user must invoke the shim build separately.  This can be done
-with
-   make -C tools/firmware/xen-dir XEN_TARGET_ARCH=x86_64
-
-However, tools/firmware/xen-dir has no `install' target.  The
-installation of all `firmware' is done in tools/firmware/Makefile.  It
-might be possible to fix this, but it is not trivial.  For example,
-the definitions of INST_DIR and DEBG_DIR would need to be copied, as
-would an appropriate $(INSTALL_DIR) call.
-
-For now, provide an `install-shim' target in tools/firmware/Makefile.
-
-This has to be called from `install' of course.  We can't make it
-a dependency of `install' because it might be run before `all' has
-completed.  We could make it depend on a `shim' target but such
-a target is nearly impossible to write because everything is done by
-the inflexible subdir-$@ machinery.
-
-The overally result of this patch is that existing make invocations
-work as before.  But additionally, the user can say
-  make -C tools/firmware install-shim XEN_TARGET_ARCH=x86_64
-to install the shim.  The user must have built it already.
-Unlike the build rune, this install-rune is properly conditional
-so it is OK to call on ARM.
-
-What a mess.
-
-Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
----
- tools/firmware/Makefile | 12 ++++++++----
- 1 file changed, 8 insertions(+), 4 deletions(-)
-
-diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
-index 6f9034f..737a709 100644
---- a/tools/firmware/Makefile
-+++ b/tools/firmware/Makefile
-@@ -47,6 +47,13 @@ ifeq ($(CONFIG_ROMBIOS),y)
- endif
- 	$(MAKE) CC=$(CC) PYTHON=$(PYTHON) subdirs-$@
- 
-+.PHONY: install-shim
-+install-shim:
-+ifeq ($(CONFIG_PV_SHIM),y)
-+	$(INSTALL_DATA) xen-dir/xen-shim $(INST_DIR)/xen-shim
-+	$(INSTALL_DATA) xen-dir/xen-shim-syms $(DEBG_DIR)/xen-shim-syms
-+endif
-+
- .PHONY: install
- install: all
- 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
-@@ -61,10 +68,7 @@ endif
- ifeq ($(CONFIG_IPXE),y)
- 	$(INSTALL_DATA) etherboot/ipxe/src/bin/ipxe.bin $(INST_DIR)/ipxe.bin
- endif
--ifeq ($(CONFIG_PV_SHIM),y)
--	$(INSTALL_DATA) xen-dir/xen-shim $(INST_DIR)/xen-shim
--	$(INSTALL_DATA) xen-dir/xen-shim-syms $(DEBG_DIR)/xen-shim-syms
--endif
-+	$(MAKE) install-shim
- 
- .PHONY: uninstall
- uninstall:
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0015-sysconfig.xencommons.in-Strip-and-debianize.patch 4.16.1-1/debian/patches/0015-sysconfig.xencommons.in-Strip-and-debianize.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0015-sysconfig.xencommons.in-Strip-and-debianize.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0015-sysconfig.xencommons.in-Strip-and-debianize.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,130 @@
+From: Hans van Kranenburg <hans@knorrie.org>
+Date: Sat, 9 Feb 2019 17:27:26 +0100
+Subject: sysconfig.xencommons.in: Strip and debianize
+
+Strip all options that are for stuff we don't ship, which is 1)
+xenstored as stubdom and 2) the new options for oom score and open file
+descriptor limit, which would not have any effect, because we're
+shipping different init scripts... :|
+
+It seems useful to give the user the option to revert to xenstored
+instead of the default oxenstored if they really want.
+
+Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
+Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
+---
+ tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 82 +---------------------
+ 1 file changed, 3 insertions(+), 79 deletions(-)
+
+diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+index 433e484..e948543 100644
+--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
++++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+@@ -6,104 +6,28 @@
+ #XENCONSOLED_TRACE=[none|guest|hv|all]
+ 
+ ## Type: string
+-## Default: daemon
++## Default: oxenstored
+ #
+-# Select type of xentore service.
+-#
+-# This can be either of:
+-#  * daemon
+-#  * domain
+-#
+-# Changing this requires a reboot to take effect.
+-#
+-#XENSTORETYPE=daemon
+-
+-## Type: string
+-## Default: xenstored
+-#
+-# Select xenstore implementation, this can be either
+-# of these below.
+-# Only evaluated if XENSTORETYPE is "daemon".
+-#
+-# This can be either of:
++# Select xenstore implementation. This can be either of:
+ #  * @sbindir@/oxenstored
+ #  * @sbindir@/xenstored
+ #
+ # Changing this requires a reboot to take effect.
+ #XENSTORED=@XENSTORED@
+ 
+-## Type: string
+-## Default: unlimited
+-#
+-# Select maximum number of file descriptors xenstored is allowed to have
+-# opened at one time.
+-# For each HVM domain xenstored might need up to 5 open file descriptors,
+-# PVH and PV domains will require up to 3 open file descriptors. Additionally
+-# 20-30 file descriptors will be opened for internal uses.
+-# The specified value (including "unlimited") will be capped by the contents
+-# of /proc/sys/fs/nr_open if existing.
+-# Only evaluated if XENSTORETYPE is "daemon".
+-#XENSTORED_MAX_OPEN_FDS=unlimited
+-
+ ## Type: string
+ ## Default: ""
+ #
+ # Additional commandline arguments to start xenstored,
+ # like "--trace-file @XEN_LOG_DIR@/xenstored-trace.log"
+-# See "@sbindir@/xenstored --help" for possible options.
+-# Only evaluated if XENSTORETYPE is "daemon".
++# See "@sbindir@/oxenstored --help" for possible options.
+ XENSTORED_ARGS=
+ 
+ ## Type: string
+ ## Default: Not defined, tracing off
+ #
+ # Log xenstored messages
+-# Only evaluated if XENSTORETYPE is "daemon".
+ #XENSTORED_TRACE=[yes|on|1]
+ 
+-## Type: integer
+-## Default: 50
+-#
+-# Percentage of dom0 memory size the xenstore daemon can use before the
+-# OOM killer is allowed to kill it.
+-# The specified value is multiplied by -10 and echoed to
+-# /proc/PID/oom_score_adj.
+-#XENSTORED_OOM_MEM_THRESHOLD=50
+-
+-## Type: string
+-## Default: @LIBEXEC@/boot/xenstore-stubdom.gz
+-#
+-# xenstore domain kernel.
+-# Only evaluated if XENSTORETYPE is "domain".
+-#XENSTORE_DOMAIN_KERNEL=@LIBEXEC@/boot/xenstore-stubdom.gz
+-
+-## Type: integer
+-## Default: 8
+-#
+-# xenstore domain memory size in MiB.
+-# Only evaluated if XENSTORETYPE is "domain".
+-#XENSTORE_DOMAIN_SIZE=8
+-
+-## Type: string
+-## Default: not set, no autoballooning of xenstore domain
+-#
+-# Maximum xenstore domain memory size. Can be specified as:
+-# - plain integer value for max size in MiB
+-# - fraction of host memory, e.g. 1/100
+-# - combination of both in form of <val>:<frac> (e.g. 8:1/100), resulting
+-#   value will be the higher of both specifications
+-# Only evaluated if XENSTORETYPE is "domain".
+-#XENSTORE_MAX_DOMAIN_SIZE=
+-
+-## Type: string
+-## Default: ""
+-#
+-# Additional arguments for starting the xenstore domain.
+-# Only evaluated if XENSTORETYPE is "domain".
+-XENSTORE_DOMAIN_ARGS=
+-
+-# qemu path
+-#QEMU_XEN=@qemu_xen_path@
+-
+ # Dom0 UUID
+ #XEN_DOM0_UUID=00000000-0000-0000-0000-000000000000
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0016-docs-man-xen-vbd-interface.7-Provide-properly-format.patch 4.16.1-1/debian/patches/0016-docs-man-xen-vbd-interface.7-Provide-properly-format.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0016-docs-man-xen-vbd-interface.7-Provide-properly-format.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0016-docs-man-xen-vbd-interface.7-Provide-properly-format.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Fri, 12 Oct 2018 17:56:56 +0100
-Subject: docs/man/xen-vbd-interface.7: Provide properly-formatted NAME
- section
-
-This manpage was omitted from
-   docs/man: Provide properly-formatted NAME sections
-because I was previously building with markdown not installed.
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
----
- docs/man/xen-vbd-interface.7.pandoc | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/docs/man/xen-vbd-interface.7.pandoc b/docs/man/xen-vbd-interface.7.pandoc
-index ba0d159..2f18d5b 100644
---- a/docs/man/xen-vbd-interface.7.pandoc
-+++ b/docs/man/xen-vbd-interface.7.pandoc
-@@ -1,3 +1,8 @@
-+Name
-+----
-+
-+xen-vbd-interface - Xen paravirtualised block device protocol
-+
- Xen guest interface
- -------------------
- 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0016-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch 4.16.1-1/debian/patches/0016-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0016-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0016-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,36 @@
+From: Ian Jackson <ian.jackson@citrix.com>
+Date: Thu, 21 Feb 2019 16:05:40 +0000
+Subject: hotplug-common: Do not adjust LD_LIBRARY_PATH
+
+This is in the upstream script because on non-Debian systems, the
+default install locations in /usr/local/lib might not be on the linker
+path, and as a result the hotplug scripts would break.
+
+A reason we might need it in Debian is our multiple version
+coinstallation scheme.  However, the hotplug scripts all call the
+utilities via the wrappers, and the binaries are configured to load
+from the right place anyway.
+
+This setting is an annoyance because it requires libdir, which is an
+arch-specific path but comes from a file we want to put in
+xen-utils-common, an arch:all package.
+
+So drop this setting.
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+---
+ tools/hotplug/Linux/xen-hotplug-common.sh.in | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh.in b/tools/hotplug/Linux/xen-hotplug-common.sh.in
+index 8c2cb9e..72cb7f6 100644
+--- a/tools/hotplug/Linux/xen-hotplug-common.sh.in
++++ b/tools/hotplug/Linux/xen-hotplug-common.sh.in
+@@ -23,7 +23,6 @@ dir=$(dirname "$0")
+ exec 2>>@XEN_LOG_DIR@/xen-hotplug.log
+ 
+ export PATH="${bindir}:${sbindir}:${LIBEXEC_BIN}:/sbin:/bin:/usr/bin:/usr/sbin:$PATH"
+-export LD_LIBRARY_PATH="${libdir}${LD_LIBRARY_PATH+:}$LD_LIBRARY_PATH"
+ export LANG="POSIX"
+ unset $(set | grep ^LC_ | cut -d= -f1)
+ 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0017-Fix-empty-fields-in-first-hypervisor-log-line.patch 4.16.1-1/debian/patches/0017-Fix-empty-fields-in-first-hypervisor-log-line.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0017-Fix-empty-fields-in-first-hypervisor-log-line.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0017-Fix-empty-fields-in-first-hypervisor-log-line.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Thu, 3 Jan 2019 22:03:06 +0100
-Subject: Fix empty fields in first hypervisor log line
-
-Instead of:
-
-    (XEN) Xen version 4.11.1 (Debian )
-    (@)
-    (gcc (Debian 8.2.0-13) 8.2.0) debug=n
-    Thu Jan  3 19:08:37 UTC 2019
-
-I'd like to see:
-
-    (XEN) Xen version 4.11.1 (Debian 4.11.1-1~)
-    (pkg-xen-devel@lists.alioth.debian.org)
-    (gcc (Debian 8.2.0-13) 8.2.0) debug=n
-    Thu Jan  3 22:44:00 CET 2019
-
-The substitution was broken since the great packaging refactoring,
-because the directory in which the build is done changed.
-
-Also, use the Maintainer address from debian/control instead of the most
-recent changelog entry. If someone wants to use the address to ask a
-question, they will end up at the team mailing list, which is better
-than an individual person.
----
- xen/Makefile | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/xen/Makefile b/xen/Makefile
-index b211dbe..9108a40 100644
---- a/xen/Makefile
-+++ b/xen/Makefile
-@@ -394,9 +394,9 @@ include/xen/compile.h: include/xen/compile.h.in
- 	    -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
- 	    -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")!g' \
- 	    -e 's/@@system_distribution@@/$(shell lsb_release -is)/g' \
--	    -e 's/@@system_maintainer_domain@@/$(shell cd ../../../..; dpkg-parsechangelog | sed -ne 's,^Maintainer: .[^<]*<[^@>]*@\([^>]*\)>,\1,p')/g' \
--	    -e 's/@@system_maintainer_local@@/$(shell cd ../../../..; dpkg-parsechangelog | sed -ne 's,^Maintainer: .[^<]*<\([^@>]*\)@.*>,\1,p')/g' \
--	    -e 's/@@system_version@@/$(shell cd ../../../..; dpkg-parsechangelog | awk '/^Version:/ {print $$2}')/g' \
-+	    -e 's/@@system_maintainer_domain@@/$(shell grep Maintainer ../debian/control | sed -ne 's,^Maintainer: .[^<]*<[^@>]*@\([^>]*\)>,\1,p')/g' \
-+	    -e 's/@@system_maintainer_local@@/$(shell grep Maintainer ../debian/control | sed -ne 's,^Maintainer: .[^<]*<\([^@>]*\)@.*>,\1,p')/g' \
-+	    -e 's/@@system_version@@/$(shell cd ..; dpkg-parsechangelog | awk '/^Version:/ {print $$2}')/g' \
- 	    < include/xen/compile.h.in > $@.new
- 	@mv -f $@.new $@
- 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0017-pygrub-Set-sys.path.patch 4.16.1-1/debian/patches/0017-pygrub-Set-sys.path.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0017-pygrub-Set-sys.path.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0017-pygrub-Set-sys.path.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,35 @@
+From: Bastian Blank <waldi@debian.org>
+Date: Sat, 5 Jul 2014 11:47:01 +0200
+Subject: pygrub: Set sys.path
+
+We install libfsimage in a non-standard path for Reasons.
+(See debian/rules.)
+
+This patch was originally part of `tools-pygrub-prefix.diff'
+(eg commit 51657319be54) and included changes to the Makefile to
+change the installation arrangements (we do that part in the rules now
+since that is a lot less prone to conflicts when we update) and to
+shared library rpath (which is now done in a separate patch).
+
+(Commit message rewritten by Ian Jackson.)
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+
+squash! pygrub: Set sys.path and rpath
+---
+ tools/pygrub/src/pygrub | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
+index 8d48cf4..46b394c 100755
+--- a/tools/pygrub/src/pygrub
++++ b/tools/pygrub/src/pygrub
+@@ -22,6 +22,8 @@ import platform
+ import curses, _curses, curses.textpad, curses.ascii
+ import getopt
+ 
++sys.path.insert(1, sys.path[0] + '/../lib/python')
++
+ import xenfsimage
+ import grub.GrubConf
+ import grub.LiloConf
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0018-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch 4.16.1-1/debian/patches/0018-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0018-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0018-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,58 @@
+From: Ian Jackson <ian.jackson@citrix.com>
+Date: Fri, 22 Feb 2019 12:24:35 +0000
+Subject: pygrub: Specify -rpath LIBEXEC_LIB when building fsimage.so
+
+If LIBEXEC_LIB is not on the default linker search path, the python
+fsimage.so module fails to find libfsimage.so.
+
+Add the relevant directory to the rpath explicitly.
+
+(This situation occurs in the Debian package, where
+--with-libexec-libdir is used to put each Xen version's libraries and
+utilities in their own directory, to allow them to be coinstalled.)
+
+Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
+---
+ tools/pygrub/Makefile | 3 ++-
+ tools/pygrub/setup.py | 5 +++++
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/tools/pygrub/Makefile b/tools/pygrub/Makefile
+index 37b2146..17bdd2d 100644
+--- a/tools/pygrub/Makefile
++++ b/tools/pygrub/Makefile
+@@ -10,12 +10,13 @@ INSTALL_LOG = build/installed_files.txt
+ all: build
+ .PHONY: build
+ build:
+-	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py build
++	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py build
+ 
+ .PHONY: install
+ install: all
+ 	$(INSTALL_DIR) $(DESTDIR)/$(bindir)
+ 	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" \
++		LIBEXEC_LIB=$(LIBEXEC_LIB) \
+ 		LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py install \
+ 		--record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
+ 		 --root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
+diff --git a/tools/pygrub/setup.py b/tools/pygrub/setup.py
+index b8f1dc4..91019e9 100644
+--- a/tools/pygrub/setup.py
++++ b/tools/pygrub/setup.py
+@@ -5,10 +5,15 @@ import sys
+ 
+ extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
+ 
++extra_link_args = []
++try: extra_link_args += [ "-Wl,-rpath," + os.environ['LIBEXEC_LIB'] ]
++except KeyError: pass
++
+ XEN_ROOT = "../.."
+ 
+ xenfsimage = Extension("xenfsimage",
+     extra_compile_args = extra_compile_args,
++    extra_link_args = extra_link_args,
+     include_dirs = [ XEN_ROOT + "/tools/libfsimage/common/" ],
+     library_dirs = [ XEN_ROOT + "/tools/libfsimage/common/" ],
+     libraries = ["xenfsimage"],
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0018-vif-common-disable-handle_iptable.patch 4.16.1-1/debian/patches/0018-vif-common-disable-handle_iptable.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0018-vif-common-disable-handle_iptable.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0018-vif-common-disable-handle_iptable.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Fri, 4 Jan 2019 00:35:45 +0100
-Subject: vif-common: disable handle_iptable
-
-Also see Debian bug #894013. The current attempt at providing
-anti-spoofing rules results in a situation that does not have any
-effect. Also note that forwarding bridged traffic to iptables is not
-enabled by default, and that for openvswitch users it does not make any
-sense.
-
-So, stop cluttering the live iptables ruleset.
-
-This functionality seems to be introduced before 2004 and since then it
-has never got some additional love.
-
-It would be nice to have a proper discussion upstream about how Xen
-could provide some anti mac/ip spoofing in the dom0. It does not seem to
-be a trivial thing to do, since it requires having quite some knowledge
-about what the domU is allowed to do or not (e.g. a domU can be a
-router...).
----
- tools/hotplug/Linux/vif-common.sh | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/tools/hotplug/Linux/vif-common.sh b/tools/hotplug/Linux/vif-common.sh
-index a8e6517..14cd44c 100644
---- a/tools/hotplug/Linux/vif-common.sh
-+++ b/tools/hotplug/Linux/vif-common.sh
-@@ -182,6 +182,9 @@ frob_iptable()
- #
- handle_iptable()
- {
-+  # This function is disabled in Debian packaging. See Debian bug #894013.
-+  return
-+
-   # Check for a working iptables installation.  Checking for the iptables
-   # binary is not sufficient, because the user may not have the appropriate
-   # modules installed.  If iptables is not working, then there's no need to do
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0019-sysconfig.xencommons.in-Strip-and-debianize.patch 4.16.1-1/debian/patches/0019-sysconfig.xencommons.in-Strip-and-debianize.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0019-sysconfig.xencommons.in-Strip-and-debianize.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0019-sysconfig.xencommons.in-Strip-and-debianize.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,118 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Sat, 9 Feb 2019 17:27:26 +0100
-Subject: sysconfig.xencommons.in: Strip and debianize
-
-Strip all options that are for stuff we don't ship, which is 1)
-xenstored as stubdom and 2) xenbackendd, which seems to be dead code
-anyway. [1]
-
-It seems useful to give the user the option to revert to xenstored
-instead of the default oxenstored if they really want.
-
-[1] https://lists.xen.org/archives/html/xen-devel/2015-07/msg04427.html
-
-Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
-Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
----
- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 73 +---------------------
- 1 file changed, 3 insertions(+), 70 deletions(-)
-
-diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
-index 0fc6557..e948543 100644
---- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
-+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
-@@ -6,26 +6,9 @@
- #XENCONSOLED_TRACE=[none|guest|hv|all]
- 
- ## Type: string
--## Default: daemon
-+## Default: oxenstored
- #
--# Select type of xentore service.
--#
--# This can be either of:
--#  * daemon
--#  * domain
--#
--# Changing this requires a reboot to take effect.
--#
--#XENSTORETYPE=daemon
--
--## Type: string
--## Default: xenstored
--#
--# Select xenstore implementation, this can be either
--# of these below.
--# Only evaluated if XENSTORETYPE is "daemon".
--#
--# This can be either of:
-+# Select xenstore implementation. This can be either of:
- #  * @sbindir@/oxenstored
- #  * @sbindir@/xenstored
- #
-@@ -37,64 +20,14 @@
- #
- # Additional commandline arguments to start xenstored,
- # like "--trace-file @XEN_LOG_DIR@/xenstored-trace.log"
--# See "@sbindir@/xenstored --help" for possible options.
--# Only evaluated if XENSTORETYPE is "daemon".
-+# See "@sbindir@/oxenstored --help" for possible options.
- XENSTORED_ARGS=
- 
- ## Type: string
- ## Default: Not defined, tracing off
- #
- # Log xenstored messages
--# Only evaluated if XENSTORETYPE is "daemon".
- #XENSTORED_TRACE=[yes|on|1]
- 
--## Type: string
--## Default: "@XEN_LIB_STORED@"
--#
--# Running xenstored on XENSTORED_ROOTDIR
--# Only evaluated if XENSTORETYPE is "daemon".
--#XENSTORED_ROOTDIR=@XEN_LIB_STORED@
--
--## Type: string
--## Default: @LIBEXEC@/boot/xenstore-stubdom.gz
--#
--# xenstore domain kernel.
--# Only evaluated if XENSTORETYPE is "domain".
--#XENSTORE_DOMAIN_KERNEL=@LIBEXEC@/boot/xenstore-stubdom.gz
--
--## Type: integer
--## Default: 8
--#
--# xenstore domain memory size in MiB.
--# Only evaluated if XENSTORETYPE is "domain".
--#XENSTORE_DOMAIN_SIZE=8
--
--## Type: string
--## Default: not set, no autoballooning of xenstore domain
--#
--# Maximum xenstore domain memory size. Can be specified as:
--# - plain integer value for max size in MiB
--# - fraction of host memory, e.g. 1/100
--# - combination of both in form of <val>:<frac> (e.g. 8:1/100), resulting
--#   value will be the higher of both specifications
--# Only evaluated if XENSTORETYPE is "domain".
--#XENSTORE_MAX_DOMAIN_SIZE=
--
--## Type: string
--## Default: ""
--#
--# Additional arguments for starting the xenstore domain.
--# Only evaluated if XENSTORETYPE is "domain".
--XENSTORE_DOMAIN_ARGS=
--
--## Type: string
--## Default: Not defined, xenbackendd debug mode off
--#
--# Running xenbackendd in debug mode
--#XENBACKENDD_DEBUG=[yes|on|1]
--
--# qemu path
--#QEMU_XEN=@qemu_xen_path@
--
- # Dom0 UUID
- #XEN_DOM0_UUID=00000000-0000-0000-0000-000000000000
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0019-tools-xl-bash-completion-also-complete-xen.patch 4.16.1-1/debian/patches/0019-tools-xl-bash-completion-also-complete-xen.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0019-tools-xl-bash-completion-also-complete-xen.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0019-tools-xl-bash-completion-also-complete-xen.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,27 @@
+From: Hans van Kranenburg <hans@knorrie.org>
+Date: Sun, 10 Feb 2019 18:26:45 +0100
+Subject: tools/xl/bash-completion: also complete 'xen'
+
+We have the `xen` alias for xl in Debian, since in the past it was a
+command that could execute either xl or xm.
+
+Now, it always does xl, so, complete the same stuff for it as we have
+for xl.
+
+Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
+
+[git-debrebase split: mixed commit: upstream part]
+---
+ tools/xl/bash-completion | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/xl/bash-completion b/tools/xl/bash-completion
+index 7c6ed32..b3883df 100644
+--- a/tools/xl/bash-completion
++++ b/tools/xl/bash-completion
+@@ -17,4 +17,4 @@ _xl()
+ 	return 0
+ }
+ 
+-complete -F _xl -o nospace -o default xl
++complete -F _xl -o nospace -o default xl xen
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0020-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch 4.16.1-1/debian/patches/0020-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0020-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0020-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Thu, 21 Feb 2019 16:05:40 +0000
-Subject: hotplug-common: Do not adjust LD_LIBRARY_PATH
-
-This is in the upstream script because on non-Debian systems, the
-default install locations in /usr/local/lib might not be on the linker
-path, and as a result the hotplug scripts would break.
-
-A reason we might need it in Debian is our multiple version
-coinstallation scheme.  However, the hotplug scripts all call the
-utilities via the wrappers, and the binaries are configured to load
-from the right place anyway.
-
-This setting is an annoyance because it requires libdir, which is an
-arch-specific path but comes from a file we want to put in
-xen-utils-common, an arch:all package.
-
-So drop this setting.
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
----
- tools/hotplug/Linux/xen-hotplug-common.sh.in | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh.in b/tools/hotplug/Linux/xen-hotplug-common.sh.in
-index 8c2cb9e..72cb7f6 100644
---- a/tools/hotplug/Linux/xen-hotplug-common.sh.in
-+++ b/tools/hotplug/Linux/xen-hotplug-common.sh.in
-@@ -23,7 +23,6 @@ dir=$(dirname "$0")
- exec 2>>@XEN_LOG_DIR@/xen-hotplug.log
- 
- export PATH="${bindir}:${sbindir}:${LIBEXEC_BIN}:/sbin:/bin:/usr/bin:/usr/sbin:$PATH"
--export LD_LIBRARY_PATH="${libdir}${LD_LIBRARY_PATH+:}$LD_LIBRARY_PATH"
- export LANG="POSIX"
- unset $(set | grep ^LC_ | cut -d= -f1)
- 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0020-tools-don-t-build-ship-xenmon.patch 4.16.1-1/debian/patches/0020-tools-don-t-build-ship-xenmon.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0020-tools-don-t-build-ship-xenmon.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0020-tools-don-t-build-ship-xenmon.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,29 @@
+From: Hans van Kranenburg <hans@knorrie.org>
+Date: Sat, 5 Sep 2020 22:43:19 +0200
+Subject: tools: don't build/ship xenmon
+
+This is something that hasn't been touched (except for making it Python
+3 compatible, which failed) since 2007. Don't build or ship it.
+
+    -# xenmon
+      File "/usr/sbin/xenmon", line 680
+	stop_cmd = "/usr/bin/pkill -INT -z global xenbaked"
+    TabError: inconsistent use of tabs and spaces in indentation
+
+Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
+---
+ tools/Makefile | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/tools/Makefile b/tools/Makefile
+index 757a560..20df647 100644
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -16,7 +16,6 @@ SUBDIRS-y += xentrace
+ SUBDIRS-$(CONFIG_XCUTILS) += xcutils
+ SUBDIRS-$(CONFIG_X86) += firmware
+ SUBDIRS-y += console
+-SUBDIRS-y += xenmon
+ SUBDIRS-y += xentop
+ SUBDIRS-y += libfsimage
+ SUBDIRS-$(CONFIG_Linux) += vchan
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0021-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch 4.16.1-1/debian/patches/0021-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0021-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0021-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,39 @@
+From: Maximilian Engelhardt <maxi@daemonizer.de>
+Date: Fri, 18 Dec 2020 21:42:35 +0100
+Subject: docs: set date to SOURCE_DATE_EPOCH if available
+
+Use the solution described in [1] to replace the call to the 'date'
+command with a version that uses SOURCE_DATE_EPOCH if available. This
+is needed for reproducible builds.
+
+[1] https://reproducible-builds.org/docs/source-date-epoch/
+
+Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
+
+[Hans van Kranenburg]
+Note: this patch is submitted upstream but not committed yet. We
+expect that it gets in. Otherwise, we don't wait and already have it
+here because I want to have the reproducible build work completed.
+---
+ docs/Makefile | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/docs/Makefile b/docs/Makefile
+index 8de1efb..ac6792f 100644
+--- a/docs/Makefile
++++ b/docs/Makefile
+@@ -3,7 +3,13 @@ include $(XEN_ROOT)/Config.mk
+ -include $(XEN_ROOT)/config/Docs.mk
+ 
+ VERSION		:= $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion)
+-DATE		:= $(shell date +%Y-%m-%d)
++
++DATE_FMT	:= +%Y-%m-%d
++ifdef SOURCE_DATE_EPOCH
++DATE		:= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
++else
++DATE		:= $(shell date "$(DATE_FMT)")
++endif
+ 
+ DOC_ARCHES      := arm x86_32 x86_64
+ MAN_SECTIONS    := 1 5 7 8
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0021-pygrub-Set-sys.path.patch 4.16.1-1/debian/patches/0021-pygrub-Set-sys.path.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0021-pygrub-Set-sys.path.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0021-pygrub-Set-sys.path.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-From: Bastian Blank <waldi@debian.org>
-Date: Sat, 5 Jul 2014 11:47:01 +0200
-Subject: pygrub: Set sys.path
-
-We install libfsimage in a non-standard path for Reasons.
-(See debian/rules.)
-
-This patch was originally part of `tools-pygrub-prefix.diff'
-(eg commit 51657319be54) and included changes to the Makefile to
-change the installation arrangements (we do that part in the rules now
-since that is a lot less prone to conflicts when we update) and to
-shared library rpath (which is now done in a separate patch).
-
-(Commit message rewritten by Ian Jackson.)
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
-
-squash! pygrub: Set sys.path and rpath
----
- tools/pygrub/src/pygrub | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
-index 8d48cf4..46b394c 100755
---- a/tools/pygrub/src/pygrub
-+++ b/tools/pygrub/src/pygrub
-@@ -22,6 +22,8 @@ import platform
- import curses, _curses, curses.textpad, curses.ascii
- import getopt
- 
-+sys.path.insert(1, sys.path[0] + '/../lib/python')
-+
- import xenfsimage
- import grub.GrubConf
- import grub.LiloConf
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0022-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch 4.16.1-1/debian/patches/0022-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0022-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0022-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,59 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Fri, 22 Feb 2019 12:24:35 +0000
-Subject: pygrub: Specify -rpath LIBEXEC_LIB when building fsimage.so
-
-If LIBEXEC_LIB is not on the default linker search path, the python
-fsimage.so module fails to find libfsimage.so.
-
-Add the relevant directory to the rpath explicitly.
-
-(This situation occurs in the Debian package, where
---with-libexec-libdir is used to put each Xen version's libraries and
-utilities in their own directory, to allow them to be coinstalled.)
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
----
- tools/pygrub/Makefile | 5 +++--
- tools/pygrub/setup.py | 5 +++++
- 2 files changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/tools/pygrub/Makefile b/tools/pygrub/Makefile
-index 3063c49..4cd1a95 100644
---- a/tools/pygrub/Makefile
-+++ b/tools/pygrub/Makefile
-@@ -10,12 +10,13 @@ INSTALL_LOG = build/installed_files.txt
- all: build
- .PHONY: build
- build:
--	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py build
-+	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py build
- 
- .PHONY: install
- install: all
- 	$(INSTALL_DIR) $(DESTDIR)/$(bindir)
--	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) \
-+	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" \
-+		LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) \
- 		setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
- 		 --root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
- 	set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
-diff --git a/tools/pygrub/setup.py b/tools/pygrub/setup.py
-index b8f1dc4..91019e9 100644
---- a/tools/pygrub/setup.py
-+++ b/tools/pygrub/setup.py
-@@ -5,10 +5,15 @@ import sys
- 
- extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
- 
-+extra_link_args = []
-+try: extra_link_args += [ "-Wl,-rpath," + os.environ['LIBEXEC_LIB'] ]
-+except KeyError: pass
-+
- XEN_ROOT = "../.."
- 
- xenfsimage = Extension("xenfsimage",
-     extra_compile_args = extra_compile_args,
-+    extra_link_args = extra_link_args,
-     include_dirs = [ XEN_ROOT + "/tools/libfsimage/common/" ],
-     library_dirs = [ XEN_ROOT + "/tools/libfsimage/common/" ],
-     libraries = ["xenfsimage"],
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0022-xen-arch-x86-make-objdump-output-user-locale-agnosti.patch 4.16.1-1/debian/patches/0022-xen-arch-x86-make-objdump-output-user-locale-agnosti.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0022-xen-arch-x86-make-objdump-output-user-locale-agnosti.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0022-xen-arch-x86-make-objdump-output-user-locale-agnosti.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,27 @@
+From: Maximilian Engelhardt <maxi@daemonizer.de>
+Date: Fri, 10 Dec 2021 00:23:30 +0100
+Subject: xen/arch/x86: make objdump output user locale agnostic
+
+The objdump output is fed to grep, so make sure it doesn't change with
+different user locales and break the grep parsing.
+This problem was identified while updating xen in Debian and the fix is
+needed for generating reproducible builds in varying environments.
+
+Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
+---
+ xen/arch/x86/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
+index 69b6cfa..bd35423 100644
+--- a/xen/arch/x86/Makefile
++++ b/xen/arch/x86/Makefile
+@@ -139,7 +139,7 @@ endif
+ ifeq ($(XEN_BUILD_PE),y)
+ 
+ # Check if the linker produces fixups in PE by default
+-nr-fixups := $(shell $(OBJDUMP) -p efi/check.efi | grep '^[[:blank:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l)
++nr-fixups := $(shell LC_ALL=C $(OBJDUMP) -p efi/check.efi | grep '^[[:blank:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l)
+ ifeq ($(nr-fixups),2)
+ MKRELOC := :
+ relocs-dummy :=
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0023-give-meaningful-error-message-if-qemu-device-model-i.patch 4.16.1-1/debian/patches/0023-give-meaningful-error-message-if-qemu-device-model-i.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0023-give-meaningful-error-message-if-qemu-device-model-i.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0023-give-meaningful-error-message-if-qemu-device-model-i.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,47 @@
+From: Michael Tokarev <mjt@tls.msk.ru>
+Date: Sun, 24 Apr 2022 12:26:38 +0300
+Subject: give meaningful error message if qemu device model is unavailable
+
+There's no sense to switch to qemu-xen-traditional device model
+if that one is not enabled in the first place. This way we'll
+have a chance later to print a message suggesting to install the
+missing qemu package if we *actually* need qemu for the device model.
+---
+ tools/libs/light/libxl_create.c | 2 ++
+ tools/libs/light/libxl_dm.c     | 3 +++
+ 2 files changed, 5 insertions(+)
+
+diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
+index 8856755..54ded26 100644
+--- a/tools/libs/light/libxl_create.c
++++ b/tools/libs/light/libxl_create.c
+@@ -109,6 +109,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
+             b_info->device_model_version =
+                 LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
+         }
++#if HAVE_QEMU_TRADITIONAL
+         if (b_info->device_model_version
+                 == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
+             const char *dm;
+@@ -128,6 +129,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
+                 }
+             }
+         }
++#endif
+     }
+ 
+     if (b_info->blkdev_start == NULL)
+diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
+index 1864ee3..2229751 100644
+--- a/tools/libs/light/libxl_dm.c
++++ b/tools/libs/light/libxl_dm.c
+@@ -2880,6 +2880,9 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
+     }
+     if (access(dm, X_OK) < 0) {
+         LOGED(ERROR, domid, "device model %s is not executable", dm);
++        if (strcmp(dm, QEMU_XEN_PATH) == 0) {
++           LOGD(ERROR, domid, "Please install the qemu-system-xen package for this domain to work");
++        }
+         rc = ERROR_FAIL;
+         goto out;
+     }
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0023-tools-xl-bash-completion-also-complete-xen.patch 4.16.1-1/debian/patches/0023-tools-xl-bash-completion-also-complete-xen.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0023-tools-xl-bash-completion-also-complete-xen.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0023-tools-xl-bash-completion-also-complete-xen.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Sun, 10 Feb 2019 18:26:45 +0100
-Subject: tools/xl/bash-completion: also complete 'xen'
-
-We have the `xen` alias for xl in Debian, since in the past it was a
-command that could execute either xl or xm.
-
-Now, it always does xl, so, complete the same stuff for it as we have
-for xl.
-
-Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
-
-[git-debrebase split: mixed commit: upstream part]
----
- tools/xl/bash-completion | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/tools/xl/bash-completion b/tools/xl/bash-completion
-index b7cd6b3..a520b07 100644
---- a/tools/xl/bash-completion
-+++ b/tools/xl/bash-completion
-@@ -17,4 +17,4 @@ _xl()
- 	return 0
- }
- 
--complete -F _xl -o nospace -o default xl
-+complete -F _xl -o nospace -o default xl xen
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0024-libxl-Fix-unneededly-rebuilding-build.o-pic.patch 4.16.1-1/debian/patches/0024-libxl-Fix-unneededly-rebuilding-build.o-pic.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0024-libxl-Fix-unneededly-rebuilding-build.o-pic.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/patches/0024-libxl-Fix-unneededly-rebuilding-build.o-pic.patch	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,106 @@
+From: Hans van Kranenburg <hans@knorrie.org>
+Date: Thu, 5 May 2022 19:44:29 +0200
+Subject: libxl: Fix unneededly rebuilding build.o(pic)
+
+[The symptoms]
+
+When doing a Xen package build for Debian with ccache enabled, we
+started getting the following error:
+
+    x86_64-linux-gnu-gcc [...] -o build.o
+    /builds/xen-team/debian-xen/debian/output/source_dir/tools/libs/light/../../../tools/libacpi/build.c
+    ccache: error: Failed to create temporary file for
+    /run/user/0/ccache-tmp/tmp.cpp_stdout.bqxKOP: Permission denied
+
+It turns out to be the case that during the install step of tools (the
+install-tools that happens inside the override_dh_auto_install part of
+d/rules), the upstream build machinery *again* tries to build this
+build.c file, while this has already been done earlier during the actual
+build phase.
+
+Since the Debian build process stopped to allow usage of ccache during
+the install phase of the process, this issue surfaces.
+
+[The cause]
+
+In tools/libs/light/Makefile, we see the following lines:
+
+    .PHONY: acpi
+    acpi:
+        $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES-y)"
+
+    [...]
+
+    $(DSDT_FILES-y) build.o build.opic: acpi
+
+'acpi' is defined as phony target. In the last line, we see that build.o
+depdends on acpi.
+
+Also see:
+    "4.6 Phony Targets"
+    https://www.gnu.org/software/make/manual/make.html#Phony-Targets
+
+A 'normal' target gives make the possibility to track timestamps of a
+target file. E.g. compiling foo.c results in foo.o, and as long as foo.c
+keeps being 'older' than foo.o, make will think "nothing to do here,
+foo.o is up to date, let's move along".
+
+Now, a phony target is some kind of fake target that does not come with
+this kind of information, and such behaves like a target that is always
+out-of-date. Hence, with a configuration as seen above, it will try to
+always unneededly build this build.o and build.opic again.
+
+[Discussion]
+
+Upstream commit e006b2e3be ("libxl: fix libacpi dependency") which
+introduced the problem tells us that the purpose of the current
+configuration is to make sure the libacpi/ dir is built before we
+attempt to work on build.c in here. The changes in there remove an
+apparently obsolete line referencing build.o from the libacpi Makefile,
+which might mean that in the past this build.* stuff was located in that
+part of the code, and was moved into libs/light later.
+
+[The fix]
+
+If it is enough to just have an order-only dependency, we can use an
+order-only prerequisite instead, in this place:
+
+    $(DSDT_FILES-y): acpi
+    build.o build.opic: | acpi
+
+Also see:
+    "4.3 Types of Prerequisites"
+    https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types
+
+Now the build machinery will not attempt to unconditionally rebuild
+build.o during make install.
+
+[Suggestions for further work]
+
+As can be seen, there's still the $(DSDT_FILES-y) which has the same
+acpi dependency and which may lead to similar unwanted side effects.
+However, since none of the files in that list have a corresponding build
+target in *this* Makefile, it does not trigger the problem for us, and
+we leave it alone, for now.
+
+Suggested-by: Michael Tokarev <mjt@tls.msk.ru>
+Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
+Fixes: e006b2e3be ("libxl: fix libacpi dependency")
+---
+ tools/libs/light/Makefile | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
+index dd43f37..3458c44 100644
+--- a/tools/libs/light/Makefile
++++ b/tools/libs/light/Makefile
+@@ -32,7 +32,8 @@ ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
+ DSDT_FILES-$(CONFIG_X86) = dsdt_pvh.c
+ ACPI_OBJS  = $(patsubst %.c,%.o,$(DSDT_FILES-y)) build.o static_tables.o
+ ACPI_PIC_OBJS = $(patsubst %.o,%.opic,$(ACPI_OBJS))
+-$(DSDT_FILES-y) build.o build.opic: acpi
++$(DSDT_FILES-y): acpi
++build.o build.opic: | acpi
+ vpath build.c $(ACPI_PATH)/
+ vpath static_tables.c $(ACPI_PATH)/
+ 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0024-tools-don-t-build-ship-xenmon.patch 4.16.1-1/debian/patches/0024-tools-don-t-build-ship-xenmon.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0024-tools-don-t-build-ship-xenmon.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0024-tools-don-t-build-ship-xenmon.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Sat, 5 Sep 2020 22:43:19 +0200
-Subject: tools: don't build/ship xenmon
-
-It can't run with Python 3, and I'm not going to fix it.
-
-Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
----
- tools/Makefile | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/tools/Makefile b/tools/Makefile
-index c10946e..c5a6f5c 100644
---- a/tools/Makefile
-+++ b/tools/Makefile
-@@ -17,7 +17,6 @@ SUBDIRS-y += xentrace
- SUBDIRS-$(CONFIG_XCUTILS) += xcutils
- SUBDIRS-$(CONFIG_X86) += firmware
- SUBDIRS-y += console
--SUBDIRS-y += xenmon
- SUBDIRS-y += xenstat
- SUBDIRS-$(CONFIG_NetBSD) += xenbackendd
- SUBDIRS-y += libfsimage
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0025-tools-Partially-revert-Cross-compilation-fixes.patch 4.16.1-1/debian/patches/0025-tools-Partially-revert-Cross-compilation-fixes.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0025-tools-Partially-revert-Cross-compilation-fixes.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0025-tools-Partially-revert-Cross-compilation-fixes.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-From: Elliott Mitchell <ehem+xen@m5p.com>
-Date: Fri, 17 Jul 2020 20:31:21 -0700
-Subject: tools: Partially revert "Cross-compilation fixes."
-
-This partially reverts commit 16504669c5cbb8b195d20412aadc838da5c428f7.
-
-Doesn't look like much of 16504669c5cbb8b195d20412aadc838da5c428f7
-actually remains due to passage of time.
-
-Of the 3, both Python and pygrub appear to mostly be building just fine
-cross-compiling.  The OCAML portion is being troublesome, this is going
-to cause bug reports elsewhere soon.  The OCAML portion though can
-already be disabled by setting OCAML_TOOLS=n and shouldn't have this
-extra form of disabling.
-
-Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
-Acked-by: Christian Lindig <christian.lindig@citrix.com>
-Acked-by: Wei Liu <wl@xen.org>
-(cherry picked from commit 69953e2856382274749b617125cc98ce38198463)
----
- tools/Makefile | 3 ---
- 1 file changed, 3 deletions(-)
-
-diff --git a/tools/Makefile b/tools/Makefile
-index c5a6f5c..e8d6022 100644
---- a/tools/Makefile
-+++ b/tools/Makefile
-@@ -38,12 +38,9 @@ SUBDIRS-$(CONFIG_X86) += debugger/gdbsx
- SUBDIRS-$(CONFIG_X86) += debugger/kdd
- SUBDIRS-$(CONFIG_TESTS) += tests
- 
--# These don't cross-compile
--ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
- SUBDIRS-y += python
- SUBDIRS-y += pygrub
- SUBDIRS-$(OCAML_TOOLS) += ocaml
--endif
- 
- ifeq ($(CONFIG_RUMP),y)
- SUBDIRS-y := libs libxc xenstore
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0026-t-h-L-vif-common.sh-fix-handle_iptable-return-value.patch 4.16.1-1/debian/patches/0026-t-h-L-vif-common.sh-fix-handle_iptable-return-value.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0026-t-h-L-vif-common.sh-fix-handle_iptable-return-value.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0026-t-h-L-vif-common.sh-fix-handle_iptable-return-value.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,30 +0,0 @@
-From: Hans van Kranenburg <hans@knorrie.org>
-Date: Thu, 26 Nov 2020 16:06:03 +0100
-Subject: t/h/L/vif-common.sh: fix handle_iptable return value
-
-A return statement without explicit value will return the value of the
-last command executed before this line with return was encountered.
-
-This is not what we want. return 0.
-
-Closes: #955994
-Fixes: 2e0814f971dd ("vif-common: disable handle_iptable")
-Reported-by: Samuel Thibault <sthibault@debian.org>
-Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
----
- tools/hotplug/Linux/vif-common.sh | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/tools/hotplug/Linux/vif-common.sh b/tools/hotplug/Linux/vif-common.sh
-index 14cd44c..99ff1ba 100644
---- a/tools/hotplug/Linux/vif-common.sh
-+++ b/tools/hotplug/Linux/vif-common.sh
-@@ -183,7 +183,7 @@ frob_iptable()
- handle_iptable()
- {
-   # This function is disabled in Debian packaging. See Debian bug #894013.
--  return
-+  return 0
- 
-   # Check for a working iptables installation.  Checking for the iptables
-   # binary is not sufficient, because the user may not have the appropriate
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0027-xen-rpi4-implement-watchdog-based-reset.patch 4.16.1-1/debian/patches/0027-xen-rpi4-implement-watchdog-based-reset.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0027-xen-rpi4-implement-watchdog-based-reset.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0027-xen-rpi4-implement-watchdog-based-reset.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,105 +0,0 @@
-From: Stefano Stabellini <sstabellini@kernel.org>
-Date: Fri, 2 Oct 2020 13:47:17 -0700
-Subject: xen/rpi4: implement watchdog-based reset
-
-The preferred method to reboot RPi4 is PSCI. If it is not available,
-touching the watchdog is required to be able to reboot the board.
-
-The implementation is based on
-drivers/watchdog/bcm2835_wdt.c:__bcm2835_restart in Linux v5.9-rc7.
-
-Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
-Acked-by: Julien Grall <jgrall@amazon.com>
-Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
-Tested-by: Roman Shaposhnik <roman@zededa.com>
-CC: roman@zededa.com
-(cherry picked from commit 25849c8b16f2a5b7fcd0a823e80a5f1b590291f9)
----
- xen/arch/arm/platforms/brcm-raspberry-pi.c | 61 ++++++++++++++++++++++++++++++
- 1 file changed, 61 insertions(+)
-
-diff --git a/xen/arch/arm/platforms/brcm-raspberry-pi.c b/xen/arch/arm/platforms/brcm-raspberry-pi.c
-index f5ae58a..811b40b 100644
---- a/xen/arch/arm/platforms/brcm-raspberry-pi.c
-+++ b/xen/arch/arm/platforms/brcm-raspberry-pi.c
-@@ -17,6 +17,10 @@
-  * GNU General Public License for more details.
-  */
- 
-+#include <xen/delay.h>
-+#include <xen/mm.h>
-+#include <xen/vmap.h>
-+#include <asm/io.h>
- #include <asm/platform.h>
- 
- static const char *const rpi4_dt_compat[] __initconst =
-@@ -37,12 +41,69 @@ static const struct dt_device_match rpi4_blacklist_dev[] __initconst =
-      * The aux peripheral also shares a page with the aux UART.
-      */
-     DT_MATCH_COMPATIBLE("brcm,bcm2835-aux"),
-+    /* Special device used for rebooting */
-+    DT_MATCH_COMPATIBLE("brcm,bcm2835-pm"),
-     { /* sentinel */ },
- };
- 
-+
-+#define PM_PASSWORD                 0x5a000000
-+#define PM_RSTC                     0x1c
-+#define PM_WDOG                     0x24
-+#define PM_RSTC_WRCFG_FULL_RESET    0x00000020
-+#define PM_RSTC_WRCFG_CLR           0xffffffcf
-+
-+static void __iomem *rpi4_map_watchdog(void)
-+{
-+    void __iomem *base;
-+    struct dt_device_node *node;
-+    paddr_t start, len;
-+    int ret;
-+
-+    node = dt_find_compatible_node(NULL, NULL, "brcm,bcm2835-pm");
-+    if ( !node )
-+        return NULL;
-+
-+    ret = dt_device_get_address(node, 0, &start, &len);
-+    if ( ret )
-+    {
-+        printk("Cannot read watchdog register address\n");
-+        return NULL;
-+    }
-+
-+    base = ioremap_nocache(start & PAGE_MASK, PAGE_SIZE);
-+    if ( !base )
-+    {
-+        printk("Unable to map watchdog register!\n");
-+        return NULL;
-+    }
-+
-+    return base;
-+}
-+
-+static void rpi4_reset(void)
-+{
-+    uint32_t val;
-+    void __iomem *base = rpi4_map_watchdog();
-+
-+    if ( !base )
-+        return;
-+
-+    /* use a timeout of 10 ticks (~150us) */
-+    writel(10 | PM_PASSWORD, base + PM_WDOG);
-+    val = readl(base + PM_RSTC);
-+    val &= PM_RSTC_WRCFG_CLR;
-+    val |= PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET;
-+    writel(val, base + PM_RSTC);
-+
-+    /* No sleeping, possibly atomic. */
-+    mdelay(1);
-+}
-+
- PLATFORM_START(rpi4, "Raspberry Pi 4")
-     .compatible     = rpi4_dt_compat,
-     .blacklist_dev  = rpi4_blacklist_dev,
-+    .reset = rpi4_reset,
-     .dma_bitsize    = 30,
- PLATFORM_END
- 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0028-tools-python-Pass-linker-to-Python-build-process.patch 4.16.1-1/debian/patches/0028-tools-python-Pass-linker-to-Python-build-process.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0028-tools-python-Pass-linker-to-Python-build-process.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0028-tools-python-Pass-linker-to-Python-build-process.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,91 +0,0 @@
-From: Elliott Mitchell <ehem+xen@m5p.com>
-Date: Sun, 11 Oct 2020 18:11:39 -0700
-Subject: tools/python: Pass linker to Python build process
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Unexpectedly the environment variable which needs to be passed is
-$LDSHARED and not $LD.  Otherwise Python may find the build `ld` instead
-of the host `ld`.
-
-Replace $(LDFLAGS) with $(SHLIB_LDFLAGS) as Python needs shared objects
-it can load at runtime, not executables.
-
-This uses $(CC) instead of $(LD) since Python distutils appends $CFLAGS
-to $LDFLAGS which breaks many linkers.
-
-Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
-Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
-(cherry picked from commit 17d192e0238d6c714e9f04593b59597b7090be38)
-
-[ Hans van Kranenburg ]
-Fixed cherry-pick conflict because we have LIBEXEC_LIB=$(LIBEXEC_LIB) in
-between in the same lines. The line wrap mess makes it a bit hard to
-follow.
----
- tools/pygrub/Makefile | 11 ++++++-----
- tools/python/Makefile |  9 +++++----
- 2 files changed, 11 insertions(+), 9 deletions(-)
-
-diff --git a/tools/pygrub/Makefile b/tools/pygrub/Makefile
-index 4cd1a95..2950f37 100644
---- a/tools/pygrub/Makefile
-+++ b/tools/pygrub/Makefile
-@@ -3,21 +3,22 @@ XEN_ROOT = $(CURDIR)/../..
- include $(XEN_ROOT)/tools/Rules.mk
- 
- PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
--PY_LDFLAGS = $(LDFLAGS) $(APPEND_LDFLAGS)
-+PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
- INSTALL_LOG = build/installed_files.txt
- 
- .PHONY: all
- all: build
- .PHONY: build
- build:
--	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py build
-+	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" \
-+		LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py build
- 
- .PHONY: install
- install: all
- 	$(INSTALL_DIR) $(DESTDIR)/$(bindir)
--	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" \
--		LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) \
--		setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
-+	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" \
-+		LDFLAGS="$(PY_LDFLAGS)" LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py install \
-+		--record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
- 		 --root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
- 	set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
- 	             "`readlink -f $(DESTDIR)/$(bindir)`" != \
-diff --git a/tools/python/Makefile b/tools/python/Makefile
-index 8d22c03..b675f5b 100644
---- a/tools/python/Makefile
-+++ b/tools/python/Makefile
-@@ -5,19 +5,20 @@ include $(XEN_ROOT)/tools/Rules.mk
- all: build
- 
- PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
--PY_LDFLAGS = $(LDFLAGS) $(APPEND_LDFLAGS)
-+PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
- INSTALL_LOG = build/installed_files.txt
- 
- .PHONY: build
- build:
--	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" $(PYTHON) setup.py build
-+	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py build
- 
- .PHONY: install
- install:
- 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
- 
--	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) \
--		setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
-+	CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" \
-+		LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py install \
-+		--record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
- 		--root="$(DESTDIR)" --force
- 
- 	$(INSTALL_PYTHON_PROG) scripts/convert-legacy-stream $(DESTDIR)$(LIBEXEC_BIN)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0029-xen-arm-acpi-Don-t-fail-if-SPCR-table-is-absent.patch 4.16.1-1/debian/patches/0029-xen-arm-acpi-Don-t-fail-if-SPCR-table-is-absent.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0029-xen-arm-acpi-Don-t-fail-if-SPCR-table-is-absent.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0029-xen-arm-acpi-Don-t-fail-if-SPCR-table-is-absent.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,47 +0,0 @@
-From: Elliott Mitchell <ehem+xen@m5p.com>
-Date: Wed, 21 Oct 2020 15:12:53 -0700
-Subject: xen/arm: acpi: Don't fail if SPCR table is absent
-
-Absence of a SPCR table likely means the console is a framebuffer.  In
-such case acpi_iomem_deny_access() should NOT fail.
-
-Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
-Acked-by: Julien Grall <jgrall@amazon.com>
-Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-(cherry picked from commit 861f0c110976fa8879b7bf63d9478b6be83d4ab6)
----
- xen/arch/arm/acpi/domain_build.c | 19 ++++++++++---------
- 1 file changed, 10 insertions(+), 9 deletions(-)
-
-diff --git a/xen/arch/arm/acpi/domain_build.c b/xen/arch/arm/acpi/domain_build.c
-index 1b1cfab..bbdc90f 100644
---- a/xen/arch/arm/acpi/domain_build.c
-+++ b/xen/arch/arm/acpi/domain_build.c
-@@ -42,17 +42,18 @@ static int __init acpi_iomem_deny_access(struct domain *d)
-     status = acpi_get_table(ACPI_SIG_SPCR, 0,
-                             (struct acpi_table_header **)&spcr);
- 
--    if ( ACPI_FAILURE(status) )
-+    if ( ACPI_SUCCESS(status) )
-     {
--        printk("Failed to get SPCR table\n");
--        return -EINVAL;
-+        mfn = spcr->serial_port.address >> PAGE_SHIFT;
-+        /* Deny MMIO access for UART */
-+        rc = iomem_deny_access(d, mfn, mfn + 1);
-+        if ( rc )
-+            return rc;
-+    }
-+    else
-+    {
-+        printk("Failed to get SPCR table, Xen console may be unavailable\n");
-     }
--
--    mfn = spcr->serial_port.address >> PAGE_SHIFT;
--    /* Deny MMIO access for UART */
--    rc = iomem_deny_access(d, mfn, mfn + 1);
--    if ( rc )
--        return rc;
- 
-     /* Deny MMIO access for GIC regions */
-     return gic_iomem_deny_access(d);
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0030-xen-acpi-Rework-acpi_os_map_memory-and-acpi_os_unmap.patch 4.16.1-1/debian/patches/0030-xen-acpi-Rework-acpi_os_map_memory-and-acpi_os_unmap.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0030-xen-acpi-Rework-acpi_os_map_memory-and-acpi_os_unmap.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0030-xen-acpi-Rework-acpi_os_map_memory-and-acpi_os_unmap.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,163 +0,0 @@
-From: Julien Grall <jgrall@amazon.com>
-Date: Sat, 26 Sep 2020 17:44:29 +0100
-Subject: xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()
-
-The functions acpi_os_{un,}map_memory() are meant to be arch-agnostic
-while the __acpi_os_{un,}map_memory() are meant to be arch-specific.
-
-Currently, the former are still containing x86 specific code.
-
-To avoid this rather strange split, the generic helpers are reworked so
-they are arch-agnostic. This requires the introduction of a new helper
-__acpi_os_unmap_memory() that will undo any mapping done by
-__acpi_os_map_memory().
-
-Currently, the arch-helper for unmap is basically a no-op so it only
-returns whether the mapping was arch specific. But this will change
-in the future.
-
-Note that the x86 version of acpi_os_map_memory() was already able to
-able the 1MB region. Hence why there is no addition of new code.
-
-Signed-off-by: Julien Grall <jgrall@amazon.com>
-Reviewed-by: Rahul Singh <rahul.singh@arm.com>
-Reviewed-by: Jan Beulich <jbeulich@suse.com>
-Acked-by: Stefano Stabellini <sstabellini@kernel.org>
-Tested-by: Rahul Singh <rahul.singh@arm.com>
-Tested-by: Elliott Mitchell <ehem+xen@m5p.com>
-(cherry picked from commit 1c4aa69ca1e1fad20b2158051eb152276d1eb973)
----
- xen/arch/arm/acpi/lib.c | 12 ++++++++++++
- xen/arch/x86/acpi/lib.c | 18 ++++++++++++++++++
- xen/drivers/acpi/osl.c  | 34 ++++++++++++++++++----------------
- xen/include/xen/acpi.h  |  1 +
- 4 files changed, 49 insertions(+), 16 deletions(-)
-
-diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
-index 4fc6e17..fcc186b 100644
---- a/xen/arch/arm/acpi/lib.c
-+++ b/xen/arch/arm/acpi/lib.c
-@@ -30,6 +30,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
-     unsigned long base, offset, mapped_size;
-     int idx;
- 
-+    /* No arch specific implementation after early boot */
-+    if ( system_state >= SYS_STATE_boot )
-+        return NULL;
-+
-     offset = phys & (PAGE_SIZE - 1);
-     mapped_size = PAGE_SIZE - offset;
-     set_fixmap(FIXMAP_ACPI_BEGIN, maddr_to_mfn(phys), PAGE_HYPERVISOR);
-@@ -49,6 +53,14 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
-     return ((char *) base + offset);
- }
- 
-+bool __acpi_unmap_table(const void *ptr, unsigned long size)
-+{
-+    vaddr_t vaddr = (vaddr_t)ptr;
-+
-+    return ((vaddr >= FIXMAP_ADDR(FIXMAP_ACPI_BEGIN)) &&
-+            (vaddr < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE)));
-+}
-+
- /* True to indicate PSCI 0.2+ is implemented */
- bool __init acpi_psci_present(void)
- {
-diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
-index 265b9ad..a22414a 100644
---- a/xen/arch/x86/acpi/lib.c
-+++ b/xen/arch/x86/acpi/lib.c
-@@ -46,6 +46,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
- 	if ((phys + size) <= (1 * 1024 * 1024))
- 		return __va(phys);
- 
-+	/* No further arch specific implementation after early boot */
-+	if (system_state >= SYS_STATE_boot)
-+		return NULL;
-+
- 	offset = phys & (PAGE_SIZE - 1);
- 	mapped_size = PAGE_SIZE - offset;
- 	set_fixmap(FIX_ACPI_END, phys);
-@@ -66,6 +70,20 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
- 	return ((char *) base + offset);
- }
- 
-+bool __acpi_unmap_table(const void *ptr, unsigned long size)
-+{
-+	unsigned long vaddr = (unsigned long)ptr;
-+
-+	if ((vaddr >= DIRECTMAP_VIRT_START) &&
-+	    (vaddr < DIRECTMAP_VIRT_END)) {
-+		ASSERT(!((__pa(ptr) + size - 1) >> 20));
-+		return true;
-+	}
-+
-+	return ((vaddr >= __fix_to_virt(FIX_ACPI_END)) &&
-+		(vaddr < (__fix_to_virt(FIX_ACPI_BEGIN) + PAGE_SIZE)));
-+}
-+
- unsigned int acpi_get_processor_id(unsigned int cpu)
- {
- 	unsigned int acpiid, apicid;
-diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
-index 4c8bb78..389505f 100644
---- a/xen/drivers/acpi/osl.c
-+++ b/xen/drivers/acpi/osl.c
-@@ -92,27 +92,29 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
- void __iomem *
- acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
- {
--	if (system_state >= SYS_STATE_boot) {
--		mfn_t mfn = _mfn(PFN_DOWN(phys));
--		unsigned int offs = phys & (PAGE_SIZE - 1);
--
--		/* The low first Mb is always mapped on x86. */
--		if (IS_ENABLED(CONFIG_X86) && !((phys + size - 1) >> 20))
--			return __va(phys);
--		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
--			      ACPI_MAP_MEM_ATTR, VMAP_DEFAULT) + offs;
--	}
--	return __acpi_map_table(phys, size);
-+	void *ptr;
-+	mfn_t mfn = _mfn(PFN_DOWN(phys));
-+	unsigned int offs = PAGE_OFFSET(phys);
-+
-+	/* Try the arch specific implementation first */
-+	ptr = __acpi_map_table(phys, size);
-+	if (ptr)
-+		return ptr;
-+
-+	/* No common implementation for early boot map */
-+	if (unlikely(system_state < SYS_STATE_boot))
-+		return NULL;
-+
-+	ptr = __vmap(&mfn, PFN_UP(offs + size), 1, 1,
-+		     ACPI_MAP_MEM_ATTR, VMAP_DEFAULT);
-+
-+	return !ptr ? NULL : (ptr + offs);
- }
- 
- void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
- {
--	if (IS_ENABLED(CONFIG_X86) &&
--	    (unsigned long)virt >= DIRECTMAP_VIRT_START &&
--	    (unsigned long)virt < DIRECTMAP_VIRT_END) {
--		ASSERT(!((__pa(virt) + size - 1) >> 20));
-+	if (__acpi_unmap_table(virt, size))
- 		return;
--	}
- 
- 	if (system_state >= SYS_STATE_boot)
- 		vunmap((void *)((unsigned long)virt & PAGE_MASK));
-diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
-index c945ab0..21d5e9f 100644
---- a/xen/include/xen/acpi.h
-+++ b/xen/include/xen/acpi.h
-@@ -68,6 +68,7 @@ typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, co
- 
- unsigned int acpi_get_processor_id (unsigned int cpu);
- char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
-+bool __acpi_unmap_table(const void *ptr, unsigned long size);
- int acpi_boot_init (void);
- int acpi_boot_table_init (void);
- int acpi_numa_init (void);
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0031-xen-arm-acpi-The-fixmap-area-should-always-be-cleare.patch 4.16.1-1/debian/patches/0031-xen-arm-acpi-The-fixmap-area-should-always-be-cleare.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0031-xen-arm-acpi-The-fixmap-area-should-always-be-cleare.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0031-xen-arm-acpi-The-fixmap-area-should-always-be-cleare.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,131 +0,0 @@
-From: Julien Grall <jgrall@amazon.com>
-Date: Sat, 26 Sep 2020 19:53:27 +0100
-Subject: xen/arm: acpi: The fixmap area should always be cleared during
- failure/unmap
-
-Commit 022387ee1ad3 "xen/arm: mm: Don't open-code Xen PT update in
-{set, clear}_fixmap()" enforced that each set_fixmap() should be
-paired with a clear_fixmap(). Any failure to follow the model would
-result to a platform crash.
-
-Unfortunately, the use of fixmap in the ACPI code was overlooked as it
-is calling set_fixmap() but not clear_fixmap().
-
-The function __acpi_os_map_table() is reworked so:
-    - We know before the mapping whether the fixmap region is big
-    enough for the mapping.
-    - It will fail if the fixmap is already in use. This is not a
-    change of behavior but clarifying the current expectation to avoid
-    hitting a BUG().
-
-The function __acpi_os_unmap_table() will now call clear_fixmap().
-
-Reported-by: Wei Xu <xuwei5@hisilicon.com>
-Signed-off-by: Julien Grall <jgrall@amazon.com>
-Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-(cherry picked from commit 4d625ff3c3a939dc270b03654337568c30c5ab6e)
----
- xen/arch/arm/acpi/lib.c | 73 +++++++++++++++++++++++++++++++++++++------------
- 1 file changed, 56 insertions(+), 17 deletions(-)
-
-diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
-index fcc186b..a59cc40 100644
---- a/xen/arch/arm/acpi/lib.c
-+++ b/xen/arch/arm/acpi/lib.c
-@@ -25,40 +25,79 @@
- #include <xen/init.h>
- #include <xen/mm.h>
- 
-+static bool fixmap_inuse;
-+
- char *__acpi_map_table(paddr_t phys, unsigned long size)
- {
--    unsigned long base, offset, mapped_size;
--    int idx;
-+    unsigned long base, offset;
-+    mfn_t mfn;
-+    unsigned int idx;
- 
-     /* No arch specific implementation after early boot */
-     if ( system_state >= SYS_STATE_boot )
-         return NULL;
- 
-     offset = phys & (PAGE_SIZE - 1);
--    mapped_size = PAGE_SIZE - offset;
--    set_fixmap(FIXMAP_ACPI_BEGIN, maddr_to_mfn(phys), PAGE_HYPERVISOR);
--    base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
-+    base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) + offset;
-+
-+    /* Check the fixmap is big enough to map the region */
-+    if ( (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - base) < size )
-+        return NULL;
-+
-+    /* With the fixmap, we can only map one region at the time */
-+    if ( fixmap_inuse )
-+        return NULL;
- 
--    /* Most cases can be covered by the below. */
-+    fixmap_inuse = true;
-+
-+    size += offset;
-+    mfn = maddr_to_mfn(phys);
-     idx = FIXMAP_ACPI_BEGIN;
--    while ( mapped_size < size )
--    {
--        if ( ++idx > FIXMAP_ACPI_END )
--            return NULL;    /* cannot handle this */
--        phys += PAGE_SIZE;
--        set_fixmap(idx, maddr_to_mfn(phys), PAGE_HYPERVISOR);
--        mapped_size += PAGE_SIZE;
--    }
- 
--    return ((char *) base + offset);
-+    do {
-+        set_fixmap(idx, mfn, PAGE_HYPERVISOR);
-+        size -= min(size, (unsigned long)PAGE_SIZE);
-+        mfn = mfn_add(mfn, 1);
-+        idx++;
-+    } while ( size > 0 );
-+
-+    return (char *)base;
- }
- 
- bool __acpi_unmap_table(const void *ptr, unsigned long size)
- {
-     vaddr_t vaddr = (vaddr_t)ptr;
-+    unsigned int idx;
-+
-+    /* We are only handling fixmap address in the arch code */
-+    if ( (vaddr < FIXMAP_ADDR(FIXMAP_ACPI_BEGIN)) ||
-+         (vaddr >= (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE)) )
-+        return false;
-+
-+    /*
-+     * __acpi_map_table() will always return a pointer in the first page
-+     * for the ACPI fixmap region. The caller is expected to free with
-+     * the same address.
-+     */
-+    ASSERT((vaddr & PAGE_MASK) == FIXMAP_ADDR(FIXMAP_ACPI_BEGIN));
-+
-+    /* The region allocated fit in the ACPI fixmap region. */
-+    ASSERT(size < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - vaddr));
-+    ASSERT(fixmap_inuse);
-+
-+    fixmap_inuse = false;
-+
-+    size += vaddr - FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
-+    idx = FIXMAP_ACPI_BEGIN;
-+
-+    do
-+    {
-+        clear_fixmap(idx);
-+        size -= min(size, (unsigned long)PAGE_SIZE);
-+        idx++;
-+    } while ( size > 0 );
- 
--    return ((vaddr >= FIXMAP_ADDR(FIXMAP_ACPI_BEGIN)) &&
--            (vaddr < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE)));
-+    return true;
- }
- 
- /* True to indicate PSCI 0.2+ is implemented */
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0032-xen-arm-Check-if-the-platform-is-not-using-ACPI-befo.patch 4.16.1-1/debian/patches/0032-xen-arm-Check-if-the-platform-is-not-using-ACPI-befo.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0032-xen-arm-Check-if-the-platform-is-not-using-ACPI-befo.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0032-xen-arm-Check-if-the-platform-is-not-using-ACPI-befo.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,39 +0,0 @@
-From: Julien Grall <jgrall@amazon.com>
-Date: Sat, 26 Sep 2020 21:16:55 +0100
-Subject: xen/arm: Check if the platform is not using ACPI before initializing
- Dom0less
-
-Dom0less requires a device-tree. However, since commit 6e3e77120378
-"xen/arm: setup: Relocate the Device-Tree later on in the boot", the
-device-tree will not get unflatten when using ACPI.
-
-This will lead to a crash during boot.
-
-Given the complexity to setup dom0less with ACPI (for instance how to
-assign device?), we should skip any code related to Dom0less when using
-ACPI.
-
-Signed-off-by: Julien Grall <jgrall@amazon.com>
-Tested-by: Rahul Singh <rahul.singh@arm.com>
-Reviewed-by: Rahul Singh <rahul.singh@arm.com>
-Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-Tested-by: Elliott Mitchell <ehem+xen@m5p.com>
-(cherry picked from commit dac867bf9adc1562a4cf9db5f89726597af13ef8)
----
- xen/arch/arm/setup.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
-index 34b1c1a..fb2f45e 100644
---- a/xen/arch/arm/setup.c
-+++ b/xen/arch/arm/setup.c
-@@ -961,7 +961,8 @@ void __init start_xen(unsigned long boot_phys_offset,
-     if ( construct_dom0(dom0) != 0)
-         panic("Could not set up DOM0 guest OS\n");
- 
--    create_domUs();
-+    if ( acpi_disabled )
-+        create_domUs();
- 
-     /*
-      * This needs to be called **before** heap_init_late() so modules
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0033-xen-arm-Introduce-fw_unreserved_regions-and-use-it.patch 4.16.1-1/debian/patches/0033-xen-arm-Introduce-fw_unreserved_regions-and-use-it.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0033-xen-arm-Introduce-fw_unreserved_regions-and-use-it.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0033-xen-arm-Introduce-fw_unreserved_regions-and-use-it.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,124 +0,0 @@
-From: Julien Grall <jgrall@amazon.com>
-Date: Sat, 26 Sep 2020 21:30:14 +0100
-Subject: xen/arm: Introduce fw_unreserved_regions() and use it
-
-Since commit 6e3e77120378 "xen/arm: setup: Relocate the Device-Tree
-later on in the boot", the device-tree will not be kept mapped when
-using ACPI.
-
-However, a few places are calling dt_unreserved_regions() which expects
-a valid DT. This will lead to a crash.
-
-As the DT should not be used for ACPI (other than for detecting the
-modules), a new function fw_unreserved_regions() is introduced.
-
-It will behave the same way on DT system. On ACPI system, it will
-unreserve the whole region.
-
-Take the opportunity to clarify that bootinfo.reserved_mem is only used
-when booting using Device-Tree.
-
-Signed-off-by: Julien Grall <jgrall@amazon.com>
-Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-(cherry picked from commit 9c2bc0f24b2ba7082df408b3c33ec9a86bf20cf0)
----
- xen/arch/arm/kernel.c       |  2 +-
- xen/arch/arm/setup.c        | 22 +++++++++++++++++-----
- xen/include/asm-arm/setup.h |  3 ++-
- 3 files changed, 20 insertions(+), 7 deletions(-)
-
-diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
-index 8eff074..27dace0 100644
---- a/xen/arch/arm/kernel.c
-+++ b/xen/arch/arm/kernel.c
-@@ -307,7 +307,7 @@ static __init int kernel_decompress(struct bootmodule *mod)
-      * Free the original kernel, update the pointers to the
-      * decompressed kernel
-      */
--    dt_unreserved_regions(addr, addr + size, init_domheap_pages, 0);
-+    fw_unreserved_regions(addr, addr + size, init_domheap_pages, 0);
- 
-     return 0;
- }
-diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
-index fb2f45e..c94827e 100644
---- a/xen/arch/arm/setup.c
-+++ b/xen/arch/arm/setup.c
-@@ -183,8 +183,9 @@ static void __init processor_id(void)
-     processor_setup();
- }
- 
--void __init dt_unreserved_regions(paddr_t s, paddr_t e,
--                                  void (*cb)(paddr_t, paddr_t), int first)
-+static void __init dt_unreserved_regions(paddr_t s, paddr_t e,
-+                                         void (*cb)(paddr_t, paddr_t),
-+                                         int first)
- {
-     int i, nr = fdt_num_mem_rsv(device_tree_flattened);
- 
-@@ -231,6 +232,17 @@ void __init dt_unreserved_regions(paddr_t s, paddr_t e,
-     cb(s, e);
- }
- 
-+void __init fw_unreserved_regions(paddr_t s, paddr_t e,
-+                                  void (*cb)(paddr_t, paddr_t), int first)
-+{
-+    if ( acpi_disabled )
-+        dt_unreserved_regions(s, e, cb, first);
-+    else
-+        cb(s, e);
-+}
-+
-+
-+
- struct bootmodule __init *add_boot_module(bootmodule_kind kind,
-                                           paddr_t start, paddr_t size,
-                                           bool domU)
-@@ -392,7 +404,7 @@ void __init discard_initial_modules(void)
-              !mfn_valid(maddr_to_mfn(e)) )
-             continue;
- 
--        dt_unreserved_regions(s, e, init_domheap_pages, 0);
-+        fw_unreserved_regions(s, e, init_domheap_pages, 0);
-     }
- 
-     mi->nr_mods = 0;
-@@ -699,7 +711,7 @@ static void __init setup_mm(void)
-                 n = mfn_to_maddr(mfn_add(xenheap_mfn_start, xenheap_pages));
-             }
- 
--            dt_unreserved_regions(s, e, init_boot_pages, 0);
-+            fw_unreserved_regions(s, e, init_boot_pages, 0);
- 
-             s = n;
-         }
-@@ -752,7 +764,7 @@ static void __init setup_mm(void)
-             if ( e > bank_end )
-                 e = bank_end;
- 
--            dt_unreserved_regions(s, e, init_boot_pages, 0);
-+            fw_unreserved_regions(s, e, init_boot_pages, 0);
-             s = n;
-         }
-     }
-diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
-index 2f8f24e..28bf622 100644
---- a/xen/include/asm-arm/setup.h
-+++ b/xen/include/asm-arm/setup.h
-@@ -67,6 +67,7 @@ struct bootcmdlines {
- 
- struct bootinfo {
-     struct meminfo mem;
-+    /* The reserved regions are only used when booting using Device-Tree */
-     struct meminfo reserved_mem;
-     struct bootmodules modules;
-     struct bootcmdlines cmdlines;
-@@ -96,7 +97,7 @@ int construct_dom0(struct domain *d);
- void create_domUs(void);
- 
- void discard_initial_modules(void);
--void dt_unreserved_regions(paddr_t s, paddr_t e,
-+void fw_unreserved_regions(paddr_t s, paddr_t e,
-                            void (*cb)(paddr_t, paddr_t), int first);
- 
- size_t boot_fdt_info(const void *fdt, paddr_t paddr);
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0034-xen-arm-acpi-add-BAD_MADT_GICC_ENTRY-macro.patch 4.16.1-1/debian/patches/0034-xen-arm-acpi-add-BAD_MADT_GICC_ENTRY-macro.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0034-xen-arm-acpi-add-BAD_MADT_GICC_ENTRY-macro.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0034-xen-arm-acpi-add-BAD_MADT_GICC_ENTRY-macro.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-From: Julien Grall <julien.grall@arm.com>
-Date: Wed, 30 Sep 2020 12:25:04 +0100
-Subject: xen/arm: acpi: add BAD_MADT_GICC_ENTRY() macro
-
-Imported from Linux commit b6cfb277378ef831c0fa84bcff5049307294adc6:
-
-    The BAD_MADT_ENTRY() macro is designed to work for all of the subtables
-    of the MADT.  In the ACPI 5.1 version of the spec, the struct for the
-    GICC subtable (struct acpi_madt_generic_interrupt) is 76 bytes long; in
-    ACPI 6.0, the struct is 80 bytes long.  But, there is only one definition
-    in ACPICA for this struct -- and that is the 6.0 version.  Hence, when
-    BAD_MADT_ENTRY() compares the struct size to the length in the GICC
-    subtable, it fails if 5.1 structs are in use, and there are systems in
-    the wild that have them.
-
-    This patch adds the BAD_MADT_GICC_ENTRY() that checks the GICC subtable
-    only, accounting for the difference in specification versions that are
-    possible.  The BAD_MADT_ENTRY() will continue to work as is for all other
-    MADT subtables.
-
-    This code is being added to an arm64 header file since that is currently
-    the only architecture using the GICC subtable of the MADT.  As a GIC is
-    specific to ARM, it is also unlikely the subtable will be used elsewhere.
-
-    Fixes: aeb823bbacc2 ("ACPICA: ACPI 6.0: Add changes for FADT table.")
-    Signed-off-by: Al Stone <al.stone@linaro.org>
-    Acked-by: Will Deacon <will.deacon@arm.com>
-    Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
-    [catalin.marinas@arm.com: extra brackets around macro arguments]
-    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-
-Signed-off-by: Julien Grall <julien.grall@arm.com>
-Signed-off-by: Andre Przywara <andre.przywara@arm.com>
-Signed-off-by: Julien Grall <jgrall@amazon.com>
-Acked-by: Stefano Stabellini <sstabellini@kernel.org>
-Tested-by: Elliott Mitchell <ehem+xen@m5p.com>
-(cherry picked from commit 7056f2f89f03f2f804ac7e776c7b2b000cd716cd)
----
- xen/include/asm-arm/acpi.h | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
-index 5034028..b52ae2d 100644
---- a/xen/include/asm-arm/acpi.h
-+++ b/xen/include/asm-arm/acpi.h
-@@ -54,6 +54,14 @@ void acpi_smp_init_cpus(void);
-  */
- paddr_t acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
- 
-+/* Macros for consistency checks of the GICC subtable of MADT */
-+#define ACPI_MADT_GICC_LENGTH	\
-+    (acpi_gbl_FADT.header.revision < 6 ? 76 : 80)
-+
-+#define BAD_MADT_GICC_ENTRY(entry, end)						\
-+    (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) ||	\
-+     (entry)->header.length != ACPI_MADT_GICC_LENGTH)
-+
- #ifdef CONFIG_ACPI
- extern bool acpi_disabled;
- /* Basic configuration for ACPI */
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0035-xen-arm-traps-Don-t-panic-when-receiving-an-unknown-.patch 4.16.1-1/debian/patches/0035-xen-arm-traps-Don-t-panic-when-receiving-an-unknown-.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0035-xen-arm-traps-Don-t-panic-when-receiving-an-unknown-.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0035-xen-arm-traps-Don-t-panic-when-receiving-an-unknown-.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,29 +0,0 @@
-From: Julien Grall <jgrall@amazon.com>
-Date: Thu, 5 Nov 2020 22:31:06 +0000
-Subject: xen/arm: traps: Don't panic when receiving an unknown debug trap
-
-Even if debug trap are only meant for debugging purpose, it is quite
-harsh to crash Xen if one of the trap sent by the guest is not handled.
-
-So switch from a panic() to a printk().
-
-Signed-off-by: Julien Grall <jgrall@amazon.com>
-Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-(cherry picked from commit 957708c2d1ae25d7375abd5e5e70c3043d64f1f1)
----
- xen/arch/arm/traps.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
-index 2197df2..22bd1bd 100644
---- a/xen/arch/arm/traps.c
-+++ b/xen/arch/arm/traps.c
-@@ -1411,7 +1411,7 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
-         show_execution_state(regs);
-         break;
-     default:
--        panic("DOM%d: Unhandled debug trap %#x\n", domid, code);
-+        printk("DOM%d: Unhandled debug trap %#x\n", domid, code);
-         break;
-     }
- }
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0036-fix-spelling-errors.patch 4.16.1-1/debian/patches/0036-fix-spelling-errors.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0036-fix-spelling-errors.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0036-fix-spelling-errors.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,211 +0,0 @@
-From: Diederik de Haas <didi.debian@cknow.org>
-Date: Fri, 4 Dec 2020 08:28:21 +0100
-Subject: fix spelling errors
-
-Only spelling errors; no functional changes.
-
-In docs/misc/dump-core-format.txt there are a few more instances of
-'informations'. I'll leave that up to someone who can properly determine
-how those sentences should be constructed.
-
-Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
-Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-Acked-by: Jan Beulich <jbeulich@suse.com>
-(cherry picked from commit ba6e78f0db820fbeea4df41fde4655020ca05928)
----
- docs/man/xl.1.pod.in                   | 2 +-
- docs/man/xl.cfg.5.pod.in               | 2 +-
- docs/man/xlcpupool.cfg.5.pod           | 2 +-
- tools/firmware/rombios/rombios.c       | 2 +-
- tools/libxl/libxl_stream_read.c        | 2 +-
- tools/xl/xl_cmdtable.c                 | 2 +-
- xen/arch/x86/boot/video.S              | 2 +-
- xen/arch/x86/cpu/vpmu.c                | 2 +-
- xen/arch/x86/mpparse.c                 | 2 +-
- xen/arch/x86/x86_emulate/x86_emulate.c | 2 +-
- xen/common/libelf/libelf-dominfo.c     | 2 +-
- xen/drivers/passthrough/arm/smmu.c     | 2 +-
- xen/tools/gen-cpuid.py                 | 2 +-
- xen/xsm/flask/policy/access_vectors    | 2 +-
- 14 files changed, 14 insertions(+), 14 deletions(-)
-
-diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
-index 52a47a6..3480707 100644
---- a/docs/man/xl.1.pod.in
-+++ b/docs/man/xl.1.pod.in
-@@ -1578,7 +1578,7 @@ List vsnd devices for a domain.
- Creates a new keyboard device in the domain specified by I<domain-id>.
- I<vkb-device> describes the device to attach, using the same format as the
- B<VKB_SPEC_STRING> string in the domain config file. See L<xl.cfg(5)>
--for more informations.
-+for more information.
- 
- =item B<vkb-detach> I<domain-id> I<devid>
- 
-diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
-index 0532739..b4625f5 100644
---- a/docs/man/xl.cfg.5.pod.in
-+++ b/docs/man/xl.cfg.5.pod.in
-@@ -2385,7 +2385,7 @@ If B<videoram> is set less than 128MB, an error will be triggered.
- 
- =item B<stdvga=BOOLEAN>
- 
--Speficies a standard VGA card with VBE (VESA BIOS Extensions) as the
-+Specifies a standard VGA card with VBE (VESA BIOS Extensions) as the
- emulated graphics device. If your guest supports VBE 2.0 or
- later (e.g. Windows XP onwards) then you should enable this.
- stdvga supports more video ram and bigger resolutions than Cirrus.
-diff --git a/docs/man/xlcpupool.cfg.5.pod b/docs/man/xlcpupool.cfg.5.pod
-index 3c9ddf7..c577c7c 100644
---- a/docs/man/xlcpupool.cfg.5.pod
-+++ b/docs/man/xlcpupool.cfg.5.pod
-@@ -106,7 +106,7 @@ means that cpus 2,3,5 will be member of the cpupool.
- means that cpus 0,2,3 and 5 will be member of the cpupool. A "node:" or
- "nodes:" modifier can be used. E.g., "0,node:1,nodes:2-3,^10-13" means
- that pcpus 0, plus all the cpus of NUMA nodes 1,2,3 with the exception
--of cpus 10,11,12,13 will be memeber of the cpupool.
-+of cpus 10,11,12,13 will be members of the cpupool.
- 
- =back
- 
-diff --git a/tools/firmware/rombios/rombios.c b/tools/firmware/rombios/rombios.c
-index 51558ee..5cda227 100644
---- a/tools/firmware/rombios/rombios.c
-+++ b/tools/firmware/rombios/rombios.c
-@@ -2607,7 +2607,7 @@ void ata_detect( )
-   write_byte(ebda_seg,&EbdaData->ata.channels[3].irq,11);
- #endif
- #if BX_MAX_ATA_INTERFACES > 4
--#error Please fill the ATA interface informations
-+#error Please fill the ATA interface information
- #endif
- 
-   // Device detection
-diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c
-index 514f6d9..99a6714 100644
---- a/tools/libxl/libxl_stream_read.c
-+++ b/tools/libxl/libxl_stream_read.c
-@@ -459,7 +459,7 @@ static void stream_continue(libxl__egc *egc,
-         while (process_record(egc, stream))
-             ; /*
-                * Nothing! process_record() helpfully tells us if no specific
--               * futher actions have been set up, in which case we want to go
-+               * further actions have been set up, in which case we want to go
-                * ahead and process the next record.
-                */
-         break;
-diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
-index 0833539..9ad31a6 100644
---- a/tools/xl/xl_cmdtable.c
-+++ b/tools/xl/xl_cmdtable.c
-@@ -154,7 +154,7 @@ struct cmd_spec cmd_table[] = {
-       "-h  Print this help.\n"
-       "-c  Leave domain running after creating the snapshot.\n"
-       "-p  Leave domain paused after creating the snapshot.\n"
--      "-D  Store the domain id in the configration."
-+      "-D  Store the domain id in the configuration."
-     },
-     { "migrate",
-       &main_migrate, 0, 1,
-diff --git a/xen/arch/x86/boot/video.S b/xen/arch/x86/boot/video.S
-index a485779..0efbe8d 100644
---- a/xen/arch/x86/boot/video.S
-+++ b/xen/arch/x86/boot/video.S
-@@ -177,7 +177,7 @@ dac_set:
-         movb    $0, _param(PARAM_LFB_COLORS+7)
- 
- dac_done:
--# get protected mode interface informations
-+# get protected mode interface information
-         movw    $0x4f0a, %ax
-         xorw    %bx, %bx
-         xorw    %di, %di
-diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
-index 0c3f378..fb1b296 100644
---- a/xen/arch/x86/cpu/vpmu.c
-+++ b/xen/arch/x86/cpu/vpmu.c
-@@ -680,7 +680,7 @@ static void pvpmu_finish(struct domain *d, xen_pmu_params_t *params)
-         vcpu_unpause(v);
- }
- 
--/* Dump some vpmu informations on console. Used in keyhandler dump_domains(). */
-+/* Dump some vpmu information to console. Used in keyhandler dump_domains(). */
- void vpmu_dump(struct vcpu *v)
- {
-     struct vpmu_struct *vpmu = vcpu_vpmu(v);
-diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c
-index d532575..dff02b1 100644
---- a/xen/arch/x86/mpparse.c
-+++ b/xen/arch/x86/mpparse.c
-@@ -170,7 +170,7 @@ static int MP_processor_info_x(struct mpc_config_processor *m,
- 	if (num_processors >= 8 && hotplug
- 	    && genapic.name == apic_default.name) {
- 		printk_once(XENLOG_WARNING
--			    "WARNING: CPUs limit of 8 reached - ignoring futher processors\n");
-+			    "WARNING: CPUs limit of 8 reached - ignoring further processors\n");
- 		unaccounted_cpus = true;
- 		return -ENOSPC;
- 	}
-diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
-index de46ec1..605e535 100644
---- a/xen/arch/x86/x86_emulate/x86_emulate.c
-+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
-@@ -3244,7 +3244,7 @@ x86_decode(
-             case 0x23: /* mov reg,dr */
-                 /*
-                  * Mov to/from cr/dr ignore the encoding of Mod, and behave as
--                 * if they were encoded as reg/reg instructions.  No futher
-+                 * if they were encoded as reg/reg instructions.  No further
-                  * disp/SIB bytes are fetched.
-                  */
-                 modrm_mod = 3;
-diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c
-index 508f08d..69c94b6 100644
---- a/xen/common/libelf/libelf-dominfo.c
-+++ b/xen/common/libelf/libelf-dominfo.c
-@@ -1,5 +1,5 @@
- /*
-- * parse xen-specific informations out of elf kernel binaries.
-+ * parse xen-specific information out of elf kernel binaries.
-  *
-  * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Lesser General Public
-diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
-index 4ba6d3a..5c95131 100644
---- a/xen/drivers/passthrough/arm/smmu.c
-+++ b/xen/drivers/passthrough/arm/smmu.c
-@@ -214,7 +214,7 @@ struct iommu_domain
- 	struct list_head		list;
- };
- 
--/* Xen: Describes informations required for a Xen domain */
-+/* Xen: Describes information required for a Xen domain */
- struct arm_smmu_xen_domain {
- 	spinlock_t			lock;
- 	/* List of context (i.e iommu_domain) associated to this domain */
-diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
-index ffd9529..14f56df 100755
---- a/xen/tools/gen-cpuid.py
-+++ b/xen/tools/gen-cpuid.py
-@@ -192,7 +192,7 @@ def crunch_numbers(state):
-         FXSR: [FFXSR, SSE],
- 
-         # SSE is taken to mean support for the %XMM registers as well as the
--        # instructions.  Several futher instruction sets are built on core
-+        # instructions.  Several further instruction sets are built on core
-         # %XMM support, without specific inter-dependencies.  Additionally
-         # AMD has a special mis-alignment sub-mode.
-         SSE: [SSE2, MISALIGNSSE],
-diff --git a/xen/xsm/flask/policy/access_vectors b/xen/xsm/flask/policy/access_vectors
-index b87c99e..5371196 100644
---- a/xen/xsm/flask/policy/access_vectors
-+++ b/xen/xsm/flask/policy/access_vectors
-@@ -509,7 +509,7 @@ class security
- #
- class version
- {
--# Extra informations (-unstable).
-+# Extra information (-unstable).
-     xen_extraversion
- # Compile information of the hypervisor.
-     xen_compile_info
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0037-xen-don-t-have-timestamp-inserted-in-config.gz.patch 4.16.1-1/debian/patches/0037-xen-don-t-have-timestamp-inserted-in-config.gz.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0037-xen-don-t-have-timestamp-inserted-in-config.gz.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0037-xen-don-t-have-timestamp-inserted-in-config.gz.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,30 +0,0 @@
-From: =?utf-8?b?IkZyw6lkw6lyaWMgUGllcnJldCAoZmVwaXRyZSki?=
- <frederic.pierret@qubes-os.org>
-Date: Wed, 4 Nov 2020 09:24:40 +0100
-Subject: xen: don't have timestamp inserted in config.gz
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-This is for improving reproducible builds.
-
-Signed-off-by: Frédéric Pierret (fepitre) <frederic.pierret@qubes-os.org>
-Acked-by: Jan Beulich <jbeulich@suse.com>
-(cherry picked from commit 5816d327e44ab37ae08730f4c54a80835998f31f)
----
- xen/common/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/xen/common/Makefile b/xen/common/Makefile
-index 06881d0..32cd650 100644
---- a/xen/common/Makefile
-+++ b/xen/common/Makefile
-@@ -77,7 +77,7 @@ obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/
- 
- CONF_FILE := $(if $(patsubst /%,,$(KCONFIG_CONFIG)),$(XEN_ROOT)/xen/)$(KCONFIG_CONFIG)
- config.gz: $(CONF_FILE)
--	gzip -c $< >$@
-+	gzip -n -c $< >$@
- 
- config_data.o: config.gz
- 
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0038-x86-EFI-don-t-insert-timestamp-when-SOURCE_DATE_EPOC.patch 4.16.1-1/debian/patches/0038-x86-EFI-don-t-insert-timestamp-when-SOURCE_DATE_EPOC.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0038-x86-EFI-don-t-insert-timestamp-when-SOURCE_DATE_EPOC.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0038-x86-EFI-don-t-insert-timestamp-when-SOURCE_DATE_EPOC.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,39 +0,0 @@
-From: Maximilian Engelhardt <maxi@daemonizer.de>
-Date: Tue, 22 Dec 2020 08:59:14 +0100
-Subject: x86/EFI: don't insert timestamp when SOURCE_DATE_EPOCH is defined
-
-By default a timestamp gets added to the xen efi binary. Unfortunately
-ld doesn't seem to provide a way to set a custom date, like from
-SOURCE_DATE_EPOCH, so set a zero value for the timestamp (option
---no-insert-timestamp) if SOURCE_DATE_EPOCH is defined. This makes
-reproducible builds possible.
-
-This is an alternative to the patch suggested in [1]. This patch only
-omits the timestamp when SOURCE_DATE_EPOCH is defined.
-
-[1] https://lists.xenproject.org/archives/html/xen-devel/2020-10/msg02161.html
-
-Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
-Acked-by: Jan Beulich <jbeulich@suse.com>
-(cherry picked from commit ee41b5c450032ae7f2531e18cd0a73bf5fb48803)
----
- xen/arch/x86/Makefile | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
-index fd0acd5..45a8c8f 100644
---- a/xen/arch/x86/Makefile
-+++ b/xen/arch/x86/Makefile
-@@ -172,6 +172,12 @@ EFI_LDFLAGS += --major-image-version=$(XEN_VERSION)
- EFI_LDFLAGS += --minor-image-version=$(XEN_SUBVERSION)
- EFI_LDFLAGS += --major-os-version=2 --minor-os-version=0
- EFI_LDFLAGS += --major-subsystem-version=2 --minor-subsystem-version=0
-+# It seems ld unfortunately can't set a custom timestamp, so add a zero value
-+# for the timestamp (option --no-insert-timestamp) if SOURCE_DATE_EPOCH is
-+# defined to make reproducible builds possible.
-+ifdef SOURCE_DATE_EPOCH
-+EFI_LDFLAGS += --no-insert-timestamp
-+endif
- 
- # Check if the compiler supports the MS ABI.
- export XEN_BUILD_EFI := $(shell $(CC) $(XEN_CFLAGS) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0039-docs-use-predictable-ordering-in-generated-documenta.patch 4.16.1-1/debian/patches/0039-docs-use-predictable-ordering-in-generated-documenta.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0039-docs-use-predictable-ordering-in-generated-documenta.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0039-docs-use-predictable-ordering-in-generated-documenta.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-From: Maximilian Engelhardt <maxi@daemonizer.de>
-Date: Fri, 18 Dec 2020 21:42:34 +0100
-Subject: docs: use predictable ordering in generated documentation
-
-When the seq number is equal, sort by the title to get predictable
-output ordering. This is useful for reproducible builds.
-
-Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
-Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
-(cherry picked from commit e18dadc5b709290b8038a1cacb52bc3b3b69cf21)
----
- docs/xen-headers | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/docs/xen-headers b/docs/xen-headers
-index 5415563..8c434d7 100755
---- a/docs/xen-headers
-+++ b/docs/xen-headers
-@@ -331,7 +331,7 @@ sub output_index () {
- <h2>Starting points</h2>
- <ul>
- END
--    foreach my $ic (sort { $a->{Seq} <=> $b->{Seq} } @incontents) {
-+    foreach my $ic (sort { $a->{Seq} <=> $b->{Seq} or $a->{Title} cmp $b->{Title} } @incontents) {
-         $o .= "<li><a href=\"$ic->{Href}\">$ic->{Title}</a></li>\n";
-     }
-     $o .= "</ul>\n";
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0040-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch 4.16.1-1/debian/patches/0040-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0040-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0040-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,39 +0,0 @@
-From: Maximilian Engelhardt <maxi@daemonizer.de>
-Date: Fri, 18 Dec 2020 21:42:35 +0100
-Subject: docs: set date to SOURCE_DATE_EPOCH if available
-
-Use the solution described in [1] to replace the call to the 'date'
-command with a version that uses SOURCE_DATE_EPOCH if available. This
-is needed for reproducible builds.
-
-[1] https://reproducible-builds.org/docs/source-date-epoch/
-
-Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
-
-[Hans van Kranenburg]
-Note: this patch is submitted upstream but not committed yet. We
-expect that it gets in. Otherwise, we don't wait and already have it
-here because I want to have the reproducible build work completed.
----
- docs/Makefile | 8 +++++++-
- 1 file changed, 7 insertions(+), 1 deletion(-)
-
-diff --git a/docs/Makefile b/docs/Makefile
-index 8de1efb..ac6792f 100644
---- a/docs/Makefile
-+++ b/docs/Makefile
-@@ -3,7 +3,13 @@ include $(XEN_ROOT)/Config.mk
- -include $(XEN_ROOT)/config/Docs.mk
- 
- VERSION		:= $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion)
--DATE		:= $(shell date +%Y-%m-%d)
-+
-+DATE_FMT	:= +%Y-%m-%d
-+ifdef SOURCE_DATE_EPOCH
-+DATE		:= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
-+else
-+DATE		:= $(shell date "$(DATE_FMT)")
-+endif
- 
- DOC_ARCHES      := arm x86_32 x86_64
- MAN_SECTIONS    := 1 5 7 8
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0041-x86-ACPI-fix-mapping-of-FACS.patch 4.16.1-1/debian/patches/0041-x86-ACPI-fix-mapping-of-FACS.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0041-x86-ACPI-fix-mapping-of-FACS.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0041-x86-ACPI-fix-mapping-of-FACS.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-From: Jan Beulich <jbeulich@suse.com>
-Date: Tue, 24 Nov 2020 11:26:02 +0100
-Subject: x86/ACPI: fix mapping of FACS
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-acpi_fadt_parse_sleep_info() runs when the system is already in
-SYS_STATE_boot. Hence its direct call to __acpi_map_table() won't work
-anymore. This call should probably have been replaced long ago already,
-as the layering violation hasn't been necessary for quite some time.
-
-Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()")
-Signed-off-by: Jan Beulich <jbeulich@suse.com>
-Acked-by: Roger Pau Monné <roger.pau@citrix.com>
-(cherry picked from commit 8b6d55c1261820bb9db8d867ce9ee77397d05203)
----
- xen/arch/x86/acpi/boot.c | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c
-index 38c2b76..3ad4105 100644
---- a/xen/arch/x86/acpi/boot.c
-+++ b/xen/arch/x86/acpi/boot.c
-@@ -422,8 +422,7 @@ acpi_fadt_parse_sleep_info(const struct acpi_table_fadt *fadt)
- 	if (!facs_pa)
- 		goto bad;
- 
--	facs = (struct acpi_table_facs *)
--		__acpi_map_table(facs_pa, sizeof(struct acpi_table_facs));
-+	facs = acpi_os_map_memory(facs_pa, sizeof(*facs));
- 	if (!facs)
- 		goto bad;
- 
-@@ -448,11 +447,16 @@ acpi_fadt_parse_sleep_info(const struct acpi_table_fadt *fadt)
- 		offsetof(struct acpi_table_facs, firmware_waking_vector);
- 	acpi_sinfo.vector_width = 32;
- 
-+	acpi_os_unmap_memory(facs, sizeof(*facs));
-+
- 	printk(KERN_INFO PREFIX
- 	       "            wakeup_vec[%"PRIx64"], vec_size[%x]\n",
- 	       acpi_sinfo.wakeup_vector, acpi_sinfo.vector_width);
- 	return;
--bad:
-+
-+ bad:
-+	if (facs)
-+		acpi_os_unmap_memory(facs, sizeof(*facs));
- 	memset(&acpi_sinfo, 0,
- 	       offsetof(struct acpi_sleep_info, sleep_control));
- 	memset(&acpi_sinfo.sleep_status + 1, 0,
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0042-x86-DMI-fix-table-mapping-when-one-lives-above-1Mb.patch 4.16.1-1/debian/patches/0042-x86-DMI-fix-table-mapping-when-one-lives-above-1Mb.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0042-x86-DMI-fix-table-mapping-when-one-lives-above-1Mb.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0042-x86-DMI-fix-table-mapping-when-one-lives-above-1Mb.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,149 +0,0 @@
-From: Jan Beulich <jbeulich@suse.com>
-Date: Tue, 24 Nov 2020 11:26:34 +0100
-Subject: x86/DMI: fix table mapping when one lives above 1Mb
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Use of __acpi_map_table() is kind of an abuse here, and doesn't work
-anymore for the majority of cases if any of the tables lives outside the
-low first Mb. Keep this (ab)use only prior to reaching SYS_STATE_boot,
-primarily to avoid needing to audit whether any of the calls here can
-happen this early in the first place; quite likely this isn't necessary
-at all - at least dmi_scan_machine() gets called late enough.
-
-For the "normal" case, call __vmap() directly, despite effectively
-duplicating acpi_os_map_memory(). There's one difference though: We
-shouldn't need to establish UC- mappings, WP or r/o WB mappings ought to
-be fine, as the tables are going to live in either RAM or ROM. Short of
-having PAGE_HYPERVISOR_WP and wanting to map the tables r/o anyway, use
-the latter of the two options. The r/o mapping implies some
-constification of code elsewhere in the file. For code touched anyway
-also switch to void (where possible) or uint8_t.
-
-Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()")
-Signed-off-by: Jan Beulich <jbeulich@suse.com>
-Acked-by: Roger Pau Monné <roger.pau@citrix.com>
-(cherry picked from commit f390941a92f102ebbbbce1b54be206a602187fd7)
----
- xen/arch/x86/dmi_scan.c | 53 ++++++++++++++++++++++++++++++++++---------------
- 1 file changed, 37 insertions(+), 16 deletions(-)
-
-diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c
-index e5930d2..d27cd34 100644
---- a/xen/arch/x86/dmi_scan.c
-+++ b/xen/arch/x86/dmi_scan.c
-@@ -12,8 +12,6 @@
- #include <xen/pci.h>
- #include <xen/pci_regs.h>
- 
--#define bt_ioremap(b,l)  ((void *)__acpi_map_table(b,l))
--#define bt_iounmap(b,l)  ((void)0)
- #define memcpy_fromio    memcpy
- #define alloc_bootmem(l) xmalloc_bytes(l)
- 
-@@ -111,9 +109,32 @@ enum dmi_entry_type {
- #define dmi_printk(x)
- #endif
- 
--static char * __init dmi_string(struct dmi_header *dm, u8 s)
-+static const void *__init bt_ioremap(paddr_t addr, unsigned int len)
- {
--	char *bp=(char *)dm;
-+    mfn_t mfn = _mfn(PFN_DOWN(addr));
-+    unsigned int offs = PAGE_OFFSET(addr);
-+
-+    if ( addr + len <= MB(1) )
-+        return __va(addr);
-+
-+    if ( system_state < SYS_STATE_boot )
-+        return __acpi_map_table(addr, len);
-+
-+    return __vmap(&mfn, PFN_UP(offs + len), 1, 1, PAGE_HYPERVISOR_RO,
-+                  VMAP_DEFAULT) + offs;
-+}
-+
-+static void __init bt_iounmap(const void *ptr, unsigned int len)
-+{
-+    if ( (unsigned long)ptr < DIRECTMAP_VIRT_START &&
-+         system_state >= SYS_STATE_boot )
-+        vunmap(ptr);
-+}
-+
-+static const char *__init dmi_string(const struct dmi_header *dm, uint8_t s)
-+{
-+	const char *bp = (const void *)dm;
-+
- 	bp+=dm->length;
- 	if(!s)
- 		return "";
-@@ -133,11 +154,10 @@ static char * __init dmi_string(struct dmi_header *dm, u8 s)
-  */
-  
- static int __init dmi_table(paddr_t base, u32 len, int num,
--			    void (*decode)(struct dmi_header *))
-+			    void (*decode)(const struct dmi_header *))
- {
--	u8 *buf;
--	struct dmi_header *dm;
--	u8 *data;
-+	const uint8_t *buf, *data;
-+	const struct dmi_header *dm;
- 	int i=0;
- 		
- 	buf = bt_ioremap(base, len);
-@@ -301,7 +321,7 @@ typedef union {
- 
- static int __init _dmi_iterate(const struct dmi_eps *dmi,
- 			       const smbios_eps_u smbios,
--			       void (*decode)(struct dmi_header *))
-+			       void (*decode)(const struct dmi_header *))
- {
- 	int num;
- 	u32 len;
-@@ -335,7 +355,7 @@ static int __init _dmi_iterate(const struct dmi_eps *dmi,
- 	return dmi_table(base, len, num, decode);
- }
- 
--static int __init dmi_iterate(void (*decode)(struct dmi_header *))
-+static int __init dmi_iterate(void (*decode)(const struct dmi_header *))
- {
- 	struct dmi_eps dmi;
- 	struct smbios3_eps smbios3;
-@@ -370,7 +390,7 @@ static int __init dmi_iterate(void (*decode)(struct dmi_header *))
- 	return -1;
- }
- 
--static int __init dmi_efi_iterate(void (*decode)(struct dmi_header *))
-+static int __init dmi_efi_iterate(void (*decode)(const struct dmi_header *))
- {
- 	int ret = -1;
- 
-@@ -433,10 +453,11 @@ static char *__initdata dmi_ident[DMI_STRING_MAX];
-  *	Save a DMI string
-  */
-  
--static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
-+static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int string)
- {
--	char *d = (char*)dm;
--	char *p = dmi_string(dm, d[string]);
-+	const char *d = (const void *)dm;
-+	const char *p = dmi_string(dm, d[string]);
-+
- 	if(p==NULL || *p == 0)
- 		return;
- 	if (dmi_ident[slot])
-@@ -629,10 +650,10 @@ static const struct dmi_blacklist __initconstrel dmi_blacklist[] = {
-  *	out of here.
-  */
- 
--static void __init dmi_decode(struct dmi_header *dm)
-+static void __init dmi_decode(const struct dmi_header *dm)
- {
- #ifdef DMI_DEBUG
--	u8 *data = (u8 *)dm;
-+	const uint8_t *data = (const void *)dm;
- #endif
- 	
- 	switch(dm->type)
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0043-x86-ACPI-fix-S3-wakeup-vector-mapping.patch 4.16.1-1/debian/patches/0043-x86-ACPI-fix-S3-wakeup-vector-mapping.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0043-x86-ACPI-fix-S3-wakeup-vector-mapping.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0043-x86-ACPI-fix-S3-wakeup-vector-mapping.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,83 +0,0 @@
-From: Jan Beulich <jbeulich@suse.com>
-Date: Tue, 5 Jan 2021 13:09:55 +0100
-Subject: x86/ACPI: fix S3 wakeup vector mapping
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Use of __acpi_map_table() here was at least close to an abuse already
-before, but it will now consistently return NULL here. Drop the layering
-violation and use set_fixmap() directly. Re-use of the ACPI fixmap area
-is hopefully going to remain "fine" for the time being.
-
-Add checks to acpi_enter_sleep(): The vector now needs to be contained
-within a single page, but the ACPI spec requires 64-byte alignment of
-FACS anyway. Also bail if no wakeup vector was determined in the first
-place, in part as preparation for a subsequent relaxation change.
-
-Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()")
-Signed-off-by: Jan Beulich <jbeulich@suse.com>
-Acked-by: Roger Pau Monné <roger.pau@citrix.com>
-(cherry picked from commit 0f089bbf43ecce6f27576cb548ba4341d0ec46a8)
----
- xen/arch/x86/acpi/boot.c  |  5 +++++
- xen/arch/x86/acpi/power.c | 15 ++++++++++++---
- 2 files changed, 17 insertions(+), 3 deletions(-)
-
-diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c
-index 3ad4105..7994228 100644
---- a/xen/arch/x86/acpi/boot.c
-+++ b/xen/arch/x86/acpi/boot.c
-@@ -443,6 +443,11 @@ acpi_fadt_parse_sleep_info(const struct acpi_table_fadt *fadt)
- 			"FACS is shorter than ACPI spec allow: %#x",
- 			facs->length);
- 
-+	if (facs_pa % 64)
-+		printk(KERN_WARNING PREFIX
-+			"FACS is not 64-byte aligned: %#lx",
-+			facs_pa);
-+
- 	acpi_sinfo.wakeup_vector = facs_pa + 
- 		offsetof(struct acpi_table_facs, firmware_waking_vector);
- 	acpi_sinfo.vector_width = 32;
-diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
-index 604cb7e..3486a9c 100644
---- a/xen/arch/x86/acpi/power.c
-+++ b/xen/arch/x86/acpi/power.c
-@@ -174,17 +174,20 @@ static void acpi_sleep_prepare(u32 state)
-     if ( state != ACPI_STATE_S3 )
-         return;
- 
--    wakeup_vector_va = __acpi_map_table(
--        acpi_sinfo.wakeup_vector, sizeof(uint64_t));
--
-     /* TBoot will set resume vector itself (when it is safe to do so). */
-     if ( tboot_in_measured_env() )
-         return;
- 
-+    set_fixmap(FIX_ACPI_END, acpi_sinfo.wakeup_vector);
-+    wakeup_vector_va = fix_to_virt(FIX_ACPI_END) +
-+                       PAGE_OFFSET(acpi_sinfo.wakeup_vector);
-+
-     if ( acpi_sinfo.vector_width == 32 )
-         *(uint32_t *)wakeup_vector_va = bootsym_phys(wakeup_start);
-     else
-         *(uint64_t *)wakeup_vector_va = bootsym_phys(wakeup_start);
-+
-+    clear_fixmap(FIX_ACPI_END);
- }
- 
- static void acpi_sleep_post(u32 state) {}
-@@ -333,6 +336,12 @@ static long enter_state_helper(void *data)
-  */
- int acpi_enter_sleep(struct xenpf_enter_acpi_sleep *sleep)
- {
-+    if ( sleep->sleep_state == ACPI_STATE_S3 &&
-+         (!acpi_sinfo.wakeup_vector || !acpi_sinfo.vector_width ||
-+          (PAGE_OFFSET(acpi_sinfo.wakeup_vector) >
-+           PAGE_SIZE - acpi_sinfo.vector_width / 8)) )
-+        return -EOPNOTSUPP;
-+
-     if ( sleep->flags & XENPF_ACPI_SLEEP_EXTENDED )
-     {
-         if ( !acpi_sinfo.sleep_control.address ||
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/0044-x86-ACPI-don-t-invalidate-S5-data-when-S3-wakeup-vec.patch 4.16.1-1/debian/patches/0044-x86-ACPI-don-t-invalidate-S5-data-when-S3-wakeup-vec.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/0044-x86-ACPI-don-t-invalidate-S5-data-when-S3-wakeup-vec.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/0044-x86-ACPI-don-t-invalidate-S5-data-when-S3-wakeup-vec.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,58 +0,0 @@
-From: Jan Beulich <jbeulich@suse.com>
-Date: Tue, 5 Jan 2021 13:11:04 +0100
-Subject: x86/ACPI: don't invalidate S5 data when S3 wakeup vector cannot be
- determined
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-We can be more tolerant as long as the data collected from FACS is only
-needed to enter S3. A prior change already added suitable checking to
-acpi_enter_sleep().
-
-Signed-off-by: Jan Beulich <jbeulich@suse.com>
-Acked-by: Roger Pau Monné <roger.pau@citrix.com>
-(cherry picked from commit 16ca5b3f873f17f4fbdaecf46c133e1aa3d623b2)
----
- xen/arch/x86/acpi/boot.c | 9 +++++----
- 1 file changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c
-index 7994228..9e857c3 100644
---- a/xen/arch/x86/acpi/boot.c
-+++ b/xen/arch/x86/acpi/boot.c
-@@ -420,22 +420,22 @@ acpi_fadt_parse_sleep_info(const struct acpi_table_fadt *fadt)
- 		facs_pa = (uint64_t)fadt->facs;
- 	}
- 	if (!facs_pa)
--		goto bad;
-+		return;
- 
- 	facs = acpi_os_map_memory(facs_pa, sizeof(*facs));
- 	if (!facs)
--		goto bad;
-+		return;
- 
- 	if (strncmp(facs->signature, "FACS", 4)) {
- 		printk(KERN_ERR PREFIX "Invalid FACS signature %.4s\n",
- 			facs->signature);
--		goto bad;
-+		goto done;
- 	}
- 
- 	if (facs->length < 24) {
- 		printk(KERN_ERR PREFIX "Invalid FACS table length: %#x",
- 			facs->length);
--		goto bad;
-+		goto done;
- 	}
- 
- 	if (facs->length < 64)
-@@ -452,6 +452,7 @@ acpi_fadt_parse_sleep_info(const struct acpi_table_fadt *fadt)
- 		offsetof(struct acpi_table_facs, firmware_waking_vector);
- 	acpi_sinfo.vector_width = 32;
- 
-+ done:
- 	acpi_os_unmap_memory(facs, sizeof(*facs));
- 
- 	printk(KERN_INFO PREFIX
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/misc/toolstestsx86_emulator-pass--no-pie--fno.patch 4.16.1-1/debian/patches/misc/toolstestsx86_emulator-pass--no-pie--fno.patch
--- 4.14.3+32-g9de3671772-1/debian/patches/misc/toolstestsx86_emulator-pass--no-pie--fno.patch	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/misc/toolstestsx86_emulator-pass--no-pie--fno.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-From: Ian Jackson <ian.jackson@citrix.com>
-Date: Tue, 1 Nov 2016 16:20:27 +0000
-Subject: tools/tests/x86_emulator: Pass -no-pie -fno-pic to gcc on x86_32
-
-The current build fails with GCC6 on Debian sid i386 (unstable):
-
- /tmp/ccqjaueF.s: Assembler messages:
- /tmp/ccqjaueF.s:3713: Error: missing or invalid displacement expression `vmovd_to_reg_len@GOT'
-
-This is due to the combination of GCC6, and Debian's decision to
-enable some hardening flags by default (to try to make runtime
-addresses less predictable):
-  https://wiki.debian.org/Hardening/PIEByDefaultTransition
-
-This is of no benefit for the x86 instruction emulator test, which is
-a rebuild of the emulator code for testing purposes only.  So pass
-options to disable this.
-
-These options will be no-ops if they are the same as the compiler
-default.
-
-On amd64, the -fno-pic breaks the build in a different way.  So do
-this only on i386.
-
-Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
-CC: Jan Beulich <jbeulich@suse.com>
-CC: Andrew Cooper <andrew.cooper3@citrix.com>
----
- tools/tests/x86_emulator/Makefile | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
-index 48b3e6d..83bc757 100644
---- a/tools/tests/x86_emulator/Makefile
-+++ b/tools/tests/x86_emulator/Makefile
-@@ -283,6 +283,10 @@ HOSTCFLAGS-x86_64 := -fno-PIE
- $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
- HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
- 
-+ifeq ($(XEN_TARGET_ARCH),x86_32)
-+HOSTCFLAGS += -no-pie -fno-pic
-+endif
-+
- x86.h := $(addprefix $(XEN_ROOT)/tools/include/xen/asm/,\
-                      x86-vendors.h x86-defns.h msr-index.h) \
-          $(addprefix $(XEN_ROOT)/tools/include/xen/lib/x86/, \
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/prefix-abiname/config-prefix.diff 4.16.1-1/debian/patches/prefix-abiname/config-prefix.diff
--- 4.14.3+32-g9de3671772-1/debian/patches/prefix-abiname/config-prefix.diff	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/prefix-abiname/config-prefix.diff	2022-05-09 20:29:23.000000000 +0000
@@ -9,7 +9,7 @@ Patch-Name: config-prefix.diff
  2 files changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/Config.mk b/Config.mk
-index 0dab3b7..4cb368f 100644
+index 5909d3a..cd0fa13 100644
 --- a/Config.mk
 +++ b/Config.mk
 @@ -74,7 +74,7 @@ EXTRA_LIB += $(EXTRA_PREFIX)/lib
diff -pruN 4.14.3+32-g9de3671772-1/debian/patches/series 4.16.1-1/debian/patches/series
--- 4.14.3+32-g9de3671772-1/debian/patches/series	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/patches/series	2022-05-09 20:29:23.000000000 +0000
@@ -1,44 +1,24 @@
 0001-Delete-config.sub-and-config.guess.patch
 0002-Delete-configure-output.patch
-0003-version.patch
+0003-Display-Debian-package-version-in-hypervisor-log.patch
 prefix-abiname/config-prefix.diff
 0005-Do-not-ship-COPYING-into-usr-include.patch
 misc/tools-pygrub-remove-static-solaris-support
-misc/toolstestsx86_emulator-pass--no-pie--fno.patch
-0008-Do-not-build-the-instruction-emulator.patch
-0009-tools-libfsimage-prefix.diff.patch
-0010-autoconf-Provide-libexec_libdir_suffix.patch
-0011-.gitignore-Add-configure-output-which-we-always-dele.patch
-0012-Revert-pvshim-make-PV-shim-build-selectable-from-con.patch
-0013-tools-firmware-Makfile-Respect-caller-s-CONFIG_PV_SH.patch
-0014-tools-firmware-Makefile-CONFIG_PV_SHIM-enable-only-o.patch
-0015-shim-Provide-separate-install-shim-target.patch
-0016-docs-man-xen-vbd-interface.7-Provide-properly-format.patch
-0017-Fix-empty-fields-in-first-hypervisor-log-line.patch
-0018-vif-common-disable-handle_iptable.patch
-0019-sysconfig.xencommons.in-Strip-and-debianize.patch
-0020-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch
-0021-pygrub-Set-sys.path.patch
-0022-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch
-0023-tools-xl-bash-completion-also-complete-xen.patch
-0024-tools-don-t-build-ship-xenmon.patch
-0025-tools-Partially-revert-Cross-compilation-fixes.patch
-0026-t-h-L-vif-common.sh-fix-handle_iptable-return-value.patch
-0027-xen-rpi4-implement-watchdog-based-reset.patch
-0028-tools-python-Pass-linker-to-Python-build-process.patch
-0029-xen-arm-acpi-Don-t-fail-if-SPCR-table-is-absent.patch
-0030-xen-acpi-Rework-acpi_os_map_memory-and-acpi_os_unmap.patch
-0031-xen-arm-acpi-The-fixmap-area-should-always-be-cleare.patch
-0032-xen-arm-Check-if-the-platform-is-not-using-ACPI-befo.patch
-0033-xen-arm-Introduce-fw_unreserved_regions-and-use-it.patch
-0034-xen-arm-acpi-add-BAD_MADT_GICC_ENTRY-macro.patch
-0035-xen-arm-traps-Don-t-panic-when-receiving-an-unknown-.patch
-0036-fix-spelling-errors.patch
-0037-xen-don-t-have-timestamp-inserted-in-config.gz.patch
-0038-x86-EFI-don-t-insert-timestamp-when-SOURCE_DATE_EPOC.patch
-0039-docs-use-predictable-ordering-in-generated-documenta.patch
-0040-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch
-0041-x86-ACPI-fix-mapping-of-FACS.patch
-0042-x86-DMI-fix-table-mapping-when-one-lives-above-1Mb.patch
-0043-x86-ACPI-fix-S3-wakeup-vector-mapping.patch
-0044-x86-ACPI-don-t-invalidate-S5-data-when-S3-wakeup-vec.patch
+0007-Do-not-build-the-instruction-emulator.patch
+0008-tools-libfsimage-prefix.diff.patch
+0009-autoconf-Provide-libexec_libdir_suffix.patch
+0010-.gitignore-Add-configure-output-which-we-always-dele.patch
+0011-config-Tools.mk.in-Respect-caller-s-CONFIG_PV_SHIM.patch
+0012-shim-Provide-separate-install-shim-target.patch
+0013-docs-man-xen-vbd-interface.7-Provide-properly-format.patch
+0014-t-h-L-vif-common.sh-disable-handle_iptable.patch
+0015-sysconfig.xencommons.in-Strip-and-debianize.patch
+0016-hotplug-common-Do-not-adjust-LD_LIBRARY_PATH.patch
+0017-pygrub-Set-sys.path.patch
+0018-pygrub-Specify-rpath-LIBEXEC_LIB-when-building-fsima.patch
+0019-tools-xl-bash-completion-also-complete-xen.patch
+0020-tools-don-t-build-ship-xenmon.patch
+0021-docs-set-date-to-SOURCE_DATE_EPOCH-if-available.patch
+0022-xen-arch-x86-make-objdump-output-user-locale-agnosti.patch
+0023-give-meaningful-error-message-if-qemu-device-model-i.patch
+0024-libxl-Fix-unneededly-rebuilding-build.o-pic.patch
diff -pruN 4.14.3+32-g9de3671772-1/debian/rules 4.16.1-1/debian/rules
--- 4.14.3+32-g9de3671772-1/debian/rules	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/rules	2022-05-09 20:29:23.000000000 +0000
@@ -5,6 +5,11 @@
 
 SHELL    := bash -e
 
+# SOURCE_BASE_DIR is used by our delta queue to find the top directory.  It
+# seems this information is currenty not directly provided by the Debian build
+# system.
+export SOURCE_BASE_DIR=$(shell pwd)
+
 # This influences dpkg-buildflags to specify better linker
 # options.  See https://wiki.debian.org/Hardening
 # Apparently some of these might incur silent breakage
@@ -19,15 +24,13 @@ SHELL    := bash -e
 # Inexplicably, if you tell make `export V=value' and `$(shell ...)'
 # it does not pass V to the shell.  WTF.  So we set a variable
 # dbmo which we include in the relevant $(shell ...) invocations.
-dbmo= DEB_BUILD_MAINT_OPTIONS="hardening=+all reproducible=+fixfilepath"
+dbmo= DEB_BUILD_MAINT_OPTIONS="hardening=+all"
 
 # Architecture handling.
 #
 # We need to explicitly specify the architecture because the Xen
 # upstream build system likes to use `uname' which can produce wrong
-# answers it other-bitness chroots, and because we need to build a
-# 64-bit hypervisor even on i386 (since there is no 32-bit hypervisor
-# anymore).
+# answers in other-bitness chroots.
 
 # Also there is terminological confusion.  The DEB_* variables follow
 # GNU GCC terminology:
@@ -42,12 +45,10 @@ include /usr/share/dpkg/architecture.mk
 # Debian nor GNU names.
 
 flavour_amd64 = amd64
-flavour_i386  = amd64
 flavour_armhf = armhf
 flavour_arm64 = arm64
 
 xen_arch_amd64 = x86_64
-xen_arch_i386  = x86_32
 xen_arch_armhf = arm32
 xen_arch_arm64 = arm64
 
@@ -164,12 +165,9 @@ export XEN_BUILD_TIME=$(shell LC_ALL=C d
 export SMBIOS_REL_DATE=$(shell LC_ALL=C date -u -d "@$(SOURCE_DATE_EPOCH)" "+%m/%d/%Y")
 export VGABIOS_REL_DATE=$(shell LC_ALL=C date -u -d "@$(SOURCE_DATE_EPOCH)" "+%d %b %Y")
 
-export PYBUILD_NAME=xen
-export PYBUILD_DISABLE=test
-export PYBUILD_SYSTEM=distutils
 
 %:
-	dh $@ --with=python3 --buildsystem=pybuild
+	dh $@ --with=python3
 
 # Without this, something on stretch passes CFLAGS in the environment
 # to the Xen build system, which then (with 4.11) chokes printing
@@ -209,22 +207,20 @@ override_dh_auto_configure:
 		--disable-blktap1 \
 		--disable-blktap2 \
 		--disable-qemu-traditional --disable-rombios \
-		--with-system-qemu=/usr/bin/qemu-system-i386 \
+		--with-system-qemu=/usr/libexec/xen-qemu-system-i386 \
 		--enable-ovmf --with-system-ovmf=/usr/share/ovmf/OVMF.fd \
 		--with-system-seabios=/usr/share/seabios/bios-256k.bin
 
 # tools/firmware/xen-dir is the `shim' used for booting PV guests
 # in an HVM container, for security (particularly, for meltdown/spectre
-# mitigation).  It's actually a hypervisor.  On i386 it is not built
-# by `make tools' because run that with XEN_COMPILE_ARCH=x86_32 which
-# is no longer a supported hypervisor architecture.  And we want to
-# build it with $(make_args_xen) not $(make_args_tools).  So do it
-# separately.
+# mitigation).  It's actually a hypervisor. It's only built for amd64.
+# Since we want to build it with $(make_args_xen) not $(make_args_tools),
+# do it separately.
 override_dh_auto_build:
 	$(MAKE) $(make_args_xen) xen
 	$(MAKE) $(make_args_tools) tools docs CONFIG_PV_SHIM=n
 	case $(flavour) in \
-	amd64|i386) \
+	amd64) \
 		$(MAKE) $(make_args_xen) -C tools/firmware/xen-dir ;; \
 	esac
 	touch debian/xen-tools-built.stamp
@@ -239,8 +235,7 @@ override_dh_auto_install: $(TEMPLATED_FI
 		install-{tools,docs} CONFIG_PV_SHIM=n
 	:
 	@# shim install target needs to be run separately because we
-	@# need to pass it the make_args_xen settings, in particular
-	@# on i386 bwe need to pass x86_64 here to actually build it.
+	@# need to pass it the make_args_xen settings.
 	@# Luckily this target, unlike the build, is a noop on
 	@# shimless arches, so it does not need to be conditional.
 	$(MAKE) $(make_args_xen) DESTDIR=$t $(make_args_xen) \
@@ -298,6 +293,8 @@ override_dh_python3:
 	dh_python3
 	dh_python3 -pxen-utils-$(upstream_version) \
 		usr/lib/xen-$(upstream_version)/bin
+	dh_python3 -pxen-utils-$(upstream_version) \
+		usr/lib/xen-$(upstream_version)/lib/python
 
 # We have two init scripts.  (There used to be xend too.)
 override_dh_installinit:
diff -pruN 4.14.3+32-g9de3671772-1/debian/salsa-ci.yml 4.16.1-1/debian/salsa-ci.yml
--- 4.14.3+32-g9de3671772-1/debian/salsa-ci.yml	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/salsa-ci.yml	2022-05-09 20:29:23.000000000 +0000
@@ -20,9 +20,18 @@ variables:
   # disable shallow cloning of git repository. This is needed for git-debrebase
   GIT_DEPTH: 0
 
+  RELEASE: 'unstable'
+
   # xen currently does not enable hardening when building the hypervisor so
   # disable blhc.
   SALSA_CI_DISABLE_BLHC: 1
 
   SALSA_CI_REPROTEST_ENABLE_DIFFOSCOPE: 1
 
+  # We do not provide packages for i386
+  SALSA_CI_DISABLE_BUILD_PACKAGE_I386: 1
+
+  # cross building xen currently fails due to Debian bug #982406 in markdown.
+  # It can be tried again when there are better chances of it building
+  # successfully.
+  SALSA_CI_DISABLE_CROSSBUILD_ARM64: 1
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-hypervisor-common.NEWS 4.16.1-1/debian/xen-hypervisor-common.NEWS
--- 4.14.3+32-g9de3671772-1/debian/xen-hypervisor-common.NEWS	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/xen-hypervisor-common.NEWS	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,20 @@
+xen (4.11.1+92-g6c33308a8d-1) unstable; urgency=high
+
+    This update contains the mitigations for the Microarchitectural Data
+    Sampling speculative side channel attacks. Only Intel based processors are
+    affected.
+
+    Note that these fixes will only have effect when also loading updated cpu
+    microcode with MD_CLEAR functionality. When using the intel-microcode
+    package to include microcode in the dom0 initrd, it has to be loaded by
+    Xen. Please refer to the hypervisor command line documentation about the
+    'ucode=scan' option.
+
+    For the fixes to be fully effective, it is currently also needed to disable
+    hyper-threading, which can be done in BIOS settings, or by using smt=no on
+    the hypervisor command line.
+
+    Additional information is available in the upstream Xen security advisory:
+    https://xenbits.xen.org/xsa/advisory-297.html
+
+ -- Hans van Kranenburg <hans@knorrie.org>  Tue, 18 Jun 2019 09:50:19 +0200
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-hypervisor-common.postinst 4.16.1-1/debian/xen-hypervisor-common.postinst
--- 4.14.3+32-g9de3671772-1/debian/xen-hypervisor-common.postinst	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/xen-hypervisor-common.postinst	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+case "$1" in
+    configure)
+        if command -v update-grub > /dev/null && [ -d /boot/grub ]; then
+            update-grub || :
+        fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+	echo "postinst called with unknown argument \`$1'" >&2
+	exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-hypervisor-common.postrm 4.16.1-1/debian/xen-hypervisor-common.postrm
--- 4.14.3+32-g9de3671772-1/debian/xen-hypervisor-common.postrm	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/xen-hypervisor-common.postrm	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+case "$1" in
+    remove)
+        if command -v update-grub > /dev/null && [ -d /boot/grub ]; then
+            update-grub || :
+        fi
+    ;;
+
+    purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-utils-common.install 4.16.1-1/debian/xen-utils-common.install
--- 4.14.3+32-g9de3671772-1/debian/xen-utils-common.install	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/xen-utils-common.install	2022-05-09 20:29:23.000000000 +0000
@@ -5,7 +5,7 @@
 
 etc/xen/scripts
 etc/xen/xl*
-etc/bash_completion.d/xl.sh => usr/share/bash-completion/completions/xl
+etc/bash_completion.d/xl => usr/share/bash-completion/completions/xl
 
 etc/default/xendomains
 etc/default/xencommons => usr/share/xen-utils-common/default.xen
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-utils-common.NEWS 4.16.1-1/debian/xen-utils-common.NEWS
--- 4.14.3+32-g9de3671772-1/debian/xen-utils-common.NEWS	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/debian/xen-utils-common.NEWS	2022-05-09 20:29:23.000000000 +0000
@@ -0,0 +1,42 @@
+xen (4.16.1-1) unstable; urgency=medium
+
+    At this version xen in Debian switched from using standard full-blown build
+    of qemu-system-i386 for the HVM domains and qdisks to a special xen-only
+    build of qemu in qemu-system-xen package. Previously we recommended
+    qemu-system-x86, now we recommend qemu-system-xen.  This significantly
+    reduces amount of inter-dependencies.
+
+    If you have apt configured to automatically install package Recommends
+    (which is the default), when updating to this version of xen, apt will
+    install the new qemu-system-xen recommendation by default, so your
+    qemu-xen domains, if any, will continue to work as before. You might
+    want to remove qemu-system-x86 package at this time if you do not use
+    it, - xen does not use it anymore.
+
+    If your apt is configured to not install Recommends by default, and you
+    do have qemu-xen domUs, you may want to install qemu-system-xen package
+    manually.
+
+ -- Michael Tokarev <mjt@tls.msk.ru>  Sat, 23 Apr 2022 12:02:00 +0300
+
+xen (4.11.4-1) unstable; urgency=medium
+
+    This package version fixes a bug that would call the stop action on the
+    xen init script when removing an obsolete xen-utils-V package for a Xen
+    version V other than the currently running one. This results in stopping
+    the xenconsoled process.
+
+    If you just upgraded from Xen 4.8 (Stretch), this will happen when
+    removing the xen-utils-4.8 package afterwards.
+
+    The resulting situation can safely be repaired by calling the start action
+    on the xen script again manually once to bring back the xenconsoled
+    process. There will be no damage to running domUs.
+
+    If you're upgrading from previous Xen 4.11 packages, no action is needed.
+
+    Having these (or later) Xen 4.11 packages installed means that the bug
+    will not trigger any more when removing xen-utils-4.11 after upgrading to
+    a newer Xen version (e.g. 4.13) in the future.
+
+ -- Hans van Kranenburg <hans@knorrie.org>  Tue, 26 May 2020 13:33:17 +0200
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-utils-common.xen.init 4.16.1-1/debian/xen-utils-common.xen.init
--- 4.14.3+32-g9de3671772-1/debian/xen-utils-common.xen.init	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/xen-utils-common.xen.init	2022-05-09 20:29:23.000000000 +0000
@@ -58,9 +58,9 @@ XENCONSOLED_PIDFILE="/run/xenconsoled.pi
 CXENSTORED="$ROOT"/bin/xenstored
 OXENSTORED="$ROOT"/bin/oxenstored
 XENSTORED_PIDFILE="/run/xenstore.pid"
-QEMU=/usr/bin/qemu-system-i386
+QEMU=/usr/libexec/xen-qemu-system-i386
 QEMU_PIDFILE="/run/qemu-dom0.pid"
-QEMU_ARGS="-xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor /dev/null -serial /dev/null -parallel /dev/null"
+QEMU_ARGS="-xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor none -serial none -parallel none"
 
 modules_setup()
 {
diff -pruN 4.14.3+32-g9de3671772-1/debian/xen-utils-V.install.vsn-in 4.16.1-1/debian/xen-utils-V.install.vsn-in
--- 4.14.3+32-g9de3671772-1/debian/xen-utils-V.install.vsn-in	2021-11-27 14:09:47.000000000 +0000
+++ 4.16.1-1/debian/xen-utils-V.install.vsn-in	2022-05-09 20:29:23.000000000 +0000
@@ -1,7 +1,7 @@
 usr/lib/xen-@version@/bin
 usr/lib/xen-@version@/lib/python
 
-? flavour = amd64 | i386
+? flavour = amd64
 usr/lib/xen-@version@/boot
 usr/lib/debug/usr/lib/xen-*/boot/* usr/lib/debug/xen-syms-@version@-shim
 # ^ Yes, the upstream build system really does install the shim symbols
diff -pruN 4.14.3+32-g9de3671772-1/docs/configure 4.16.1-1/docs/configure
--- 4.14.3+32-g9de3671772-1/docs/configure	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/configure	2022-04-12 12:21:23.000000000 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Xen Hypervisor Documentation 4.14.
+# Generated by GNU Autoconf 2.69 for Xen Hypervisor Documentation 4.16.
 #
 # Report bugs to <xen-devel@lists.xen.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Xen Hypervisor Documentation'
 PACKAGE_TARNAME='xen'
-PACKAGE_VERSION='4.14'
-PACKAGE_STRING='Xen Hypervisor Documentation 4.14'
+PACKAGE_VERSION='4.16'
+PACKAGE_STRING='Xen Hypervisor Documentation 4.16'
 PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 PACKAGE_URL='https://www.xen.org/'
 
@@ -597,10 +597,7 @@ DEBUG_DIR
 XEN_DUMP_DIR
 XEN_PAGING_DIR
 XEN_LOCK_DIR
-XEN_SCRIPT_DIR
-XEN_CONFIG_DIR
 INITD_DIR
-CONFIG_DIR
 SHAREDIR
 XEN_LIB_DIR
 XEN_RUN_STORED
@@ -612,7 +609,10 @@ LIBEXEC_INC
 LIBEXEC_LIB
 LIBEXEC_BIN
 LIBEXEC
+XEN_SCRIPT_DIR
 CONFIG_LEAF_DIR
+XEN_CONFIG_DIR
+CONFIG_DIR
 XENSTORED_PORT
 XENSTORED_KVA
 target_alias
@@ -660,6 +660,7 @@ enable_option_checking
 with_initddir
 with_sysconfig_leaf_dir
 with_libexec_leaf_dir
+with_xen_scriptdir
 with_xen_dumpdir
 with_rundir
 with_debugdir
@@ -1223,7 +1224,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Xen Hypervisor Documentation 4.14 to adapt to many kinds of systems.
+\`configure' configures Xen Hypervisor Documentation 4.16 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1285,7 +1286,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Xen Hypervisor Documentation 4.14:";;
+     short | recursive ) echo "Configuration of Xen Hypervisor Documentation 4.16:";;
    esac
   cat <<\_ACEOF
 
@@ -1301,6 +1302,9 @@ Optional Packages:
                           "default". [sysconfig]
   --with-libexec-leaf-dir=SUBDIR
                           Name of subdirectory in libexecdir to use.
+  --with-xen-scriptdir=DIR
+                          Path to directory for dom0 hotplug scripts.
+                          [SYSCONFDIR/xen/scripts]
   --with-xen-dumpdir=DIR  Path to directory for domU crash dumps.
                           [LOCALSTATEDIR/lib/xen/dump]
   --with-rundir=DIR       Path to directory for runtime data.
@@ -1383,7 +1387,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Xen Hypervisor Documentation configure 4.14
+Xen Hypervisor Documentation configure 4.16
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1400,7 +1404,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Xen Hypervisor Documentation $as_me 4.14, which was
+It was created by Xen Hypervisor Documentation $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -1749,7 +1753,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_files="$ac_config_files ../config/Docs.mk man/xl.cfg.5.pod man/xl.1.pod"
+ac_config_files="$ac_config_files ../config/Docs.mk man/xl.cfg.5.pod man/xl.1.pod man/xl-disk-configuration.5.pod man/xl-network-configuration.5.pod man/xl.conf.5.pod"
 
 ac_aux_dir=
 for ac_dir in ../ "$srcdir"/../; do
@@ -1839,6 +1843,12 @@ if test "x$sysconfdir" = 'x${prefix}/etc
     esac
 fi
 
+CONFIG_DIR=$sysconfdir
+
+
+XEN_CONFIG_DIR=$CONFIG_DIR/xen
+
+
 
 # Check whether --with-initddir was given.
 if test "${with_initddir+set}" = set; then :
@@ -1881,6 +1891,17 @@ fi
 
 
 
+# Check whether --with-xen-scriptdir was given.
+if test "${with_xen_scriptdir+set}" = set; then :
+  withval=$with_xen_scriptdir; xen_scriptdir_path=$withval
+else
+  xen_scriptdir_path=$XEN_CONFIG_DIR/scripts
+fi
+
+XEN_SCRIPT_DIR=$xen_scriptdir_path
+
+
+
 # Check whether --with-xen-dumpdir was given.
 if test "${with_xen_dumpdir+set}" = set; then :
   withval=$with_xen_dumpdir; xen_dumpdir_path=$withval
@@ -1945,21 +1966,12 @@ XEN_LIB_DIR=$localstatedir/lib/xen
 SHAREDIR=$prefix/share
 
 
-CONFIG_DIR=$sysconfdir
-
-
 INITD_DIR=$initddir_path
 
 
-XEN_CONFIG_DIR=$CONFIG_DIR/xen
-
-
-XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
-
-
 case "$host_os" in
 *freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
-*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 *) XEN_LOCK_DIR=$localstatedir/lock ;;
 esac
 
@@ -2809,7 +2821,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Xen Hypervisor Documentation $as_me 4.14, which was
+This file was extended by Xen Hypervisor Documentation $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -2863,7 +2875,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Xen Hypervisor Documentation config.status 4.14
+Xen Hypervisor Documentation config.status 4.16
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -2976,6 +2988,9 @@ do
     "../config/Docs.mk") CONFIG_FILES="$CONFIG_FILES ../config/Docs.mk" ;;
     "man/xl.cfg.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl.cfg.5.pod" ;;
     "man/xl.1.pod") CONFIG_FILES="$CONFIG_FILES man/xl.1.pod" ;;
+    "man/xl-disk-configuration.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl-disk-configuration.5.pod" ;;
+    "man/xl-network-configuration.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl-network-configuration.5.pod" ;;
+    "man/xl.conf.5.pod") CONFIG_FILES="$CONFIG_FILES man/xl.conf.5.pod" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
diff -pruN 4.14.3+32-g9de3671772-1/docs/configure.ac 4.16.1-1/docs/configure.ac
--- 4.14.3+32-g9de3671772-1/docs/configure.ac	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/configure.ac	2022-04-12 12:21:23.000000000 +0000
@@ -9,6 +9,9 @@ AC_CONFIG_FILES([
 ../config/Docs.mk
 man/xl.cfg.5.pod
 man/xl.1.pod
+man/xl-disk-configuration.5.pod
+man/xl-network-configuration.5.pod
+man/xl.conf.5.pod
 ])
 AC_CONFIG_AUX_DIR([../])
 
diff -pruN 4.14.3+32-g9de3671772-1/docs/designs/argo.pandoc 4.16.1-1/docs/designs/argo.pandoc
--- 4.14.3+32-g9de3671772-1/docs/designs/argo.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/designs/argo.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -439,6 +439,51 @@ that teardown of any domain will not int
 operation. It enables introducing granular locking without complex or
 error-prone lock acquisition logic.
 
+# Related Material
+
+## Enabling Argo in Xen
+
+To enable Argo in a build of the Xen hypervisor, please ensure that
+CONFIG_ARGO is enabled in the Xen hypervisor build configuration file.
+
+To make Argo available for use at runtime on a Xen system, please see the
+Argo settings in the Xen command line documentation.
+
+## Linux Argo drivers
+
+A Linux kernel device driver for Argo and corresponding Linux userspace
+software, libargo, that utilizes it for interdomain communication between
+application level software is available and maintained by the OpenXT Project,
+at:
+
+https://github.com/OpenXT/linux-xen-argo
+
+The repository contains the primary Linux kernel Argo driver, which is derived
+from the original XenClient v4v driver. The document at the following link
+describes planning and design notes from OpenXT community discussion for
+improvements to the driver:
+
+https://openxt.atlassian.net/wiki/spaces/DC/pages/775389197/New+Linux+Driver+for+Argo
+
+An alternative Linux Argo driver is also available in the same repository,
+implemented to explore a different approach for Linux to use the Argo
+primitives under the Vsock address family to allow socket communication between
+Xen domains.
+
+## v4v drivers
+
+A Windows driver for v4v has previously been used in XenClient and OpenXT
+which could be ported to Argo. It may require update for compatibility with
+recent versions of Windows software.
+
+https://github.com/OpenXT/xc-windows/tree/master/xenv4v
+
+The Linux, Windows and OSX guest tools for the Open Source HP uxen hypervisor
+contain drivers for v4v which are relevant as code bases of interest for
+porting or developing new guest OS drivers for Argo.
+
+https://github.com/uxen-virt/uxen/tree/ascara/vm-support
+
 # Future Work
 
 - Performance measurement and optimization
diff -pruN 4.14.3+32-g9de3671772-1/docs/designs/dmop.pandoc 4.16.1-1/docs/designs/dmop.pandoc
--- 4.14.3+32-g9de3671772-1/docs/designs/dmop.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/designs/dmop.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -4,9 +4,15 @@ DMOP
 Introduction
 ------------
 
-The aim of DMOP is to prevent a compromised device model from compromising
-domains other than the one it is providing emulation for (which is therefore
-likely already compromised).
+The DMOP hypercall has a new ABI design to solve problems in the Xen
+ecosystem.  First, the ABI is fully stable, to reduce the coupling between
+device models and the version of Xen.  Specifically, device model software
+using DMOP (be it user, stub domain or kernel software) need not be recompiled
+to match the version of the running hypervisor.
+
+Secondly, for device models in userspace, the ABI is designed specifically to
+allow a kernel to audit the memory ranges used, without having to know the
+internal structure of sub-ops.
 
 The problem occurs when you a device model issues an hypercall that
 includes references to user memory other than the operation structure
diff -pruN 4.14.3+32-g9de3671772-1/docs/designs/launch/hyperlaunch-devicetree.rst 4.16.1-1/docs/designs/launch/hyperlaunch-devicetree.rst
--- 4.14.3+32-g9de3671772-1/docs/designs/launch/hyperlaunch-devicetree.rst	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/docs/designs/launch/hyperlaunch-devicetree.rst	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,343 @@
+-------------------------------------
+Xen Hyperlaunch Device Tree Bindings
+-------------------------------------
+
+The Xen Hyperlaunch device tree adopts the dom0less device tree structure and
+extends it to meet the requirements for the Hyperlaunch capability. The primary
+difference is the introduction of the ``hypervisor`` node that is under the
+``/chosen`` node. The move to a dedicated node was driven by:
+
+1. Reduces the need to walk over nodes that are not of interest, e.g. only
+   nodes of interest should be in ``/chosen/hypervisor``
+
+2. Allows for the domain construction information to easily be sanitized by
+   simple removing the ``/chosen/hypervisor`` node.
+
+Example Configuration
+---------------------
+
+Below are two example device tree definitions for the hypervisor node. The
+first is an example of a multiboot-based configuration for x86 and the second
+is a module-based configuration for Arm.
+
+Multiboot x86 Configuration:
+""""""""""""""""""""""""""""
+
+::
+
+    hypervisor {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        compatible = “hypervisor,xen”
+
+        // Configuration container
+        config {
+            compatible = "xen,config";
+
+            module {
+                compatible = "module,microcode", "multiboot,module";
+                mb-index = <1>;
+            };
+
+            module {
+                compatible = "module,xsm-policy", "multiboot,module";
+                mb-index = <2>;
+            };
+        };
+
+        // Boot Domain definition
+        domain {
+            compatible = "xen,domain";
+
+            domid = <0x7FF5>;
+
+            // FUNCTION_NONE            (0)
+            // FUNCTION_BOOT            (1 << 0)
+            // FUNCTION_CRASH           (1 << 1)
+            // FUNCTION_CONSOLE         (1 << 2)
+            // FUNCTION_XENSTORE        (1 << 30)
+            // FUNCTION_LEGACY_DOM0     (1 << 31)
+            functions = <0x00000001>;
+
+            memory = <0x0 0x20000>;
+            cpus = <1>;
+            module {
+                compatible = "module,kernel", "multiboot,module";
+                mb-index = <3>;
+            };
+
+            module {
+                compatible = "module,ramdisk", "multiboot,module";
+                mb-index = <4>;
+            };
+            module {
+                compatible = "module,config", "multiboot,module";
+                mb-index = <5>;
+            };
+
+        // Classic Dom0 definition
+        domain {
+            compatible = "xen,domain";
+
+            domid = <0>;
+
+            // PERMISSION_NONE          (0)
+            // PERMISSION_CONTROL       (1 << 0)
+            // PERMISSION_HARDWARE      (1 << 1)
+            permissions = <3>;
+
+            // FUNCTION_NONE            (0)
+            // FUNCTION_BOOT            (1 << 0)
+            // FUNCTION_CRASH           (1 << 1)
+            // FUNCTION_CONSOLE         (1 << 2)
+            // FUNCTION_XENSTORE        (1 << 30)
+            // FUNCTION_LEGACY_DOM0     (1 << 31)
+            functions = <0xC0000006>;
+
+            // MODE_PARAVIRTUALIZED     (1 << 0) /* PV | PVH/HVM */
+            // MODE_ENABLE_DEVICE_MODEL (1 << 1) /* HVM | PVH */
+            // MODE_LONG                (1 << 2) /* 64 BIT | 32 BIT */
+            mode = <5>; /* 64 BIT, PV */
+
+            // UUID
+            domain-uuid = [B3 FB 98 FB 8F 9F 67 A3];
+
+            cpus = <1>;
+            memory = <0x0 0x20000>;
+            security-id = “dom0_t;
+
+            module {
+                compatible = "module,kernel", "multiboot,module";
+                mb-index = <6>;
+                bootargs = "console=hvc0";
+            };
+            module {
+                compatible = "module,ramdisk", "multiboot,module";
+                mb-index = <7>;
+            };
+    };
+
+The multiboot modules supplied when using the above config would be, in order:
+
+* (the above config, compiled)
+* CPU microcode
+* XSM policy
+* kernel for boot domain
+* ramdisk for boot domain
+* boot domain configuration file
+* kernel for the classic dom0 domain
+* ramdisk for the classic dom0 domain
+
+Module Arm Configuration:
+"""""""""""""""""""""""""
+
+::
+
+    hypervisor {
+        compatible = “hypervisor,xen”
+
+        // Configuration container
+        config {
+            compatible = "xen,config";
+
+            module {
+                compatible = "module,microcode”;
+                module-addr = <0x0000ff00 0x80>;
+            };
+
+            module {
+                compatible = "module,xsm-policy";
+                module-addr = <0x0000ff00 0x80>;
+
+            };
+        };
+
+        // Boot Domain definition
+        domain {
+            compatible = "xen,domain";
+
+            domid = <0x7FF5>;
+
+            // FUNCTION_NONE            (0)
+            // FUNCTION_BOOT            (1 << 0)
+            // FUNCTION_CRASH           (1 << 1)
+            // FUNCTION_CONSOLE         (1 << 2)
+            // FUNCTION_XENSTORE        (1 << 30)
+            // FUNCTION_LEGACY_DOM0     (1 << 31)
+            functions = <0x00000001>;
+
+            memory = <0x0 0x20000>;
+            cpus = <1>;
+            module {
+                compatible = "module,kernel";
+                module-addr = <0x0000ff00 0x80>;
+            };
+
+            module {
+                compatible = "module,ramdisk";
+                module-addr = <0x0000ff00 0x80>;
+            };
+            module {
+                compatible = "module,config";
+                module-addr = <0x0000ff00 0x80>;
+            };
+
+        // Classic Dom0 definition
+        domain@0 {
+            compatible = "xen,domain";
+
+            domid = <0>;
+
+            // PERMISSION_NONE          (0)
+            // PERMISSION_CONTROL       (1 << 0)
+            // PERMISSION_HARDWARE      (1 << 1)
+            permissions = <3>;
+
+            // FUNCTION_NONE            (0)
+            // FUNCTION_BOOT            (1 << 0)
+            // FUNCTION_CRASH           (1 << 1)
+            // FUNCTION_CONSOLE         (1 << 2)
+            // FUNCTION_XENSTORE        (1 << 30)
+            // FUNCTION_LEGACY_DOM0     (1 << 31)
+            functions = <0xC0000006>;
+
+            // MODE_PARAVIRTUALIZED     (1 << 0) /* PV | PVH/HVM */
+            // MODE_ENABLE_DEVICE_MODEL (1 << 1) /* HVM | PVH */
+            // MODE_LONG                (1 << 2) /* 64 BIT | 32 BIT */
+            mode = <5>; /* 64 BIT, PV */
+
+            // UUID
+            domain-uuid = [B3 FB 98 FB 8F 9F 67 A3];
+
+            cpus = <1>;
+            memory = <0x0 0x20000>;
+            security-id = “dom0_t”;
+
+            module {
+                compatible = "module,kernel";
+                module-addr = <0x0000ff00 0x80>;
+                bootargs = "console=hvc0";
+            };
+            module {
+                compatible = "module,ramdisk";
+                module-addr = <0x0000ff00 0x80>;
+            };
+    };
+
+The modules that would be supplied when using the above config would be:
+
+* (the above config, compiled into hardware tree)
+* CPU microcode
+* XSM policy
+* kernel for boot domain
+* ramdisk for boot domain
+* boot domain configuration file
+* kernel for the classic dom0 domain
+* ramdisk for the classic dom0 domain
+
+The hypervisor device tree would be compiled into the hardware device tree and
+provided to Xen using the standard method currently in use. The remaining
+modules would need to be loaded in the respective addresses specified in the
+`module-addr` property.
+
+
+The Hypervisor node
+-------------------
+
+The hypervisor node is a top level container for the domains that will be built
+by hypervisor on start up. On the ``hypervisor`` node the ``compatible``
+property is used to identify the type of hypervisor node present..
+
+compatible
+  Identifies the type of node. Required.
+
+The Config node
+---------------
+
+A config node is for detailing any modules that are of interest to Xen itself.
+For example this would be where Xen would be informed of microcode or XSM
+policy locations. If the modules are multiboot modules and are able to be
+located by index within the module chain, the ``mb-index`` property should be
+used to specify the index in the multiboot module chain.. If the module will be
+located by physical memory address, then the ``module-addr`` property should be
+used to identify the location and size of the module.
+
+compatible
+  Identifies the type of node. Required.
+
+The Domain node
+---------------
+
+A domain node is for describing the construction of a domain. It may provide a
+domid property which will be used as the requested domain id for the domain
+with a value of “0” signifying to use the next available domain id, which is
+the default behavior if omitted. A domain configuration is not able to request
+a domid of “0”. After that a domain node may have any of the following
+parameters,
+
+compatible
+  Identifies the type of node. Required.
+
+domid
+  Identifies the domid requested to assign to the domain. Required.
+
+permissions
+  This sets what Discretionary Access Control permissions
+  a domain is assigned. Optional, default is none.
+
+functions
+  This identifies what system functions a domain will fulfill.
+  Optional, the default is none.
+
+.. note::  The `functions` bits that have been selected to indicate
+   ``FUNCTION_XENSTORE`` and ``FUNCTION_LEGACY_DOM0`` are the last two bits
+   (30, 31) such that should these features ever be fully retired, the flags may
+   be dropped without leaving a gap in the flag set.
+
+mode
+  The mode the domain will be executed under. Required.
+
+domain-uuid
+  A globally unique identifier for the domain. Optional,
+  the default is NULL.
+
+cpus
+  The number of vCPUs to be assigned to the domain. Optional,
+  the default is “1”.
+
+memory
+  The amount of memory to assign to the domain, in KBs.
+  Required.
+
+security-id
+  The security identity to be assigned to the domain when XSM
+  is the access control mechanism being used. Optional,
+  the default is “domu_t”.
+
+The Module node
+---------------
+
+This node describes a boot module loaded by the boot loader. The required
+compatible property follows the format: module,<type> where type can be
+“kernel”, “ramdisk”, “device-tree”, “microcode”, “xsm-policy” or “config”. In
+the case the module is a multiboot module, the additional property string
+“multiboot,module” may be present. One of two properties is required and
+identifies how to locate the module. They are the mb-index, used for multiboot
+modules, and the module-addr for memory address based location.
+
+compatible
+  This identifies what the module is and thus what the hypervisor
+  should use the module for during domain construction. Required.
+
+mb-index
+  This identifies the index for this module in the multiboot module chain.
+  Required for multiboot environments.
+
+module-addr
+  This identifies where in memory this module is located. Required for
+  non-multiboot environments.
+
+bootargs
+  This is used to provide the boot params to kernel modules.
+
+.. note::  The bootargs property is intended for situations where the same kernel multiboot module is used for more than one domain.
diff -pruN 4.14.3+32-g9de3671772-1/docs/designs/launch/hyperlaunch.rst 4.16.1-1/docs/designs/launch/hyperlaunch.rst
--- 4.14.3+32-g9de3671772-1/docs/designs/launch/hyperlaunch.rst	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/docs/designs/launch/hyperlaunch.rst	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,1004 @@
+###########################
+Hyperlaunch Design Document
+###########################
+
+.. sectnum:: :depth: 4
+
+This post is a Request for Comment on the included v4 of a design document that
+describes Hyperlaunch: a new method of launching the Xen hypervisor, relating
+to dom0less and work from the Hyperlaunch project. We invite discussion of this
+on this list, at the monthly Xen Community Calls, and at dedicated meetings on
+this topic in the Xen Working Group which will be announced in advance on the
+Xen Development mailing list.
+
+
+.. contents:: :depth: 3
+
+
+Introduction
+============
+
+This document describes the design and motivation for the funded development of
+a new, flexible system for launching the Xen hypervisor and virtual machines
+named: "Hyperlaunch".
+
+The design enables seamless transition for existing systems that require a
+dom0, and provides a new general capability to build and launch alternative
+configurations of virtual machines, including support for static partitioning
+and accelerated start of VMs during host boot, while adhering to the principles
+of least privilege. It incorporates the existing dom0less functionality,
+extended to fold in the new developments from the Hyperlaunch project, with
+support for both x86 and Arm platform architectures, building upon and
+replacing the earlier 'late hardware domain' feature for disaggregation of
+dom0.
+
+Hyperlaunch is designed to be flexible and reusable across multiple use cases,
+and our aim is to ensure that it is capable, widely exercised, comprehensively
+tested, and well understood by the Xen community.
+
+Document Structure
+==================
+
+This is the primary design document for Hyperlaunch, to provide an overview of
+the feature. Separate additional documents will cover specific aspects of
+Hyperlaunch in further detail, including:
+
+  - The Device Tree specification for Hyperlaunch metadata
+  - New Domain Roles for Xen and the Xen Security Modules (XSM) policy
+  - Passthrough of PCI devices with Hyperlaunch
+
+Approach
+========
+
+Born out of improving support for Dynamic Root of Trust for Measurement (DRTM),
+the Hyperlaunch project is focused on restructuring the system launch of Xen.
+The Hyperlaunch design provides a security architecture that builds on the
+principles of Least Privilege and Strong Isolation, achieving this through the
+disaggregation of system functions. It enables this with the introduction of a
+boot domain that works in conjunction with the hypervisor to provide the
+ability to launch multiple domains as part of host boot while maintaining a
+least privilege implementation.
+
+While the Hyperlaunch project inception was and continues to be driven by a
+focus on security through disaggregation, there are multiple use cases with a
+non-security focus that require or benefit from the ability to launch multiple
+domains at host boot. This was proven by the need that drove the implementation
+of the dom0less capability in the Arm branch of Xen.
+
+Hyperlaunch is designed to be flexible and reusable across multiple use cases,
+and our aim is to ensure that it is capable, widely exercised, comprehensively
+tested, and provides a robust foundation for current and emerging system launch
+requirements of the Xen community.
+
+
+Objectives
+----------
+
+* In general strive to maintain compatibility with existing Xen behavior
+* A default build of the hypervisor should be capable of booting both legacy-compatible and new styles of launch:
+
+        * classic Xen boot: starting a single, privileged Dom0
+        * classic Xen boot with late hardware domain: starting a Dom0 that transitions hardware access/control to another domain
+        * a dom0less boot: starting multiple domains without privilege assignment controls
+        * Hyperlaunch: starting one or more VMs, with flexible configuration
+
+* Preferred that it be managed via KCONFIG options to govern inclusion of support for each style
+* The selection between classic boot and Hyperlaunch boot should be automatic
+
+        * Preferred that it not require a kernel command line parameter for selection
+
+* It should not require modification to boot loaders
+* It should provide a user friendly interface for its configuration and management
+* It must provide a method for building systems that fallback to console access in the event of misconfiguration
+* It should be able to boot an x86 Xen environment without the need for a Dom0 domain
+
+
+Requirements and Design
+=======================
+
+Hyperlaunch is defined as the ability of a hypervisor to construct and start
+one or more virtual machines at system launch in a specific way. A hypervisor
+can support one or both modes of configuration, Hyperlaunch Static and
+Hyperlaunch Dynamic. The Hyperlaunch Static mode functions as a static
+partitioning hypervisor ensuring only the virtual machines started at system
+launch are running on the system. The Hyperlaunch Dynamic mode functions as a
+dynamic hypervisor allowing for additional virtual machines to be started after
+the initial virtual machines have started. The Xen hypervisor is capable of
+both modes of configuration from the same binary and when paired with its XSM
+flask, provides strong controls that enable fine grained system partitioning.
+
+Hypervisor Launch Landscape
+---------
+
+This comparison table presents the distinctive capabilities of Hyperlaunch with
+reference to existing launch configurations currently available in Xen and
+other hypervisors.
+
+::
+
+ +---------------+-----------+------------+-----------+-------------+---------------------+
+ | **Xen Dom0**  | **Linux** | **Late**   | **Jail**  | **Xen**     | **Xen Hyperlaunch** |
+ | **(Classic)** | **KVM**   | **HW Dom** | **house** | **dom0less**+---------+-----------+
+ |               |           |            |           |             | Static  | Dynamic   |
+ +===============+===========+============+===========+=============+=========+===========+
+ | Hypervisor able to launch multiple VMs during host boot                                |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |     Y     |       Y     |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Hypervisor supports Static Partitioning                                                |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |     Y     |       Y     |    Y    |           |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Able to launch VMs dynamically after host boot                                         |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |       Y       |     Y     |      Y*    |     Y     |       Y*    |         |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Supports strong isolation between all VMs started at host boot                         |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |     Y     |       Y     |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Enables flexible sequencing of VM start during host boot                               |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |             |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Prevent all-powerful static root domain being launched at boot                         |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |       Y*    |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Operates without a Highly-privileged management VM (eg. Dom0)                          |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |      Y*    |           |       Y*    |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Operates without a privileged toolstack VM (Control Domain)                            |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |       Y*    |    Y    |           |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Extensible VM configuration applied before launch of VMs at host boot                  |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |             |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Flexible granular assignment of permissions and functions to VMs                       |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |             |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | Supports extensible VM measurement architecture for DRTM and attestation               |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |             |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ | PCI passthrough configured at host boot                                                |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+ |               |           |            |           |             |    Y    |     Y     |
+ +---------------+-----------+------------+-----------+-------------+---------+-----------+
+
+
+Domain Construction
+-------------------
+
+An important aspect of the Hyperlaunch architecture is that the hypervisor
+performs domain construction for all the Initial Domains,  ie. it builds each
+domain that is described in the Launch Control Module. More specifically, the
+hypervisor will perform the function of *domain creation* for each Initial
+Domain: it allocates the unique domain identifier assigned to the virtual
+machine and records essential metadata about it in the internal data structure
+that enables scheduling the domain to run. It will also perform *basic domain
+construction*: build the initial page tables with data from the kernel and
+initial ramdisk supplied, and as appropriate for the domain type, populate the
+p2m table and ACPI tables.
+
+Subsequent to this, the boot domain can apply additional configuration to the
+initial domains from the data in the LCM, in *extended domain construction*.
+
+The benefits of this structure include:
+
+* Security: Contrains the permissions required by the boot domain: it does not
+  require the capability to create domains in this structure. This aligns with
+  the principles of least privilege.
+* Flexibility: Enables policy-based dynamic assignment of hardware by the boot
+  domain, customizable according to use-case and able to adapt to hardware
+  discovery
+* Compatibility: Supports reuse of familiar tools with use-case customized boot
+  domains.
+* Commonality: Reuses the same logic for initial basic domain building across
+  diverse Xen deployments.
+	* It aligns the x86 initial domain construction with the existing Arm
+	  dom0less feature for construction of multiple domains at boot.
+	* The boot domain implementation may vary significantly with different
+	  deployment use cases, whereas the hypervisor implementation is
+	  common.
+* Correctness: Increases confidence in the implementation of domain
+  construction, since it is performed by the hypervisor in well maintained and
+  centrally tested logic.
+* Performance: Enables launch for configurations where a fast start of
+  multiple domains at boot is a requirement.
+* Capability: Supports launch of advanced configurations where a sequenced
+  start of multiple domains is required, or multiple domains are involved in
+  startup of the running system configuration
+	* eg. for PCI passthrough on systems where the toolstack runs in a
+	  separate domain to the hardware management.
+
+Please, see the ‘Hyperlaunch Device Tree’ design document, which describes the
+configuration module that is provided to the hypervisor by the bootloader.
+
+The hypervisor determines how these domains are started as host boot completes:
+in some systems the Boot Domain acts upon the extended boot configuration
+supplied as part of launch, performing configuration tasks for preparing the
+other domains for the hypervisor to commence running them.
+
+Common Boot Configurations
+--------------------------
+
+When looking across those that have expressed interest or discussed a need for
+launching multiple domains at host boot, the Hyperlaunch approach is to provide
+the means to start nearly any combination of domains. Below is an enumerated
+selection of common boot configurations for reference in the following section.
+
+Dynamic Launch with a Highly-Privileged Domain 0
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Hyperlaunch Classic: Dom0
+        This configuration mimics the classic Xen start and domain construction
+        where a single domain is constructed with all privileges and functions for
+        managing hardware and running virtualization toolstack software.
+
+Hyperlaunch Classic: Extended Launch Dom0
+        This configuration is where a Dom0 is started via a Boot Domain that runs
+        first. This is for cases where some preprocessing in a less privileged domain
+        is required before starting the all-privileged Domain 0.
+
+Hyperlaunch Classic: Basic Cloud
+        This configuration constructs a Dom0 that is started in parallel with some
+        number of workload domains.
+
+Hyperlaunch Classic: Cloud
+        This configuration builds a Dom0 and some number of workload domains, launched
+        via a Boot Domain that runs first.
+
+
+Static Launch Configurations: without a Domain 0 or a Control Domain
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Hyperlaunch Static: Basic
+        Simple static partitioning where all domains that can be run on this system are
+        built and started during host boot and where no domain is started with the
+        Control Domain permissions, thus making it not possible to create/start any
+        further new domains.
+
+Hyperlaunch Static: Standard
+        This is a variation of the “Hyperlaunch Static: Basic” static partitioning
+        configuration with the introduction of a Boot Domain. This configuration allows
+        for use of a Boot Domain to be able to apply extended configuration
+        to the Initial Domains before they are started and
+        sequence the order in which they start.
+
+Hyperlaunch Static: Disaggregated
+        This is a variation of the “Hyperlaunch Static: Standard” configuration with
+        the introduction of a Boot Domain and an illustration that some functions can
+        be disaggregated to dedicated domains.
+
+Dynamic Launch of Disaggregated System Configurations
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Hyperlaunch Dynamic: Hardware Domain
+        This configuration mimics the existing Xen feature late hardware domain with
+        the one difference being that the hardware domain is constructed by the
+        hypervisor at startup instead of later by Dom0.
+
+Hyperlaunch Dynamic: Flexible Disaggregation
+        This configuration is similar to the “Hyperlaunch Classic: Dom0” configuration
+        except that it includes starting a separate hardware domain during Xen startup.
+        It is also similar to “Hyperlaunch Dynamic: Hardware Domain” configuration, but
+        it launches via a Boot Domain that runs first.
+
+Hyperlaunch Dynamic: Full Disaggregation
+        In this configuration it is demonstrated how it is possible to start a fully
+        disaggregated system: the virtualization toolstack runs in a Control Domain,
+        separate from the domains responsible for managing hardware, XenStore, the Xen
+        Console and Crash functions, each launched via a Boot Domain.
+
+
+Example Use Cases and Configurations
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following example use cases can be matched to configurations listed in the
+previous section.
+
+Use case: Modern cloud hypervisor
+"""""""""""""""""""""""""""""""""
+
+**Option:** Hyperlaunch Classic: Cloud
+
+This configuration will support strong isolation for virtual TPM domains and
+measured launch in support of attestation to infrastructure management, while
+allowing the use of existing Dom0 virtualization toolstack software.
+
+Use case: Edge device with security or safety requirements
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+**Option:** Hyperlaunch Static: Boot
+
+This configuration runs without requiring a highly-privileged Dom0, and enables
+extended VM configuration to be applied to the Initial VMs prior to launching
+them, optionally in a sequenced start.
+
+Use case: Client hypervisor
+"""""""""""""""""""""""""""
+
+**Option:** Hyperlaunch Dynamic: Flexible Disaggregation
+
+**Option:** Hyperlaunch Dynamic: Full Disaggregation
+
+These configurations enable dynamic client workloads, strong isolation for the
+domain running the virtualization toolstack software and each domain managing
+hardware, with PCI passthrough performed during host boot and support for
+measured launch.
+
+Hyperlaunch Disaggregated Launch
+--------------------------------
+
+
+Existing in Xen today are two primary permissions, *control domain* and
+*hardware domain*, and two functions, *console domain* and *xenstore domain*,
+that can be assigned to a domain. Traditionally all of these permissions and
+functions are all assigned to Dom0 at start and can then be delegated to other
+domains created by the toolstack in Dom0. With Hyperlaunch it becomes possible
+to assign these permissions and functions to any domain for which there is a
+definition provided at startup.
+
+Additionally, two further functions are introduced: the *recovery domain*,
+intended to assist with recovery from failures encountered starting VMs during
+host boot, and the *boot domain*, for performing aspects of domain construction
+during startup.
+
+Supporting the booting of each of the above common boot configurations is
+accomplished by considering the set of initial domains and the assignment of
+Xen’s permissions and functions, including the ones introduced by Hyperlaunch,
+to these domains. A discussion of these will be covered later but for now they
+are laid out in a table with a mapping to the common boot configurations. This
+table is not intended to be an exhaustive list of configurations and does not
+account for flask policy specified functions that are use case specific.
+
+In the table each number represents a separate domain being
+constructed by the Hyperlaunch construction path as Xen starts, and the
+designator, ``{n}`` signifies that there may be “n” additional domains that may
+be constructed that do not have any special role for a general Xen system.
+
+::
+
+ +-------------------+------------------+-----------------------------------+
+ | Configuration     |    Permission    |            Function               |
+ |                   +------+------+----+------+--------+--------+----------+
+ |                   | None | Ctrl | HW | Boot |Recovery| Console| Xenstore |
+ +===================+======+======+====+======+========+========+==========+
+ | Classic: Dom0     |      |  0   | 0  |      |   0    |   0    |    0     |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Classic: Extended |      |  1   | 1  |  0   |   1    |   1    |    1     |
+ | Launch Dom0       |      |      |    |      |        |        |          |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Classic:          | {n}  |  0   | 0  |      |   0    |   0    |    0     |
+ | Basic Cloud       |      |      |    |      |        |        |          |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Classic: Cloud    | {n}  |  1   | 1  |  0   |   1    |   1    |    1     |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Static: Basic     | {n}  |      | 0  |      |   0    |   0    |    0     |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Static: Standard  | {n}  |      | 1  |  0   |   1    |   1    |    1     |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Static:           | {n}  |      | 2  |  0   |   3    |   4    |    1     |
+ | Disaggregated     |      |      |    |      |        |        |          |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Dynamic:          |      |  0   | 1  |      |   0    |   0    |    0     |
+ | Hardware Domain   |      |      |    |      |        |        |          |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Dynamic: Flexible | {n}  |  1   | 2  |  0   |   1    |   1    |    1     |
+ | Disaggregation    |      |      |    |      |        |        |          |
+ +-------------------+------+------+----+------+--------+--------+----------+
+ | Dynamic: Full     | {n}  |  2   | 3  |  0   |   4    |   5    |    1     |
+ | Disaggregation    |      |      |    |      |        |        |          |
+ +-------------------+------+------+----+------+--------+--------+----------+
+
+Overview of Hyperlaunch Flow
+----------------------------
+
+Before delving into Hyperlaunch, a good basis to start with is an understanding
+of the current process to create a domain. A way to view this process starts
+with the core configuration which is the information the hypervisor requires to
+make the call to `domain_create`, followed by basic construction to provide the
+memory image to run, including the kernel and ramdisk. A subsequent step
+applies the extended configuration used by the toolstack to provide a domain
+with any additional configuration information. Until the extended configuration
+is completed, a domain has access to no resources except its allocated vcpus
+and memory. The exception to this is Dom0, which the hypervisor explicitly
+grants control and access to all system resources, except for those that only
+the hypervisor should have control over.  This exception for Dom0 is driven by
+the system structure with a monolithic Dom0 domain predating introduction of
+support for disaggregation into Xen, and the corresponding default assignment
+of multiple roles within the Xen system to Dom0.
+
+While not a different domain creation path, there does exist the Hardware
+Domain (hwdom), sometimes also referred to as late-Dom0. It is an early effort
+to disaggregate Dom0’s roles into a separate control domain and hardware
+domain. This capability is activated by the passing of a domain id to the
+`hardware_dom` kernel command line parameter, and the Xen hypervisor will then
+flag that domain id as the hardware domain. Later when the toolstack constructs
+a domain with that domain id as the requested domid, the hypervisor will
+transfer all device I/O from Dom0 to this domain. In addition it will also
+transfer the “host shutdown on domain shutdown” flag from Dom0 to the hardware
+domain. It is worth mentioning that this approach for disaggregation was
+created in this manner due to the inability of Xen to launch more than one
+domain at startup.
+
+Hyperlaunch Xen startup
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The Hyperlaunch approach’s primary focus is on how to assign the roles
+traditionally granted to Dom0 to one or more domains at host boot. While the
+statement is simple to make, the implications are not trivial by any means.
+This also explains why the Hyperlaunch approach is orthogonal to the existing
+dom0less capability. The dom0less capability focuses on enabling the launch of
+multiple domains in parallel with Dom0 at host boot. A corollary for dom0less
+is that for systems that don’t require Dom0 after all guest domains have
+started, they are able to do the host boot without a Dom0. Though it should be
+noted that it may be possible to start  Dom0 at a later point. Whereas with
+Hyperlaunch, its approach of separating Dom0’s roles requires the ability to
+launch multiple domains at host boot. The direct consequences from this
+approach are profound and provide a myriad of possible configurations for which
+a sample of common boot configurations were already presented.
+
+To enable the Hyperlaunch approach a new alternative path for host boot within
+the hypervisor must be introduced. This alternative path effectively branches
+just before the current point of Dom0 construction and begins an alternate
+means of system construction. The determination if this alternate path should
+be taken is through the inspection of the boot chain. If the bootloader has
+loaded a specific configuration, as described later, it will enable Xen to
+detect that a Hyperlaunch configuration has been provided. Once a Hyperlaunch
+configuration is detected, this alternate path can be thought of as occurring
+in phases: domain creation, domain preparation, and launch finalization.
+
+Domain Creation
+"""""""""""""""
+
+The domain creation phase begins with Xen parsing the bootloader provided
+material, to understand the content of the modules provided. It will then load
+any microcode or XSM policy it discovers. For each domain configuration Xen
+finds, it parses the configuration to construct the necessary domain definition
+to instantiate an instance of the domain and leave it in a paused state. When
+all domain configurations have been instantiated as domains, if one of them is
+flagged as the Boot Domain, that domain will be unpaused starting the domain
+preparation phase. If there is no Boot Domain defined, then the domain
+preparation phase will be skipped and Xen will trigger the launch finalization
+phase.
+
+Domain Preparation Phase
+""""""""""""""""""""""""
+
+The domain preparation phase is an optional check point for the execution of a
+workload specific domain, the Boot Domain. While the Boot Domain is the first
+domain to run and has some degree of control over the system, it is extremely
+restricted in both system resource access and hypervisor operations. Its
+purpose is to:
+
+* Access the configuration provided by the bootloader
+* Finalize the configuration of the domains
+* Conduct any setup and launch related operations
+* Do an ordered unpause of domains that require an ordered start
+
+When the Boot Domain has completed, it will notify the hypervisor that it is
+done triggering the launch finalization phase.
+
+
+Launch Finalization
+"""""""""""""""""""
+
+The hypervisor handles the launch finalization phase which is equivalent to the
+clean up phase. As such the steps taken by the hypervisor, not necessarily in
+implementation order, are as follows,
+
+* Free the boot module chain
+* If a Boot Domain was used, reclaim Boot Domain resources
+* Unpause any domains still in a paused state
+* Boot Domain uses a reserved function thus can never be respawned
+
+While the focus thus far has been on how the Hyperlaunch capability will work,
+it is worth mentioning what it does not do or limit from occurring. It does not
+stop or inhibit the assigning of the control domain role which gives the domain
+the ability to create, start, stop, restart, and destroy domains or the
+hardware domain role which gives access to all I/O devices except those that
+the hypervisor has reserved for itself. In particular it is still possible to
+construct a domain with all the privileged roles, i.e. a Dom0, with or without
+the domain id being zero. In fact what limitations are imposed now become fully
+configurable without the risk of circumvention by an all privileged domain.
+
+Structuring of Hyperlaunch
+--------------------------
+
+The structure of Hyperlaunch is built around the existing capabilities of the
+host boot protocol. This approach was driven by the objective not to require
+modifications to the boot loader. The only requirement is that the boot loader
+supports the Multiboot2 (MB2) protocol. For UEFI boot, our recommendation is to
+use GRUB.efi to load Xen and the initial domain materials via the multiboot2
+method. On Arm platforms, Hyperlaunch is compatible with the existing interface
+for boot into the hypervisor.
+
+
+x86 Multiboot2
+^^^^^^^^^^^^^^
+
+The MB2 protocol has no concept of a manifest to tell the initial kernel what
+is contained in the chain, leaving it to the kernel to impose a loading
+convention, use magic number identification, or both. When considering the
+passing of multiple kernels, ramdisks, and domain configuration along with any
+existing modules already passed, there is no sane convention that could be
+imposed and magic number identification is nearly impossible when considering
+the objective not to impose unnecessary complication to the hypervisor.
+
+As it was alluded to previously, a manifest describing the contents in the MB2
+chain and how they relate within a Xen context is needed. To address this need
+the Launch Control Module (LCM) was designed to provide such a manifest. The
+LCM was designed to have a specific set of properties,
+
+* minimize the complexity of the parsing logic required by the hypervisor
+* allow for expanding and optional configuration fragments without breaking
+  backwards compatibility
+
+To enable automatic detection of a Hyperlaunch configuration, the LCM must be
+the first MB2 module in the MB2 module chain. The LCM is implemented using the
+Device Tree as defined in the Hyperlaunch Device Tree design document. With the
+LCM implemented in Device Tree, it has a magic number that enables the
+hypervisor to detect its presence when used in a Multiboot2 module chain. The
+hypervisor can confirm that it is a proper LCM Device Tree by checking for a
+compliant Hyperlaunch Device Tree. The Hyperlaunch Device Tree nodes are
+designed to allow,
+
+* for the hypervisor to parse only those entries it understands,
+* for packing custom information for a custom boot domain,
+* the ability to use a new LCM with an older hypervisor,
+* and the ability to use an older LCM with a new hypervisor.
+
+Arm Device Tree
+^^^^^^^^^^^^^^^
+
+As discussed the LCM is in Device Tree format and was designed to co-exist in
+the Device Tree ecosystem, and in particular in parallel with dom0less Device
+Tree entries. On Arm, Xen is already designed to boot from a host Device Tree
+description (dtb) file and the LCM entries can be embedded into this host dtb
+file. This makes detecting the LCM entries and supporting Hyperlaunch on Arm
+relatively straight forward. Relative to the described x86 approach, at the
+point where Xen inspects the first MB2 module, on Arm Xen will check if the top
+level LCM node exists in the host dtb file. If the LCM node does exist, then at
+that point it will enter into the same code path as the x86 entry would go.
+
+Xen hypervisor
+^^^^^^^^^^^^^^
+
+It was previously discussed at a higher level of the new host boot flow that
+will be introduced. Within this new flow is the configuration parsing and
+domain creation phase which will be expanded upon here. The hypervisor will
+inspect the LCM for a config node and if found will iterate through all modules
+nodes. The module nodes are used to identify if any modules contain microcode
+or an XSM policy. As it processes domain nodes, it will construct the domain
+using the node properties and the modules nodes. Once it has completed
+iterating through all the entries in the LCM, if a constructed domain has the
+Boot Domain attribute, it will then be unpaused. Otherwise the hypervisor will
+start the launch finalization phase.
+
+Boot Domain
+^^^^^^^^^^^
+
+Traditionally domain creation was controlled by the user within the Dom0
+environment whereby custom toolstacks could be implemented to impose
+requirements on the process. The Boot Domain is a means to enable the user to
+continue to maintain a degree of that control over domain creation but within a
+limited privilege environment. The Boot Domain will have access to the LCM and
+the boot chain along with access to a subset of the hypercall operations. When
+the Boot Domain is finished it will notify the hypervisor through a hypercall
+op.
+
+Recovery Domain
+^^^^^^^^^^^^^^^
+
+With the existing Dom0 host boot path, when a failure occurs there are several
+assumptions that can safely be made to get the user to a console for
+troubleshooting. With the Hyperlaunch host boot path those assumptions can no
+longer be made, thus a means is needed to get the user to a console in the case
+of a recoverable failure. The recovery domain is configured by a domain
+configuration entry in the LCM, in the same manner as the other initial
+domains, and it will not be unpaused at launch finalization unless a failure is
+encountered starting the initial domains.
+
+Xen has existing support for a Crash Environment where memory can be reserved
+at host boot and a kernel loaded into it, to be jumped into at any point while
+the system is running when a crash is detected. The Recovery Domain
+functionality is a separate, complementary capability. The Crash Environment
+replaces the previously active hypervisor and running guests, and enables a
+process for mounting disks to write out log information prior to rebooting the
+system. In contrast, the Recovery Domain is able to use the functionality of
+the Xen hypervisor, that is still present and running, to perform recovery
+handling for errors encountered with starting the initial domains.
+
+Deferred Design
+"""""""""""""""
+
+To be determined:
+
+* Define what is detected as a crash
+* Explain how crash detection is performed and which components are involved
+* Explain how the recovery domain is unpaused
+* Explain how and when the resources assigned to the recovery domain are reclaimed
+* Define what the recovery domain is able to do
+* Determine what permissions the recovery domain requires to perform its job
+
+
+Control Domain
+^^^^^^^^^^^^^^
+
+The concept of the Control Domain already exists within Xen as a boolean,
+`is_privileged`, that governs access to many of the privileged interfaces of
+the hypervisor that support a domain running a virtualization system toolstack.
+Hyperlaunch will allow the `is_privileged` flag to be set on any domain that is
+created at launch, rather than only a Dom0. It may potentially be set on
+multiple domains.
+
+Hardware Domain
+^^^^^^^^^^^^^^^
+
+The Hardware Domain is also an existing concept for Xen that is enabled through
+the `is_hardware_domain` check. With Hyperlaunch the previous process of I/O
+accesses being assigned to Dom0 for later transfer to the hardware domain would
+no longer be required. Instead during the configuration phase the Xen
+hypervisor would directly assign the I/O accesses to the domain with the
+hardware domain permission bit enabled.
+
+Console Domain
+^^^^^^^^^^^^^^
+
+Traditionally the Xen console is assigned to the control domain and then
+reassignable by the toolstack to another domain. With Hyperlaunch it becomes
+possible to construct a boot configuration where there is no control domain or
+have a use case where the Xen console needs to be isolated. As such it becomes
+necessary to be able to designate which of the initial domains should be
+assigned the Xen console. Therefore Hyperlaunch introduces the ability to
+specify an initial domain which the console is assigned along with a convention
+of ordered assignment for when there is no explicit assignment.
+
+Communication of Domain Configurations
+======================================
+
+There are several standard methods for an Operating System to access machine
+configuration and environment information: ACPI is common on x86 systems,
+whereas Device Tree is more typical on Arm platforms. There are currently
+implementations of both in Xen.
+
+* For dom0less, guest Device Trees are dynamically constructed by the
+  hypervisor to convey domain configuration data
+
+* For PVH dom0 on x86, ACPI tables are built by the hypervisor before the
+  domain is started
+
+Note that both of these mechanisms convey static data that is fixed prior to
+the point of domain construction. Hyperlaunch will retain both the existing
+ACPI and Device Tree methods.
+
+Communication of data between a Boot Domain and a Control Domain is of note
+since they may not be running concurrently: the method used will depend on
+their specific implementations, but one option available is to use Xen’s hypfs
+for transfer of basic data to support system bootstrap.
+
+-------------------------------------------------------------------------------
+
+Appendix
+========
+
+Appendix 1: Flow Sequence of Steps of a Hyperlaunch Boot
+--------------------------------------------------------
+
+Provided here is an ordered flow of a Hyperlaunch with a highlight logic
+decision points. Not all branch points are recorded, specifically for the
+variety of error conditions that may occur. ::
+
+  1. Hypervisor Startup:
+  2a. (x86) Inspect first module provided by the bootloader
+      a. Is the module an LCM
+          i. YES: proceed with the Hyperlaunch host boot path
+          ii. NO: proceed with a Dom0 host boot path
+  2b. (Arm) Inspect host dtb for `/chosen/hypervisor` node
+      a. Is the LCM present
+          i. YES: proceed with the Hyperlaunch host boot path
+          ii. NO: proceed with a Dom0/dom0less host boot path
+  3. Iterate through the LCM entries looking for the module description
+     entry
+      a. Check if any of the modules are microcode or policy and if so,
+         load
+  4. Iterate through the LCM entries processing all domain description
+     entries
+      a. Use the details from the Basic Configuration to call
+         `domain_create`
+      b. Record if a domain is flagged as the Boot Domain
+      c. Record if a domain is flagged as the Recovery Domain
+  5. Was a Boot Domain created
+      a. YES:
+          i. Attach console to Boot Domain
+          ii. Unpause Boot Domain
+          iii. Goto Boot Domain (step 6)
+      b. NO: Goto Launch Finalization (step 10)
+  6. Boot Domain:
+  7. Boot Domain comes online and may do any of the following actions
+      a. Process the LCM
+      b. Validate the MB2 chain
+      c. Make additional configuration settings for staged domains
+      d. Unpause any precursor domains
+      e. Set any runtime configurations
+  8. Boot Domain does any necessary cleanup
+  9. Boot Domain make hypercall op call to signal it is finished
+      i. Hypervisor reclaims all Boot Domain resources
+      ii. Hypervisor records that the Boot Domain ran
+      ii. Goto Launch Finalization (step 9)
+  10. Launch Finalization
+  11. If a configured domain was flagged to have the console, the
+      hypervisor assigns it
+  12. The hypervisor clears the LCM and bootloader loaded module,
+      reclaiming the memory
+  13. The hypervisor iterates through domains unpausing any domain not
+      flagged as the recovery domain
+
+
+Appendix 2: Considerations in Naming the Hyperlaunch Feature
+------------------------------------------------------------
+
+* The term “Launch” is preferred over “Boot”
+
+        * Multiple individual component boots can occur in the new system start
+          process; Launch is preferable for describing the whole process
+        * Fortunately there is consensus in the current group of stakeholders
+          that the term “Launch” is good and appropriate
+
+* The names we define must support becoming meaningful and simple to use
+  outside the Xen community
+
+        * They must be able to be resolved quickly via search engine to a clear
+          explanation (eg. Xen marketing material, documentation or wiki)
+        * We prefer that the terms be helpful for marketing communications
+        * Consequence: avoid the term “domain” which is Xen-specific and
+          requires a definition to be provided each time when used elsewhere
+
+
+* There is a need to communicate that Xen is  capable of being used as a Static
+  Partitioning hypervisor
+
+        * The community members using and maintaining dom0less are the current
+          primary stakeholders for this
+
+* There is a need to communicate that the new launch functionality provides new
+  capabilities not available elsewhere, and is more than just supporting Static
+  Partitioning
+
+        * No other hypervisor known to the authors of this document is capable
+          of providing what Hyperlaunch will be able to do. The launch sequence is
+          designed to:
+
+                * Remove dependency on a single, highly-privileged initial domain
+                * Allow the initial domains started to be independent and fully
+                  isolated from each other
+                * Support configurations where no further VMs can be launched
+                  once the initial domains have started
+                * Use a standard, extensible format for conveying VM
+                  configuration data
+                * Ensure that domain building of all initial domains is
+                  performed by the hypervisor from materials supplied by the
+                  bootloader
+                * Enable flexible configuration to be applied to all initial
+                  domains by an optional Boot Domain, that runs with limited
+                  privilege, before any other domain starts and obtains the VM
+                  configuration data from the bootloader materials via the
+                  hypervisor
+                * Enable measurements of all of the boot materials prior to
+                  their use, in a sequence with minimized privilege
+                * Support use-case-specific customized Boot Domains
+                * Complement the hypervisor’s existing ability to enforce
+                  policy-based Mandatory Access Control
+
+
+* “Static” and “Dynamic” have different and important meanings in different
+  communities
+
+        * Static and Dynamic Partitioning describe the ability to create new
+          virtual machines, or not, after the initial host boot process
+          completes
+        * Static and Dynamic Root of Trust describe the nature of the trust
+          chain for a measured launch. In this case Static is referring to the
+          fact that the trust chain is fixed and non-repeatable until the next
+          host reboot or shutdown. Whereas Dynamic in this case refers to the
+          ability to conduct the measured launch at any time and potentially
+          multiple times before the next host reboot or shutdown.
+
+                * We will be using Hyperlaunch with both Static and Dynamic
+                  Roots of Trust, to launch both Static and Dynamically
+                  Partitioned Systems, and being clear about exactly which
+                  combination is being started will be very important (eg. for
+                  certification processes)
+
+        * Consequence: uses of “Static” and “Dynamic” need to be qualified if
+          they are incorporated into the naming of this functionality
+
+                * This can be done by adding the preceding, stronger branded
+                  term: “Hyperlaunch”, before “Static” or “Dynamic”
+                * ie. “Hyperlaunch Static” describes launch of a
+                  Statically Partitioned system
+                * and “Hyperlaunch Dynamic” describes launch of a
+                  Dynamically Partitioned system.
+                * In practice, this means that “Hyperlaunch Static” describes
+                  starting a Static Partitioned system where no new domains can
+                  be started later (ie. no VM has the Control Domain
+                  permission), whereas “Hyperlaunch Dynamic” will launch some
+                  VM with the Control Domain permission, able to create VMs
+                  dynamically at a later point.
+
+**Naming Proposal:**
+
+* New Term: “Hyperlaunch” : the ability of a hypervisor to construct and start
+  one or more virtual machines at system launch, in the following manner:
+
+        * The hypervisor must build all of the domains that it starts at host
+          boot
+
+                * Similar to the way the dom0 domain is built by the hypervisor
+                  today, and how dom0less works: it will run a loop to build
+                  them all, driven from the configuration provided
+                * This is a requirement for ensuring that there is Strong
+                  Isolation between each of the initial VMs
+
+        * A single file contains the VM configs (“Launch Control Module”: LCM,
+          in Device Tree binary format) is provided to the hypervisor
+
+                * The hypervisor parses it and builds domains
+                * If the LCM config says that a Boot Domain should run first,
+                  then the LCM file itself is made available to the Boot Domain
+                  for it to parse and act on, to invoke operations via the
+                  hypervisor to apply additional configuration to the other VMs
+                  (ie. executing a privilege-constrained toolstack)
+
+* New Term: “Hyperlaunch Static”: starts a Static Partitioned system, where
+  only the virtual machines started at system launch are running on the system
+
+* New Term: “Hyperlaunch Dynamic”: starts a system where virtual machines may
+  be dynamically added after the initial virtual machines have started.
+
+
+In the default configuration, Xen will be capable of both styles of Hyperlaunch
+from the same hypervisor binary, when paired with its XSM flask, provides
+strong controls that enable fine grained system partitioning.
+
+
+* Retiring Term: “DomB”: will no longer be used to describe the optional first
+  domain that is started. It is replaced with the more general term: “Boot
+  Domain”.
+
+* Retiring Term: “Dom0less”: it is to be replaced with “Hyperlaunch Static”
+
+
+Appendix 3: Terminology
+-----------------------
+
+To help ensure clarity in reading this document, the following is the
+definition of terminology used within this document.
+
+
+Basic Configuration
+    the minimal information the hypervisor requires to instantiate a domain instance
+
+
+Boot Domain
+    a domain with limited privileges launched by the hypervisor during a
+    Multiple Domain Boot that runs as the first domain started. In the Hyperlaunch
+    architecture, it is responsible for assisting with higher level operations of
+    the domain setup process.
+
+
+Classic Launch
+    a backwards-compatible host boot that ends with the launch of a single domain (Dom0)
+
+
+Console Domain
+    a domain that has the Xen console assigned to it
+
+
+Control Domain
+    a privileged domain that has been granted Control Domain permissions which
+    are those that are required by the Xen toolstack for managing other domains.
+    These permissions are a subset of those that are granted to Dom0.
+
+
+Device Tree
+    a standardized data structure, with defined file formats, for describing
+    initial system configuration
+
+
+Disaggregation
+    the separation of system roles and responsibilities across multiple
+    connected components that work together to provide functionality
+
+
+Dom0
+    the highly-privileged, first and only domain started at host boot on a
+    conventional Xen system
+
+
+Dom0less
+    an existing feature of Xen on Arm that provides Multiple Domain Boot
+
+
+Domain
+    a running instance of a virtual machine; (as the term is commonly used in
+    the Xen Community)
+
+DomB
+     the former name for Hyperlaunch
+
+
+Extended Configuration
+    any configuration options for a domain beyond its Basic Configuration
+
+
+Hardware Domain
+    a privileged domain that has been granted permissions to access and manage
+    host hardware. These permissions are a subset of those that are granted to
+    Dom0.
+
+
+Host Boot
+    the system startup of Xen using the configuration provided by the bootloader
+
+
+Hyperlaunch
+    a flexible host boot that ends with the launch of one or more domains
+
+
+Initial Domain
+    a domain that is described in the LCM that is run as part of a multiple
+    domain boot. This includes the Boot Domain, Recovery Domain and all Launched
+    Domains.
+
+
+Late Hardware Domain
+    a Hardware Domain that is launched after host boot has already completed
+    with a running Dom0. When the Late Hardware Domain is started, Dom0
+    relinquishes and transfers the permissions to access and manage host hardware
+    to it..
+
+
+Launch Control Module (LCM)
+    A file supplied to the hypervisor by the bootloader that contains
+    configuration data for the hypervisor and the initial set of virtual machines
+    to be run at boot
+
+
+Launched Domain
+    a domain, aside from the boot domain and recovery domain, that is started as
+    part of a multiple domain boot and remains running once the boot process is
+    complete
+
+
+Multiple Domain Boot
+    a system configuration where the hypervisor and multiple virtual machines
+    are all launched when the host system hardware boots
+
+
+Recovery Domain
+    an optional fallback domain that the hypervisor may start in the event of a
+    detectable error encountered during the multiple domain boot process
+
+
+System Device Tree
+    this is the product of an Arm community project to extend Device Tree to
+    cover more aspects of initial system configuration
+
+
+Appendix 4: Copyright License
+-----------------------------
+
+This work is licensed under a Creative Commons Attribution 4.0 International
+License. A copy of this license may be obtained from the Creative Commons
+website (https://creativecommons.org/licenses/by/4.0/legalcode).
+
+| Contributions by:
+| Christopher Clark are Copyright © 2021 Star Lab Corporation
+| Daniel P. Smith are Copyright  © 2021 Apertus Solutions, LLC
diff -pruN 4.14.3+32-g9de3671772-1/docs/designs/xenstore-migration.md 4.16.1-1/docs/designs/xenstore-migration.md
--- 4.14.3+32-g9de3671772-1/docs/designs/xenstore-migration.md	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/designs/xenstore-migration.md	2022-04-12 12:21:23.000000000 +0000
@@ -116,7 +116,7 @@ xenstored state that needs to be restore
 +-------+-------+-------+-------+
 | rw-socket-fd                  |
 +-------------------------------+
-| ro-socket-fd                  |
+| evtchn-fd                     |
 +-------------------------------+
 ```
 
@@ -126,8 +126,8 @@ xenstored state that needs to be restore
 | `rw-socket-fd` | The file descriptor of the socket accepting  |
 |                | read-write connections                       |
 |                |                                              |
-| `ro-socket-fd` | The file descriptor of the socket accepting  |
-|                | read-only connections                        |
+| `evtchn-fd`    | The file descriptor used to communicate with |
+|                | the event channel driver                     |
 
 xenstored will resume in the original process context. Hence `rw-socket-fd` and
 `ro-socket-fd` simply specify the file descriptors of the sockets. Sockets
@@ -147,7 +147,7 @@ the domain being migrated.
 ```
     0       1       2       3       4       5       6       7    octet
 +-------+-------+-------+-------+-------+-------+-------+-------+
-| conn-id                       | conn-type     | flags         |
+| conn-id                       | conn-type     |               |
 +-------------------------------+---------------+---------------+
 | conn-spec
 ...
@@ -169,9 +169,6 @@ the domain being migrated.
 |                | 0x0001: socket                               |
 |                | 0x0002 - 0xFFFF: reserved for future use     |
 |                |                                              |
-| `flags`        | A bit-wise OR of:                            |
-|                | 0001: read-only                              |
-|                |                                              |
 | `conn-spec`    | See below                                    |
 |                |                                              |
 | `in-data-len`  | The length (in octets) of any data read      |
@@ -216,11 +213,13 @@ For `shared ring` connections it is as f
 |           | operation [2] or DOMID_INVALID [3] otherwise      |
 |           |                                                   |
 | `evtchn`  | The port number of the interdomain channel used   |
-|           | by `domid` to communicate with xenstored          |
+|           | by xenstored to communicate with `domid`          |
 |           |                                                   |
 
-Since the ABI guarantees that entry 1 in `domid`'s grant table will always
-contain the GFN of the shared page.
+The GFN of the shared page is not preserved because the ABI reserves
+entry 1 in `domid`'s grant table to point to the xenstore shared page.
+Note there is no guarantee the page will still be valid at the time of
+the restore because a domain can revoke the permission.
 
 For `socket` connections it is as follows:
 
@@ -386,7 +385,7 @@ A node permission specifier has the foll
 ```
     0       1       2       3    octet
 +-------+-------+-------+-------+
-| perm  | pad   | domid         |
+| perm  | flags | domid         |
 +-------+-------+---------------+
 ```
 
@@ -395,9 +394,13 @@ A node permission specifier has the foll
 | `perm`  | One of the ASCII values `w`, `r`, `b` or `n` as     |
 |         | specified for the `SET_PERMS` operation [2]         |
 |         |                                                     |
+| `flags` | A bit-wise OR of:                                   |
+|         | 0x01: stale permission, ignore when checking        |
+|         |       permissions                                   |
+|         |                                                     |
 | `domid` | The domain-id to which the permission relates       |
 
-Note that perm1 defines the domain owning the code. See [4] for more
+Note that perm1 defines the domain owning the node. See [4] for more
 explanation of node permissions.
 
 * * *
diff -pruN 4.14.3+32-g9de3671772-1/docs/features/dom0less.pandoc 4.16.1-1/docs/features/dom0less.pandoc
--- 4.14.3+32-g9de3671772-1/docs/features/dom0less.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/features/dom0less.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -16,9 +16,10 @@ Multiboot specification has been extende
 to be passed to Xen. See docs/misc/arm/device-tree/booting.txt for more
 information about the Multiboot specification and how to use it.
 
-Currently, a control domain ("dom0") is still required, but in the
-future it will become unnecessary when all domains are created
-directly from Xen. Instead of waiting for the control domain to be fully
+Currently, a control domain ("dom0") is still required to manage the DomU
+domains, but the system can start also without dom0 if the Device Tree
+doesn't specify the dom0 kernel and it declares one or more domUs.
+Instead of waiting for the control domain (when declared) to be fully
 booted and the Xen tools to become available, domains created by Xen
 this way are started right away in parallel. Hence, their boot time is
 typically much shorter.
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xenstore-chmod.1.pod 4.16.1-1/docs/man/xenstore-chmod.1.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xenstore-chmod.1.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xenstore-chmod.1.pod	2022-04-12 12:21:23.000000000 +0000
@@ -46,10 +46,6 @@ write, and set permissions).
 
 Apply the permissions to the key and all its I<children>.
 
-=item B<-s>
-
-Connect to the Xenstore daemon using a local socket only.
-
 =item B<-u>
 
 Apply the permissions to the key and all its I<parents>.
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xenstore-ls.1.pod 4.16.1-1/docs/man/xenstore-ls.1.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xenstore-ls.1.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xenstore-ls.1.pod	2022-04-12 12:21:23.000000000 +0000
@@ -50,10 +50,6 @@ I<and> the permissions for any domain no
 subsequent entries.  The key owner always has full access (read,
 write, and set permissions).
 
-=item B<-s>
-
-Connect to the Xenstore daemon using a local socket only.
-
 =back
 
 =head1 BUGS
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xenstore-read.1.pod 4.16.1-1/docs/man/xenstore-read.1.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xenstore-read.1.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xenstore-read.1.pod	2022-04-12 12:21:23.000000000 +0000
@@ -16,10 +16,6 @@ Read values of one or more Xenstore I<PA
 
 Prefix value with key name.
 
-=item B<-s>
-
-Connect to the Xenstore daemon using a local socket only.
-
 =item B<-R>
 
 Read raw value, skip escaping non-printable characters (\x..).
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xenstore-write.1.pod 4.16.1-1/docs/man/xenstore-write.1.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xenstore-write.1.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xenstore-write.1.pod	2022-04-12 12:21:23.000000000 +0000
@@ -13,10 +13,6 @@ provided to write them at once - in one
 
 =over
 
-=item B<-s>
-
-Connect to the Xenstore daemon using a local socket only.
-
 =item B<-R>
 
 Write raw value, skip parsing escaped characters (\x..).
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xen-vtpmmgr.7.pod 4.16.1-1/docs/man/xen-vtpmmgr.7.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xen-vtpmmgr.7.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xen-vtpmmgr.7.pod	2022-04-12 12:21:23.000000000 +0000
@@ -92,6 +92,13 @@ Valid arguments:
 
 =over 4
 
+=item srk_handle=<HANDLE>
+
+Specify a srk_handle for TPM 2.0.  TPM 2.0 uses a key hierarchy, and
+this allow specifying the parent handle for vtpmmgr to create its own
+key under.  Using this option bypasses vtpmmgr trying to take ownership
+of the TPM.
+
 =item owner_auth=<AUTHSPEC>
 
 =item srk_auth=<AUTHSPEC>
@@ -222,6 +229,17 @@ XSM label, not the kernel.
 
 =head1 Appendix B: vtpmmgr on TPM 2.0
 
+=head2 WARNING: Incomplete - cannot persist data
+
+TPM 2.0 support for vTPM manager is incomplete.  There is no support for
+persisting an encryption key, so vTPM manager regenerates primary and secondary
+key handles each boot.
+
+Also, the vTPM manger group command implementation hardcodes TPM 1.2 commands.
+This means running manage-vtpmmgr.pl fails when the TPM 2.0 hardware rejects
+the TPM 1.2 commands.  vTPM manager with TPM 2.0 cannot create groups and
+therefore cannot persist vTPM contents.
+
 =head2 Manager disk image setup:
 
 The vTPM Manager requires a disk image to store its encrypted data. The image
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl.1.pod.in 4.16.1-1/docs/man/xl.1.pod.in
--- 4.14.3+32-g9de3671772-1/docs/man/xl.1.pod.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xl.1.pod.in	2022-04-12 12:21:23.000000000 +0000
@@ -50,7 +50,7 @@ setup the bridge.
 
 If you specify the amount of memory dom0 has, passing B<dom0_mem> to
 Xen, it is highly recommended to disable B<autoballoon>. Edit
-B</etc/xen/xl.conf> and set it to 0.
+B<@XEN_CONFIG_DIR@/xl.conf> and set it to 0.
 
 =item run xl as B<root>
 
@@ -86,6 +86,10 @@ Always use carriage-return-based overwri
 messages without scrolling the screen.  Without -t, this is done only
 if stderr is a tty.
 
+=item B<-T>
+
+Include timestamps and pid of the xl process in output.
+
 =back
 
 =head1 DOMAIN SUBCOMMANDS
@@ -171,13 +175,6 @@ B<EXAMPLES>
 
 =over 4
 
-=item I<with config file>
-
-  xl create DebianLenny
-
-This creates a domain with the file /etc/xen/DebianLenny, and returns as
-soon as it is run.
-
 =item I<with extra parameters>
 
   xl create hvm.cfg 'cpus="0-3"; pci=["01:05.1","01:05.2"]'
@@ -578,7 +575,7 @@ See the corresponding option of the I<cr
 =item B<-N> I<netbufscript>
 
 Use <netbufscript> to setup network buffering instead of the
-default script (/etc/xen/scripts/remus-netbuf-setup).
+default script (@XEN_SCRIPT_DIR@/remus-netbuf-setup).
 
 =item B<-F>
 
@@ -1351,7 +1348,7 @@ All the specified CPUs that can be added
 to it. If some CPU can't (e.g., because they're already part of another
 cpupool), an error is reported about each one of them.
 
-=item B<cpupool-cpu-remove> I<cpus|node:nodes>
+=item B<cpupool-cpu-remove> I<cpu-pool> I<cpus|node:nodes>
 
 Removes one or more CPUs or NUMA nodes from I<cpu-pool>. CPUs and NUMA
 nodes can be specified as single CPU/node IDs or as ranges, using the
@@ -1389,7 +1386,7 @@ Note that only PV block devices are supp
 Requests to attach emulated devices (eg, vdev=hdc) will result in only
 the PV view being available to the guest.
 
-=item B<block-detach> I<domain-id> I<devid> [I<OPTIONS>]
+=item B<block-detach> [I<OPTIONS>] I<domain-id> I<devid>
 
 Detach a domain's virtual block device. I<devid> may be the symbolic
 name or the numeric device id given to the device by domain 0.  You
@@ -1406,7 +1403,7 @@ B<OPTIONS>
 =item B<--force>
 
 If this parameter is specified the device will be forcefully detached, which
-may cause IO errors in the domain.
+may cause IO errors in the domain and possibly a guest crash
 
 =back
 
@@ -1578,7 +1575,7 @@ List vsnd devices for a domain.
 Creates a new keyboard device in the domain specified by I<domain-id>.
 I<vkb-device> describes the device to attach, using the same format as the
 B<VKB_SPEC_STRING> string in the domain config file. See L<xl.cfg(5)>
-for more informations.
+for more information.
 
 =item B<vkb-detach> I<domain-id> I<devid>
 
@@ -1595,16 +1592,24 @@ List virtual network interfaces for a do
 
 =over 4
 
-=item B<pci-assignable-list>
+=item B<pci-assignable-list> [I<-n>]
+
+List all the B<BDF> of assignable PCI devices. See
+L<xl-pci-configuration(5)> for more information. If the -n option is
+specified then any name supplied when the device was made assignable
+will also be displayed.
 
-List all the assignable PCI devices.
 These are devices in the system which are configured to be
 available for passthrough and are bound to a suitable PCI
 backend driver in domain 0 rather than a real driver.
 
-=item B<pci-assignable-add> I<BDF>
+=item B<pci-assignable-add> [I<-n NAME>] I<BDF>
+
+Make the device at B<BDF> assignable to guests. See
+L<xl-pci-configuration(5)> for more information. If the -n option is
+supplied then the assignable device entry will the named with the
+given B<NAME>.
 
-Make the device at PCI Bus/Device/Function BDF assignable to guests.
 This will bind the device to the pciback driver and assign it to the
 "quarantine domain".  If it is already bound to a driver, it will
 first be unbound, and the original driver stored so that it can be
@@ -1618,10 +1623,13 @@ not to do this on a device critical to d
 storage controllers, network interfaces, or GPUs that are currently
 being used.
 
-=item B<pci-assignable-remove> [I<-r>] I<BDF>
+=item B<pci-assignable-remove> [I<-r>] I<BDF>|I<NAME>
+
+Make a device non-assignable to guests. The device may be identified
+either by its B<BDF> or the B<NAME> supplied when the device was made
+assignable. See L<xl-pci-configuration(5)> for more information.
 
-Make the device at PCI Bus/Device/Function BDF not assignable to
-guests.  This will at least unbind the device from pciback, and
+This will at least unbind the device from pciback, and
 re-assign it from the "quarantine domain" back to domain 0.  If the -r
 option is specified, it will also attempt to re-bind the device to its
 original driver, making it usable by Domain 0 again.  If the device is
@@ -1637,15 +1645,15 @@ As always, this should only be done if y
 confident that the particular device you're re-assigning to dom0 will
 cancel all in-flight DMA on FLR.
 
-=item B<pci-attach> I<domain-id> I<BDF>
+=item B<pci-attach> I<domain-id> I<PCI_SPEC_STRING>
 
-Hot-plug a new pass-through pci device to the specified domain.
-B<BDF> is the PCI Bus/Device/Function of the physical device to pass-through.
+Hot-plug a new pass-through pci device to the specified domain. See
+L<xl-pci-configuration(5)> for more information.
 
-=item B<pci-detach> [I<OPTIONS>] I<domain-id> I<BDF>
+=item B<pci-detach> [I<OPTIONS>] I<domain-id> I<PCI_SPEC_STRING>
 
-Hot-unplug a previously assigned pci device from a domain. B<BDF> is the PCI
-Bus/Device/Function of the physical device to be removed from the guest domain.
+Hot-unplug a pci device that was previously passed through to a domain. See
+L<xl-pci-configuration(5)> for more information.
 
 B<OPTIONS>
 
@@ -1660,7 +1668,7 @@ even without guest domain's collaboratio
 
 =item B<pci-list> I<domain-id>
 
-List pass-through pci devices for a domain.
+List the B<BDF> of pci devices passed through to a domain.
 
 =back
 
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl.cfg.5.pod.in 4.16.1-1/docs/man/xl.cfg.5.pod.in
--- 4.14.3+32-g9de3671772-1/docs/man/xl.cfg.5.pod.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xl.cfg.5.pod.in	2022-04-12 12:21:23.000000000 +0000
@@ -580,6 +580,11 @@ to have. This value controls how many pa
 via the grant mechanism by this domain. The default value is settable via
 L<xl.conf(5)>.
 
+=item B<max_grant_version=NUMBER>
+
+Specify the maximum grant table version the domain is allowed to use. The
+default value is settable via L<xl.conf(5)>.
+
 =item B<nomigrate=BOOLEAN>
 
 Disable migration of this domain.  This enables certain other features
@@ -681,6 +686,32 @@ Windows).
 
 If this option is not specified then it will default to B<false>.
 
+=item B<vmtrace_buf_kb=KBYTES>
+
+Specifies the size of vmtrace buffer that would be allocated for each
+vCPU belonging to this domain.  Disabled (i.e.  B<vmtrace_buf_kb=0>) by
+default.
+
+B<NOTE>: Acceptable values are platform specific.  For Intel Processor
+Trace, this value must be a power of 2 between 4k and 16M.
+
+=item B<vpmu=BOOLEAN>
+
+Currently ARM only.
+
+Specifies whether to enable the access to PMU registers by disabling
+the PMU traps.
+
+The PMU registers are not virtualized and the physical registers are directly
+accessible when this parameter is enabled. There is no interrupt support and
+Xen will not save/restore the register values on context switches.
+
+vPMU, by design and purpose, exposes system level performance
+information to the guest. Only to be used by sufficiently privileged
+domains. This feature is currently in experimental state.
+
+If this option is not specified then it will default to B<false>.
+
 =back
 
 =head2 Devices
@@ -1101,73 +1132,7 @@ option is valid only when the B<controll
 =item B<pci=[ "PCI_SPEC_STRING", "PCI_SPEC_STRING", ...]>
 
 Specifies the host PCI devices to passthrough to this guest.
-Each B<PCI_SPEC_STRING> has the form of
-B<[DDDD:]BB:DD.F[@VSLOT],KEY=VALUE,KEY=VALUE,...> where:
-
-=over 4
-
-=item B<[DDDD:]BB:DD.F>
-
-Identifies the PCI device from the host perspective in the domain
-(B<DDDD>), Bus (B<BB>), Device (B<DD>) and Function (B<F>) syntax. This is
-the same scheme as used in the output of B<lspci(1)> for the device in
-question.
-
-Note: by default B<lspci(1)> will omit the domain (B<DDDD>) if it
-is zero and it is optional here also. You may specify the function
-(B<F>) as B<*> to indicate all functions.
-
-=item B<@VSLOT>
-
-Specifies the virtual slot where the guest will see this
-device. This is equivalent to the B<DD> which the guest sees. In a
-guest B<DDDD> and B<BB> are C<0000:00>.
-
-=item B<permissive=BOOLEAN>
-
-By default pciback only allows PV guests to write "known safe" values
-into PCI configuration space, likewise QEMU (both qemu-xen and
-qemu-xen-traditional) imposes the same constraint on HVM guests.
-However, many devices require writes to other areas of the configuration space
-in order to operate properly.  This option tells the backend (pciback or QEMU)
-to allow all writes to the PCI configuration space of this device by this
-domain.
-
-B<This option should be enabled with caution:> it gives the guest much
-more control over the device, which may have security or stability
-implications.  It is recommended to only enable this option for
-trusted VMs under administrator's control.
-
-=item B<msitranslate=BOOLEAN>
-
-Specifies that MSI-INTx translation should be turned on for the PCI
-device. When enabled, MSI-INTx translation will always enable MSI on
-the PCI device regardless of whether the guest uses INTx or MSI. Some
-device drivers, such as NVIDIA's, detect an inconsistency and do not
-function when this option is enabled. Therefore the default is false (0).
-
-=item B<seize=BOOLEAN>
-
-Tells B<xl> to automatically attempt to re-assign a device to
-pciback if it is not already assigned.
-
-B<WARNING:> If you set this option, B<xl> will gladly re-assign a critical
-system device, such as a network or a disk controller being used by
-dom0 without confirmation.  Please use with care.
-
-=item B<power_mgmt=BOOLEAN>
-
-B<(HVM only)> Specifies that the VM should be able to program the
-D0-D3hot power management states for the PCI device. The default is false (0).
-
-=item B<rdm_policy=STRING>
-
-B<(HVM/x86 only)> This is the same as the policy setting inside the B<rdm>
-option but just specific to a given device. The default is "relaxed".
-
-Note: this would override global B<rdm> option.
-
-=back
+See L<xl-pci-configuration(5)> for more details.
 
 =item B<pci_permissive=BOOLEAN>
 
@@ -2318,11 +2283,31 @@ This set incorporates use of a hypercall
 This enlightenment may improve performance of Windows guests with multiple
 virtual CPUs.
 
+=item B<ex_processor_masks>
+
+This set enables new hypercall variants taking a variably-sized sparse
+B<Virtual Processor Set> as an argument, rather than a simple 64-bit
+mask. Hence this enlightenment must be specified for guests with more
+than 64 vCPUs if B<hcall_remote_tlb_flush> and/or B<hcall_ipi> are also
+specified.
+
+=item B<no_vp_limit>
+
+This group when set indicates to a guest that the hypervisor does not
+explicitly have any limits on the number of Virtual processors a guest
+is allowed to bring up. It is strongly recommended to keep this enabled
+for guests with more than 64 vCPUs.
+
+=item B<cpu_hotplug>
+
+This set enables dynamic changes to Virtual processor states in Windows
+guests effectively allowing vCPU hotplug.
+
 =item B<defaults>
 
 This is a special value that enables the default set of groups, which
 is currently the B<base>, B<freq>, B<time_ref_count>, B<apic_assist>,
-B<crash_ctl> and B<stimer> groups.
+B<crash_ctl>, B<stimer>, B<no_vp_limit> and B<cpu_hotplug> groups.
 
 =item B<all>
 
@@ -2385,7 +2370,7 @@ If B<videoram> is set less than 128MB, a
 
 =item B<stdvga=BOOLEAN>
 
-Speficies a standard VGA card with VBE (VESA BIOS Extensions) as the
+Specifies a standard VGA card with VBE (VESA BIOS Extensions) as the
 emulated graphics device. If your guest supports VBE 2.0 or
 later (e.g. Windows XP onwards) then you should enable this.
 stdvga supports more video ram and bigger resolutions than Cirrus.
@@ -2779,6 +2764,10 @@ In case of B<qemu-xen-traditional> it is
 image, in case of B<qemu-xen> it is expected to be Linux-based stubdomain
 kernel.
 
+=item B<stubdomain_cmdline="STRING">
+
+Set the device-model stubdomain kernel command line to B<STRING>.
+
 =item B<stubdomain_ramdisk="PATH">
 
 Override the path to the ramdisk image used as device-model stubdomain.
@@ -2898,6 +2887,20 @@ No MCA capabilities in above list are en
 
 =back
 
+=item B<msr_relaxed=BOOLEAN>
+
+The "msr_relaxed" boolean is an interim option, and defaults to false.
+
+In Xen 4.15, the default behaviour for unhandled MSRs has been changed,
+to avoid leaking host data into guests, and to avoid breaking guest
+logic which uses #GP probing to identify the availability of MSRs.
+
+However, this new stricter behaviour has the possibility to break
+guests, and a more 4.14-like behaviour can be selected by setting this
+option.
+
+If using this option is necessary to fix an issue, please report a bug.
+
 =back
 
 =head1 SEE ALSO
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl.conf.5.pod 4.16.1-1/docs/man/xl.conf.5.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xl.conf.5.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xl.conf.5.pod	1970-01-01 00:00:00.000000000 +0000
@@ -1,229 +0,0 @@
-=head1 NAME
-
-/etc/xen/xl.conf - XL Global/Host Configuration 
-
-=head1 DESCRIPTION
-
-The F<xl.conf> file allows configuration of hostwide C<xl> toolstack
-options.
-
-For details of per-domain configuration options please see
-L<xl.cfg(5)>.
-
-=head1 SYNTAX
-
-The config file consists of a series of C<KEY=VALUE> pairs.
-
-A value C<VALUE> is one of:
-
-=over 4
-
-=item B<"STRING">
-
-A string, surrounded by either single or double quotes.
-
-=item B<NUMBER>
-
-A number, in either decimal, octal (using a C<0> prefix) or
-hexadecimal (using an C<0x> prefix).
-
-=item B<BOOLEAN>
-
-A C<NUMBER> interpreted as C<False> (C<0>) or C<True> (any other
-value).
-
-=item B<[ VALUE, VALUE, ... ]>
-
-A list of C<VALUES> of the above types. Lists are homogeneous and are
-not nested.
-
-=back
-
-The semantics of each C<KEY> defines which form of C<VALUE> is required.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<domid_policy="xen"|"random">
-
-Determines how domain-id is set when creating a new domain.
-
-If set to "xen" then the hypervisor will allocate new domain-id values on a sequential basis.
-
-If set to "random" then a random domain-id value will be chosen.
-
-Default: "xen"
-
-=item B<autoballoon="off"|"on"|"auto">
-
-If set to "on" then C<xl> will automatically reduce the amount of
-memory assigned to domain 0 in order to free memory for new domains.
-
-If set to "off" then C<xl> will not automatically reduce the amount of
-domain 0 memory.
-
-If set to "auto" then auto-ballooning will be disabled if the
-C<dom0_mem> option was provided on the Xen command line.
-
-You are strongly recommended to set this to C<"off"> (or C<"auto">) if
-you use the C<dom0_mem> hypervisor command line to reduce the amount
-of memory given to domain 0 by default.
-
-Default: C<"auto">
-
-=item B<run_hotplug_scripts=BOOLEAN>
-
-If disabled hotplug scripts will be called from udev, as it used to
-be in the previous releases. With the default option, hotplug scripts
-will be launched by xl directly.
-
-Default: C<1>
-
-=item B<lockfile="PATH">
-
-Sets the path to the lock file used by xl to serialise certain
-operations (primarily domain creation).
-
-Default: C</var/lock/xl>
-
-=item B<max_grant_frames=NUMBER>
-
-Sets the default value for the C<max_grant_frames> domain config value.
-
-Default: value of Xen command line B<gnttab_max_frames> parameter (or its
-default value if unspecified).
-
-=item B<max_maptrack_frames=NUMBER>
-
-Sets the default value for the C<max_maptrack_frames> domain config value.
-
-Default: value of Xen command line B<gnttab_max_maptrack_frames>
-parameter (or its default value if unspecified).
-
-=item B<vif.default.script="PATH">
-
-Configures the default hotplug script used by virtual network devices.
-
-The old B<vifscript> option is deprecated and should not be used.
-
-Default: C</etc/xen/scripts/vif-bridge>
-
-=item B<vif.default.bridge="NAME">
-
-Configures the default bridge to set for virtual network devices.
-
-The old B<defaultbridge> option is deprecated and should not be used.
-
-Default: C<xenbr0>
-
-=item B<vif.default.backend="NAME">
-
-Configures the default backend to set for virtual network devices.
-
-Default: C<0>
-
-=item B<vif.default.gatewaydev="NAME">
-
-Configures the default gateway device to set for virtual network devices.
-
-Default: C<None>
-
-=item B<remus.default.netbufscript="PATH">
-
-Configures the default script used by Remus to setup network buffering.
-
-Default: C</etc/xen/scripts/remus-netbuf-setup>
-
-=item B<colo.default.proxyscript="PATH">
-
-Configures the default script used by COLO to setup colo-proxy.
-
-Default: C</etc/xen/scripts/colo-proxy-setup>
-
-=item B<output_format="json|sxp">
-
-Configures the default output format used by xl when printing "machine
-readable" information. The default is to use the C<JSON>
-L<https://www.json.org/> syntax. However for compatibility with the
-previous C<xm> toolstack this can be configured to use the old C<SXP>
-(S-Expression-like) syntax instead.
-
-Default: C<json>
-
-=item B<blkdev_start="NAME">
-
-Configures the name of the first block device to be used for temporary
-block device allocations by the toolstack.
-The default choice is "xvda".
-
-=item B<claim_mode=BOOLEAN>
-
-If this option is enabled then when a guest is created there will be an
-guarantee that there is memory available for the guest.
-The self-balloon mechanism can deflate/inflate the balloon
-quickly and the amount of free memory (which C<xl info> can show) is
-stale the moment it is printed. When claim is enabled a reservation for
-the amount of memory (see 'memory' in xl.conf(5)) is set, which is then
-reduced as the domain's memory is populated and eventually reaches zero.
-The free memory in C<xl info> is the combination of the hypervisor's
-free heap memory minus the outstanding claims value.
-
-If the reservation cannot be meet the guest creation fails immediately
-instead of taking seconds/minutes (depending on the size of the guest)
-while the guest is populated.
-
-Default: C<1>
-
-=over 4
-
-=item C<0>
-
-No claim is made. Memory population during guest creation will be
-attempted as normal and may fail due to memory exhaustion.
-
-=item C<1>
-
-Free memory as reported by the hypervisor is used for
-calculating whether there is enough memory free to launch a guest.
-This guarantees immediate feedback whether the guest can be launched due
-to memory exhaustion (which can take a long time to find out if launching
-massively huge guests).
-
-=back
-
-=item B<vm.cpumask>="CPULIST"
-
-=item B<vm.hvm.cpumask>="CPULIST"
-
-=item B<vm.pv.cpumask>="CPULIST"
-
-Global masks that are applied when creating guests and pinning vcpus
-to indicate which cpus they are allowed to run on.  Specifically,
-C<vm.cpumask> applies to all guest types, C<vm.hvm.cpumask> applies to
-both HVM and PVH guests and C<vm.pv.cpumask> applies to PV guests.
-
-The hard affinity of guest's vcpus are logical-AND'ed with respective
-masks. If the resulting affinity mask is empty, operation will fail.
-
-Use --ignore-global-affinity-masks to skip applying global masks.
-
-The default value for these masks are all 1's, i.e. all cpus are allowed.
-
-Due to bug(s), these options may not interact well with other options
-concerning CPU affinity. One example is CPU pools. Users should always double
-check that the required affinity has taken effect.
-
-=back
-
-=head1 SEE ALSO
-
-=over 4
-
-=item L<xl(1)>
-
-=item L<xl.cfg(5)>
-
-=item https://www.json.org/
-
-=back
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl.conf.5.pod.in 4.16.1-1/docs/man/xl.conf.5.pod.in
--- 4.14.3+32-g9de3671772-1/docs/man/xl.conf.5.pod.in	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/docs/man/xl.conf.5.pod.in	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,235 @@
+=head1 NAME
+
+@XEN_CONFIG_DIR@/xl.conf - XL Global/Host Configuration
+
+=head1 DESCRIPTION
+
+The F<xl.conf> file allows configuration of hostwide C<xl> toolstack
+options.
+
+For details of per-domain configuration options please see
+L<xl.cfg(5)>.
+
+=head1 SYNTAX
+
+The config file consists of a series of C<KEY=VALUE> pairs.
+
+A value C<VALUE> is one of:
+
+=over 4
+
+=item B<"STRING">
+
+A string, surrounded by either single or double quotes.
+
+=item B<NUMBER>
+
+A number, in either decimal, octal (using a C<0> prefix) or
+hexadecimal (using an C<0x> prefix).
+
+=item B<BOOLEAN>
+
+A C<NUMBER> interpreted as C<False> (C<0>) or C<True> (any other
+value).
+
+=item B<[ VALUE, VALUE, ... ]>
+
+A list of C<VALUES> of the above types. Lists are homogeneous and are
+not nested.
+
+=back
+
+The semantics of each C<KEY> defines which form of C<VALUE> is required.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<domid_policy="xen"|"random">
+
+Determines how domain-id is set when creating a new domain.
+
+If set to "xen" then the hypervisor will allocate new domain-id values on a sequential basis.
+
+If set to "random" then a random domain-id value will be chosen.
+
+Default: "xen"
+
+=item B<autoballoon="off"|"on"|"auto">
+
+If set to "on" then C<xl> will automatically reduce the amount of
+memory assigned to domain 0 in order to free memory for new domains.
+
+If set to "off" then C<xl> will not automatically reduce the amount of
+domain 0 memory.
+
+If set to "auto" then auto-ballooning will be disabled if the
+C<dom0_mem> option was provided on the Xen command line.
+
+You are strongly recommended to set this to C<"off"> (or C<"auto">) if
+you use the C<dom0_mem> hypervisor command line to reduce the amount
+of memory given to domain 0 by default.
+
+Default: C<"auto">
+
+=item B<run_hotplug_scripts=BOOLEAN>
+
+If disabled hotplug scripts will be called from udev, as it used to
+be in the previous releases. With the default option, hotplug scripts
+will be launched by xl directly.
+
+Default: C<1>
+
+=item B<lockfile="PATH">
+
+Sets the path to the lock file used by xl to serialise certain
+operations (primarily domain creation).
+
+Default: C</var/lock/xl>
+
+=item B<max_grant_frames=NUMBER>
+
+Sets the default value for the C<max_grant_frames> domain config value.
+
+Default: value of Xen command line B<gnttab_max_frames> parameter (or its
+default value if unspecified).
+
+=item B<max_maptrack_frames=NUMBER>
+
+Sets the default value for the C<max_maptrack_frames> domain config value.
+
+Default: value of Xen command line B<gnttab_max_maptrack_frames>
+parameter (or its default value if unspecified).
+
+=item B<max_grant_version=NUMBER>
+
+Sets the default value for the C<max_grant_version> domain config value.
+
+Default: maximum grant version supported by the hypervisor.
+
+=item B<vif.default.script="PATH">
+
+Configures the default hotplug script used by virtual network devices.
+
+The old B<vifscript> option is deprecated and should not be used.
+
+Default: C<@XEN_SCRIPT_DIR@/vif-bridge>
+
+=item B<vif.default.bridge="NAME">
+
+Configures the default bridge to set for virtual network devices.
+
+The old B<defaultbridge> option is deprecated and should not be used.
+
+Default: C<xenbr0>
+
+=item B<vif.default.backend="NAME">
+
+Configures the default backend to set for virtual network devices.
+
+Default: C<0>
+
+=item B<vif.default.gatewaydev="NAME">
+
+Configures the default gateway device to set for virtual network devices.
+
+Default: C<None>
+
+=item B<remus.default.netbufscript="PATH">
+
+Configures the default script used by Remus to setup network buffering.
+
+Default: C<@XEN_SCRIPT_DIR@/remus-netbuf-setup>
+
+=item B<colo.default.proxyscript="PATH">
+
+Configures the default script used by COLO to setup colo-proxy.
+
+Default: C<@XEN_SCRIPT_DIR@/colo-proxy-setup>
+
+=item B<output_format="json|sxp">
+
+Configures the default output format used by xl when printing "machine
+readable" information. The default is to use the C<JSON>
+L<https://www.json.org/> syntax. However for compatibility with the
+previous C<xm> toolstack this can be configured to use the old C<SXP>
+(S-Expression-like) syntax instead.
+
+Default: C<json>
+
+=item B<blkdev_start="NAME">
+
+Configures the name of the first block device to be used for temporary
+block device allocations by the toolstack.
+The default choice is "xvda".
+
+=item B<claim_mode=BOOLEAN>
+
+If this option is enabled then when a guest is created there will be an
+guarantee that there is memory available for the guest.
+The self-balloon mechanism can deflate/inflate the balloon
+quickly and the amount of free memory (which C<xl info> can show) is
+stale the moment it is printed. When claim is enabled a reservation for
+the amount of memory (see 'memory' in xl.conf(5)) is set, which is then
+reduced as the domain's memory is populated and eventually reaches zero.
+The free memory in C<xl info> is the combination of the hypervisor's
+free heap memory minus the outstanding claims value.
+
+If the reservation cannot be meet the guest creation fails immediately
+instead of taking seconds/minutes (depending on the size of the guest)
+while the guest is populated.
+
+Default: C<1>
+
+=over 4
+
+=item C<0>
+
+No claim is made. Memory population during guest creation will be
+attempted as normal and may fail due to memory exhaustion.
+
+=item C<1>
+
+Free memory as reported by the hypervisor is used for
+calculating whether there is enough memory free to launch a guest.
+This guarantees immediate feedback whether the guest can be launched due
+to memory exhaustion (which can take a long time to find out if launching
+massively huge guests).
+
+=back
+
+=item B<vm.cpumask>="CPULIST"
+
+=item B<vm.hvm.cpumask>="CPULIST"
+
+=item B<vm.pv.cpumask>="CPULIST"
+
+Global masks that are applied when creating guests and pinning vcpus
+to indicate which cpus they are allowed to run on.  Specifically,
+C<vm.cpumask> applies to all guest types, C<vm.hvm.cpumask> applies to
+both HVM and PVH guests and C<vm.pv.cpumask> applies to PV guests.
+
+The hard affinity of guest's vcpus are logical-AND'ed with respective
+masks. If the resulting affinity mask is empty, operation will fail.
+
+Use --ignore-global-affinity-masks to skip applying global masks.
+
+The default value for these masks are all 1's, i.e. all cpus are allowed.
+
+Due to bug(s), these options may not interact well with other options
+concerning CPU affinity. One example is CPU pools. Users should always double
+check that the required affinity has taken effect.
+
+=back
+
+=head1 SEE ALSO
+
+=over 4
+
+=item L<xl(1)>
+
+=item L<xl.cfg(5)>
+
+=item https://www.json.org/
+
+=back
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xlcpupool.cfg.5.pod 4.16.1-1/docs/man/xlcpupool.cfg.5.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xlcpupool.cfg.5.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xlcpupool.cfg.5.pod	2022-04-12 12:21:23.000000000 +0000
@@ -106,7 +106,7 @@ means that cpus 2,3,5 will be member of
 means that cpus 0,2,3 and 5 will be member of the cpupool. A "node:" or
 "nodes:" modifier can be used. E.g., "0,node:1,nodes:2-3,^10-13" means
 that pcpus 0, plus all the cpus of NUMA nodes 1,2,3 with the exception
-of cpus 10,11,12,13 will be memeber of the cpupool.
+of cpus 10,11,12,13 will be members of the cpupool.
 
 =back
 
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl-disk-configuration.5.pod 4.16.1-1/docs/man/xl-disk-configuration.5.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xl-disk-configuration.5.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xl-disk-configuration.5.pod	1970-01-01 00:00:00.000000000 +0000
@@ -1,529 +0,0 @@
-=head1 NAME
-
-xl-disk-configuration - XL Disk Configuration Syntax
-
-=head1 SYNTAX
-
-This document specifies the xl config file format disk configuration
-option.  It has the following form:
-
-   disk = [ 'DISKSPEC', 'DISKSPEC', ... ]
-
-where each C<DISKSPEC> is in this form:
-
-   [<key>=<value>|<flag>,]*,
-     [<target>, [<format>, [<vdev>, [<access>]]]],
-     [<key>=<value>|<flag>,]*
-     [target=<target>]
-
-For example, these strings are equivalent:
-
-    /dev/vg/guest-volume,,hda
-    /dev/vg/guest-volume,raw,hda,rw
-    format=raw, vdev=hda, access=rw, target=/dev/vg/guest-volume
-    raw:/dev/vg/guest-volume,hda,w  (deprecated, see below)
-
-As are these:
-
-    /root/image.iso,,hdc,cdrom
-    /root/image.iso,,hdc,,cdrom
-    /root/image.iso,raw,hdc,devtype=cdrom
-    format=raw, vdev=hdc, access=ro, devtype=cdrom, target=/root/image.iso
-    raw:/root/image.iso,hdc:cdrom,ro   (deprecated, see below)
-
-These might be specified in the domain config file like this:
-
-    disk = [ '/dev/vg/guest-volume,,hda', '/root/image.iso,,hdc,cdrom' ]
-
-
-More formally, the string is a series of comma-separated keyword/value
-pairs, flags and positional parameters.  Parameters which are not bare
-keywords and which do not contain "=" symbols are assigned to the
-so-far-unspecified positional parameters, in the order below.  The
-positional parameters may also be specified explicitly by name.
-
-Each parameter may be specified at most once, either as a positional
-parameter or a named parameter.  Default values apply if the parameter
-is not specified, or if it is specified with an empty value (whether
-positionally or explicitly).
-
-Whitespace may appear before each parameter and will be ignored.
-
-=head1 Positional Parameters
-
-=over 4
-
-=item B<target>
-
-=over 4
-
-=item Description
-
-Block device or image file path.  When this is used as a path, F</dev>
-will be prepended if the path doesn't start with a '/'.
-
-=item Supported values
-
-N/A
-
-=item Deprecated values
-
-N/A
-
-=item Default value
-
-None.  While a path is provided in most cases there is an exception:
-for a cdrom device, lack of this attribute would imply an empty cdrom
-drive.
-
-=item Special syntax
-
-When this parameter is specified by name, ie with the C<target=>
-syntax in the configuration file, it consumes the whole rest of the
-C<DISKSPEC> including trailing whitespaces.  Therefore in that case
-it must come last.  This is permissible even if an empty value for
-the target was already specified as a positional parameter.  This
-is the only way to specify a target string containing metacharacters
-such as commas and (in some cases) colons, which would otherwise be
-misinterpreted.
-
-Future parameter and flag names will start with an ascii letter and
-contain only ascii alphanumerics, hyphens and underscores, and will
-not be legal as vdevs.  Targets which might match that syntax
-should not be specified as positional parameters.
-
-=back
-
-=item B<format>
-
-=over 4
-
-=item Description
-
-Specifies the format of image file.
-
-=item Supported values
-
-raw, qcow, qcow2, vhd, qed
-
-=item Deprecated values
-
-None
-
-=item Default value
-
-raw
-
-=back
-
-=item B<vdev>
-
-=over 4
-
-=item Description
-
-Virtual device as seen by the guest (also referred to as guest drive
-designation in some specifications).  See L<xen-vbd-interface(7)>.
-
-=item Supported values
-
-hd[x], xvd[x], sd[x] etc.  Please refer to the above specification for
-further details.
-
-=item Deprecated values
-
-None
-
-=item Default Value
-
-None, this parameter is mandatory.
-
-=back
-
-=item B<access>
-
-=over 4
-
-=item Description
-
-Specified access control information.  Whether or not the block device is
-provided to the guest in read-only or read-write mode depends on this
-attribute.
-
-=item Supported values
-
-C<ro>, C<r>   (specifies read-only)
-
-C<rw>, C<w>   (specifies read/write)
-
-=item Deprecated values
-
-None
-
-=item Default value
-
-C<rw> unless devtype=cdrom, in which case C<r>
-
-=back
-
-=back
-
-=head1 Other Parameters And Flags
-
-=over 4
-
-=item B<devtype>=I<DEVTYPE>
-
-=over 4
-
-=item Description
-
-Qualifies virtual device type.
-
-=item Supported values
-
-cdrom
-
-=item Deprecated values
-
-None
-
-=item Mandatory
-
-No
-
-=back
-
-=item B<cdrom>
-
-Convenience alias for "devtype=cdrom".
-
-
-=item B<backend>=I<DOMAIN-NAME>
-
-=over 4
-
-=item Description
-
-Designates a backend domain for the device
-
-=item Supported values
-
-Valid domain names
-
-=item Mandatory
-
-No
-
-=back
-
-Specifies the backend domain which this device should attach to. This
-defaults to domain 0. Specifying another domain requires setting up a
-driver domain which is outside the scope of this document.
-
-
-=item B<backendtype>=I<TYPE>
-
-=over 4
-
-=item Description
-
-Specifies the backend implementation to use
-
-=item Supported values
-
-phy, qdisk
-
-=item Mandatory
-
-No
-
-=item Default value
-
-Automatically determine which backend to use.
-
-=back
-
-This does not affect the guest's view of the device.  It controls
-which software implementation of the Xen backend driver is used.
-
-Not all backend drivers support all combinations of other options.
-For example, "phy" does not support formats other than "raw".
-Normally this option should not be specified, in which case libxl will
-automatically determine the most suitable backend.
-
-
-=item B<script>=I<SCRIPT>
-
-Specifies that B<target> is not a normal host path, but rather
-information to be interpreted by the executable program I<SCRIPT>,
-(looked for in F</etc/xen/scripts>, if it doesn't contain a slash).
-
-These scripts are normally called "block-I<SCRIPT>".
-
-
-=item B<direct-io-safe>
-
-=over 4
-
-=item Description
-
-Disables non-O_DIRECT workaround
-
-=item Supported values
-
-absent, present
-
-=item Mandatory
-
-No
-
-=item Default value
-
-absent (workaround may be enabled)
-
-=back
-
-There is a memory lifetime bug in some driver domain (dom0) kernels
-which can cause crashes when using O_DIRECT.  The bug occurs due to a
-mismatch between the backend-visible lifetime of pages used for the
-Xen PV network protocol and that expected by the backend kernel's
-networking subsystem.  This can cause crashes when using certain
-backends with certain underlying storage.
-
-See:
- L<https://lists.xenproject.org/archives/html/xen-devel/2012-12/msg01154.html>
-
-For this reason, (this version of) the Xen libxl toolstack disables
-O_DIRECT when using the qemu-based Xen PV backend (C<qdisk>).
-
-However, this workaround has performance and scaling implications, and
-it is only necessary if the underlying device is a network filesystem.
-If the underlying device is not, then it is good to disable it; that
-is what this option is for.
-
-This option simply requests that the workaround be disabled.  (However,
-not all backends versions which use the workaround understand this
-option, so this is on a best effort basis.)
-
-It's important to note that if you are storing the VM disk on a
-network filesystem or a network block device (NFS or ISCSI) it might
-not be safe to use this option.  Otherwise specifying it is safe and
-can give better performances.
-
-If in the future the bug is fixed properly this option will then be
-silently ignored.
-
-
-=item B<discard> / B<no-discard>
-
-=over 4
-
-=item Description
-
-Request that backend advertise discard support to frontend
-
-=item Supported values
-
-discard, no-discard
-
-=item Mandatory
-
-No
-
-=item Default value
-
-discard
-
-=back
-
-An advisory setting for the backend driver, specifying whether to
-advertise discard support (TRIM, UNMAP) to the frontend.  The real
-benefit of this option is to be able to force it off rather than on.  It
-can be used to disable "hole punching" for file based backends which
-were intentionally created non-sparse to avoid fragmentation of the
-file.
-
-=back
-
-
-=head1 COLO Parameters
-
-=over 4
-
-=item B<colo>
-
-Enable COLO HA for disk. For better understanding block replication on
-QEMU, please refer to: L<https://wiki.qemu.org/Features/BlockReplication>
-Note that the COLO configuration settings should be considered unstable.
-They may change incompatibly in future versions of Xen.
-
-
-=item B<colo-host>
-
-=over 4
-
-=item Description
-
-Secondary host's address
-
-=item Mandatory
-
-Yes when COLO enabled
-
-=back
-
-=item B<colo-port>
-
-=over 4
-
-=item Description
-
-Secondary port.  We will run a nbd server on secondary host,
-and the nbd server will listen this port.
-
-=item Mandatory
-
-Yes when COLO enabled
-
-=back
-
-=item B<colo-export>
-
-=over 4
-
-=item Description
-
-We will run a nbd server on secondary host, exportname is
-the nbd server's disk export name.
-
-=item Mandatory
-
-Yes when COLO enabled
-
-=back
-
-=item B<active-disk>
-
-=over 4
-
-=item Description
-
-This is used by secondary. Secondary guest's write will be buffered in this
-disk.
-
-=item Mandatory
-
-Yes when COLO enabled
-
-=back
-
-=item B<hidden-disk>
-
-=over 4
-
-=item Description
-
-This is used by secondary. It buffers the original content that is modified
-by the primary VM.
-
-=item Mandatory
-
-Yes when COLO enabled
-
-=back
-
-=back
-
-
-=head1 Deprecated Parameters, Prefixes And Syntaxes
-
-Deprecated forms are acceptable and are intended work compatibly with
-xend and xl from xen 4.1.  In future they may print a warning.
-Support for deprecated parameters and syntaxes are likely to be
-dropped in future versions of xl.
-
-There is support for a deprecated old syntax for C<DISKSPEC>:
-
-  [<format>:][<target>],<vdev>[:<devtype>],<access>   (deprecated)
-
-This syntax also supports deprecated prefixes, described below.  These
-are found prepended to the format parameter - eg C<tap:aio:qcow:>.
-
-=over 4
-
-=item B<format>
-
-=over 4
-
-=item Description
-
-Specifies the format (deprecated)
-
-=item Supported values
-
-raw:  qcow2:  vhd:
-
-=back
-
-In xend and old versions of libxl it was necessary to specify the
-format with a prefix.  For compatibility, these three prefixes are
-recognised as specifying the corresponding format.  They are
-equivalent to C<format=FORMAT> or the specification of B<format>
-(without a colon) as a positional parameter.
-
-
-=item B<script>
-
-=over 4
-
-=item Description
-
-Specifies the script (deprecated)
-
-=item Supported values
-
-iscsi:  nbd:  enbd:  drbd:
-
-=back
-
-In xend and old versions of libxl it was necessary to specify the
-"script" (see above) with a prefix.  For compatibility, these four
-prefixes are recognised as specifying the corresponding script.  They
-are equivalent to C<script=block-SCRIPT>.
-
-
-=item B<deprecated-prefix>
-
-=over 4
-
-=item Description
-
-Deprecated prefix, ignored
-
-=item Supported values
-
-tapdisk:  tap2:  aio:  ioemu:  file:  phy:
-
-=back
-
-Various prefixes were required by xend and older versions of libxl to
-make the block devices work.  In some cases these options would
-override the backend type, but in other cases they would be ignored in
-favour of "making it work"; in yet other cases it would be necessary
-to specify several of these, for example:
-
-  tap:aio:/some/path...
-
-All of these prefixes are now stripped and ignored.
-
-=back
-
-=head2 Missing format and empty target
-
-The following syntax is also supported:
-
-  ,<vdev>:<devtype>,<access>   (deprecated)
-
-This is solely for compatibility with xend's syntax for empty cdroms,
-which is (for example) C<,hdc:cdrom,r>.
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl-disk-configuration.5.pod.in 4.16.1-1/docs/man/xl-disk-configuration.5.pod.in
--- 4.14.3+32-g9de3671772-1/docs/man/xl-disk-configuration.5.pod.in	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/docs/man/xl-disk-configuration.5.pod.in	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,529 @@
+=head1 NAME
+
+xl-disk-configuration - XL Disk Configuration Syntax
+
+=head1 SYNTAX
+
+This document specifies the xl config file format disk configuration
+option.  It has the following form:
+
+   disk = [ 'DISKSPEC', 'DISKSPEC', ... ]
+
+where each C<DISKSPEC> is in this form:
+
+   [<key>=<value>|<flag>,]*,
+     [<target>, [<format>, [<vdev>, [<access>]]]],
+     [<key>=<value>|<flag>,]*
+     [target=<target>]
+
+For example, these strings are equivalent:
+
+    /dev/vg/guest-volume,,hda
+    /dev/vg/guest-volume,raw,hda,rw
+    format=raw, vdev=hda, access=rw, target=/dev/vg/guest-volume
+    raw:/dev/vg/guest-volume,hda,w  (deprecated, see below)
+
+As are these:
+
+    /root/image.iso,,hdc,cdrom
+    /root/image.iso,,hdc,,cdrom
+    /root/image.iso,raw,hdc,devtype=cdrom
+    format=raw, vdev=hdc, access=ro, devtype=cdrom, target=/root/image.iso
+    raw:/root/image.iso,hdc:cdrom,ro   (deprecated, see below)
+
+These might be specified in the domain config file like this:
+
+    disk = [ '/dev/vg/guest-volume,,hda', '/root/image.iso,,hdc,cdrom' ]
+
+
+More formally, the string is a series of comma-separated keyword/value
+pairs, flags and positional parameters.  Parameters which are not bare
+keywords and which do not contain "=" symbols are assigned to the
+so-far-unspecified positional parameters, in the order below.  The
+positional parameters may also be specified explicitly by name.
+
+Each parameter may be specified at most once, either as a positional
+parameter or a named parameter.  Default values apply if the parameter
+is not specified, or if it is specified with an empty value (whether
+positionally or explicitly).
+
+Whitespace may appear before each parameter and will be ignored.
+
+=head1 Positional Parameters
+
+=over 4
+
+=item B<target>
+
+=over 4
+
+=item Description
+
+Block device or image file path.  When this is used as a path, F</dev>
+will be prepended if the path doesn't start with a '/'.
+
+=item Supported values
+
+N/A
+
+=item Deprecated values
+
+N/A
+
+=item Default value
+
+None.  While a path is provided in most cases there is an exception:
+for a cdrom device, lack of this attribute would imply an empty cdrom
+drive.
+
+=item Special syntax
+
+When this parameter is specified by name, ie with the C<target=>
+syntax in the configuration file, it consumes the whole rest of the
+C<DISKSPEC> including trailing whitespaces.  Therefore in that case
+it must come last.  This is permissible even if an empty value for
+the target was already specified as a positional parameter.  This
+is the only way to specify a target string containing metacharacters
+such as commas and (in some cases) colons, which would otherwise be
+misinterpreted.
+
+Future parameter and flag names will start with an ascii letter and
+contain only ascii alphanumerics, hyphens and underscores, and will
+not be legal as vdevs.  Targets which might match that syntax
+should not be specified as positional parameters.
+
+=back
+
+=item B<format>
+
+=over 4
+
+=item Description
+
+Specifies the format of image file.
+
+=item Supported values
+
+raw, qcow, qcow2, vhd, qed
+
+=item Deprecated values
+
+None
+
+=item Default value
+
+raw
+
+=back
+
+=item B<vdev>
+
+=over 4
+
+=item Description
+
+Virtual device as seen by the guest (also referred to as guest drive
+designation in some specifications).  See L<xen-vbd-interface(7)>.
+
+=item Supported values
+
+hd[x], xvd[x], sd[x] etc.  Please refer to the above specification for
+further details.
+
+=item Deprecated values
+
+None
+
+=item Default Value
+
+None, this parameter is mandatory.
+
+=back
+
+=item B<access>
+
+=over 4
+
+=item Description
+
+Specified access control information.  Whether or not the block device is
+provided to the guest in read-only or read-write mode depends on this
+attribute.
+
+=item Supported values
+
+C<ro>, C<r>   (specifies read-only)
+
+C<rw>, C<w>   (specifies read/write)
+
+=item Deprecated values
+
+None
+
+=item Default value
+
+C<rw> unless devtype=cdrom, in which case C<r>
+
+=back
+
+=back
+
+=head1 Other Parameters And Flags
+
+=over 4
+
+=item B<devtype>=I<DEVTYPE>
+
+=over 4
+
+=item Description
+
+Qualifies virtual device type.
+
+=item Supported values
+
+cdrom
+
+=item Deprecated values
+
+None
+
+=item Mandatory
+
+No
+
+=back
+
+=item B<cdrom>
+
+Convenience alias for "devtype=cdrom".
+
+
+=item B<backend>=I<DOMAIN-NAME>
+
+=over 4
+
+=item Description
+
+Designates a backend domain for the device
+
+=item Supported values
+
+Valid domain names
+
+=item Mandatory
+
+No
+
+=back
+
+Specifies the backend domain which this device should attach to. This
+defaults to domain 0. Specifying another domain requires setting up a
+driver domain which is outside the scope of this document.
+
+
+=item B<backendtype>=I<TYPE>
+
+=over 4
+
+=item Description
+
+Specifies the backend implementation to use
+
+=item Supported values
+
+phy, qdisk
+
+=item Mandatory
+
+No
+
+=item Default value
+
+Automatically determine which backend to use.
+
+=back
+
+This does not affect the guest's view of the device.  It controls
+which software implementation of the Xen backend driver is used.
+
+Not all backend drivers support all combinations of other options.
+For example, "phy" does not support formats other than "raw".
+Normally this option should not be specified, in which case libxl will
+automatically determine the most suitable backend.
+
+
+=item B<script>=I<SCRIPT>
+
+Specifies that B<target> is not a normal host path, but rather
+information to be interpreted by the executable program I<SCRIPT>,
+(looked for in F<@XEN_SCRIPT_DIR@>, if it doesn't contain a slash).
+
+These scripts are normally called "block-I<SCRIPT>".
+
+
+=item B<direct-io-safe>
+
+=over 4
+
+=item Description
+
+Disables non-O_DIRECT workaround
+
+=item Supported values
+
+absent, present
+
+=item Mandatory
+
+No
+
+=item Default value
+
+absent (workaround may be enabled)
+
+=back
+
+There is a memory lifetime bug in some driver domain (dom0) kernels
+which can cause crashes when using O_DIRECT.  The bug occurs due to a
+mismatch between the backend-visible lifetime of pages used for the
+Xen PV network protocol and that expected by the backend kernel's
+networking subsystem.  This can cause crashes when using certain
+backends with certain underlying storage.
+
+See:
+ L<https://lists.xenproject.org/archives/html/xen-devel/2012-12/msg01154.html>
+
+For this reason, (this version of) the Xen libxl toolstack disables
+O_DIRECT when using the qemu-based Xen PV backend (C<qdisk>).
+
+However, this workaround has performance and scaling implications, and
+it is only necessary if the underlying device is a network filesystem.
+If the underlying device is not, then it is good to disable it; that
+is what this option is for.
+
+This option simply requests that the workaround be disabled.  (However,
+not all backends versions which use the workaround understand this
+option, so this is on a best effort basis.)
+
+It's important to note that if you are storing the VM disk on a
+network filesystem or a network block device (NFS or ISCSI) it might
+not be safe to use this option.  Otherwise specifying it is safe and
+can give better performances.
+
+If in the future the bug is fixed properly this option will then be
+silently ignored.
+
+
+=item B<discard> / B<no-discard>
+
+=over 4
+
+=item Description
+
+Request that backend advertise discard support to frontend
+
+=item Supported values
+
+discard, no-discard
+
+=item Mandatory
+
+No
+
+=item Default value
+
+discard
+
+=back
+
+An advisory setting for the backend driver, specifying whether to
+advertise discard support (TRIM, UNMAP) to the frontend.  The real
+benefit of this option is to be able to force it off rather than on.  It
+can be used to disable "hole punching" for file based backends which
+were intentionally created non-sparse to avoid fragmentation of the
+file.
+
+=back
+
+
+=head1 COLO Parameters
+
+=over 4
+
+=item B<colo>
+
+Enable COLO HA for disk. For better understanding block replication on
+QEMU, please refer to: L<https://wiki.qemu.org/Features/BlockReplication>
+Note that the COLO configuration settings should be considered unstable.
+They may change incompatibly in future versions of Xen.
+
+
+=item B<colo-host>
+
+=over 4
+
+=item Description
+
+Secondary host's address
+
+=item Mandatory
+
+Yes when COLO enabled
+
+=back
+
+=item B<colo-port>
+
+=over 4
+
+=item Description
+
+Secondary port.  We will run a nbd server on secondary host,
+and the nbd server will listen this port.
+
+=item Mandatory
+
+Yes when COLO enabled
+
+=back
+
+=item B<colo-export>
+
+=over 4
+
+=item Description
+
+We will run a nbd server on secondary host, exportname is
+the nbd server's disk export name.
+
+=item Mandatory
+
+Yes when COLO enabled
+
+=back
+
+=item B<active-disk>
+
+=over 4
+
+=item Description
+
+This is used by secondary. Secondary guest's write will be buffered in this
+disk.
+
+=item Mandatory
+
+Yes when COLO enabled
+
+=back
+
+=item B<hidden-disk>
+
+=over 4
+
+=item Description
+
+This is used by secondary. It buffers the original content that is modified
+by the primary VM.
+
+=item Mandatory
+
+Yes when COLO enabled
+
+=back
+
+=back
+
+
+=head1 Deprecated Parameters, Prefixes And Syntaxes
+
+Deprecated forms are acceptable and are intended work compatibly with
+xend and xl from xen 4.1.  In future they may print a warning.
+Support for deprecated parameters and syntaxes are likely to be
+dropped in future versions of xl.
+
+There is support for a deprecated old syntax for C<DISKSPEC>:
+
+  [<format>:][<target>],<vdev>[:<devtype>],<access>   (deprecated)
+
+This syntax also supports deprecated prefixes, described below.  These
+are found prepended to the format parameter - eg C<tap:aio:qcow:>.
+
+=over 4
+
+=item B<format>
+
+=over 4
+
+=item Description
+
+Specifies the format (deprecated)
+
+=item Supported values
+
+raw:  qcow2:  vhd:
+
+=back
+
+In xend and old versions of libxl it was necessary to specify the
+format with a prefix.  For compatibility, these three prefixes are
+recognised as specifying the corresponding format.  They are
+equivalent to C<format=FORMAT> or the specification of B<format>
+(without a colon) as a positional parameter.
+
+
+=item B<script>
+
+=over 4
+
+=item Description
+
+Specifies the script (deprecated)
+
+=item Supported values
+
+iscsi:  nbd:  enbd:  drbd:
+
+=back
+
+In xend and old versions of libxl it was necessary to specify the
+"script" (see above) with a prefix.  For compatibility, these four
+prefixes are recognised as specifying the corresponding script.  They
+are equivalent to C<script=block-SCRIPT>.
+
+
+=item B<deprecated-prefix>
+
+=over 4
+
+=item Description
+
+Deprecated prefix, ignored
+
+=item Supported values
+
+tapdisk:  tap2:  aio:  ioemu:  file:  phy:
+
+=back
+
+Various prefixes were required by xend and older versions of libxl to
+make the block devices work.  In some cases these options would
+override the backend type, but in other cases they would be ignored in
+favour of "making it work"; in yet other cases it would be necessary
+to specify several of these, for example:
+
+  tap:aio:/some/path...
+
+All of these prefixes are now stripped and ignored.
+
+=back
+
+=head2 Missing format and empty target
+
+The following syntax is also supported:
+
+  ,<vdev>:<devtype>,<access>   (deprecated)
+
+This is solely for compatibility with xend's syntax for empty cdroms,
+which is (for example) C<,hdc:cdrom,r>.
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl-network-configuration.5.pod 4.16.1-1/docs/man/xl-network-configuration.5.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xl-network-configuration.5.pod	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/man/xl-network-configuration.5.pod	1970-01-01 00:00:00.000000000 +0000
@@ -1,251 +0,0 @@
-=encoding utf8
-
-=head1 NAME
-
-xl-network-configuration - XL Network Configuration Syntax
-
-
-=head1 SYNTAX
-
-This document specifies the xl config file format vif configuration
-option.  It has the following form:
-
-        vif = [ '<vifspec>', '<vifspec>', ... ]
-
-where each vifspec is in this form:
-
-        [<key>=<value>|<flag>,]
-
-For example:
-
-        'mac=00:16:3E:74:3d:76,model=rtl8139,bridge=xenbr0'
-        'mac=00:16:3E:74:34:32'
-        '' # The empty string
-
-These might be specified in the domain config file like this:
-
-        vif = [ 'mac=00:16:3E:74:34:32', 'mac=00:16:3e:5f:48:e4,bridge=xenbr1' ]
-
-More formally, the string is a series of comma-separated keyword/value
-pairs. All keywords are optional.
-
-Each device has a C<DEVID> which is its index within the vif list, starting from 0.
-
-
-=head1 Keywords
-
-
-=head2 mac
-
-If specified then this option specifies the MAC address inside the
-guest of this VIF device. The value is a 48-bit number represented as
-six groups of two hexadecimal digits, separated by colons (:).
-
-The default if this keyword is not specified is to be automatically
-generate a MAC address inside the space assigned to Xen's
-L<Organizationally Unique Identifier|https://en.wikipedia.org/wiki/Organizationally_Unique_Identifier> (00:16:3e).
-
-If you are choosing a MAC address then it is strongly recommend to
-follow one of the following strategies:
-
-=over
-
-=item *
-
-Generate a random sequence of 6 byte, set the locally administered
-bit (bit 2 of the first byte) and clear the multicast bit (bit 1
-of the first byte). In other words the first byte should have the
-bit pattern xxxxxx10 (where x is a randomly generated bit) and the
-remaining 5 bytes are randomly generated See
-[https://en.wikipedia.org/wiki/MAC_address] for more details the
-structure of a MAC address.
-
-
-=item *
-
-Allocate an address from within the space defined by your
-organization's OUI (if you have one) following your organization's
-procedures for doing so.
-
-
-=item *
-
-Allocate an address from within the space defined by Xen's OUI
-(00:16:3e). Taking care not to clash with other users of the
-physical network segment where this VIF will reside.
-
-
-=back
-
-If you have an OUI for your own use then that is the preferred
-strategy. Otherwise in general you should prefer to generate a random
-MAC and set the locally administered bit since this allows for more
-bits of randomness than using the Xen OUI.
-
-
-=head2 bridge
-
-Specifies the name of the network bridge which this VIF should be
-added to. The default is C<xenbr0>. The bridge must be configured using
-your distribution's network configuration tools. See the L<wiki|https://wiki.xenproject.org/wiki/Network_Configuration_Examples_(Xen_4.1%2B)>
-for guidance and examples.
-
-
-=head2 gatewaydev
-
-Specifies the name of the network interface which has an IP and which
-is in the network the VIF should communicate with. This is used in the host
-by the vif-route hotplug script. See L<wiki|https://wiki.xenproject.org/wiki/Vif-route> for guidance and
-examples.
-
-NOTE: netdev is a deprecated alias of this option.
-
-
-=head2 type
-
-This keyword is valid for HVM guests only.
-
-Specifies the type of device to valid values are:
-
-=over
-
-=item *
-
-C<ioemu> (default) -- this device will be provided as an emulate
-device to the guest and also as a paravirtualised device which the
-guest may choose to use instead if it has suitable drivers
-available.
-
-
-=item *
-
-C<vif> -- this device will be provided as a paravirtualised device
-only.
-
-
-=back
-
-
-=head2 model
-
-This keyword is valid for HVM guest devices with C<type=ioemu> only.
-
-Specifies the type device to emulated for this guest. Valid values
-are:
-
-=over
-
-=item *
-
-C<rtl8139> (default) -- Realtek RTL8139
-
-
-=item *
-
-C<e1000> -- Intel E1000
-
-
-=item *
-
-in principle any device supported by your device model
-
-
-=back
-
-
-=head2 vifname
-
-Specifies the backend device name for the virtual device.
-
-If the domain is an HVM domain then the associated emulated (tap)
-device will have a "-emu" suffice added.
-
-The default name for the virtual device is C<vifDOMID.DEVID> where
-C<DOMID> is the guest domain ID and C<DEVID> is the device
-number. Likewise the default tap name is C<vifDOMID.DEVID-emu>.
-
-
-=head2 script
-
-Specifies the hotplug script to run to configure this device (e.g. to
-add it to the relevant bridge). Defaults to
-C<XEN_SCRIPT_DIR/vif-bridge> but can be set to any script. Some example
-scripts are installed in C<XEN_SCRIPT_DIR>.
-
-
-=head2 ip
-
-Specifies the IP address for the device, the default is not to
-specify an IP address.
-
-What, if any, effect this has depends on the hotplug script which is
-configured. A typically behaviour (exhibited by the example hotplug
-scripts) if set might be to configure firewall rules to allow only the
-specified IP address to be used by the guest (blocking all others).
-
-
-=head2 backend
-
-Specifies the backend domain which this device should attach to. This
-defaults to domain 0.  Specifying another domain requires setting up a
-driver domain which is outside the scope of this document.
-
-
-=head2 rate
-
-Specifies the rate at which the outgoing traffic will be limited to.
-The default if this keyword is not specified is unlimited.
-
-The rate may be specified as "/s" or optionally "/s@".
-
-=over
-
-=item *
-
-C<RATE> is in bytes and can accept suffixes:
-
-=over
-
-=item *
-
-GB, MB, KB, B for bytes.
-
-
-=item *
-
-Gb, Mb, Kb, b for bits.
-
-
-=back
-
-
-
-=item *
-
-C<INTERVAL> is in microseconds and can accept suffixes: ms, us, s.
-It determines the frequency at which the vif transmission credit
-is replenished. The default is 50ms.
-
-
-=back
-
-Vif rate limiting is credit-based. It means that for "1MB/s@20ms", the
-available credit will be equivalent of the traffic you would have done
-at "1MB/s" during 20ms. This will results in a credit of 20,000 bytes
-replenished every 20,000 us.
-
-For example:
-
-        'rate=10Mb/s' -- meaning up to 10 megabits every second
-        'rate=250KB/s' -- meaning up to 250 kilobytes every second
-        'rate=1MB/s@20ms' -- meaning 20,000 bytes in every 20 millisecond period
-
-NOTE: The actual underlying limits of rate limiting are dependent
-on the underlying netback implementation.
-
-
-=head2 devid
-
-Specifies the devid manually instead of letting xl choose the lowest index available.
-
-NOTE: This should not be set unless you have a reason to.
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl-network-configuration.5.pod.in 4.16.1-1/docs/man/xl-network-configuration.5.pod.in
--- 4.14.3+32-g9de3671772-1/docs/man/xl-network-configuration.5.pod.in	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/docs/man/xl-network-configuration.5.pod.in	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,260 @@
+=encoding utf8
+
+=head1 NAME
+
+xl-network-configuration - XL Network Configuration Syntax
+
+
+=head1 SYNTAX
+
+This document specifies the xl config file format vif configuration
+option.  It has the following form:
+
+        vif = [ '<vifspec>', '<vifspec>', ... ]
+
+where each vifspec is in this form:
+
+        [<key>=<value>|<flag>,]
+
+For example:
+
+        'mac=00:16:3E:74:3d:76,model=rtl8139,bridge=xenbr0'
+        'mac=00:16:3E:74:34:32'
+        '' # The empty string
+
+These might be specified in the domain config file like this:
+
+        vif = [ 'mac=00:16:3E:74:34:32', 'mac=00:16:3e:5f:48:e4,bridge=xenbr1' ]
+
+More formally, the string is a series of comma-separated keyword/value
+pairs. All keywords are optional.
+
+Each device has a C<DEVID> which is its index within the vif list, starting from 0.
+
+
+=head1 Keywords
+
+
+=head2 mac
+
+If specified then this option specifies the MAC address inside the
+guest of this VIF device. The value is a 48-bit number represented as
+six groups of two hexadecimal digits, separated by colons (:).
+
+The default if this keyword is not specified is to be automatically
+generate a MAC address inside the space assigned to Xen's
+L<Organizationally Unique Identifier|https://en.wikipedia.org/wiki/Organizationally_Unique_Identifier> (00:16:3e).
+
+If you are choosing a MAC address then it is strongly recommend to
+follow one of the following strategies:
+
+=over
+
+=item *
+
+Generate a random sequence of 6 byte, set the locally administered
+bit (bit 2 of the first byte) and clear the multicast bit (bit 1
+of the first byte). In other words the first byte should have the
+bit pattern xxxxxx10 (where x is a randomly generated bit) and the
+remaining 5 bytes are randomly generated See
+[https://en.wikipedia.org/wiki/MAC_address] for more details the
+structure of a MAC address.
+
+
+=item *
+
+Allocate an address from within the space defined by your
+organization's OUI (if you have one) following your organization's
+procedures for doing so.
+
+
+=item *
+
+Allocate an address from within the space defined by Xen's OUI
+(00:16:3e). Taking care not to clash with other users of the
+physical network segment where this VIF will reside.
+
+
+=back
+
+If you have an OUI for your own use then that is the preferred
+strategy. Otherwise in general you should prefer to generate a random
+MAC and set the locally administered bit since this allows for more
+bits of randomness than using the Xen OUI.
+
+
+=head2 bridge
+
+Specifies the name of the network bridge which this VIF should be
+added to. The default is C<xenbr0>. The bridge must be configured using
+your distribution's network configuration tools. See the L<wiki|https://wiki.xenproject.org/wiki/Network_Configuration_Examples_(Xen_4.1%2B)>
+for guidance and examples.
+
+
+=head2 gatewaydev
+
+Specifies the name of the network interface which has an IP and which
+is in the network the VIF should communicate with. This is used in the host
+by the vif-route hotplug script. See L<wiki|https://wiki.xenproject.org/wiki/Vif-route> for guidance and
+examples.
+
+NOTE: netdev is a deprecated alias of this option.
+
+
+=head2 type
+
+This keyword is valid for HVM guests only.
+
+Specifies the type of device to valid values are:
+
+=over
+
+=item *
+
+C<ioemu> (default) -- this device will be provided as an emulate
+device to the guest and also as a paravirtualised device which the
+guest may choose to use instead if it has suitable drivers
+available.
+
+
+=item *
+
+C<vif> -- this device will be provided as a paravirtualised device
+only.
+
+
+=back
+
+
+=head2 model
+
+This keyword is valid for HVM guest devices with C<type=ioemu> only.
+
+Specifies the type device to emulated for this guest. Valid values
+are:
+
+=over
+
+=item *
+
+C<rtl8139> (default) -- Realtek RTL8139
+
+
+=item *
+
+C<e1000> -- Intel E1000
+
+
+=item *
+
+in principle any device supported by your device model
+
+
+=back
+
+
+=head2 vifname
+
+Specifies the backend device name for the virtual device.
+
+If the domain is an HVM domain then the associated emulated (tap)
+device will have a "-emu" suffice added.
+
+The default name for the virtual device is C<vifDOMID.DEVID> where
+C<DOMID> is the guest domain ID and C<DEVID> is the device
+number. Likewise the default tap name is C<vifDOMID.DEVID-emu>.
+
+
+=head2 script
+
+Specifies the hotplug script to run to configure this device (e.g. to
+add it to the relevant bridge). Defaults to
+C<@XEN_SCRIPT_DIR@/vif-bridge> but can be set to any script. Some example
+scripts are installed in C<@XEN_SCRIPT_DIR@>.
+
+Note on NetBSD HVM guests will ignore the script option for tap
+(emulated) interfaces and always use
+C<XEN_SCRIPT_DIR/qemu-ifup> to configure the interface in bridged mode.
+
+=head2 ip
+
+Specifies the IP address for the device, the default is not to
+specify an IP address.
+
+What, if any, effect this has depends on the hotplug script which is
+configured. A typically behaviour (exhibited by the example hotplug
+scripts) if set might be to configure firewall rules to allow only the
+specified IP address to be used by the guest (blocking all others).
+
+
+=head2 backend
+
+Specifies the backend domain which this device should attach to. This
+defaults to domain 0.  Specifying another domain requires setting up a
+driver domain which is outside the scope of this document.
+
+
+=head2 rate
+
+Specifies the rate at which the outgoing traffic will be limited to.
+The default if this keyword is not specified is unlimited.
+
+The rate may be specified as "/s" or optionally "/s@".
+
+=over
+
+=item *
+
+C<RATE> is in bytes and can accept suffixes:
+
+=over
+
+=item *
+
+GB, MB, KB, B for bytes.
+
+
+=item *
+
+Gb, Mb, Kb, b for bits.
+
+
+=back
+
+
+
+=item *
+
+C<INTERVAL> is in microseconds and can accept suffixes: ms, us, s.
+It determines the frequency at which the vif transmission credit
+is replenished. The default is 50ms.
+
+
+=back
+
+Vif rate limiting is credit-based. It means that for "1MB/s@20ms", the
+available credit will be equivalent of the traffic you would have done
+at "1MB/s" during 20ms. This will results in a credit of 20,000 bytes
+replenished every 20,000 us.
+
+For example:
+
+        'rate=10Mb/s' -- meaning up to 10 megabits every second
+        'rate=250KB/s' -- meaning up to 250 kilobytes every second
+        'rate=1MB/s@20ms' -- meaning 20,000 bytes in every 20 millisecond period
+
+NOTE: The actual underlying limits of rate limiting are dependent
+on the underlying netback implementation.
+
+
+=head2 devid
+
+Specifies the devid manually instead of letting xl choose the lowest index available.
+
+NOTE: This should not be set unless you have a reason to.
+
+=head2 mtu
+
+Specifies the MTU (i.e. the maximum size of an IP payload, exclusing headers). The
+default value is 1500 but, if the VIF is attached to a bridge, it will be set to match
+unless overridden by this parameter.
diff -pruN 4.14.3+32-g9de3671772-1/docs/man/xl-pci-configuration.5.pod 4.16.1-1/docs/man/xl-pci-configuration.5.pod
--- 4.14.3+32-g9de3671772-1/docs/man/xl-pci-configuration.5.pod	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/docs/man/xl-pci-configuration.5.pod	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,218 @@
+=encoding utf8
+
+=head1 NAME
+
+xl-pci-configuration - XL PCI Configuration Syntax
+
+=head1 SYNTAX
+
+This document specifies the format for B<BDF> and B<PCI_SPEC_STRING> which are
+used by the L<xl.cfg(5)> pci configuration option, and related L<xl(1)>
+commands.
+
+A B<BDF> has the following form:
+
+    [DDDD:]BB:SS.F
+
+B<DDDD> is the domain number, B<BB> is the bus number, B<SS> is the device (or
+slot) number, and B<F> is the function number. This is the same scheme as
+used in the output of L<lspci(1)> for the device in question. By default
+L<lspci(1)> will omit the domain (B<DDDD>) if it is zero and hence a zero
+value for domain may also be omitted when specifying a B<BDF>.
+
+Each B<PCI_SPEC_STRING> has the one of the forms:
+
+=over 4
+
+    [<bdf>[@<vslot>,][<key>=<value>,]*
+    [<key>=<value>,]*
+
+=back
+
+For example, these strings are equivalent:
+
+=over 4
+
+    36:00.0@20,seize=1
+    36:00.0,vslot=20,seize=1
+    bdf=36:00.0,vslot=20,seize=1
+
+=back
+
+More formally, the string is a series of comma-separated keyword/value
+pairs, flags and positional parameters.  Parameters which are not bare
+keywords and which do not contain "=" symbols are assigned to the
+positional parameters, in the order specified below.  The positional
+parameters may also be specified by name.
+
+Each parameter may be specified at most once, either as a positional
+parameter or a named parameter.  Default values apply if the parameter
+is not specified, or if it is specified with an empty value (whether
+positionally or explicitly).
+
+B<NOTE>: In context of B<xl pci-detach> (see L<xl(1)>), parameters other than
+B<bdf> or B<name> will be ignored.
+
+=head1 Positional Parameters
+
+=over 4
+
+=item B<bdf>=I<BDF>
+
+=over 4
+
+=item Description
+
+This identifies the PCI device from the host perspective.
+
+In the context of a B<PCI_SPEC_STRING> you may specify the function (B<F>) as
+B<*> to indicate all functions of a multi-function device.
+
+=item Default Value
+
+None. This parameter is mandatory in its positional form. As a non-positional
+parameter it is also mandatory unless a B<name> parameter is present, in
+which case B<bdf> must not be present since the B<name> will be used to find
+the B<bdf> in the list of assignable devices. See L<xl(1)> for more information
+on naming assignable devices.
+
+=back
+
+=item B<vslot>=I<NUMBER>
+
+=over 4
+
+=item Description
+
+Specifies the virtual slot (device) number where the guest will see this
+device. For example, running L<lspci(1)> in a Linux guest where B<vslot>
+was specified as C<8> would identify the device as C<00:08.0>. Virtual domain
+and bus numbers are always 0.
+
+B<NOTE:> This parameter is always parsed as a hexidecimal value.
+
+=item Default Value
+
+None. This parameter is not mandatory. An available B<vslot> will be selected
+if this parameter is not specified.
+
+=back
+
+=back
+
+=head1 Other Parameters and Flags
+
+=over 4
+
+=item B<permissive>=I<BOOLEAN>
+
+=over 4
+
+=item Description
+
+By default pciback only allows PV guests to write "known safe" values
+into PCI configuration space, likewise QEMU (both qemu-xen and
+qemu-xen-traditional) imposes the same constraint on HVM guests.
+However, many devices require writes to other areas of the configuration space
+in order to operate properly.  This option tells the backend (pciback or QEMU)
+to allow all writes to the PCI configuration space of this device by this
+domain.
+
+B<This option should be enabled with caution:> it gives the guest much
+more control over the device, which may have security or stability
+implications.  It is recommended to only enable this option for
+trusted VMs under administrator's control.
+
+=item Default Value
+
+0
+
+=back
+
+=item B<msitranslate>=I<BOOLEAN>
+
+=over 4
+
+=item Description
+
+Specifies that MSI-INTx translation should be turned on for the PCI
+device. When enabled, MSI-INTx translation will always enable MSI on
+the PCI device regardless of whether the guest uses INTx or MSI.
+
+=item Default Value
+
+Some device drivers, such as NVIDIA's, detect an inconsistency and do not
+function when this option is enabled. Therefore the default is false (0).
+
+=back
+
+=item B<seize>=I<BOOLEAN>
+
+=over 4
+
+=item Description
+
+Tells L<xl(1)> to automatically attempt to make the device assignable to
+guests if that has not already been done by the B<pci-assignable-add>
+command.
+
+B<WARNING:> If you set this option, L<xl> will gladly re-assign a critical
+system device, such as a network or a disk controller being used by
+dom0 without confirmation.  Please use with care.
+
+=item Default Value
+
+0
+
+=back
+
+=item B<power_mgmt>=I<BOOLEAN>
+
+=over 4
+
+=item Description
+
+B<(HVM only)> Specifies that the VM should be able to program the
+D0-D3hot power management states for the PCI device.
+
+=item Default Value
+
+0
+
+=back
+
+=item B<rdm_policy>=I<STRING>
+
+=over 4
+
+=item Description
+
+B<(HVM/x86 only)> This is the same as the policy setting inside the B<rdm>
+option in L<xl.cfg(5)> but just specific to a given device.
+
+B<NOTE>: This overrides the global B<rdm> option.
+
+=item Default Value
+
+"strict"
+
+=back
+
+=item B<name>=I<STRING>
+
+=over 4
+
+=item Description
+
+This is the name given when the B<BDF> was made assignable. See L<xl(1)> for
+more information on naming assignable devices.
+
+=item Default Value
+
+None. This parameter must not be present if a B<bdf> parameter is present.
+If a B<bdf> parameter is not present then B<name> is mandatory as it is
+required to look up the B<BDF> in the list of assignable devices.
+
+=back
+
+=back
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/arm/device-tree/booting.txt 4.16.1-1/docs/misc/arm/device-tree/booting.txt
--- 4.14.3+32-g9de3671772-1/docs/misc/arm/device-tree/booting.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/arm/device-tree/booting.txt	2022-04-12 12:21:23.000000000 +0000
@@ -51,6 +51,8 @@ Each node contains the following propert
 	Xen 4.4 supported a different set of legacy compatible strings
 	which remain supported such that systems supporting both 4.4
 	and later can use a single DTB.
+	However when booting Xen using UEFI, the legacy compatible
+	strings are not supported.
 
 	- "xen,multiboot-module" equivalent to "multiboot,module"
 	- "xen,linux-zimage"     equivalent to "multiboot,kernel"
@@ -70,6 +72,14 @@ Each node contains the following propert
 	priority of this field vs. other mechanisms of specifying the
 	bootargs for the kernel.
 
+- xen,uefi-binary (UEFI boot only)
+
+	String property that specifies the file name to be loaded by the UEFI
+	boot for this module. If this is specified, there is no need to specify
+	the reg property because it will be created by the UEFI stub on boot.
+	This option is needed only when UEFI boot is used, the node needs to be
+	compatible with multiboot,kernel or multiboot,ramdisk.
+
 Examples
 ========
 
@@ -121,6 +131,14 @@ A Xen-aware bootloader would set xen,xen
 for Dom0 and bootargs for native Linux.
 
 
+UEFI boot and DT
+================
+
+When Xen is booted using UEFI, it doesn't read the configuration file if any
+multiboot module is specified. To force Xen to load the configuration file, the
+boolean property xen,uefi-cfg-load must be declared in the /chosen node.
+
+
 Creating Multiple Domains directly from Xen
 ===========================================
 
@@ -182,6 +200,13 @@ The kernel sub-node has the following pr
 
     Command line parameters for the guest kernel.
 
+- xen,uefi-binary (UEFI boot only)
+
+    String property that specifies the file name to be loaded by the UEFI boot
+    for this module. If this is specified, there is no need to specify the reg
+    property because it will be created by the UEFI stub on boot.
+    This option is needed only when UEFI boot is used.
+
 The ramdisk sub-node has the following properties:
 
 - compatible
@@ -193,6 +218,13 @@ The ramdisk sub-node has the following p
     Specifies the physical address of the ramdisk in RAM and its
     length.
 
+- xen,uefi-binary (UEFI boot only)
+
+    String property that specifies the file name to be loaded by the UEFI boot
+    for this module. If this is specified, there is no need to specify the reg
+    property because it will be created by the UEFI stub on boot.
+    This option is needed only when UEFI boot is used.
+
 
 Example
 =======
@@ -257,6 +289,13 @@ The dtb sub-node should have the followi
     Specifies the physical address of the device tree binary fragment
     RAM and its length.
 
+- xen,uefi-binary (UEFI boot only)
+
+    String property that specifies the file name to be loaded by the UEFI boot
+    for this module. If this is specified, there is no need to specify the reg
+    property because it will be created by the UEFI stub on boot.
+    This option is needed only when UEFI boot is used.
+
 As an example:
 
         module@0xc000000 {
@@ -268,3 +307,45 @@ The DTB fragment is loaded at 0xc000000
 follow the convention explained in docs/misc/arm/passthrough.txt. The
 DTB fragment will be added to the guest device tree, so that the guest
 kernel will be able to discover the device.
+
+
+Static Allocation
+=============
+
+Static Allocation refers to system or sub-system(domains) for which memory
+areas are pre-defined by configuration using physical address ranges.
+
+Memory can be statically allocated to a domain using the property "xen,static-
+mem" defined in the domain configuration. The number of cells for the address
+and the size must be defined using respectively the properties
+"#xen,static-mem-address-cells" and "#xen,static-mem-size-cells".
+
+The property 'memory' is still needed and should match the amount of memory
+given to the guest. Currently, it either comes from static memory or lets Xen
+allocate from heap. *Mixing* is not supported.
+
+The static memory will be mapped in the guest at the usual guest memory
+addresses (GUEST_RAM0_BASE, GUEST_RAM1_BASE) defined by
+xen/include/public/arch-arm.h.
+
+Below is an example on how to specify the static memory region in the
+device-tree:
+
+    / {
+        chosen {
+            domU1 {
+                compatible = "xen,domain";
+                #address-cells = <0x2>;
+                #size-cells = <0x2>;
+                cpus = <2>;
+                memory = <0x0 0x80000>;
+                #xen,static-mem-address-cells = <0x1>;
+                #xen,static-mem-size-cells = <0x1>;
+                xen,static-mem = <0x30000000 0x20000000>;
+                ...
+            };
+        };
+    };
+
+This will reserve a 512MB region starting at the host physical address
+0x30000000 to be exclusively used by DomU1.
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/arm/device-tree/guest.txt 4.16.1-1/docs/misc/arm/device-tree/guest.txt
--- 4.14.3+32-g9de3671772-1/docs/misc/arm/device-tree/guest.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/arm/device-tree/guest.txt	2022-04-12 12:21:23.000000000 +0000
@@ -7,10 +7,14 @@ the following properties:
 	compatible = "xen,xen-<version>", "xen,xen";
   where <version> is the version of the Xen ABI of the platform.
 
-- reg: specifies the base physical address and size of a region in
-  memory where the grant table should be mapped to, using an
-  HYPERVISOR_memory_op hypercall. The memory region is large enough to map
-  the whole grant table (it is larger or equal to gnttab_max_grant_frames()).
+- reg: specifies the base physical address and size of the regions in memory
+  where the special resources should be mapped to, using an HYPERVISOR_memory_op
+  hypercall.
+  Region 0 is reserved for mapping grant table, it must be always present.
+  The memory region is large enough to map the whole grant table (it is larger
+  or equal to gnttab_max_grant_frames()).
+  Regions 1...N are extended regions (unused address space) for mapping foreign
+  GFNs and grants, they might be absent if there is nothing to expose.
   This property is unnecessary when booting Dom0 using ACPI.
 
 - interrupts: the interrupt used by Xen to inject event notifications.
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/arm/silicon-errata.txt 4.16.1-1/docs/misc/arm/silicon-errata.txt
--- 4.14.3+32-g9de3671772-1/docs/misc/arm/silicon-errata.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/arm/silicon-errata.txt	2022-04-12 12:21:23.000000000 +0000
@@ -55,5 +55,7 @@ stable hypervisors.
 | ARM            | Cortex-A72      | #853709         | N/A                     |
 | ARM            | Cortex-A73      | #858921         | ARM_ERRATUM_858921      |
 | ARM            | Cortex-A76      | #1165522        | N/A                     |
+| ARM            | Cortex-A76      | #1286807        | ARM64_ERRATUM_1286807   |
 | ARM            | Neoverse-N1     | #1165522        | N/A
+| ARM            | Neoverse-N1     | #1286807        | ARM64_ERRATUM_1286807   |
 | ARM            | MMU-500         | #842869         | N/A                     |
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/efi.pandoc 4.16.1-1/docs/misc/efi.pandoc
--- 4.14.3+32-g9de3671772-1/docs/misc/efi.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/efi.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -14,6 +14,8 @@ loaded the modules and describes them in
 bootloader provides a device tree containing modules then any configuration
 files are ignored, and the bootloader is responsible for populating all
 relevant device tree nodes.
+The property "xen,uefi-cfg-load" can be specified in the /chosen node to force
+Xen to load the configuration file even if multiboot modules are found.
 
 Once built, `make install-xen` will place the resulting binary directly into
 the EFI boot partition, provided `EFI_VENDOR` is set in the environment (and
@@ -116,3 +118,317 @@ Filenames must be specified relative to
 
 Extra options to be passed to Xen can also be specified on the command line,
 following a `--` separator option.
+
+## Unified Xen kernel image
+
+The "Unified" kernel image can be generated by adding additional
+sections to the Xen EFI executable with objcopy, similar to how
+[systemd-boot uses the stub to add them to the Linux kernel](https://wiki.archlinux.org/index.php/systemd-boot#Preparing_a_unified_kernel_image)
+
+The sections for the xen configuration file, the dom0 kernel, dom0 initrd,
+XSM and CPU microcode should be added after the Xen `.pad` section, the
+ending address of which can be located with:
+
+```
+objdump -h xen.efi \
+	| perl -ane '/\.pad/ && printf "0x%016x\n", hex($F[2]) + hex($F[3])'
+```
+
+For all the examples the `.pad` section ended at 0xffff82d041000000.
+All the sections are optional (`.config`, `.kernel`, `.ramdisk`, `.xsm`,
+`.ucode` (x86) and `.dtb` (ARM)) and the order does not matter.
+The virtual addresses do not need to be contiguous, although they should not
+be overlapping and should all be greater than the last virtual address of the
+hypervisor components.
+
+```
+objcopy \
+	--add-section .config=xen.cfg \
+	--change-section-vma .config=0xffff82d041000000
+	--add-section .ucode=ucode.bin \
+	--change-section-vma .ucode=0xffff82d041010000 \
+	--add-section .xsm=xsm.cfg \
+	--change-section-vma .xsm=0xffff82d041080000 \
+	--add-section .kernel=vmlinux \
+	--change-section-vma .kernel=0xffff82d041100000 \
+	--add-section .ramdisk=initrd.img \
+	--change-section-vma .ramdisk=0xffff82d042000000 \
+	xen.efi \
+	xen.unified.efi
+```
+
+The unified executable can be signed with sbsigntool to make
+it usable with UEFI secure boot:
+
+```
+sbsign \
+	--key signing.key \
+	--cert cert.pem \
+	--output xen.signed.efi \
+	xen.unified.efi
+```
+## UEFI boot and Dom0 modules on ARM
+
+When booting using UEFI on ARM, it is possible to specify the Dom0 modules
+directly from the device tree without using the Xen configuration file, here an
+example:
+
+chosen {
+	#size-cells = <0x1>;
+	#address-cells = <0x1>;
+	xen,xen-bootargs = "[Xen boot arguments]"
+
+	module@1 {
+		compatible = "multiboot,kernel", "multiboot,module";
+		xen,uefi-binary = "vmlinuz-3.0.31-0.4-xen";
+		bootargs = "[domain 0 command line options]";
+	};
+
+	module@2 {
+		compatible = "multiboot,ramdisk", "multiboot,module";
+		xen,uefi-binary = "initrd-3.0.31-0.4-xen";
+	};
+}
+
+## UEFI boot and dom0less on ARM
+
+Dom0less feature is supported by ARM and it is possible to use it when Xen is
+started as an EFI application.
+The way to specify the domU domains is by Device Tree as specified in the
+[dom0less](dom0less.html) documentation page under the "Device Tree
+configuration" section, but instead of declaring the reg property in the boot
+module, the user must specify the "xen,uefi-binary" property containing the name
+of the binary file that has to be loaded in memory.
+The UEFI stub will load the binary in memory and it will add the reg property
+accordingly.
+
+An example here:
+
+domU1 {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "xen,domain";
+	memory = <0 0x20000>;
+	cpus = <1>;
+	vpl011;
+
+	module@1 {
+		compatible = "multiboot,kernel", "multiboot,module";
+		xen,uefi-binary = "vmlinuz-3.0.31-0.4-xen";
+		bootargs = "console=ttyAMA0";
+	};
+	module@2 {
+		compatible = "multiboot,ramdisk", "multiboot,module";
+		xen,uefi-binary = "initrd-3.0.31-0.4-xen";
+	};
+	module@3 {
+		compatible = "multiboot,device-tree", "multiboot,module";
+		xen,uefi-binary = "passthrough.dtb";
+	};
+};
+
+## How to boot different Xen setup using UEFI
+
+These are the different ways to boot a Xen system from UEFI:
+
+ - Boot Xen and Dom0 (minimum required)
+ - Boot Xen and DomU(s) (true dom0less, only on ARM)
+ - Boot Xen, Dom0 and DomU(s) (only on ARM)
+
+### Boot Xen and Dom0
+
+This configuration can be started using the Xen configuration file in the
+example above.
+
+### Boot Xen and DomU(s)
+
+This configuration needs the domU domain(s) specified in the /chosen node,
+examples of how to do that are provided by the documentation about dom0less
+and the example above shows how to use the "xen,uefi-binary" property to use the
+UEFI stub for module loading.
+When adding DomU modules to device tree, also add the property
+xen,uefi-cfg-load under chosen for Xen to load the Xen config file.
+Otherwise, Xen will skip the config file and rely on device tree alone.
+When using the Xen configuration file in conjunction with the device tree, you
+can specify the Xen boot arguments in the configuration file with the "options="
+keyword or in the device tree with the "xen,xen-bootargs" property, but be
+aware that the Xen configuration file value has a precedence over the DT value.
+
+Example 1 of how to boot a true dom0less configuration:
+
+Xen configuration file: skipped.
+
+Device tree:
+
+```
+chosen {
+	#size-cells = <0x1>;
+	#address-cells = <0x1>;
+	xen,xen-bootargs = "<Xen command line>"
+
+	domU1 {
+		#size-cells = <0x1>;
+		#address-cells = <0x1>;
+		compatible = "xen,domain";
+		cpus = <0x1>;
+		memory = <0x0 0xc0000>;
+		vpl011;
+
+		module@1 {
+			compatible = "multiboot,kernel", "multiboot,module";
+			xen,uefi-binary = "Image-domu1.bin";
+			bootargs = "console=ttyAMA0 root=/dev/ram0 rw";
+		};
+	};
+	domU2 {
+		#size-cells = <0x1>;
+		#address-cells = <0x1>;
+		compatible = "xen,domain";
+		cpus = <0x1>;
+		memory = <0x0 0x100000>;
+		vpl011;
+
+		module@2 {
+			compatible = "multiboot,kernel", "multiboot,module";
+			xen,uefi-binary = "Image-domu2.bin";
+			bootargs = "console=ttyAMA0 root=/dev/ram0 rw";
+		};
+	};
+};
+```
+
+Example 2 of how to boot a true dom0less configuration:
+
+Xen configuration file:
+
+```
+[global]
+default=xen
+
+[xen]
+options=<Xen command line>
+dtb=<optional DTB>
+```
+
+Device tree:
+
+```
+chosen {
+	#size-cells = <0x1>;
+	#address-cells = <0x1>;
+	xen,uefi-cfg-load;
+
+	domU1 {
+		#size-cells = <0x1>;
+		#address-cells = <0x1>;
+		compatible = "xen,domain";
+		cpus = <0x1>;
+		memory = <0x0 0xc0000>;
+		vpl011;
+
+		module@1 {
+			compatible = "multiboot,kernel", "multiboot,module";
+			xen,uefi-binary = "Image-domu1.bin";
+			bootargs = "console=ttyAMA0 root=/dev/ram0 rw";
+		};
+	};
+	domU2 {
+		#size-cells = <0x1>;
+		#address-cells = <0x1>;
+		compatible = "xen,domain";
+		cpus = <0x1>;
+		memory = <0x0 0x100000>;
+		vpl011;
+
+		module@2 {
+			compatible = "multiboot,kernel", "multiboot,module";
+			xen,uefi-binary = "Image-domu2.bin";
+			bootargs = "console=ttyAMA0 root=/dev/ram0 rw";
+		};
+	};
+};
+```
+
+### Boot Xen, Dom0 and DomU(s)
+
+This configuration is a mix of the two configuration above, to boot this one
+the configuration file can be processed or the Dom0 modules can be read from
+the device tree.
+
+Here the first example:
+
+Xen configuration file:
+
+```
+[global]
+default=xen
+
+[xen]
+options=<Xen command line>
+kernel=vmlinuz-3.0.31-0.4-xen [domain 0 command line options]
+ramdisk=initrd-3.0.31-0.4-xen
+dtb=<optional DTB>
+```
+
+Device tree:
+
+```
+chosen {
+	#size-cells = <0x1>;
+	#address-cells = <0x1>;
+	xen,uefi-cfg-load;
+
+	domU1 {
+		#size-cells = <0x1>;
+		#address-cells = <0x1>;
+		compatible = "xen,domain";
+		cpus = <0x1>;
+		memory = <0x0 0xc0000>;
+		vpl011;
+
+		module@1 {
+			compatible = "multiboot,kernel", "multiboot,module";
+			xen,uefi-binary = "Image-domu1.bin";
+			bootargs = "console=ttyAMA0 root=/dev/ram0 rw";
+		};
+	};
+};
+```
+
+Here the second example:
+
+Device tree:
+
+```
+chosen {
+	#size-cells = <0x1>;
+	#address-cells = <0x1>;
+	xen,xen-bootargs = "[Xen boot arguments]"
+
+	module@1 {
+		compatible = "multiboot,kernel", "multiboot,module";
+		xen,uefi-binary = "vmlinuz-3.0.31-0.4-xen";
+		bootargs = "[domain 0 command line options]";
+	};
+
+	module@2 {
+		compatible = "multiboot,ramdisk", "multiboot,module";
+		xen,uefi-binary = "initrd-3.0.31-0.4-xen";
+	};
+
+	domU1 {
+		#size-cells = <0x1>;
+		#address-cells = <0x1>;
+		compatible = "xen,domain";
+		cpus = <0x1>;
+		memory = <0x0 0xc0000>;
+		vpl011;
+
+		module@1 {
+			compatible = "multiboot,kernel", "multiboot,module";
+			xen,uefi-binary = "Image-domu1.bin";
+			bootargs = "console=ttyAMA0 root=/dev/ram0 rw";
+		};
+	};
+};
+```
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/hypfs-paths.pandoc 4.16.1-1/docs/misc/hypfs-paths.pandoc
--- 4.14.3+32-g9de3671772-1/docs/misc/hypfs-paths.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/hypfs-paths.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -175,11 +175,27 @@ The major version of Xen.
 
 The minor version of Xen.
 
+#### /cpupool/
+
+A directory of all current cpupools.
+
+#### /cpupool/*/
+
+The individual cpupools. Each entry is a directory with the name being the
+cpupool-id (e.g. /cpupool/0/).
+
+#### /cpupool/*/sched-gran = ("cpu" | "core" | "socket") [w]
+
+The scheduling granularity of a cpupool.
+
+Writing a value is allowed only for cpupools with no cpu assigned and if the
+architecture is supporting different scheduling granularities.
+
 #### /params/
 
 A directory of runtime parameters.
 
-#### /params/*
+#### /params/* [w]
 
 The individual parameters. The description of the different parameters can be
 found in `docs/misc/xen-command-line.pandoc`.
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/printk-formats.txt 4.16.1-1/docs/misc/printk-formats.txt
--- 4.14.3+32-g9de3671772-1/docs/misc/printk-formats.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/printk-formats.txt	2022-04-12 12:21:23.000000000 +0000
@@ -48,3 +48,8 @@ Domain and vCPU information:
                The domain part as above, with the vcpu_id printed in decimal.
                  e.g.  d0v1
                        d[IDLE]v0
+
+PCI:
+
+       %pp     PCI device address in S:B:D.F format from a pci_sbdf_t.
+                 e.g.  0004:02:00.0
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/xen-command-line.pandoc 4.16.1-1/docs/misc/xen-command-line.pandoc
--- 4.14.3+32-g9de3671772-1/docs/misc/xen-command-line.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/xen-command-line.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -75,13 +75,10 @@ of Boolean and String.  These are noted
 ## Parameter details
 
 ### acpi
-> `= force | ht | noirq | <boolean>`
+> `= force | ht | noirq | <boolean> | verbose`
 
 **String**, or **Boolean** to disable.
 
-The **acpi** option is used to control a set of four related boolean
-flags; `acpi_force`, `acpi_ht`, `acpi_noirq` and `acpi_disabled`.
-
 By default, Xen will scan the DMI data and blacklist certain systems
 which are known to have broken ACPI setups.  Providing `acpi=force`
 will cause Xen to ignore the blacklist and attempt to use all ACPI
@@ -97,12 +94,15 @@ which requires this option to function s
 Additionally, this will not prevent Xen from finding IO-APIC entries
 from the MP tables.
 
-Finally, any of the boolean false options can be used to disable ACPI
+Further, any of the boolean false options can be used to disable ACPI
 usage entirely.
 
 Because responsibility for ACPI processing is shared between Xen and
 the domain 0 kernel this option is automatically propagated to the
-domain 0 command line
+domain 0 command line.
+
+Finally, `acpi=verbose` will enable per-processor information logging
+which may otherwise be too noisy in particular on large systems.
 
 ### acpi_apic_instance
 > `= <integer>`
@@ -271,7 +271,7 @@ enough. Setting this to a high value may
 the NMI watchdog is also enabled.
 
 ### cet
-    = List of [ shstk=<bool> ]
+    = List of [ shstk=<bool>, ibt=<bool> ]
 
     Applicability: x86
 
@@ -279,6 +279,10 @@ Controls for the use of Control-flow Enf
 of hardware features designed to combat Return-oriented Programming (ROP, also
 call/jmp COP/JOP) attacks.
 
+CET is incompatible with 32bit PV guests.  If any CET sub-options are active,
+they will override the `pv=32` boolean to `false`.  Backwards compatibility
+can be maintained with the pv-shim mechanism.
+
 *   The `shstk=` boolean controls whether Xen uses Shadow Stacks for its own
     protection.
 
@@ -287,9 +291,13 @@ call/jmp COP/JOP) attacks.
     `cet=no-shstk` will cause Xen not to use Shadow Stacks even when support
     is available in hardware.
 
-    Shadow Stacks are incompatible with 32bit PV guests.  This option will
-    override the `pv=32` boolean to false.  Backwards compatibility can be
-    maintained with the `pv-shim` mechanism.
+*   The `ibt=` boolean controls whether Xen uses Indirect Branch Tracking for
+    its own protection.
+
+    The option is available when `CONFIG_XEN_IBT` is compiled in, and defaults
+    to `true` on hardware supporting CET-IBT.  Specifying `cet=no-ibt` will
+    cause Xen not to use Indirect Branch Tracking even when support is
+    available in hardware.
 
 ### clocksource (x86)
 > `= pit | hpet | acpi | tsc`
@@ -318,8 +326,8 @@ Interrupts.  Specifying zero disables CM
 Flag to indicate whether to probe for a CMOS Real Time Clock irrespective of
 ACPI indicating none to be there.
 
-### com1
-### com2
+### com1 (x86)
+### com2 (x86)
 > `= <baud>[/<base-baud>][,[DPS][,[<io-base>|pci|amt][,[<irq>|msi][,[<port-bdf>][,[<bridge-bdf>]]]]]]`
 
 Both option `com1` and `com2` follow the same format.
@@ -574,6 +582,47 @@ reduction of features at Xen's disposal
 ### cpuinfo (x86)
 > `= <boolean>`
 
+### crash-debug-debugkey
+### crash-debug-hwdom
+### crash-debug-kexeccmd
+### crash-debug-panic
+### crash-debug-watchdog
+> `= <string>`
+
+> Can be modified at runtime
+
+Specify debug-key actions in cases of crashes. Each of the parameters applies
+to a different crash reason. The `<string>` is a sequence of debug key
+characters, with `+` having the special meaning of a 10 millisecond pause.
+
+`crash-debug-debugkey` will be used for crashes induced by the `C` debug
+key (i.e. manually induced crash).
+
+`crash-debug-hwdom` denotes a crash of dom0.
+
+`crash-debug-kexeccmd` is an explicit request of dom0 to continue with the
+kdump kernel via kexec. Only available on hypervisors built with CONFIG_KEXEC.
+
+`crash-debug-panic` is a crash of the hypervisor.
+
+`crash-debug-watchdog` is a crash due to the watchdog timer expiring.
+
+It should be noted that dumping diagnosis data to the console can fail in
+multiple ways (missing data, hanging system, ...) depending on the reason
+of the crash, which might have left the hypervisor in a bad state. In case
+a debug-key action leads to another crash recursion will be avoided, so no
+additional debug-key actions will be performed in this case. A crash in the
+early boot phase will not result in any debug-key action, as the system
+might not yet be in a state where the handlers can work.
+
+So e.g. `crash-debug-watchdog=0+0r` would dump dom0 state twice with 10
+milliseconds between the two state dumps, followed by the run queues of the
+hypervisor, if the system crashes due to a watchdog timeout.
+
+Depending on the reason of the system crash it might happen that triggering
+some debug key action will result in a hang instead of dumping data and then
+doing a reboot or crash dump.
+
 ### crashinfo_maxaddr
 > `= <size>`
 
@@ -699,7 +748,7 @@ Specify the bit width of the DMA heap.
 
 ### dom0
     = List of [ pv | pvh, shadow=<bool>, verbose=<bool>,
-                cpuid-faulting=<bool> ]
+                cpuid-faulting=<bool>, msr-relaxed=<bool> ]
 
     Applicability: x86
 
@@ -748,6 +797,18 @@ Controls for how dom0 is constructed on
     restore the pre-4.13 behaviour.  If specifying `no-cpuid-faulting` fixes
     an issue in dom0, please report a bug.
 
+*   The `msr-relaxed` boolean is an interim option, and defaults to false.
+
+    In Xen 4.15, the default behaviour for unhandled MSRs has been changed,
+    to avoid leaking host data into guests, and to avoid breaking guest
+    logic which uses \#GP probing to identify the availability of MSRs.
+
+    However, this new stricter behaviour has the possibility to break
+    guests, and a more 4.14-like behaviour can be selected by specifying
+    `dom0=msr-relaxed`.
+
+    If using this option is necessary to fix an issue, please report a bug.
+
 ### dom0-iommu
     = List of [ passthrough=<bool>, strict=<bool>, map-inclusive=<bool>,
                 map-reserved=<bool>, none ]
@@ -783,12 +844,12 @@ Controls for the dom0 IOMMU setup.
 
     Typically, some devices in a system use bits of RAM for communication, and
     these areas should be listed as reserved in the E820 table and identified
-    via RMRR or IVMD entries in the APCI tables, so Xen can ensure that they
+    via RMRR or IVMD entries in the ACPI tables, so Xen can ensure that they
     are identity-mapped in the IOMMU.  However, some firmware makes mistakes,
     and this option is a coarse-grain workaround for those errors.
 
     Where possible, finer grain corrections should be made with the `rmrr=`,
-    `ivrs_hpet=` or `ivrs_ioapic=` command line options.
+    `ivmd=`, `ivrs_hpet[]=`, or `ivrs_ioapic[]=` command line options.
 
     This option is disabled by default, and deprecated and intended for
     removal in future versions of Xen.  If specifying `map-inclusive` is the
@@ -1028,6 +1089,17 @@ hardware domain is architecture dependen
 Note that specifying zero as domU value means zero, while for dom0 it means
 to use the default.
 
+### ext_regions (Arm)
+> `= <boolean>`
+
+> Default : `true`
+
+Flag to enable or disable support for extended regions for Dom0.
+
+Extended regions are ranges of unused address space exposed to Dom0 as
+"safe to use" for special memory mappings. Disable if your board device
+tree is incomplete.
+
 ### flask
 > `= permissive | enforcing | late | disabled`
 
@@ -1311,7 +1383,7 @@ detection of systems known to misbehave
 > Default: `new` unless directed-EOI is supported
 
 ### iommu
-    = List of [ <bool>, verbose, debug, force, required, quarantine,
+    = List of [ <bool>, verbose, debug, force, required, quarantine[=scratch-page],
                 sharept, intremap, intpost, crash-disable,
                 snoop, qinval, igfx, amd-iommu-perdev-intremap,
                 dom0-{passthrough,strict} ]
@@ -1349,11 +1421,32 @@ boolean (e.g. `iommu=no`) can override t
     will prevent Xen from booting if IOMMUs aren't discovered and enabled
     successfully.
 
-*   The `quarantine` boolean can be used to control Xen's behavior when
-    de-assigning devices from guests.  If enabled (the default), Xen always
+*   The `quarantine` option can be used to control Xen's behavior when
+    de-assigning devices from guests.
+
+    When a PCI device is assigned to an untrusted domain, it is possible
+    for that domain to program the device to DMA to an arbitrary address.
+    The IOMMU is used to protect the host from malicious DMA by making
+    sure that the device addresses can only target memory assigned to the
+    guest.  However, when the guest domain is torn down, assigning the
+    device back to the hardware domain would allow any in-flight DMA to
+    potentially target critical host data.  To avoid this, quarantining
+    should be enabled.  Quarantining can be done in two ways: In its basic
+    form, all in-flight DMA will simply be forced to encounter IOMMU
+    faults.  Since there are systems where doing so can cause host lockup,
+    an alternative form is available where writes to memory will be made
+    fault, but reads will be directed to a scratch page.  The implication
+    here is that such reads will go unnoticed, i.e. an admin may not
+    become aware of the underlying problem.
+
+    Therefore, if this option is set to true (the default), Xen always
     quarantines such devices; they must be explicitly assigned back to Dom0
-    before they can be used there again.  If disabled, Xen will only
-    quarantine devices the toolstack hass arranged for getting quarantined.
+    before they can be used there again.  If set to "scratch-page", still
+    active DMA reads will additionally be directed to a "scratch" page.  If
+    set to false, Xen will only quarantine devices the toolstack has arranged
+    for getting quarantined, and only in the "basic" form.
+
+    This option is only valid on builds supporting PCI.
 
 *   The `sharept` boolean controls whether the IOMMU pagetables are shared
     with the CPU-side HAP pagetables, or allocated separately.  Sharing
@@ -1409,8 +1502,8 @@ The following options are specific to In
     version 6 and greater as Registered-Based Invalidation isn't supported
     by them.
 
-*   The `igfx` boolean is active by default, and controls whether the IOMMU in
-    front of an Intel Graphics Device is enabled or not.
+*   The `igfx` boolean is active by default, and controls whether IOMMUs in
+    front of solely graphics devices get enabled or not.
 
     It is intended as a debugging mechanism for graphics issues, and to be
     similar to Linux's `intel_iommu=igfx_off` option.  If specifying `no-igfx`
@@ -1449,6 +1542,31 @@ _dom0-iommu=map-inclusive_ - using both
 > `= <integer>`
 
 ### irq_vector_map (x86)
+
+### ivmd (x86)
+> `= <start>[-<end>][=<bdf1>[-<bdf1'>][,<bdf2>[-<bdf2'>][,...]]][;<start>...]`
+
+Define IVMD-like ranges that are missing from ACPI tables along with the
+device(s) they belong to, and use them for 1:1 mapping.  End addresses can be
+omitted when exactly one page is meant.  The ranges are inclusive when start
+and end are specified.  Note that only PCI segment 0 is supported at this time,
+but it is fine to specify it explicitly.
+
+'start' and 'end' values are page numbers (not full physical addresses),
+in hexadecimal format (can optionally be preceded by "0x").
+
+Omitting the optional (range of) BDF spcifiers signals that the range is to
+be applied to all devices.
+
+Usage example: If device 0:0:1d.0 requires one page (0xd5d45) to be
+reserved, and devices 0:0:1a.0...0:0:1a.3 collectively require three pages
+(0xd5d46 thru 0xd5d48) to be reserved, one usage would be:
+
+ivmd=d5d45=0:1d.0;0xd5d46-0xd5d48=0:1a.0-0:1a.3
+
+Note: grub2 requires to escape or quote special characters, like ';' when
+multiple ranges are specified - refer to the grub2 documentation.
+
 ### ivrs_hpet[`<hpet>`] (AMD)
 > `=[<seg>:]<bus>:<device>.<func>`
 
@@ -1676,6 +1794,16 @@ This option is ignored in **pv-shim** mo
 ### nr_irqs (x86)
 > `= <integer>`
 
+### irq-max-guests (x86)
+> `= <integer>`
+
+> Default: `32`
+
+Maximum number of guests any individual IRQ could be shared between,
+i.e. a limit on the number of guests it is possible to start each having
+assigned a device sharing a common interrupt line.  Accepts values between
+1 and 255.
+
 ### numa (x86)
 > `= on | off | fake=<integer> | noacpi`
 
@@ -1699,6 +1827,13 @@ All numbers specified must be hexadecima
 
 This option can be specified more than once (up to 8 times at present).
 
+### pci-passthrough (arm)
+> `= <boolean>`
+
+> Default: `false`
+
+Flag to enable or disable support for PCI passthrough
+
 ### pcid (x86)
 > `= <boolean> | xpti=<bool>`
 
@@ -1911,9 +2046,11 @@ with read and write permissions.
 ### sched
 > `= credit | credit2 | arinc653 | rtds | null`
 
-> Default: `sched=credit`
+> Default: `sched=credit2`
 
-Choose the default scheduler.
+Choose the default scheduler. Note the default scheduler is selectable via
+Kconfig and depends on enabled schedulers. Check
+`CONFIG_SCHED_DEFAULT` to see which scheduler is the default.
 
 ### sched_credit2_max_cpus_runqueue
 > `= <integer>`
@@ -2140,9 +2277,9 @@ to use.
 
 If Xen was compiled with INDIRECT_THUNK support, `bti-thunk=` can be used to
 select which of the thunks gets patched into the `__x86_indirect_thunk_%reg`
-locations.  The default thunk is `retpoline` (generally preferred for Intel
-hardware), with the alternatives being `jmp` (a `jmp *%reg` gadget, minimal
-overhead), and `lfence` (an `lfence; jmp *%reg` gadget, preferred for AMD).
+locations.  The default thunk is `retpoline` (generally preferred), with the
+alternatives being `jmp` (a `jmp *%reg` gadget, minimal overhead), and
+`lfence` (an `lfence; jmp *%reg` gadget).
 
 On hardware supporting IBRS (Indirect Branch Restricted Speculation), the
 `ibrs=` option can be used to force or prevent Xen using the feature itself.
@@ -2242,7 +2379,9 @@ Several microcode updates are relevant:
    Introduced MSR_TSX_CTRL on all TSX-enabled MDS_NO parts to date,
    CLX/WHL-R/CFL-R, with the controls becoming architectural moving forward
    and formally retiring HLE from the architecture.  The user can disable TSX
-   to mitigate TAA, and elect to hide the HLE/RTM CPUID bits.
+   to mitigate TAA, and elect to hide the HLE/RTM CPUID bits.  Also causes
+   VERW to once-again flush the microarchiectural buffers in case a TAA
+   mitigation is wanted along with TSX being enabled.
 
  * June 2021, removing the workaround for March 2019 on client CPUs and
    formally de-featured TSX on SKL/KBL/WHL/CFL (Note: SKX still retains the
@@ -2250,19 +2389,32 @@ Several microcode updates are relevant:
    PCR3 works fine, and TSX is disabled by default, but the user can re-enable
    TSX at their own risk, accepting that the memory order erratum is unfixed.
 
+ * February 2022, removing the VERW flushing workaround from November 2019 on
+   client CPUs and formally de-featuring TSX on WHL-R/CFL-R (Note: CLX still
+   retains the VERW flushing workaround).  TSX defaults to disabled, and is
+   locked off when SGX is enabled in the BIOS.  When SGX is not enabled, TSX
+   can be re-enabled at the users own risk, as it reintroduces the TSX Async
+   Abort speculative vulnerability.
+
 On systems with the ability to configure TSX, this boolean offers system wide
 control of whether TSX is enabled or disabled.
 
+When TSX is disabled, transactions unconditionally abort.  This is compatible
+with the TSX spec, which requires software to have a non-transactional path as
+a fallback.  The RTM and HLE CPUID bits are hidden from VMs by default, but
+can be re-enabled if required.  This allows VMs which previously saw RTM/HLE
+to be migrated in, although any TSX-enabled software will run with reduced
+performance.
+
+ * When TSX is locked off by firmware, `tsx=` is ignored and treated as
+   `false`.
+
  * An explicit `tsx=` choice is honoured, even if it is `true` and would
    result in a vulnerable system.
 
  * When no explicit `tsx=` choice is given, parts vulnerable to TAA will be
    mitigated by disabling TSX, as this is the lowest overhead option.
 
-   If the use of TSX is important, the more expensive TAA mitigations can be
-   opted in to with `smt=0 spec-ctrl=md-clear`, at which point TSX will remain
-   active by default.
-
  * When no explicit `tsx=` option is given, parts susceptible to the memory
    ordering errata default to `true` to enable working TSX.  Alternatively,
    selecting `tsx=0` will disable TSX and restore PCR3 to a working state.
@@ -2275,7 +2427,7 @@ control of whether TSX is enabled or dis
    Alternatively, selecting `tsx=1` will re-enable TSX at the users own risk.
 
 ### ucode
-> `= List of [ <integer> | scan=<bool>, nmi=<bool> ]`
+> `= List of [ <integer> | scan=<bool>, nmi=<bool>, allow-same=<bool> ]`
 
     Applicability: x86
     Default: `nmi`
@@ -2307,6 +2459,11 @@ precedence over `scan`.
 stop_machine context. In NMI handler, even NMIs are blocked, which is
 considered safer. The default value is `true`.
 
+'allow-same' alters the default acceptance policy for new microcode to permit
+trying to reload the same version.  Many CPUs will actually reload microcode
+of the same version, and this allows for easy testing of the late microcode
+loading path.
+
 ### unrestricted_guest (Intel)
 > `= <boolean>`
 
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/xenstore-paths.pandoc 4.16.1-1/docs/misc/xenstore-paths.pandoc
--- 4.14.3+32-g9de3671772-1/docs/misc/xenstore-paths.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/xenstore-paths.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -298,6 +298,9 @@ A virtual keyboard device frontend. Desc
 A virtual network device frontend. Described by
 [xen/include/public/io/netif.h][NETIF]
 
+NOTE: ~/device/vif/$DEVID/mtu can be used to inform the frontend of an
+      increased MTU. (The default MTU is 1500 octets).
+
 #### ~/device/vscsi/$DEVID/* []
 
 A virtual scsi device frontend. Described by
diff -pruN 4.14.3+32-g9de3671772-1/docs/misc/xenstore.txt 4.16.1-1/docs/misc/xenstore.txt
--- 4.14.3+32-g9de3671772-1/docs/misc/xenstore.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/misc/xenstore.txt	2022-04-12 12:21:23.000000000 +0000
@@ -294,6 +294,22 @@ IS_DOMAIN_INTRODUCED	<domid>|		T| or F|
 	ie, if INTRODUCE for the domain has not yet been followed by
 	domain destruction or explicit RELEASE.
 
+RESUME			<domid>|
+
+	Arranges that @releaseDomain events will once more be
+	generated when the domain becomes shut down.  This might have
+	to be used if a domain were to be shut down (generating one
+	@releaseDomain) and then subsequently restarted, since the
+	state-sensitive algorithm in xenstored will not otherwise send
+	further watch event notifications if the domain were to be
+	shut down again.
+
+	This command will be issued in place such as resume because
+	Xen will "shutdown" the domain on suspend.
+
+	xenstored prevents the use of RESUME other than by dom0.
+
+
 SET_TARGET		<domid>|<tdomid>|
 	Notifies xenstored that domain <domid> is targeting domain
 	<tdomid>. This grants domain <domid> full access to paths
@@ -317,6 +333,27 @@ CONTROL			<command>|[<parameters>|]
 	Current commands are:
 	check
 		checks xenstored innards
+	live-update|<params>|+
+		perform a live-update of the Xenstore daemon, only to
+		be used via xenstore-control command.
+		<params> are implementation specific and are used for
+		different steps of the live-update processing. Currently
+		supported <params> are:
+		-f <file>  specify new daemon binary
+		-b <size>  specify size of new stubdom binary
+		-d <chunk-size> <binary-chunk>  transfer chunk of new
+			stubdom binary
+		-c <pars>  specify new command line to use
+		-s [-t <sec>] [-F]  start live update process (-t specifies
+			timeout in seconds to wait for active transactions
+			to finish, default is 60 seconds; -F will force
+			live update to happen even with running transactions
+			after timeout elapsed)
+		-a  abort live update handling
+		All sub-options will return "OK" in case of success or an
+		error string in case of failure. -s can return "BUSY" in case
+		of an active transaction, a retry of -s can be done in that
+		case.
 	log|on
 		turn xenstore logging on
 	log|off
diff -pruN 4.14.3+32-g9de3671772-1/docs/process/branching-checklist.txt 4.16.1-1/docs/process/branching-checklist.txt
--- 4.14.3+32-g9de3671772-1/docs/process/branching-checklist.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/process/branching-checklist.txt	2022-04-12 12:21:23.000000000 +0000
@@ -86,8 +86,8 @@ including turning off debug.
 
 Set off a manual osstest run, since the osstest cr-for-branches change
 will take a while to take effect:
-  ssh osstest.test-lab
-  cd branches/for-xen-$v-testing.git
+  ssh osstest@osstest.test-lab
+  cd testing.git
   screen -S $v
   BRANCHES=xen-$v-testing ./cr-for-branches branches -w "./cr-daily-branch --real"
 
diff -pruN 4.14.3+32-g9de3671772-1/docs/process/release-technician-checklist.txt 4.16.1-1/docs/process/release-technician-checklist.txt
--- 4.14.3+32-g9de3671772-1/docs/process/release-technician-checklist.txt	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/process/release-technician-checklist.txt	2022-04-12 12:21:23.000000000 +0000
@@ -53,9 +53,12 @@ t=RELEASE-$r
 #   QEMU_UPSTREAM_REVISION,
 #   QEMU_TRADITIONAL_REVISION
 #   MINIOS_UPSTREAM_REVISION
+#     (drop any references to the specific commits, e.g. date or title)
 * change SUPPORT.md heading version number; -unstable or -rc tag
 *     (empty in stable branches after .0 release).
 * SUPPORT.md: insert correct version number in release-notes link
+* CHANGELOG.md: set section heading to delete UNRELEASED and add date;
+#               in unstable branches set to X.Y.0 and RELEASE-X.YY.0
 * change xen-unstable xen/Makefile XEN_EXTRAVERSION
 # if main version number has changed (eg 4.7 -> 4.8) rerun ./autogen.sh
 * rerun ./autogen.sh to update version number in configure
diff -pruN 4.14.3+32-g9de3671772-1/docs/process/xen-release-management.pandoc 4.16.1-1/docs/process/xen-release-management.pandoc
--- 4.14.3+32-g9de3671772-1/docs/process/xen-release-management.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/process/xen-release-management.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -15,8 +15,10 @@ that they can have an idea what to expec
 
 # Xen release cycle
 
-The Xen hypervisor project now releases every 8 months. The actual release date
-depends on a lot of factors.
+The Xen hypervisor project now releases every 8 months.  We aim to
+release in the first half of March/July/November.  These dates have
+been chosen to avoid major holidays and cultural events; if one
+release slips, ideally the subsequent release cycle would be shortened.
 
 We can roughly divide one release into two periods. The development period
 and the freeze period. The former is 6 months long and the latter is about 2
@@ -33,6 +35,12 @@ During freeze period, the tree is closed
 accepted. This period can be shorter or longer than 2 months. If it ends up
 longer than 2 months, it eats into the next development period.
 
+The precise release schedule depends on a lot of factors and needs to
+be set afresh by the Release Manager in each release cycle.  When the
+release is in March, particular consideration should be given to the
+Chinese New Year holiday which will then typically occur during the
+freeze, so the freeze should probably be extended to compensate.
+
 # The different roles in a Xen release
 
 ## Release Manager
diff -pruN 4.14.3+32-g9de3671772-1/docs/specs/libxc-migration-stream.pandoc 4.16.1-1/docs/specs/libxc-migration-stream.pandoc
--- 4.14.3+32-g9de3671772-1/docs/specs/libxc-migration-stream.pandoc	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/specs/libxc-migration-stream.pandoc	2022-04-12 12:21:23.000000000 +0000
@@ -3,7 +3,7 @@
   Andrew Cooper <<andrew.cooper3@citrix.com>>
   Wen Congyang <<wency@cn.fujitsu.com>>
   Yang Hongyang <<hongyang.yang@easystack.cn>>
-% Revision 2
+% Revision 3
 
 Introduction
 ============
@@ -227,7 +227,13 @@ type         0x00000000: END
 
              0x0000000F: CHECKPOINT_DIRTY_PFN_LIST (Secondary -> Primary)
 
-             0x00000010 - 0x7FFFFFFF: Reserved for future _mandatory_
+             0x00000010: STATIC_DATA_END
+
+             0x00000011: X86_CPUID_POLICY
+
+             0x00000012: X86_MSR_POLICY
+
+             0x00000013 - 0x7FFFFFFF: Reserved for future _mandatory_
              records.
 
              0x80000000 - 0xFFFFFFFF: Reserved for future _optional_
@@ -732,6 +738,7 @@ A typical save record for an x86 HVM gue
 * X86_TSC_INFO
 * HVM_PARAMS
 * HVM_CONTEXT
+* END record
 
 HVM_PARAMS must precede HVM_CONTEXT, as certain parameters can affect
 the validity of architectural state in the context.
diff -pruN 4.14.3+32-g9de3671772-1/docs/xen-headers 4.16.1-1/docs/xen-headers
--- 4.14.3+32-g9de3671772-1/docs/xen-headers	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/docs/xen-headers	2022-04-12 12:21:23.000000000 +0000
@@ -331,7 +331,7 @@ sub output_index () {
 <h2>Starting points</h2>
 <ul>
 END
-    foreach my $ic (sort { $a->{Seq} <=> $b->{Seq} } @incontents) {
+    foreach my $ic (sort { $a->{Seq} <=> $b->{Seq} or $a->{Title} cmp $b->{Title} } @incontents) {
         $o .= "<li><a href=\"$ic->{Href}\">$ic->{Title}</a></li>\n";
     }
     $o .= "</ul>\n";
diff -pruN 4.14.3+32-g9de3671772-1/.gitignore 4.16.1-1/.gitignore
--- 4.14.3+32-g9de3671772-1/.gitignore	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/.gitignore	2022-04-12 12:21:23.000000000 +0000
@@ -48,7 +48,10 @@ dist/*
 docs/tmp.*
 docs/html/
 docs/man/xl.cfg.5.pod
+docs/man/xl-disk-configuration.5.pod
+docs/man/xl-network-configuration.5.pod
 docs/man/xl.1.pod
+docs/man/xl.conf.5.pod
 docs/man1/
 docs/man5/
 docs/man7/
@@ -71,7 +74,6 @@ stubdom/include
 stubdom/ioemu
 stubdom/ioemu/
 stubdom/libs-*
-stubdom/libxc-*
 stubdom/libxencall-*
 stubdom/libxenevtchn-*
 stubdom/libxenforeignmemory-*
@@ -92,6 +94,7 @@ stubdom/stubdompath.sh
 stubdom/tpm_emulator-*
 stubdom/vtpm/vtpm_manager.h
 stubdom/xenstore
+stubdom/xenstorepvh
 stubdom/zlib-*
 tools/*/build/lib*/*.py
 tools/autom4te.cache/
@@ -114,10 +117,52 @@ tools/libs/hypfs/headers.chk
 tools/libs/hypfs/xenhypfs.pc
 tools/libs/call/headers.chk
 tools/libs/call/xencall.pc
+tools/libs/ctrl/_*.[ch]
+tools/libs/ctrl/libxenctrl.map
+tools/libs/ctrl/xencontrol.pc
 tools/libs/foreignmemory/headers.chk
 tools/libs/foreignmemory/xenforeignmemory.pc
 tools/libs/devicemodel/headers.chk
 tools/libs/devicemodel/xendevicemodel.pc
+tools/libs/guest/_*.[ch]
+tools/libs/guest/libxenguest.map
+tools/libs/guest/xenguest.pc
+tools/libs/guest/xc_bitops.h
+tools/libs/guest/xc_core.h
+tools/libs/guest/xc_core_arm.h
+tools/libs/guest/xc_core_x86.h
+tools/libs/guest/xc_private.h
+tools/libs/light/_*.[ch]
+tools/libs/light/*.pyc
+tools/libs/light/_libxl.api-for-check
+tools/libs/light/*.api-ok
+tools/libs/light/libxenlight.map
+tools/libs/light/libxl-save-helper
+tools/libs/light/dsdt*
+tools/libs/light/mk_dsdt
+tools/libs/light/ssdt*
+tools/libs/light/testidl
+tools/libs/light/testidl.c
+tools/libs/light/test_timedereg
+tools/libs/light/test_fdderegrace
+tools/libs/light/tmp.*
+tools/libs/light/xenlight.pc
+tools/libs/stat/_paths.h
+tools/libs/stat/headers.chk
+tools/libs/stat/libxenstat.map
+tools/libs/stat/xenstat.pc
+tools/libs/store/headers.chk
+tools/libs/store/list.h
+tools/libs/store/utils.h
+tools/libs/store/xenstore.pc
+tools/libs/store/xs_lib.c
+tools/libs/util/*.pc
+tools/libs/util/_paths.h
+tools/libs/util/libxlu_cfg_y.output
+tools/libs/util/libxenutil.map
+tools/libs/vchan/headers.chk
+tools/libs/vchan/libxenvchan.map
+tools/libs/vchan/xenvchan.pc
 tools/console/xenconsole
 tools/console/xenconsoled
 tools/console/client/_paths.h
@@ -188,22 +233,12 @@ tools/hotplug/Linux/xendomains
 tools/hotplug/NetBSD/rc.d/xencommons
 tools/hotplug/NetBSD/rc.d/xendriverdomain
 tools/include/acpi
+tools/include/_libxl*.h
+tools/include/_xentoolcore_list.h
 tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libvchan/xenvchan.pc
-tools/libxc/*.pc
-tools/libxl/_libxl.api-for-check
-tools/libxl/*.api-ok
-tools/libxl/*.pc
-tools/libxl/dsdt*
-tools/libxl/libxlu_cfg_y.output
-tools/libxl/mk_dsdt
-tools/libxl/ssdt*
-tools/libxl/testenum
-tools/libxl/testenum.c
-tools/libxl/tmp.*
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
@@ -240,40 +275,28 @@ tools/tests/x86_emulator/*sse*.[ch]
 tools/tests/x86_emulator/test_x86_emulator
 tools/tests/x86_emulator/x86_emulate
 tools/tests/x86_emulator/xop*.[ch]
-tools/tests/xen-access/xen-access
-tools/tests/xenstore/xs-test
-tools/tests/regression/installed/*
-tools/tests/regression/build/*
-tools/tests/regression/downloads/*
-tools/tests/mem-sharing/memshrtool
-tools/tests/mce-test/tools/xen-mceinj
 tools/tests/vpci/list.h
 tools/tests/vpci/vpci.[hc]
 tools/tests/vpci/test_vpci
 tools/xcutils/lsevtchn
 tools/xcutils/readnotes
-tools/xenbackendd/_paths.h
-tools/xenbackendd/xenbackendd
 tools/xenmon/xentrace_setmask
 tools/xenmon/xenbaked
 tools/xenpaging/xenpaging
 tools/xenpmd/xenpmd
-tools/xenstat/libxenstat/src/_paths.h
-tools/xenstat/libxenstat/xenstat.pc
-tools/xenstat/xentop/xentop
 tools/xenstore/xenstore
 tools/xenstore/xenstore-chmod
+tools/xenstore/xenstore-control
 tools/xenstore/xenstore-exists
 tools/xenstore/xenstore-list
+tools/xenstore/xenstore-ls
 tools/xenstore/xenstore-read
 tools/xenstore/xenstore-rm
+tools/xenstore/xenstore-watch
 tools/xenstore/xenstore-write
-tools/xenstore/xenstore-control
-tools/xenstore/xenstore-ls
 tools/xenstore/xenstored
-tools/xenstore/xenstored_test
-tools/xenstore/xenstore.pc
 tools/xenstore/xs_tdb_dump
+tools/xentop/xentop
 tools/xentrace/xentrace_setsize
 tools/xentrace/tbctl
 tools/xentrace/xenctx
@@ -293,11 +316,13 @@ xen/arch/x86/efi.lds
 xen/arch/x86/efi/check.efi
 xen/arch/x86/efi/mkreloc
 xen/arch/*/xen.lds
-xen/arch/*/asm-offsets.s
 xen/arch/*/efi/boot.c
 xen/arch/*/efi/compat.c
+xen/arch/*/efi/ebmalloc.c
 xen/arch/*/efi/efi.h
+xen/arch/*/efi/pe.c
 xen/arch/*/efi/runtime.c
+xen/asm-offsets.s
 xen/common/config_data.S
 xen/common/config.gz
 xen/include/headers*.chk
@@ -360,22 +385,14 @@ tools/include/xen-foreign/arm64.h
 tools/misc/xen-hptool
 tools/misc/xen-mfndump
 tools/libs/toolcore/include/_*.h
-tools/libxc/_*.[ch]
-tools/libxl/_*.[ch]
-tools/libxl/testidl
-tools/libxl/testidl.c
-tools/libxl/*.pyc
-tools/libxl/libxl-save-helper
-tools/libxl/test_timedereg
-tools/libxl/test_fdderegrace
 tools/firmware/etherboot/eb-roms.h
 tools/firmware/etherboot/gpxe-git-snapshot.tar.gz
 tools/misc/xenhypfs
 tools/misc/xenwatchdogd
 tools/misc/xen-hvmcrash
 tools/misc/xen-lowmemd
-tools/libvchan/vchan-node[12]
-tools/libvchan/vchan-socket-proxy
+tools/vchan/vchan-node[12]
+tools/vchan/vchan-socket-proxy
 tools/ocaml/*/.ocamldep.make
 tools/ocaml/*/*.cm[ixao]
 tools/ocaml/*/*.cmxa
@@ -409,7 +426,6 @@ tools/firmware/etherboot/ipxe.tar.gz
 tools/firmware/etherboot/ipxe/
 tools/python/xen/lowlevel/xl/_pyxl_types.c
 tools/python/xen/lowlevel/xl/_pyxl_types.h
-tools/xenstore/xenstore-watch
 tools/xl/_paths.h
 tools/xl/xl
 
diff -pruN 4.14.3+32-g9de3671772-1/m4/header.m4 4.16.1-1/m4/header.m4
--- 4.14.3+32-g9de3671772-1/m4/header.m4	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/m4/header.m4	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,13 @@
+AC_DEFUN([AX_FIND_HEADER], [
+ax_found=0
+m4_foreach_w([header], $2, [
+    AS_IF([test "$ax_found" = "0"], [
+        AC_CHECK_HEADER(header, [
+            AC_DEFINE($1, [<header>], [Header path for $1])
+            ax_found=1])
+    ])
+])
+AS_IF([test "$ax_found" = "0"], [
+    AC_MSG_ERROR([No header found from list $2])
+])
+])
diff -pruN 4.14.3+32-g9de3671772-1/m4/paths.m4 4.16.1-1/m4/paths.m4
--- 4.14.3+32-g9de3671772-1/m4/paths.m4	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/m4/paths.m4	2022-04-12 12:21:23.000000000 +0000
@@ -34,6 +34,12 @@ if test "x$sysconfdir" = 'x${prefix}/etc
     esac
 fi
 
+CONFIG_DIR=$sysconfdir
+AC_SUBST(CONFIG_DIR)
+
+XEN_CONFIG_DIR=$CONFIG_DIR/xen
+AC_SUBST(XEN_CONFIG_DIR)
+
 AC_ARG_WITH([initddir],
     AS_HELP_STRING([--with-initddir=DIR],
     [Path to directory with sysv runlevel scripts. [SYSCONFDIR/init.d]]),
@@ -70,6 +76,14 @@ AC_ARG_WITH([libexec-leaf-dir],
     [libexec_subdir=$withval],
     [libexec_subdir=$PACKAGE_TARNAME])
 
+AC_ARG_WITH([xen-scriptdir],
+    AS_HELP_STRING([--with-xen-scriptdir=DIR],
+    [Path to directory for dom0 hotplug scripts. [SYSCONFDIR/xen/scripts]]),
+    [xen_scriptdir_path=$withval],
+    [xen_scriptdir_path=$XEN_CONFIG_DIR/scripts])
+XEN_SCRIPT_DIR=$xen_scriptdir_path
+AC_SUBST(XEN_SCRIPT_DIR)
+
 AC_ARG_WITH([xen-dumpdir],
     AS_HELP_STRING([--with-xen-dumpdir=DIR],
     [Path to directory for domU crash dumps. [LOCALSTATEDIR/lib/xen/dump]]),
@@ -128,21 +142,12 @@ AC_SUBST(XEN_LIB_DIR)
 SHAREDIR=$prefix/share
 AC_SUBST(SHAREDIR)
 
-CONFIG_DIR=$sysconfdir
-AC_SUBST(CONFIG_DIR)
-
 INITD_DIR=$initddir_path
 AC_SUBST(INITD_DIR)
 
-XEN_CONFIG_DIR=$CONFIG_DIR/xen
-AC_SUBST(XEN_CONFIG_DIR)
-
-XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
-AC_SUBST(XEN_SCRIPT_DIR)
-
 case "$host_os" in
 *freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
-*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 *) XEN_LOCK_DIR=$localstatedir/lock ;;
 esac
 AC_SUBST(XEN_LOCK_DIR)
diff -pruN 4.14.3+32-g9de3671772-1/MAINTAINERS 4.16.1-1/MAINTAINERS
--- 4.14.3+32-g9de3671772-1/MAINTAINERS	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/MAINTAINERS	2022-04-12 12:21:23.000000000 +0000
@@ -60,7 +60,7 @@ The maintainer for this branch is:
 
 Tools backport requests should also be copied to:
 
-	Ian Jackson <Ian.Jackson@eu.citrix.com>
+	Anthony Perard <anthony.perard@citrix.com>
 
 
 	Unstable Subsystem Maintainers
@@ -152,12 +152,13 @@ M:	Stewart Hildebrand <stewart.hildebran
 S:	Supported
 L:	xen-devel@dornerworks.com
 F:	xen/common/sched/arinc653.c
-F:	tools/libxc/xc_arinc653.c
+F:	tools/libs/ctrl/xc_arinc653.c
 
 ARM (W/ VIRTUALISATION EXTENSIONS) ARCHITECTURE
 M:	Stefano Stabellini <sstabellini@kernel.org>
 M:	Julien Grall <julien@xen.org>
 R:	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
+R:	Bertrand Marquis <bertrand.marquis@arm.com>
 S:	Supported
 L:	xen-devel@lists.xenproject.org
 F:	docs/misc/arm/
@@ -175,8 +176,14 @@ F:	xen/include/asm-arm/
 F:	xen/include/public/arch-arm/
 F:	xen/include/public/arch-arm.h
 
+ARM SMMUv3
+M:	Bertrand Marquis <bertrand.marquis@arm.com>
+M:	Rahul Singh <rahul.singh@arm.com>
+S:	Supported
+F:	xen/drivers/passthrough/arm/smmu-v3.c
+
 Change Log
-M:	Paul Durrant <paul@xen.org>
+M:	Ian Jackson <iwj@xenproject.org>
 R:	Community Manager <community.manager@xenproject.org>
 S:	Maintained
 F:	CHANGELOG.md
@@ -224,9 +231,19 @@ F:	tools/debugger/gdbsx/
 
 GOLANG BINDINGS
 M:	George Dunlap <george.dunlap@citrix.com>
+M:     Nick Rosbrook <rosbrookn@ainfosec.com>
 S:	Maintained
 F:	tools/golang
 
+HYPFS
+M:	Juergen Gross <jgross@suse.com>
+S:	Supported
+F:	tools/include/xenhypfs.h
+F:	tools/libs/hypfs/
+F:	tools/misc/xenhypfs.c
+F:	xen/common/hypfs.c
+F:	xen/include/xen/hypfs.h
+
 INTEL(R) TRUSTED EXECUTION TECHNOLOGY (TXT)
 R:	Lukasz Hawrylko <lukasz.hawrylko@linux.intel.com>
 S:	Odd Fixes
@@ -258,6 +275,13 @@ X:	xen/drivers/passthrough/vtd/
 X:	xen/drivers/passthrough/device_tree.c
 F:	xen/include/xen/iommu.h
 
+I/O EMULATION (IOREQ)
+M:	Paul Durrant <paul@xen.org>
+S:	Supported
+F:	xen/common/ioreq.c
+F:	xen/include/xen/ioreq.h
+F:	xen/include/public/hvm/ioreq.h
+
 KCONFIG
 M:	Doug Goldstein <cardoe@cardoe.com>
 S:	Supported
@@ -273,16 +297,39 @@ KEXEC
 M:	Andrew Cooper <andrew.cooper3@citrix.com>
 S:	Supported
 F:	xen/common/{kexec,kimage}.c
-F:	xen/include/{kexec,kimage}.h
+F:	xen/include/xen/{kexec,kimage}.h
 F:	xen/arch/x86/machine_kexec.c
 F:	xen/arch/x86/x86_64/kexec_reloc.S
 
+LIBS
+M:	Ian Jackson <iwj@xenproject.org>
+M:	Wei Liu <wl@xen.org>
+R:	Juergen Gross <jgross@suse.com>
+S:	Supported
+F:	tools/include/libxenvchan.h
+F:	tools/include/xencall.h
+F:	tools/include/xenctrl*.h
+F:	tools/include/xendevicemodel.h
+F:	tools/include/xenevtchn.h
+F:	tools/include/xenforeignmemory.h
+F:	tools/include/xengnttab.h
+F:	tools/include/xenguest.h
+F:	tools/include/xenhypfs.h
+F:	tools/include/xenstat.h
+F:	tools/include/xenstore*.h
+F:	tools/include/xenstore-compat/*.h
+F:	tools/include/xentoolcore*.h
+F:	tools/include/xentoollog.h
+F:	tools/libs/
+
 LIBXENLIGHT
-M:	Ian Jackson <ian.jackson@eu.citrix.com>
+M:	Ian Jackson <iwj@xenproject.org>
 M:	Wei Liu <wl@xen.org>
 M:	Anthony PERARD <anthony.perard@citrix.com>
 S:	Supported
-F:	tools/libxl/
+F:	tools/include/libxl*.h
+F:	tools/libs/light/
+F:	tools/libs/util/
 F:	tools/xl/
 
 LIVEPATCH
@@ -338,7 +385,7 @@ S:	Supported
 F:	tools/python
 
 QEMU-DM
-M:	Ian Jackson <ian.jackson@eu.citrix.com>
+M:	Ian Jackson <iwj@xenproject.org>
 S:	Supported
 T:	git https://xenbits.xenproject.org/git-http/qemu-xen-traditional.git
 
@@ -350,15 +397,23 @@ T:	git https://xenbits.xenproject.org/gi
 
 REMUS
 M:	Shriram Rajagopalan <rshriram@cs.ubc.ca>
-M:	Yang Hongyang <imhy.yang@gmail.com>
 S:	Maintained
 F:	docs/README.remus
-F:	tools/libxl/libxl_remus_*
-F:	tools/libxl/libxl_netbuffer.c
-F:	tools/libxl/libxl_nonetbuffer.c
+F:	tools/libs/light/libxl_remus_*
+F:	tools/libs/light/libxl_netbuffer.c
+F:	tools/libs/light/libxl_nonetbuffer.c
 F:	tools/hotplug/Linux/remus-netbuf-setup
 F:	tools/hotplug/Linux/block-drbd-probe
 
+RISCV
+M:	Bob Eshleman <bobbyeshleman@gmail.com>
+M:	Alistair Francis <alistair.francis@wdc.com>
+R:	Connor Davis <connojdavis@gmail.com>
+S:	Supported
+F:	config/riscv64.mk
+F:	xen/arch/riscv/
+F:	xen/include/asm-riscv/
+
 RTDS SCHEDULER
 M:	Dario Faggioli <dfaggioli@suse.com>
 M:	Meng Xu <mengxu@cis.upenn.edu>
@@ -390,7 +445,7 @@ F:	xen/arch/arm/tee/
 F:	xen/include/asm-arm/tee
 
 TOOLSTACK
-M:	Ian Jackson <ian.jackson@eu.citrix.com>
+M:	Ian Jackson <iwj@xenproject.org>
 M:	Wei Liu <wl@xen.org>
 S:	Supported
 F:	autogen.sh
@@ -411,7 +466,7 @@ M:	Tamas K Lengyel <tamas@tklengyel.com>
 R:	Alexandru Isaila <aisaila@bitdefender.com>
 R:	Petre Pircalabu <ppircalabu@bitdefender.com>
 S:	Supported
-F:	tools/tests/xen-access
+F:	tools/misc/xen-access.c
 F:	xen/arch/*/monitor.c
 F:	xen/arch/*/vm_event.c
 F:	xen/arch/arm/mem_access.c
@@ -446,8 +501,8 @@ F:	docs/misc/vtpm-platforms.txt
 X86 ARCHITECTURE
 M:	Jan Beulich <jbeulich@suse.com>
 M:	Andrew Cooper <andrew.cooper3@citrix.com>
+M:	Roger Pau Monné <roger.pau@citrix.com>
 R:	Wei Liu <wl@xen.org>
-R:	Roger Pau Monné <roger.pau@citrix.com>
 S:	Supported
 L:	xen-devel@lists.xenproject.org
 F:	xen/arch/x86/
@@ -474,7 +529,7 @@ F:	xen/arch/x86/hvm/ioreq.c
 F:	xen/include/asm-x86/hvm/emulate.h
 F:	xen/include/asm-x86/hvm/io.h
 F:	xen/include/asm-x86/hvm/ioreq.h
-F:	xen/include/public/hvm/ioreq.h
+F:	xen/include/asm-x86/ioreq.h
 
 X86 MEMORY MANAGEMENT
 M:	Jan Beulich <jbeulich@suse.com>
@@ -494,7 +549,9 @@ F:	xen/arch/x86/mm/mem_sharing.c
 F:	tools/tests/mem-sharing/
 
 X86 SHADOW PAGETABLES
-M:	Tim Deegan <tim@xen.org>
+M:	Jan Beulich <jbeulich@suse.com>
+M:	Andrew Cooper <andrew.cooper3@citrix.com>
+R:	Tim Deegan <tim@xen.org>
 S:	Maintained
 F:	xen/arch/x86/mm/shadow/
 
@@ -509,6 +566,14 @@ F:	xen/include/asm-x86/guest/hyperv-hcal
 F:	xen/include/asm-x86/guest/hyperv-tlfs.h
 F:	xen/include/asm-x86/hvm/viridian.h
 
+XENSTORE
+M:	Ian Jackson <iwj@xenproject.org>
+M:	Wei Liu <wl@xen.org>
+M:	Juergen Gross <jgross@suse.com>
+R:	Julien Grall <julien@xen.org>
+S:	Supported
+F:	tools/xenstore/
+
 XENTRACE
 M:	George Dunlap <george.dunlap@citrix.com>
 S:	Supported
@@ -518,6 +583,7 @@ F:	xen/include/xen/trace.h
 
 XSM/FLASK
 M:	Daniel De Graaf <dgdegra@tycho.nsa.gov>
+R:	Daniel P. Smith <dpsmith@apertussolutions.com>
 S:	Supported
 F:	tools/flask/
 F:	xen/include/xsm/
@@ -527,7 +593,7 @@ F:	docs/misc/xsm-flask.txt
 THE REST
 M:	Andrew Cooper <andrew.cooper3@citrix.com>
 M:	George Dunlap <george.dunlap@citrix.com>
-M:	Ian Jackson <ian.jackson@eu.citrix.com>
+M:	Ian Jackson <iwj@xenproject.org>
 M:	Jan Beulich <jbeulich@suse.com>
 M:	Julien Grall <julien@xen.org>
 M:	Stefano Stabellini <sstabellini@kernel.org>
diff -pruN 4.14.3+32-g9de3671772-1/Makefile 4.16.1-1/Makefile
--- 4.14.3+32-g9de3671772-1/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -62,11 +62,17 @@ build-xen:
 build-tools: build-tools-public-headers
 	$(MAKE) -C tools build
 
+.PHONY: build-tools-oxenstored
+build-tools-oxenstored: build-tools-public-headers
+	$(MAKE) -s -C tools/ocaml clean
+	$(MAKE) -s -C tools/libs
+	$(MAKE) -C tools/ocaml build-tools-oxenstored
+
 .PHONY: build-stubdom
 build-stubdom: mini-os-dir build-tools-public-headers
 	$(MAKE) -C stubdom build
 ifeq (x86_64,$(XEN_TARGET_ARCH))
-	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
+	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub-if-enabled
 endif
 
 .PHONY: build-docs
@@ -137,7 +143,7 @@ install-tools: install-tools-public-head
 install-stubdom: mini-os-dir install-tools
 	$(MAKE) -C stubdom install
 ifeq (x86_64,$(XEN_TARGET_ARCH))
-	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
+	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub-if-enabled
 endif
 
 .PHONY: tools/firmware/seabios-dir-force-update
diff -pruN 4.14.3+32-g9de3671772-1/README 4.16.1-1/README
--- 4.14.3+32-g9de3671772-1/README	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/README	2022-04-12 12:21:23.000000000 +0000
@@ -1,11 +1,11 @@
-###################################
-__  __            _  _    _ _  _
-\ \/ /___ _ __   | || |  / | || |
- \  // _ \ '_ \  | || |_ | | || |_
- /  \  __/ | | | |__   _|| |__   _|
-/_/\_\___|_| |_|    |_|(_)_|  |_|
+##################################
+__  __            _  _    _  __
+\ \/ /___ _ __   | || |  / |/ /_
+ \  // _ \ '_ \  | || |_ | | '_ \
+ /  \  __/ | | | |__   _|| | (_) |
+/_/\_\___|_| |_|    |_|(_)_|\___/
 
-###################################
+##################################
 
 https://www.xen.org/
 
@@ -42,8 +42,11 @@ provided by your OS distributor:
         - GNU Binutils 2.16.91.0.5 or later
         or
         - Clang/LLVM 3.5 or later
-      - For ARM:
-        - GCC 4.8 or later
+      - For ARM 32-bit:
+        - GCC 4.9 or later
+        - GNU Binutils 2.24 or later
+      - For ARM 64-bit:
+        - GCC 5.1 or later
         - GNU Binutils 2.24 or later
     * Development install of zlib (e.g., zlib-dev)
     * Development install of Python 2.6 or later (e.g., python-dev)
@@ -60,11 +63,7 @@ provided by your OS distributor:
     * bridge-utils package (/sbin/brctl)
     * iproute package (/sbin/ip)
     * GNU bison and GNU flex
-    * GNU gettext
     * ACPI ASL compiler (iasl)
-    * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
-      Required when building on a 64-bit platform to build
-      32-bit components which are enabled on a default build.
 
 In addition to the above there are a number of optional build
 prerequisites. Omitting these will cause the related features to be
@@ -84,6 +83,8 @@ disabled at compile time:
     * 16-bit x86 assembler, loader and compiler for qemu-traditional / rombios
       (dev86 rpm or bin86 & bcc debs)
     * Development install of liblzma for rombios
+    * Development install of libbz2, liblzma, liblzo2, and libzstd for DomU
+      kernel decompression.
 
 Second, you need to acquire a suitable kernel for use in domain 0. If
 possible you should use a kernel provided by your OS distributor. If
diff -pruN 4.14.3+32-g9de3671772-1/scripts/travis-build 4.16.1-1/scripts/travis-build
--- 4.14.3+32-g9de3671772-1/scripts/travis-build	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/scripts/travis-build	2022-04-12 12:21:23.000000000 +0000
@@ -16,6 +16,11 @@ cfgargs+=("--disable-rombios")
 cfgargs+=("--enable-docs")
 cfgargs+=("--with-system-seabios=/usr/share/seabios/bios.bin")
 
+# Qemu requires Python 3.5 or later
+if ! type python3 || python3 -c "import sys; res = sys.version_info < (3, 5); exit(not(res))"; then
+    cfgargs+=("--with-system-qemu=/bin/false")
+fi
+
 if [[ "${XEN_TARGET_ARCH}" == "x86_64" ]]; then
     cfgargs+=("--enable-tools")
 else
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/configure 4.16.1-1/stubdom/configure
--- 4.14.3+32-g9de3671772-1/stubdom/configure	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/configure	2022-04-12 12:21:23.000000000 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Xen Hypervisor Stub Domains 4.14.
+# Generated by GNU Autoconf 2.69 for Xen Hypervisor Stub Domains 4.16.
 #
 # Report bugs to <xen-devel@lists.xen.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Xen Hypervisor Stub Domains'
 PACKAGE_TARNAME='xen'
-PACKAGE_VERSION='4.14'
-PACKAGE_STRING='Xen Hypervisor Stub Domains 4.14'
+PACKAGE_VERSION='4.16'
+PACKAGE_STRING='Xen Hypervisor Stub Domains 4.16'
 PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 PACKAGE_URL='https://www.xen.org/'
 
@@ -630,6 +630,7 @@ WGET
 CMAKE
 extfiles
 debug
+xenstorepvh
 xenstore
 grub
 caml
@@ -689,6 +690,7 @@ enable_c_stubdom
 enable_caml_stubdom
 enable_pv_grub
 enable_xenstore_stubdom
+enable_xenstorepvh_stubdom
 enable_vtpm_stubdom
 enable_vtpmmgr_stubdom
 enable_qemu_traditional
@@ -1263,7 +1265,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Xen Hypervisor Stub Domains 4.14 to adapt to many kinds of systems.
+\`configure' configures Xen Hypervisor Stub Domains 4.16 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1329,7 +1331,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Xen Hypervisor Stub Domains 4.14:";;
+     short | recursive ) echo "Configuration of Xen Hypervisor Stub Domains 4.16:";;
    esac
   cat <<\_ACEOF
 
@@ -1340,10 +1342,13 @@ Optional Features:
   --enable-ioemu-stubdom  Build and install ioemu-stubdom
   --enable-c-stubdom      Build and install c-stubdom (default is DISABLED)
   --enable-caml-stubdom   Build and install caml-stubdom (default is DISABLED)
-  --disable-pv-grub       Build and install pv-grub (default is ENABLED)
+  --enable-pv-grub        Build and install pv-grub (default is DISABLED)
   --disable-xenstore-stubdom
                           Build and install xenstore-stubdom (default is
                           ENABLED)
+  --disable-xenstorepvh-stubdom
+                          Build and install xenstorepvh-stubdom (default is
+                          ENABLED)
   --enable-vtpm-stubdom   Build and install vtpm-stubdom
   --enable-vtpmmgr-stubdom
                           Build and install vtpmmgr-stubdom
@@ -1439,7 +1444,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Xen Hypervisor Stub Domains configure 4.14
+Xen Hypervisor Stub Domains configure 4.16
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1494,7 +1499,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Xen Hypervisor Stub Domains $as_me 4.14, which was
+It was created by Xen Hypervisor Stub Domains $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2124,11 +2129,7 @@ fi
 else
 
 
-grub=y
-STUBDOM_TARGETS="$STUBDOM_TARGETS grub"
-STUBDOM_BUILD="$STUBDOM_BUILD pv-grub"
-STUBDOM_INSTALL="$STUBDOM_INSTALL install-grub"
-STUBDOM_UNINSTALL="$STUBDOM_UNINSTALL install-grub"
+grub=n
 
 
 fi
@@ -2178,6 +2179,48 @@ fi
 
 
 
+# Check whether --enable-xenstorepvh-stubdom was given.
+if test "${enable_xenstorepvh_stubdom+set}" = set; then :
+  enableval=$enable_xenstorepvh_stubdom;
+
+if test "x$enableval" = "xyes"; then :
+
+
+xenstorepvh=y
+STUBDOM_TARGETS="$STUBDOM_TARGETS xenstorepvh"
+STUBDOM_BUILD="$STUBDOM_BUILD xenstorepvh-stubdom"
+STUBDOM_INSTALL="$STUBDOM_INSTALL install-xenstorepvh"
+STUBDOM_UNINSTALL="$STUBDOM_UNINSTALL install-xenstorepvh"
+
+
+else
+
+if test "x$enableval" = "xno"; then :
+
+
+xenstorepvh=n
+
+
+fi
+
+fi
+
+
+else
+
+
+xenstorepvh=y
+STUBDOM_TARGETS="$STUBDOM_TARGETS xenstorepvh"
+STUBDOM_BUILD="$STUBDOM_BUILD xenstorepvh-stubdom"
+STUBDOM_INSTALL="$STUBDOM_INSTALL install-xenstorepvh"
+STUBDOM_UNINSTALL="$STUBDOM_UNINSTALL install-xenstorepvh"
+
+
+fi
+
+
+
+
 # Check whether --enable-vtpm-stubdom was given.
 if test "${enable_vtpm_stubdom+set}" = set; then :
   enableval=$enable_vtpm_stubdom;
@@ -2243,14 +2286,6 @@ fi
 # Check whether --enable-qemu-traditional was given.
 if test "${enable_qemu_traditional+set}" = set; then :
   enableval=$enable_qemu_traditional;
-else
-
-    case "$host_cpu" in
-        i[3456]86|x86_64)
-           enable_qemu_traditional="yes";;
-        *) enable_qemu_traditional="no";;
-    esac
-
 fi
 
 if test "x$enable_qemu_traditional" = "xyes"; then :
@@ -4248,7 +4283,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Xen Hypervisor Stub Domains $as_me 4.14, which was
+This file was extended by Xen Hypervisor Stub Domains $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4302,7 +4337,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Xen Hypervisor Stub Domains config.status 4.14
+Xen Hypervisor Stub Domains config.status 4.16
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/configure.ac 4.16.1-1/stubdom/configure.ac
--- 4.14.3+32-g9de3671772-1/stubdom/configure.ac	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/configure.ac	2022-04-12 12:21:23.000000000 +0000
@@ -21,18 +21,13 @@ m4_include([../m4/fetcher.m4])
 AX_STUBDOM_CONDITIONAL([ioemu-stubdom], [ioemu])
 AX_STUBDOM_DEFAULT_DISABLE([c-stubdom], [c])
 AX_STUBDOM_DEFAULT_DISABLE([caml-stubdom], [caml])
-AX_STUBDOM_DEFAULT_ENABLE([pv-grub], [grub])
+AX_STUBDOM_DEFAULT_DISABLE([pv-grub], [grub])
 AX_STUBDOM_DEFAULT_ENABLE([xenstore-stubdom], [xenstore])
+AX_STUBDOM_DEFAULT_ENABLE([xenstorepvh-stubdom], [xenstorepvh])
 AX_STUBDOM_CONDITIONAL([vtpm-stubdom], [vtpm])
 AX_STUBDOM_CONDITIONAL([vtpmmgr-stubdom], [vtpmmgr])
 
-AC_ARG_ENABLE([qemu-traditional],,,[
-    case "$host_cpu" in
-        i[[3456]]86|x86_64)
-           enable_qemu_traditional="yes";;
-        *) enable_qemu_traditional="no";;
-    esac
-])
+AC_ARG_ENABLE([qemu-traditional])
 AS_IF([test "x$enable_qemu_traditional" = "xyes"], [
     qemu_traditional=y],[
     qemu_traditional=n
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/grub/kexec.c 4.16.1-1/stubdom/grub/kexec.c
--- 4.14.3+32-g9de3671772-1/stubdom/grub/kexec.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/grub/kexec.c	2022-04-12 12:21:23.000000000 +0000
@@ -20,7 +20,7 @@
 #include <sys/mman.h>
 
 #include <xenctrl.h>
-#include <xc_dom.h>
+#include <xenguest.h>
 
 #include <kernel.h>
 #include <console.h>
@@ -222,6 +222,7 @@ void kexec(void *kernel, long kernel_siz
     char features[] = "";
     struct mmu_update *m2p_updates;
     unsigned long nr_m2p_updates;
+    uint64_t virt_base;
 
     DEBUG("booting with cmdline %s\n", cmdline);
     xc_handle = xc_interface_open(0,0,0);
@@ -294,10 +295,11 @@ void kexec(void *kernel, long kernel_siz
         goto out;
     }
 
+    virt_base = xc_dom_virt_base(dom);
     /* copy hypercall page */
     /* TODO: domctl instead, but requires privileges */
-    if (dom->parms.virt_hypercall != -1) {
-        pfn = PHYS_PFN(dom->parms.virt_hypercall - dom->parms.virt_base);
+    if (xc_dom_virt_hypercall(dom) != -1) {
+        pfn = PHYS_PFN(xc_dom_virt_hypercall(dom) - virt_base);
         memcpy((void *) pages[pfn], hypercall_page, PAGE_SIZE);
     }
 
@@ -313,11 +315,11 @@ void kexec(void *kernel, long kernel_siz
     /* Move current console, xenstore and boot MFNs to the allocated place */
     do_exchange(dom, dom->console_pfn, start_info.console.domU.mfn);
     do_exchange(dom, dom->xenstore_pfn, start_info.store_mfn);
-    DEBUG("virt base at %llx\n", dom->parms.virt_base);
+    DEBUG("virt base at %llx\n", virt_base);
     DEBUG("bootstack_pfn %lx\n", dom->bootstack_pfn);
-    _boot_target = dom->parms.virt_base + PFN_PHYS(dom->bootstack_pfn);
+    _boot_target = virt_base + PFN_PHYS(dom->bootstack_pfn);
     DEBUG("_boot_target %lx\n", _boot_target);
-    do_exchange(dom, PHYS_PFN(_boot_target - dom->parms.virt_base),
+    do_exchange(dom, PHYS_PFN(_boot_target - virt_base),
             virt_to_mfn(&_boot_page));
 
     if ( dom->arch_hooks->setup_pgtables )
@@ -373,13 +375,13 @@ void kexec(void *kernel, long kernel_siz
     _boot_oldpdmfn = virt_to_mfn(start_info.pt_base);
     DEBUG("boot old pd mfn %lx\n", _boot_oldpdmfn);
     DEBUG("boot pd virt %lx\n", dom->pgtables_seg.vstart);
-    _boot_pdmfn = dom->pv_p2m[PHYS_PFN(dom->pgtables_seg.vstart - dom->parms.virt_base)];
+    _boot_pdmfn = dom->pv_p2m[PHYS_PFN(dom->pgtables_seg.vstart - virt_base)];
     DEBUG("boot pd mfn %lx\n", _boot_pdmfn);
     _boot_stack = _boot_target + PAGE_SIZE;
     DEBUG("boot stack %lx\n", _boot_stack);
-    _boot_start_info = dom->parms.virt_base + PFN_PHYS(dom->start_info_pfn);
+    _boot_start_info = virt_base + PFN_PHYS(dom->start_info_pfn);
     DEBUG("boot start info %lx\n", _boot_start_info);
-    _boot_start = dom->parms.virt_entry;
+    _boot_start = xc_dom_virt_entry(dom);
     DEBUG("boot start %lx\n", _boot_start);
 
     /* Keep only useful entries */
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/grub/Makefile 4.16.1-1/stubdom/grub/Makefile
--- 4.14.3+32-g9de3671772-1/stubdom/grub/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/grub/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -6,7 +6,9 @@ vpath %.c ../grub-upstream
 BOOT=$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o
 
 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/toollog/include
-DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc/include -I$(XEN_ROOT)/tools/include -I.
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/ctrl/include
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/guest/include
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/include -I.
 DEF_CPPFLAGS += -I../grub-upstream/stage1
 DEF_CPPFLAGS += -I../grub-upstream/stage2
 DEF_CPPFLAGS += -I../grub-upstream/netboot
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/Makefile 4.16.1-1/stubdom/Makefile
--- 4.14.3+32-g9de3671772-1/stubdom/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -23,6 +23,13 @@ endif
 
 -include $(XEN_ROOT)/config/Stubdom.mk
 
+include $(XEN_ROOT)/tools/libs/uselibs.mk
+
+define LIB_deps
+ LIBDEPS_$(1) = $$(foreach use,$$(USELIBS_$(1)),libxen$$(use))
+endef
+$(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_deps,$(lib))))
+
 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
 ifeq ($(XEN_TARGET_ARCH),x86_32)
 GNU_TARGET_ARCH:=i686
@@ -98,7 +105,7 @@ cross-newlib: $(NEWLIB_STAMPFILE)
 $(NEWLIB_STAMPFILE): mk-headers-$(XEN_TARGET_ARCH) newlib-$(NEWLIB_VERSION)
 	mkdir -p newlib-$(XEN_TARGET_ARCH)
 	( cd newlib-$(XEN_TARGET_ARCH) && \
-	  CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \
+	  CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --enable-newlib-io-c99-formats --disable-multilib && \
 	  $(MAKE) DESTDIR= && \
 	  $(MAKE) DESTDIR= install )
 
@@ -232,6 +239,8 @@ tpm_emulator-$(XEN_TARGET_ARCH): tpm_emu
 	patch -d $@ -p1 < vtpm-implicit-fallthrough.patch
 	patch -d $@ -p1 < vtpm_TPM_ChangeAuthAsymFinish.patch
 	patch -d $@ -p1 < vtpm_extern.patch
+	patch -d $@ -p1 < vtpm-microsecond-duration.patch
+	patch -d $@ -p1 < vtpm-command-duration.patch
 	mkdir $@/build
 	cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement"
 	touch $@
@@ -320,45 +329,50 @@ ioemu/linkfarm.stamp:
 	touch ioemu/linkfarm.stamp
 endif
 
+#######
+# libraries under tools/libs
+#######
+
+STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel ctrl guest
+
+LIBDEP_guest := cross-zlib
+
+#######
+# common handling
+#######
+
 define do_links
   mkdir -p $(dir $@)include
   cd $(dir $@); \
   ln -sf $(dir $<)include/*.h include/; \
   ln -sf $(dir $<)*.[ch] .; \
-  ln -sf $(dir $<)*.pc.in .; \
   ln -sf $(dir $<)Makefile .
   touch $@
 endef
 
-libs-$(XEN_TARGET_ARCH)/toolcore/stamp: $(XEN_ROOT)/tools/libs/toolcore/Makefile
-	$(do_links)
+define BUILD_lib
+ .PHONY: libxen$(1) clean-libxen$(1)
+ libxen$(1): libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a
+ libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: $$(LIBDEPS_$(1)) $$(LIBDEP_$(1))
+ libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: mk-headers-$$(XEN_TARGET_ARCH) $$(NEWLIB_STAMPFILE)
+	CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libs-$$(XEN_TARGET_ARCH)/$(1)
 
-libs-$(XEN_TARGET_ARCH)/toollog/stamp: $(XEN_ROOT)/tools/libs/toollog/Makefile
-	$(do_links)
-
-libs-$(XEN_TARGET_ARCH)/evtchn/stamp: $(XEN_ROOT)/tools/libs/evtchn/Makefile
-	$(do_links)
-
-libs-$(XEN_TARGET_ARCH)/gnttab/stamp: $(XEN_ROOT)/tools/libs/gnttab/Makefile
-	$(do_links)
-
-libs-$(XEN_TARGET_ARCH)/call/stamp: $(XEN_ROOT)/tools/libs/call/Makefile
-	$(do_links)
+ clean-libxen$(1):
+	[ ! -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile ] || $$(MAKE) DESTDIR= -C libs-$$(XEN_TARGET_ARCH)/$(1) clean
 
-libs-$(XEN_TARGET_ARCH)/foreignmemory/stamp: $(XEN_ROOT)/tools/libs/foreignmemory/Makefile
-	$(do_links)
+ libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile
+	$$(do_links)
+endef
 
-libs-$(XEN_TARGET_ARCH)/devicemodel/stamp: $(XEN_ROOT)/tools/libs/devicemodel/Makefile
-	$(do_links)
+$(foreach lib,$(STUB_LIBS),$(eval $(call BUILD_lib,$(lib))))
 
-libxc-$(XEN_TARGET_ARCH)/stamp: $(XEN_ROOT)/tools/libxc/Makefile
+xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile
 	$(do_links)
 
-xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile
+xenstorepvh/stamp: $(XEN_ROOT)/tools/xenstore/Makefile
 	$(do_links)
 
-LINK_LIBS_DIRS := toolcore toollog evtchn gnttab call foreignmemory devicemodel
-LINK_DIRS := libxc-$(XEN_TARGET_ARCH) xenstore $(foreach dir,$(LINK_LIBS_DIRS),libs-$(XEN_TARGET_ARCH)/$(dir))
+LINK_DIRS := xenstore xenstorepvh $(foreach dir,$(STUB_LIBS),libs-$(XEN_TARGET_ARCH)/$(dir))
 LINK_STAMPS := $(foreach dir,$(LINK_DIRS),$(dir)/stamp)
 
 mk-headers-$(XEN_TARGET_ARCH): $(IOEMU_LINKFARM_TARGET) $(LINK_STAMPS)
@@ -382,80 +396,6 @@ $(TARGETS_MINIOS): mini-os-%:
 	done
 
 #######
-# libxentoolcore
-#######
-
-.PHONY: libxentoolcore
-libxentoolcore: libs-$(XEN_TARGET_ARCH)/toolcore/libxentoolcore.a
-libs-$(XEN_TARGET_ARCH)/toolcore/libxentoolcore.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toolcore
-
-#######
-# libxentoollog
-#######
-
-.PHONY: libxentoollog
-libxentoollog: libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a
-libs-$(XEN_TARGET_ARCH)/toollog/libxentoollog.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog
-
-#######
-# libxenevtchn
-#######
-
-.PHONY: libxenevtchn
-libxenevtchn: libs-$(XEN_TARGET_ARCH)/evtchn/libxenevtchn.a
-libs-$(XEN_TARGET_ARCH)/evtchn/libxenevtchn.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/evtchn
-
-#######
-# libxengnttab
-#######
-
-.PHONY: libxengnttab
-libxengnttab: libs-$(XEN_TARGET_ARCH)/gnttab/libxengnttab.a
-libs-$(XEN_TARGET_ARCH)/gnttab/libxengnttab.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/gnttab
-
-#######
-# libxencall
-#######
-
-.PHONY: libxencall
-libxencall: libs-$(XEN_TARGET_ARCH)/call/libxencall.a
-libs-$(XEN_TARGET_ARCH)/call/libxencall.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/call
-
-#######
-# libxenforeignmemory
-#######
-
-.PHONY: libxenforeignmemory
-libxenforeignmemory: libs-$(XEN_TARGET_ARCH)/foreignmemory/libxenforeignmemory.a
-libs-$(XEN_TARGET_ARCH)/foreignmemory/libxenforeignmemory.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory
-
-#######
-# libxendevicemodel
-#######
-
-.PHONY: libxendevicemodel
-libxendevicemodel: libs-$(XEN_TARGET_ARCH)/devicemodel/libxendevicemodel.a
-libs-$(XEN_TARGET_ARCH)/devicemodel/libxendevicemodel.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/devicemodel
-
-#######
-# libxc
-#######
-
-.PHONY: libxc
-libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
-libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoolcore libxentoollog libxenevtchn libxengnttab libxencall libxenforeignmemory libxendevicemodel cross-zlib
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libxc-$(XEN_TARGET_ARCH)
-
- libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a
-
-#######
 # ioemu
 #######
 
@@ -463,7 +403,7 @@ ioemu-minios-config.mk: $(CURDIR)/ioemu-
 	MINIOS_CONFIG="$<" CONFIG_FILE="$(CURDIR)/$@" $(MAKE) DESTDIR= -C $(MINI_OS) config
 
 .PHONY: ioemu
-ioemu: cross-zlib cross-libpci libxc ioemu-minios-config.mk
+ioemu: cross-zlib cross-libpci libxenguest ioemu-minios-config.mk
 	[ -f ioemu/config-host.mak ] || \
 	  ( $(buildmakevars2shellvars); \
 	    cd ioemu ; \
@@ -551,21 +491,32 @@ xenstore-minios-config.mk: $(CURDIR)/xen
 xenstore: $(CROSS_ROOT) xenstore-minios-config.mk
 	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat xenstore-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C $@ xenstored.a CONFIG_STUBDOM=y
 
+#############
+# xenstorepvh
+#############
+
+xenstorepvh-minios-config.mk: $(CURDIR)/xenstorepvh-minios.cfg
+	MINIOS_CONFIG="$<" CONFIG_FILE="$(CURDIR)/$@" $(MAKE) DESTDIR= -C $(MINI_OS) config
+
+.PHONY: xenstorepvh
+xenstorepvh: $(CROSS_ROOT) xenstorepvh-minios-config.mk
+	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell cat xenstorepvh-minios-config.mk)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C $@ xenstored.a CONFIG_STUBDOM=y
+
 ########
 # minios
 ########
 
 .PHONY: ioemu-stubdom
 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
-ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
+ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxenguest ioemu
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/ioemu-minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
 
 .PHONY: caml-stubdom
-caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc cross-ocaml caml
+caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxenguest cross-ocaml caml
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/caml/minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
 
 .PHONY: c-stubdom
-c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
+c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxenguest c
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/c/minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
 
 .PHONY: vtpm-stubdom
@@ -577,13 +528,24 @@ vtpmmgr-stubdom: mini-os-$(XEN_TARGET_AR
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/vtpmmgr/minios.cfg" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS="$(CURDIR)/vtpmmgr/vtpmmgr.a" APP_LDLIBS="-lm -lpolarssl"
 
 .PHONY: pv-grub
-pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
+pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxenguest grub
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/grub/minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 
+.PHONY: pv-grub-if-enabled
+ifneq ($(filter grub,$(STUBDOM_TARGETS)),)
+pv-grub-if-enabled: pv-grub
+else
+pv-grub-if-enabled:
+endif
+
 .PHONY: xenstore-stubdom
-xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxc xenstore
+xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxenguest xenstore
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/xenstore-minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/xenstore/xenstored.a
 
+.PHONY: xenstorepvh-stubdom
+xenstorepvh-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstorepvh libxenguest xenstorepvh
+	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/xenstorepvh-minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/xenstorepvh/xenstored.a
+
 #########
 # install
 #########
@@ -605,6 +567,12 @@ install-grub: pv-grub
 	$(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)"
 	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)$(XENFIRMWAREDIR)/pv-grub-$(XEN_TARGET_ARCH).gz"
 
+ifneq ($(filter grub,$(STUBDOM_TARGETS)),)
+install-grub-if-enabled: install-grub
+else
+install-grub-if-enabled:
+endif
+
 install-c: c-stubdom
 
 install-caml: caml-stubdom
@@ -613,6 +581,10 @@ install-xenstore: xenstore-stubdom
 	$(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)"
 	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR)$(XENFIRMWAREDIR)/xenstore-stubdom.gz"
 
+install-xenstorepvh: xenstorepvh-stubdom
+	$(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)"
+	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-xenstorepvh/mini-os.gz "$(DESTDIR)$(XENFIRMWAREDIR)/xenstorepvh-stubdom.gz"
+
 install-vtpm: vtpm-stubdom
 	$(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)"
 	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-vtpm/mini-os.gz "$(DESTDIR)$(XENFIRMWAREDIR)/vtpm-stubdom.gz"
@@ -646,6 +618,9 @@ uninstall-grub:
 uninstall-xenstore:
 	rm -f $(DESTDIR)$(XENFIRMWAREDIR)/xenstore-stubdom.gz
 
+uninstall-xenstorepvh:
+	rm -f $(DESTDIR)$(XENFIRMWAREDIR)/xenstorepvh-stubdom.gz
+
 uninstall-vtpm:
 	rm -f $(DESTDIR)$(XENFIRMWAREDIR)/vtpm-stubdom.gz
 
@@ -658,12 +633,14 @@ uninstall-vtpmmgr:
 
 # Only clean the libxc/ioemu/mini-os part
 .PHONY: clean
+clean: $(foreach lib,$(STUB_LIBS),clean-libxen$(lib))
 clean:
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-ioemu
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-c
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstore
+	rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstorepvh
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-vtpm
 	rm -fr mini-os-$(XEN_TARGET_ARCH)-vtpmmgr
 	$(MAKE) DESTDIR= -C caml clean
@@ -674,16 +651,9 @@ clean:
 	rm -f $(STUBDOMPATH)
 	rm -f *-minios-config.mk
 	rm -fr pkg-config
-	[ ! -e libs-$(XEN_TARGET_ARCH)/toolcore/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toolcore clean
-	[ ! -e libs-$(XEN_TARGET_ARCH)/toollog/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/toollog clean
-	[ ! -e libs-$(XEN_TARGET_ARCH)/evtchn/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/evtchn clean
-	[ ! -e libs-$(XEN_TARGET_ARCH)/gnttab/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/gnttab clean
-	[ ! -e libs-$(XEN_TARGET_ARCH)/call/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/call clean
-	[ ! -e libs-$(XEN_TARGET_ARCH)/foreignmemory/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory clean
-	[ ! -e libs-$(XEN_TARGET_ARCH)/devicemodel/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/devicemodel clean
-	[ ! -e libxc-$(XEN_TARGET_ARCH)/Makefile ] || $(MAKE) DESTDIR= -C libxc-$(XEN_TARGET_ARCH) clean
 	-[ ! -d ioemu ] || $(MAKE) DESTDIR= -C ioemu clean
 	-[ ! -d xenstore ] || $(MAKE) DESTDIR= -C xenstore clean
+	-[ ! -d xenstorepvh ] || $(MAKE) DESTDIR= -C xenstorepvh clean
 
 # clean the cross-compilation result
 .PHONY: crossclean
@@ -692,7 +662,7 @@ crossclean: clean
 	rm -fr newlib-$(XEN_TARGET_ARCH)
 	rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
 	rm -fr libs-$(XEN_TARGET_ARCH)
-	rm -fr libxc-$(XEN_TARGET_ARCH) ioemu xenstore
+	rm -fr ioemu xenstore xenstorepvh
 	rm -fr gmp-$(XEN_TARGET_ARCH)
 	rm -fr polarssl-$(XEN_TARGET_ARCH)
 	rm -fr openssl-$(XEN_TARGET_ARCH)
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/mini-os.mk 4.16.1-1/stubdom/mini-os.mk
--- 4.14.3+32-g9de3671772-1/stubdom/mini-os.mk	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/stubdom/mini-os.mk	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,17 @@
+# Included by Mini-OS stubdom builds to set variables depending on Xen
+# internal paths.
+#
+# Input variables are:
+# XEN_ROOT
+# MINIOS_TARGET_ARCH
+
+XENSTORE_CPPFLAGS = -isystem $(XEN_ROOT)/tools/include
+TOOLCORE_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toolcore
+TOOLLOG_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog
+EVTCHN_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn
+GNTTAB_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab
+CALL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call
+FOREIGNMEMORY_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory
+DEVICEMODEL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/devicemodel
+CTRL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/ctrl
+GUEST_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/guest
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpm-command-duration.patch 4.16.1-1/stubdom/vtpm-command-duration.patch
--- 4.14.3+32-g9de3671772-1/stubdom/vtpm-command-duration.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/stubdom/vtpm-command-duration.patch	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,52 @@
+From e7c976b5864e7d2649292d90ea60d5aea091a990 Mon Sep 17 00:00:00 2001
+From: Jason Andryuk <jandryuk@gmail.com>
+Date: Sun, 14 Mar 2021 12:46:34 -0400
+Subject: [PATCH 2/2] Increase command durations
+
+Wth Linux 5.4 xen-tpmfront and a Xen vtpm-stubdom, xen-tpmfront was
+failing commands with -ETIME:
+tpm tpm0: tpm_try_transmit: send(): error-62
+
+The vtpm was returning the data, but it was after the duration timeout
+in vtpm_send.  Linux may have started being more stringent about timing?
+
+The vtpm-stubdom has a little delay since it writes its disk before
+returning the response.
+
+Anyway, the durations are rather low.  When they were 1/10/1000 before
+converting to microseconds, Linux showed all three durations rounded to
+10000.  Update them with values from a physical TPM1.2.  These were
+taken from a WEC which was software downgraded from a TPM2 to a TPM1.2.
+They might be excessive, but I'd rather have a command succeed than
+return -ETIME.
+
+An IFX physical TPM1.2 uses:
+1000000
+1500000
+150000000
+
+Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
+---
+ tpm/tpm_data.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/tpm/tpm_data.c b/tpm/tpm_data.c
+index bebaf10..844afca 100644
+--- a/tpm/tpm_data.c
++++ b/tpm/tpm_data.c
+@@ -71,9 +71,9 @@ static void init_timeouts(void)
+   tpmData.permanent.data.tis_timeouts[1] = 2000000;
+   tpmData.permanent.data.tis_timeouts[2] = 750000;
+   tpmData.permanent.data.tis_timeouts[3] = 750000;
+-  tpmData.permanent.data.cmd_durations[0] = 1000;
+-  tpmData.permanent.data.cmd_durations[1] = 10000;
+-  tpmData.permanent.data.cmd_durations[2] = 1000000;
++  tpmData.permanent.data.cmd_durations[0] = 3000000;
++  tpmData.permanent.data.cmd_durations[1] = 3000000;
++  tpmData.permanent.data.cmd_durations[2] = 600000000;
+ }
+ 
+ void tpm_init_data(void)
+-- 
+2.30.2
+
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/init.c 4.16.1-1/stubdom/vtpmmgr/init.c
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/init.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/init.c	2022-04-12 12:21:23.000000000 +0000
@@ -289,16 +289,21 @@ int parse_cmdline_opts(int argc, char**
    memcpy(vtpm_globals.srk_auth, WELLKNOWN_AUTH, sizeof(TPM_AUTHDATA));
 
    for(i = 1; i < argc; ++i) {
-      if(!strncmp(argv[i], "owner_auth:", 10)) {
-         if((rc = parse_auth_string(argv[i] + 10, vtpm_globals.owner_auth)) < 0) {
+      if(!strncmp(argv[i], "owner_auth=", 11)) {
+         if((rc = parse_auth_string(argv[i] + 11, vtpm_globals.owner_auth)) < 0) {
             goto err_invalid;
          }
          if(rc == 1) {
             opts->gen_owner_auth = 1;
          }
       }
-      else if(!strncmp(argv[i], "srk_auth:", 8)) {
-         if((rc = parse_auth_string(argv[i] + 8, vtpm_globals.srk_auth)) != 0) {
+      else if(!strncmp(argv[i], "srk_auth=", 9)) {
+         if((rc = parse_auth_string(argv[i] + 9, vtpm_globals.srk_auth)) != 0) {
+            goto err_invalid;
+         }
+      }
+      else if(!strncmp(argv[i], "srk_handle=", 11)) {
+         if(sscanf(argv[i] + 11, "%x", &vtpm_globals.srk_handle) != 1) {
             goto err_invalid;
          }
       }
@@ -498,20 +503,6 @@ egress:
    return status;
 }
 
-void vtpmmgr_shutdown(void)
-{
-   /* Cleanup TPM resources */
-   TPM_TerminateHandle(vtpm_globals.oiap.AuthHandle);
-
-   /* Close tpmback */
-   shutdown_tpmback();
-
-   /* Close tpmfront/tpm_tis */
-   close(vtpm_globals.tpm_fd);
-
-   vtpmloginfo(VTPM_LOG_VTPM, "VTPM Manager stopped.\n");
-}
-
 /* TPM 2.0 */
 
 static void tpm2_AuthArea_ctor(const char *authValue, UINT32 authLen,
@@ -586,7 +577,11 @@ TPM_RESULT vtpmmgr2_create(void)
 {
     TPM_RESULT status = TPM_SUCCESS;
 
-    TPMTRYRETURN(tpm2_take_ownership());
+    if ( vtpm_globals.srk_handle == 0 ) {
+        TPMTRYRETURN(tpm2_take_ownership());
+    } else {
+        tpm2_AuthArea_ctor(NULL, 0, &vtpm_globals.srk_auth_area);
+    }
 
    /* create SK */
     TPM2_Create_Params_out out;
@@ -661,7 +656,7 @@ static TPM_RC flush_tpm2(void)
 {
     int i;
 
-    for (i = TRANSIENT_FIRST; i < TRANSIENT_LAST; i++)
+    for (i = TRANSIENT_FIRST; i <= TRANSIENT_LAST; i++)
          TPM2_FlushContext(i);
 
     return TPM_SUCCESS;
@@ -788,3 +783,25 @@ abort_egress:
 egress:
     return status;
 }
+
+void vtpmmgr_shutdown(void)
+{
+   /* Cleanup TPM resources */
+   TPM_TerminateHandle(vtpm_globals.oiap.AuthHandle);
+
+   /* Close tpmback */
+   shutdown_tpmback();
+
+    if (hw_is_tpm2()) {
+        /* Blow away all stale handles left in the tpm*/
+        if (flush_tpm2() != TPM_SUCCESS) {
+            vtpmlogerror(VTPM_LOG_TPM,
+                         "TPM2_FlushResources failed, continuing shutdown..\n");
+        }
+    }
+
+   /* Close tpmfront/tpm_tis */
+   close(vtpm_globals.tpm_fd);
+
+   vtpmloginfo(VTPM_LOG_VTPM, "VTPM Manager stopped.\n");
+}
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/marshal.h 4.16.1-1/stubdom/vtpmmgr/marshal.h
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/marshal.h	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/marshal.h	2022-04-12 12:21:23.000000000 +0000
@@ -891,6 +891,15 @@ inline int sizeof_TPM_AUTH_SESSION(const
 }
 
 static
+inline int sizeof_TPM_RQU_HEADER(BYTE* ptr) {
+	int rv = 0;
+	rv += sizeof_UINT16(ptr);
+	rv += sizeof_UINT32(ptr);
+	rv += sizeof_UINT32(ptr);
+	return rv;
+}
+
+static
 inline BYTE* pack_TPM_RQU_HEADER(BYTE* ptr,
 		TPM_TAG tag,
 		UINT32 size,
@@ -920,8 +929,14 @@ inline int unpack3_TPM_RQU_HEADER(BYTE*
 		unpack3_UINT32(ptr, pos, max, ord);
 }
 
+static
+inline int sizeof_TPM_RQU_GetRandom(BYTE* ptr) {
+	return sizeof_TPM_RQU_HEADER(ptr) + sizeof_UINT32(ptr);
+}
+
 #define pack_TPM_RSP_HEADER(p, t, s, r) pack_TPM_RQU_HEADER(p, t, s, r)
 #define unpack_TPM_RSP_HEADER(p, t, s, r) unpack_TPM_RQU_HEADER(p, t, s, r)
 #define unpack3_TPM_RSP_HEADER(p, l, m, t, s, r) unpack3_TPM_RQU_HEADER(p, l, m, t, s, r)
+#define sizeof_TPM_RSP_HEADER(p) sizeof_TPM_RQU_HEADER(p)
 
 #endif
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/tpm2.c 4.16.1-1/stubdom/vtpmmgr/tpm2.c
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/tpm2.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/tpm2.c	2022-04-12 12:21:23.000000000 +0000
@@ -126,7 +126,7 @@
     ptr = unpack_TPM_RSP_HEADER(ptr, \
           &(tag), &(paramSize), &(status));\
     if ((status) != TPM_SUCCESS){ \
-        vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s\n", tpm_get_error_name(status));\
+        vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s (%x)\n", tpm_get_error_name(status), (status));\
         goto abort_egress;\
     }\
 } while(0)
@@ -427,15 +427,22 @@ abort_egress:
 
 TPM_RC TPM2_GetRandom(UINT32 * bytesRequested, BYTE * randomBytes)
 {
+    UINT16 bytesReq;
     TPM_BEGIN(TPM_ST_NO_SESSIONS, TPM_CC_GetRandom);
 
-    ptr = pack_UINT16(ptr, (UINT16)*bytesRequested);
+    if (*bytesRequested > UINT16_MAX)
+        bytesReq = UINT16_MAX;
+    else
+        bytesReq = *bytesRequested;
+
+    ptr = pack_UINT16(ptr, bytesReq);
 
     TPM_TRANSMIT();
     TPM_UNPACK_VERIFY();
 
-    ptr = unpack_UINT16(ptr, (UINT16 *)bytesRequested);
-    ptr = unpack_TPM_BUFFER(ptr, randomBytes, *bytesRequested);
+    ptr = unpack_UINT16(ptr, &bytesReq);
+    *bytesRequested = bytesReq;
+    ptr = unpack_TPM_BUFFER(ptr, randomBytes, bytesReq);
 
 abort_egress:
     return status;
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/tpm.c 4.16.1-1/stubdom/vtpmmgr/tpm.c
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/tpm.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/tpm.c	2022-04-12 12:21:23.000000000 +0000
@@ -109,7 +109,7 @@
 			UINT32 rsp_status; \
 			UNPACK_OUT(TPM_RSP_HEADER, &rsp_tag, &rsp_len, &rsp_status); \
 			if (rsp_status != TPM_SUCCESS) { \
-				vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s\n", tpm_get_error_name(rsp_status)); \
+				vtpmlogerror(VTPM_LOG_TPM, "Failed with return code %s (%x)\n", tpm_get_error_name(rsp_status), rsp_status); \
 				status = rsp_status; \
 				goto abort_egress; \
 			} \
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/vtpm_cmd_handler.c 4.16.1-1/stubdom/vtpmmgr/vtpm_cmd_handler.c
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/vtpm_cmd_handler.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/vtpm_cmd_handler.c	2022-04-12 12:21:23.000000000 +0000
@@ -47,6 +47,7 @@
 #include "vtpm_disk.h"
 #include "vtpmmgr.h"
 #include "tpm.h"
+#include "tpm2.h"
 #include "tpmrsa.h"
 #include "tcg.h"
 #include "mgmt_authority.h"
@@ -772,6 +773,64 @@ static int vtpmmgr_permcheck(struct tpm_
 	return 1;
 }
 
+TPM_RESULT vtpmmgr_handle_getrandom(struct tpm_opaque *opaque,
+				    tpmcmd_t* tpmcmd)
+{
+	TPM_RESULT status = TPM_SUCCESS;
+	TPM_TAG tag;
+	UINT32 size;
+	const int max_rand_size = TCPA_MAX_BUFFER_LENGTH -
+				  sizeof_TPM_RQU_GetRandom(tpmcmd->req);
+	UINT32 rand_offset;
+	UINT32 rand_size;
+	TPM_COMMAND_CODE ord;
+	BYTE *p;
+
+	if (tpmcmd->req_len != sizeof_TPM_RQU_GetRandom(tpmcmd->req)) {
+		status = TPM_BAD_PARAMETER;
+		tag = TPM_TAG_RQU_COMMAND;
+		goto abort_egress;
+	}
+
+	p = unpack_TPM_RQU_HEADER(tpmcmd->req, &tag, &size, &ord);
+
+	if (!hw_is_tpm2()) {
+		size = TCPA_MAX_BUFFER_LENGTH;
+		TPMTRYRETURN(TPM_TransmitData(tpmcmd->req, tpmcmd->req_len,
+					      tpmcmd->resp, &size));
+		tpmcmd->resp_len = size;
+
+		return TPM_SUCCESS;
+	}
+
+	/* TPM_GetRandom req: <header><uint32 num bytes> */
+	unpack_UINT32(p, &rand_size);
+
+	/* Returning fewer bytes is acceptable per the spec. */
+	if (rand_size > max_rand_size)
+		rand_size = max_rand_size;
+
+	/* Call TPM2_GetRandom but return a TPM_GetRandom response. */
+	/* TPM_GetRandom resp: <header><uint32 num bytes><num random bytes> */
+	rand_offset = sizeof_TPM_RSP_HEADER(tpmcmd->resp) +
+		      sizeof_UINT32(tpmcmd->resp);
+
+	TPMTRYRETURN(TPM2_GetRandom(&rand_size, tpmcmd->resp + rand_offset));
+
+	p = pack_TPM_RSP_HEADER(tpmcmd->resp, TPM_TAG_RSP_COMMAND,
+				rand_offset + rand_size, status);
+	p = pack_UINT32(p, rand_size);
+	tpmcmd->resp_len = rand_offset + rand_size;
+
+	return status;
+
+abort_egress:
+	tpmcmd->resp_len = VTPM_COMMAND_HEADER_SIZE;
+	pack_TPM_RSP_HEADER(tpmcmd->resp, tag + 3, tpmcmd->resp_len, status);
+
+	return status;
+}
+
 TPM_RESULT vtpmmgr_handle_cmd(
 		struct tpm_opaque *opaque,
 		tpmcmd_t* tpmcmd)
@@ -781,6 +840,12 @@ TPM_RESULT vtpmmgr_handle_cmd(
 	UINT32 size;
 	TPM_COMMAND_CODE ord;
 
+	if (tpmcmd->req_len < sizeof_TPM_RQU_HEADER(tpmcmd->req)) {
+		status = TPM_BAD_PARAMETER;
+		tag = TPM_TAG_RQU_COMMAND;
+		goto abort_egress;
+	}
+
 	unpack_TPM_RQU_HEADER(tpmcmd->req,
 			&tag, &size, &ord);
 
@@ -842,7 +907,7 @@ TPM_RESULT vtpmmgr_handle_cmd(
 		switch(ord) {
 		case TPM_ORD_GetRandom:
 			vtpmloginfo(VTPM_LOG_VTPM, "Passthrough: TPM_GetRandom\n");
-			break;
+			return vtpmmgr_handle_getrandom(opaque, tpmcmd);
 		case TPM_ORD_PcrRead:
 			vtpmloginfo(VTPM_LOG_VTPM, "Passthrough: TPM_PcrRead\n");
 			// Quotes also need to be restricted to hide PCR values
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/vtpmmgr.c 4.16.1-1/stubdom/vtpmmgr/vtpmmgr.c
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/vtpmmgr.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/vtpmmgr.c	2022-04-12 12:21:23.000000000 +0000
@@ -67,11 +67,21 @@ int hw_is_tpm2(void)
     return (hardware_version.hw_version == TPM2_HARDWARE) ? 1 : 0;
 }
 
+static int do_shutdown;
+
+void app_shutdown(unsigned int reason)
+{
+    printk("Shutdown requested: %d\n", reason);
+    do_shutdown = 1;
+
+    shutdown_tpmback();
+}
+
 void main_loop(void) {
    tpmcmd_t* tpmcmd;
    uint8_t respbuf[TCPA_MAX_BUFFER_LENGTH];
 
-   while(1) {
+   while (!do_shutdown) {
       /* Wait for requests from a vtpm */
       vtpmloginfo(VTPM_LOG_VTPM, "Waiting for commands from vTPM's:\n");
       if((tpmcmd = tpmback_req_any()) == NULL) {
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/vtpmmgr.h 4.16.1-1/stubdom/vtpmmgr/vtpmmgr.h
--- 4.14.3+32-g9de3671772-1/stubdom/vtpmmgr/vtpmmgr.h	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/stubdom/vtpmmgr/vtpmmgr.h	2022-04-12 12:21:23.000000000 +0000
@@ -53,7 +53,7 @@
 enum {
     TPM1_HARDWARE = 1,
     TPM2_HARDWARE,
-} tpm_version;
+};
 
 struct tpm_hardware_version {
     int hw_version;
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/vtpm-microsecond-duration.patch 4.16.1-1/stubdom/vtpm-microsecond-duration.patch
--- 4.14.3+32-g9de3671772-1/stubdom/vtpm-microsecond-duration.patch	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/stubdom/vtpm-microsecond-duration.patch	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,52 @@
+From 5a510e0afd7c288e3f0fb3523ec749ba1366ad61 Mon Sep 17 00:00:00 2001
+From: Jason Andryuk <jandryuk@gmail.com>
+Date: Sun, 14 Mar 2021 12:42:10 -0400
+Subject: [PATCH 1/2] Use microseconds for timeouts and durations
+
+The timeout and duration fields should be in microseconds according to
+the spec.
+
+TPM_CAP_PROP_TIS_TIMEOUT:
+A 4 element array of UINT32 values each denoting the timeout value in
+microseconds for the following in this order:
+
+TPM_CAP_PROP_DURATION:
+A 3 element array of UINT32 values each denoting the duration value in
+microseconds of the duration of the three classes of commands:
+
+Linux will scale the timeouts up by 1000, but not the durations.  Change
+the units for both sets as appropriate.
+
+Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
+---
+ tpm/tpm_data.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/tpm/tpm_data.c b/tpm/tpm_data.c
+index a3a79ef..bebaf10 100644
+--- a/tpm/tpm_data.c
++++ b/tpm/tpm_data.c
+@@ -67,13 +67,13 @@ static void init_nv_storage(void)
+ static void init_timeouts(void)
+ {
+   /* for the timeouts we use the PC platform defaults */
+-  tpmData.permanent.data.tis_timeouts[0] = 750;
+-  tpmData.permanent.data.tis_timeouts[1] = 2000;
+-  tpmData.permanent.data.tis_timeouts[2] = 750;
+-  tpmData.permanent.data.tis_timeouts[3] = 750;
+-  tpmData.permanent.data.cmd_durations[0] = 1;
+-  tpmData.permanent.data.cmd_durations[1] = 10;
+-  tpmData.permanent.data.cmd_durations[2] = 1000;
++  tpmData.permanent.data.tis_timeouts[0] = 750000;
++  tpmData.permanent.data.tis_timeouts[1] = 2000000;
++  tpmData.permanent.data.tis_timeouts[2] = 750000;
++  tpmData.permanent.data.tis_timeouts[3] = 750000;
++  tpmData.permanent.data.cmd_durations[0] = 1000;
++  tpmData.permanent.data.cmd_durations[1] = 10000;
++  tpmData.permanent.data.cmd_durations[2] = 1000000;
+ }
+ 
+ void tpm_init_data(void)
+-- 
+2.30.2
+
diff -pruN 4.14.3+32-g9de3671772-1/stubdom/xenstorepvh-minios.cfg 4.16.1-1/stubdom/xenstorepvh-minios.cfg
--- 4.14.3+32-g9de3671772-1/stubdom/xenstorepvh-minios.cfg	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/stubdom/xenstorepvh-minios.cfg	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,10 @@
+CONFIG_PARAVIRT=n
+CONFIG_BLKFRONT=n
+CONFIG_NETFRONT=n
+CONFIG_FBFRONT=n
+CONFIG_KBDFRONT=n
+CONFIG_CONSFRONT=n
+CONFIG_XENBUS=n
+CONFIG_LWIP=n
+CONFIG_BALLOON=y
+XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff -pruN 4.14.3+32-g9de3671772-1/SUPPORT.md 4.16.1-1/SUPPORT.md
--- 4.14.3+32-g9de3671772-1/SUPPORT.md	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/SUPPORT.md	2022-04-12 12:21:23.000000000 +0000
@@ -9,13 +9,13 @@ for the definitions of the support statu
 
 # Release Support
 
-    Xen-Version: 4.14
-    Initial-Release: 2020-07-24
-    Supported-Until: 2022-01-24
-    Security-Support-Until: 2023-07-24
+    Xen-Version: 4.16
+    Initial-Release: 2021-12-02
+    Supported-Until: 2023-06-02
+    Security-Support-Until: 2024-12-02
 
 Release Notes
-: <a href="https://wiki.xenproject.org/wiki/Xen_Project_4.14_Release_Notes">RN</a>
+: <a href="https://wiki.xenproject.org/wiki/Xen_Project_4.16_Release_Notes">RN</a>
 
 # Feature Support
 
@@ -38,6 +38,9 @@ supported in this document.
 ### ARM v8
 
     Status: Supported
+    Status, Cortex A57 r0p0-r1p1: Supported, not security supported
+
+For the Cortex A57 r0p0 - r1p1, see Errata 832075.
 
 ## Host hardware support
 
@@ -64,7 +67,8 @@ supported in this document.
     Status, Intel VT-d: Supported
     Status, ARM SMMUv1: Supported, not security supported
     Status, ARM SMMUv2: Supported, not security supported
-    Status, Renesas IPMMU-VMSA: Tech Preview
+    Status, ARM SMMUv3: Tech Preview
+    Status, Renesas IPMMU-VMSA: Supported, not security supported
 
 ### ARM/GICv3 ITS
 
@@ -175,6 +179,14 @@ Support for running qemu-xen device mode
 
     Status: Tech Preview
 
+## Liveupdate of C xenstored daemon
+
+    Status: Tech Preview
+
+## Liveupdate of OCaml xenstored daemon
+
+    Status: Tech Preview
+
 ## Toolstack/3rd party
 
 ### libvirt driver for xl
@@ -237,6 +249,13 @@ Export hypervisor coverage data suitable
 
     Status: Supported, Not security supported
 
+### Processor trace support
+
+Support for using Intel Processor Trace technology to trace guests
+from dom0.
+
+    Status, x86: Tech Preview
+
 ## Memory Management
 
 ### Dynamic memory control
@@ -325,9 +344,10 @@ Currently only single-vcpu domains are s
 A very simple, very static scheduling policy
 that always schedules the same vCPU(s) on the same pCPU(s).
 It is designed for maximum determinism and minimum overhead
-on embedded platforms.
+on embedded platforms and the x86 PV shim.
 
     Status: Experimental
+    Status, x86/shim: Supported
 
 ### NUMA scheduler affinity
 
@@ -413,7 +433,8 @@ Guest-side driver capable of speaking th
 
 Guest-side driver capable of speaking the Xen PV display protocol
 
-    Status, Linux: Supported
+    Status, Linux: Supported (outside of "backend allocation" mode)
+    Status, Linux: Experimental (in "backend allocation" mode)
 
 ### PV Console (frontend)
 
@@ -650,11 +671,19 @@ such as KVM, Hyper-V, Bromium, and so on
 
 ### vPMU
 
-Virtual Performance Management Unit for HVM guests
+Virtual Performance Management Unit
 
-    Status, x86: Supported, Not security supported
+    Status, x86 HVM: Supported, Not security supported
+    Status, ARM: Experimental
+
+On ARM, support for accessing PMU registers from the guests.
+There is no interrupt support and Xen will not save/restore
+the register values on context switches.
+
+Disabled by default.
+On ARM, enable with guest parameter.
+On x86, enable with hypervisor command line option.
 
-Disabled by default (enable with hypervisor command line option).
 This feature is not security supported: see https://xenbits.xen.org/xsa/advisory-163.html
 
 ### Argo: Inter-domain message delivery by hypercall
@@ -689,6 +718,10 @@ to be used in addition to QEMU.
 
 	Status: Experimental
 
+### ARM/IOREQ servers
+
+	Status: Tech Preview
+
 ### ARM/Non-PCI device passthrough
 
     Status: Supported, not security supported
diff -pruN 4.14.3+32-g9de3671772-1/tools/config.h.in 4.16.1-1/tools/config.h.in
--- 4.14.3+32-g9de3671772-1/tools/config.h.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/config.h.in	2022-04-12 12:21:23.000000000 +0000
@@ -84,6 +84,9 @@
 /* Define curses header to use */
 #undef INCLUDE_CURSES_H
 
+/* Header path for INCLUDE_ENDIAN_H */
+#undef INCLUDE_ENDIAN_H
+
 /* Define extfs header to use */
 #undef INCLUDE_EXTFS_H
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/configure 4.16.1-1/tools/configure
--- 4.14.3+32-g9de3671772-1/tools/configure	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/configure	2022-04-12 12:21:23.000000000 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Xen Hypervisor Tools 4.14.
+# Generated by GNU Autoconf 2.69 for Xen Hypervisor Tools 4.16.
 #
 # Report bugs to <xen-devel@lists.xen.org>.
 #
@@ -580,12 +580,12 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Xen Hypervisor Tools'
 PACKAGE_TARNAME='xen'
-PACKAGE_VERSION='4.14'
-PACKAGE_STRING='Xen Hypervisor Tools 4.14'
+PACKAGE_VERSION='4.16'
+PACKAGE_STRING='Xen Hypervisor Tools 4.16'
 PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 PACKAGE_URL='https://www.xen.org/'
 
-ac_unique_file="libxl/libxl.c"
+ac_unique_file="libs/light/libxl.c"
 # Factoring default headers for most tests.
 ac_includes_default="\
 #include <stdio.h>
@@ -643,6 +643,8 @@ PTHREAD_CFLAGS
 EXTFS_LIBS
 system_aio
 zlib
+libzstd_LIBS
+libzstd_CFLAGS
 FETCHER
 FTP
 FALSE
@@ -662,6 +664,7 @@ GREP
 CPP
 pyconfig
 PYTHONPATH
+BASH
 CHECKPOLICY
 XENSTORED
 GO
@@ -679,14 +682,13 @@ OCAMLOPT
 OCAMLLIB
 OCAMLVERSION
 OCAMLC
+ABI_DUMPER
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
 SET_MAKE
 AWK
 IASL
-XGETTEXT
-BASH
 FLEX
 BISON
 PERL
@@ -696,7 +698,6 @@ APPEND_INCLUDES
 PREPEND_LIB
 PREPEND_INCLUDES
 EXTRA_QEMUU_CONFIGURE_ARGS
-ipxe
 qemu_xen_systemd
 qemu_xen_path
 qemu_xen
@@ -704,6 +705,7 @@ rombios
 BCC
 LD86
 AS86
+ipxe
 qemu_traditional
 LINUX_BACKEND_MODULES
 golang
@@ -718,10 +720,7 @@ DEBUG_DIR
 XEN_DUMP_DIR
 XEN_PAGING_DIR
 XEN_LOCK_DIR
-XEN_SCRIPT_DIR
-XEN_CONFIG_DIR
 INITD_DIR
-CONFIG_DIR
 SHAREDIR
 XEN_LIB_DIR
 XEN_RUN_STORED
@@ -733,7 +732,10 @@ LIBEXEC_INC
 LIBEXEC_LIB
 LIBEXEC_BIN
 LIBEXEC
+XEN_SCRIPT_DIR
 CONFIG_LEAF_DIR
+XEN_CONFIG_DIR
+CONFIG_DIR
 XENSTORED_PORT
 XENSTORED_KVA
 FILE_OFFSET_BITS
@@ -799,6 +801,7 @@ enable_largefile
 with_initddir
 with_sysconfig_leaf_dir
 with_libexec_leaf_dir
+with_xen_scriptdir
 with_xen_dumpdir
 with_rundir
 with_debugdir
@@ -812,13 +815,13 @@ enable_seabios
 enable_golang
 with_linux_backend_modules
 enable_qemu_traditional
+enable_ipxe
+with_system_ipxe
 enable_rombios
 with_system_qemu
 with_stubdom_qmp_proxy
 with_system_seabios
 with_system_ovmf
-enable_ipxe
-with_system_ipxe
 with_extra_qemuu_configure_args
 with_xenstored
 enable_systemd
@@ -843,8 +846,6 @@ PYTHON
 PERL
 BISON
 FLEX
-BASH
-XGETTEXT
 AS86
 LD86
 BCC
@@ -858,6 +859,8 @@ glib_CFLAGS
 glib_LIBS
 pixman_CFLAGS
 pixman_LIBS
+libzstd_CFLAGS
+libzstd_LIBS
 LIBNL3_CFLAGS
 LIBNL3_LIBS
 SYSTEMD_CFLAGS
@@ -1412,7 +1415,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Xen Hypervisor Tools 4.14 to adapt to many kinds of systems.
+\`configure' configures Xen Hypervisor Tools 4.16 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1478,7 +1481,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Xen Hypervisor Tools 4.14:";;
+     short | recursive ) echo "Configuration of Xen Hypervisor Tools 4.16:";;
    esac
   cat <<\_ACEOF
 
@@ -1499,12 +1502,12 @@ Optional Features:
   --disable-seabios       Disable SeaBIOS (default is ENABLED)
   --disable-golang        Disable Go tools (default is ENABLED)
   --enable-qemu-traditional
-                          Enable qemu traditional device model, (DEFAULT is on
-                          for Linux or NetBSD x86, otherwise off)
+                          Enable qemu traditional device model, (DEFAULT is
+                          off)
+  --enable-ipxe           Enable in-tree IPXE, (DEFAULT is off, see also
+                          --with-system-ipxe)
   --enable-rombios        Enable ROMBIOS, (DEFAULT is on if qemu-traditional
-                          is enabled, otherwise off)
-  --disable-ipxe          Enable in-tree IPXE, (DEFAULT is on if rombios is
-                          enabled, otherwise off, see also --with-system-ipxe)
+                          or ipxe is enabled, otherwise off)
   --enable-systemd        Enable systemd support (default is DISABLED)
   --enable-9pfs           Explicitly enable 9pfs support in QEMU build
                           (default is to defer to QEMU configure default)
@@ -1523,6 +1526,9 @@ Optional Packages:
                           "default". [sysconfig]
   --with-libexec-leaf-dir=SUBDIR
                           Name of subdirectory in libexecdir to use.
+  --with-xen-scriptdir=DIR
+                          Path to directory for dom0 hotplug scripts.
+                          [SYSCONFDIR/xen/scripts]
   --with-xen-dumpdir=DIR  Path to directory for domU crash dumps.
                           [LOCALSTATEDIR/lib/xen/dump]
   --with-rundir=DIR       Path to directory for runtime data.
@@ -1532,6 +1538,11 @@ Optional Packages:
   --with-linux-backend-modules="mod1 mod2"
                           List of Linux backend module or modalias names to be
                           autoloaded on startup.
+  --with-system-ipxe[=PATH]
+                          Use system supplied IPXE PATH instead of building
+                          and installing our own version, it takes precedence
+                          over --{en,dis}able-ipxe, --without-system-ipxe is
+                          an error
   --with-system-qemu[=PATH]
                           Use system supplied qemu PATH or qemu (taken from
                           $PATH) as qemu-xen device model instead of building
@@ -1545,12 +1556,6 @@ Optional Packages:
   --with-system-ovmf[=PATH]
                           Use system supplied OVMF PATH instead of building
                           and installing our own version
-  --with-system-ipxe[=PATH]
-                          Use system supplied IPXE PATH instead of building
-                          and installing our own version, it takes precedence
-                          over --{en,dis}able-ipxe and is bound by the
-                          presence of rombios, --without-system-ipxe is an
-                          error
   --with-extra-qemuu-configure-args[="--ARG1 ..."]
                           List of additional configure options for upstream
                           qemu
@@ -1589,8 +1594,6 @@ Some influential environment variables:
   PERL        Path to Perl parser
   BISON       Path to Bison parser generator
   FLEX        Path to Flex lexical analyser generator
-  BASH        Path to bash shell
-  XGETTEXT    Path to xgetttext tool
   AS86        Path to as86 tool
   LD86        Path to ld86 tool
   BCC         Path to bcc tool
@@ -1607,6 +1610,10 @@ Some influential environment variables:
   pixman_CFLAGS
               C compiler flags for pixman, overriding pkg-config
   pixman_LIBS linker flags for pixman, overriding pkg-config
+  libzstd_CFLAGS
+              C compiler flags for libzstd, overriding pkg-config
+  libzstd_LIBS
+              linker flags for libzstd, overriding pkg-config
   LIBNL3_CFLAGS
               C compiler flags for LIBNL3, overriding pkg-config
   LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config
@@ -1682,7 +1689,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Xen Hypervisor Tools configure 4.14
+Xen Hypervisor Tools configure 4.16
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2097,7 +2104,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Xen Hypervisor Tools $as_me 4.14, which was
+It was created by Xen Hypervisor Tools $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3883,6 +3890,8 @@ esac
 
 
 
+
+
 test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
 test "x$exec_prefix" = "xNONE" && exec_prefix=${prefix}
 
@@ -3912,6 +3921,12 @@ if test "x$sysconfdir" = 'x${prefix}/etc
     esac
 fi
 
+CONFIG_DIR=$sysconfdir
+
+
+XEN_CONFIG_DIR=$CONFIG_DIR/xen
+
+
 
 # Check whether --with-initddir was given.
 if test "${with_initddir+set}" = set; then :
@@ -3954,6 +3969,17 @@ fi
 
 
 
+# Check whether --with-xen-scriptdir was given.
+if test "${with_xen_scriptdir+set}" = set; then :
+  withval=$with_xen_scriptdir; xen_scriptdir_path=$withval
+else
+  xen_scriptdir_path=$XEN_CONFIG_DIR/scripts
+fi
+
+XEN_SCRIPT_DIR=$xen_scriptdir_path
+
+
+
 # Check whether --with-xen-dumpdir was given.
 if test "${with_xen_dumpdir+set}" = set; then :
   withval=$with_xen_dumpdir; xen_dumpdir_path=$withval
@@ -4018,21 +4044,12 @@ XEN_LIB_DIR=$localstatedir/lib/xen
 SHAREDIR=$prefix/share
 
 
-CONFIG_DIR=$sysconfdir
-
-
 INITD_DIR=$initddir_path
 
 
-XEN_CONFIG_DIR=$CONFIG_DIR/xen
-
-
-XEN_SCRIPT_DIR=$XEN_CONFIG_DIR/scripts
-
-
 case "$host_os" in
 *freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
-*netbsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
+*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
 *) XEN_LOCK_DIR=$localstatedir/lock ;;
 esac
 
@@ -4269,19 +4286,6 @@ LINUX_BACKEND_MODULES="`eval echo $LINUX
 # Check whether --enable-qemu-traditional was given.
 if test "${enable_qemu_traditional+set}" = set; then :
   enableval=$enable_qemu_traditional;
-else
-
-    case "$host_cpu" in
-        i[3456]86|x86_64)
-           enable_qemu_traditional="yes";;
-        *) enable_qemu_traditional="no";;
-    esac
-    case "$host_os" in
-        freebsd*)
-           enable_qemu_traditional="no";;
-    esac
-
-
 fi
 
 if test "x$enable_qemu_traditional" = "xyes"; then :
@@ -4297,12 +4301,57 @@ else
 fi
 
 
+# Check whether --enable-ipxe was given.
+if test "${enable_ipxe+set}" = set; then :
+  enableval=$enable_ipxe;
+else
+
+    if test "x$enable_qemu_traditional" = "xyes"; then :
+
+        enable_ipxe="yes"
+
+else
+
+        enable_ipxe="no"
+
+fi
+
+fi
+
+if test "x$enable_ipxe" = "xno"; then :
+  ipxe=n
+else
+  ipxe=y
+fi
+
+# Check whether --with-system-ipxe was given.
+if test "${with_system_ipxe+set}" = set; then :
+  withval=$with_system_ipxe;
+    case $withval in
+        no) as_fn_error $? "--without-system-ipxe has no effect" "$LINENO" 5 ;;
+        /*)  ipxe_path=$withval; ipxe=n ;;
+        *) as_fn_error $? "IPXE specified, but is not an absolute path" "$LINENO" 5 ;;
+    esac
+
+fi
+
+if test "x$ipxe" = "xy" -o -n "$ipxe_path" ; then :
+
+
+cat >>confdefs.h <<_ACEOF
+#define IPXE_PATH "${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"
+_ACEOF
+
+
+fi
+
+
 # Check whether --enable-rombios was given.
 if test "${enable_rombios+set}" = set; then :
   enableval=$enable_rombios;
 else
 
-    if test "x$enable_qemu_traditional" = "xyes"; then :
+    if test "x$enable_qemu_traditional" = "xyes" -o "x$enable_ipxe" = "xyes"; then :
 
         enable_rombios="yes"
 
@@ -4617,55 +4666,6 @@ _ACEOF
 
 fi
 
-# Check whether --enable-ipxe was given.
-if test "${enable_ipxe+set}" = set; then :
-  enableval=$enable_ipxe;
-     if test "x$enable_ipxe" = "xno"; then :
-  ipxe=n
-else
-  ipxe=y
-fi
-
-else
-
-    if test "x$enable_rombios" = "xno"; then :
-  ipxe=n
-else
-  ipxe=y
-fi
-
-fi
-
-
-# Check whether --with-system-ipxe was given.
-if test "${with_system_ipxe+set}" = set; then :
-  withval=$with_system_ipxe;
-    case $withval in
-        no) as_fn_error $? "--without-system-ipxe has no effect" "$LINENO" 5 ;;
-        /*)  ipxe_path=$withval; ipxe=n ;;
-        *) as_fn_error $? "IPXE specified, but is not an absolute path" "$LINENO" 5 ;;
-    esac
-
-fi
-
-if test "x$ipxe" = "xy" -o -n "$ipxe_path" ; then :
-
-
-    if test "x$enable_rombios" = "xno"; then :
-
-        as_fn_error $? "Rombios is required to use IPXE" "$LINENO" 5
-
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define IPXE_PATH "${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"
-_ACEOF
-
-
-fi
-
-
 
 # Check whether --with-extra-qemuu-configure-args was given.
 if test "${with_extra_qemuu_configure_args+set}" = set; then :
@@ -4717,8 +4717,6 @@ LDFLAGS="$PREPEND_LDFLAGS $LDFLAGS $APPE
 
 
 
-
-
 # Checks for programs.
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -5383,16 +5381,16 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCR
 
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
-# Extract the first word of "bison", so it can be a program name with args.
-set dummy bison; ac_word=$2
+# Extract the first word of "flex", so it can be a program name with args.
+set dummy flex; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_BISON+:} false; then :
+if ${ac_cv_path_FLEX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $BISON in
+  case $FLEX in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_BISON="$BISON" # Let the user override the test with a path.
+  ac_cv_path_FLEX="$FLEX" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5402,7 +5400,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
+    ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -5413,26 +5411,26 @@ IFS=$as_save_IFS
   ;;
 esac
 fi
-BISON=$ac_cv_path_BISON
-if test -n "$BISON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5
-$as_echo "$BISON" >&6; }
+FLEX=$ac_cv_path_FLEX
+if test -n "$FLEX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5
+$as_echo "$FLEX" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "flex", so it can be a program name with args.
-set dummy flex; ac_word=$2
+# Extract the first word of "abi-dumper", so it can be a program name with args.
+set dummy abi-dumper; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_FLEX+:} false; then :
+if ${ac_cv_path_ABI_DUMPER+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $FLEX in
+  case $ABI_DUMPER in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_FLEX="$FLEX" # Let the user override the test with a path.
+  ac_cv_path_ABI_DUMPER="$ABI_DUMPER" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5442,7 +5440,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext"
+    ac_cv_path_ABI_DUMPER="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -5453,10 +5451,10 @@ IFS=$as_save_IFS
   ;;
 esac
 fi
-FLEX=$ac_cv_path_FLEX
-if test -n "$FLEX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5
-$as_echo "$FLEX" >&6; }
+ABI_DUMPER=$ac_cv_path_ABI_DUMPER
+if test -n "$ABI_DUMPER"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ABI_DUMPER" >&5
+$as_echo "$ABI_DUMPER" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -7826,51 +7824,6 @@ fi
 
 if ! $rump; then
 
-# Extract the first word of "xgettext", so it can be a program name with args.
-set dummy xgettext; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_XGETTEXT+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $XGETTEXT in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT="no"
-  ;;
-esac
-fi
-XGETTEXT=$ac_cv_path_XGETTEXT
-if test -n "$XGETTEXT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5
-$as_echo "$XGETTEXT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-if test x"${XGETTEXT}" = x"no"
-then
-    as_fn_error $? "Unable to find xgettext, please install xgettext" "$LINENO" 5
-fi
 case "$host_cpu" in
 i[3456]86|x86_64|aarch64)
     # Extract the first word of "iasl", so it can be a program name with args.
@@ -8747,6 +8700,77 @@ fi
 
 
 
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd" >&5
+$as_echo_n "checking for libzstd... " >&6; }
+
+if test -n "$libzstd_CFLAGS"; then
+    pkg_cv_libzstd_CFLAGS="$libzstd_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_libzstd_CFLAGS=`$PKG_CONFIG --cflags "libzstd" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$libzstd_LIBS"; then
+    pkg_cv_libzstd_LIBS="$libzstd_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_libzstd_LIBS=`$PKG_CONFIG --libs "libzstd" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        libzstd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd" 2>&1`
+        else
+	        libzstd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$libzstd_PKG_ERRORS" >&5
+
+	true
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	true
+else
+	libzstd_CFLAGS=$pkg_cv_libzstd_CFLAGS
+	libzstd_LIBS=$pkg_cv_libzstd_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	zlib="$zlib -DHAVE_ZSTD $libzstd_CFLAGS $libzstd_LIBS"
+fi
+
 
 
 ac_fn_c_check_header_mongrel "$LINENO" "ext2fs/ext2fs.h" "ac_cv_header_ext2fs_ext2fs_h" "$ac_includes_default"
@@ -10022,6 +10046,138 @@ else
 fi
 
 
+if test "x$pvshim" = "xy"; then :
+
+    # Extract the first word of "bison", so it can be a program name with args.
+set dummy bison; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_BISON+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BISON in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BISON="$BISON" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_BISON" && ac_cv_path_BISON="no"
+  ;;
+esac
+fi
+BISON=$ac_cv_path_BISON
+if test -n "$BISON"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5
+$as_echo "$BISON" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+if test x"${BISON}" = x"no"
+then
+    as_fn_error $? "Unable to find bison, please install bison" "$LINENO" 5
+fi
+
+else
+
+    # Extract the first word of "bison", so it can be a program name with args.
+set dummy bison; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_BISON+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BISON in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BISON="$BISON" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+BISON=$ac_cv_path_BISON
+if test -n "$BISON"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5
+$as_echo "$BISON" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+fi
+
+
+ax_found=0
+
+    if test "$ax_found" = "0"; then :
+
+        ac_fn_c_check_header_mongrel "$LINENO" "endian.h" "ac_cv_header_endian_h" "$ac_includes_default"
+if test "x$ac_cv_header_endian_h" = xyes; then :
+
+
+$as_echo "#define INCLUDE_ENDIAN_H <endian.h>" >>confdefs.h
+
+            ax_found=1
+fi
+
+
+
+fi
+
+    if test "$ax_found" = "0"; then :
+
+        ac_fn_c_check_header_mongrel "$LINENO" "sys/endian.h" "ac_cv_header_sys_endian_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_endian_h" = xyes; then :
+
+
+$as_echo "#define INCLUDE_ENDIAN_H <sys/endian.h>" >>confdefs.h
+
+            ax_found=1
+fi
+
+
+
+fi
+
+if test "$ax_found" = "0"; then :
+
+    as_fn_error $? "No header found from list endian.h sys/endian.h" "$LINENO" 5
+
+fi
+
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -10529,7 +10685,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Xen Hypervisor Tools $as_me 4.14, which was
+This file was extended by Xen Hypervisor Tools $as_me 4.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -10592,7 +10748,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Xen Hypervisor Tools config.status 4.14
+Xen Hypervisor Tools config.status 4.16
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/configure.ac 4.16.1-1/tools/configure.ac
--- 4.14.3+32-g9de3671772-1/tools/configure.ac	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/configure.ac	2022-04-12 12:21:23.000000000 +0000
@@ -4,7 +4,7 @@
 AC_PREREQ([2.67])
 AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]),
     [xen-devel@lists.xen.org], [xen], [https://www.xen.org/])
-AC_CONFIG_SRCDIR([libxl/libxl.c])
+AC_CONFIG_SRCDIR([libs/light/libxl.c])
 AC_CONFIG_FILES([
 ../config/Tools.mk
 hotplug/FreeBSD/rc.d/xencommons
@@ -74,6 +74,7 @@ m4_include([../m4/ax_compare_version.m4]
 m4_include([../m4/paths.m4])
 m4_include([../m4/systemd.m4])
 m4_include([../m4/golang.m4])
+m4_include([../m4/header.m4])
 
 AX_XEN_EXPAND_CONFIG()
 
@@ -119,18 +120,7 @@ AC_SUBST(LINUX_BACKEND_MODULES)
 
 AC_ARG_ENABLE([qemu-traditional],
     AS_HELP_STRING([--enable-qemu-traditional],
-                   [Enable qemu traditional device model, (DEFAULT is on for Linux or NetBSD x86, otherwise off)]),,[
-    case "$host_cpu" in
-        i[[3456]]86|x86_64)
-           enable_qemu_traditional="yes";;
-        *) enable_qemu_traditional="no";;
-    esac
-    case "$host_os" in
-        freebsd*)
-           enable_qemu_traditional="no";;
-    esac
-
-])
+                   [Enable qemu traditional device model, (DEFAULT is off)]))
 AS_IF([test "x$enable_qemu_traditional" = "xyes"], [
 AC_DEFINE([HAVE_QEMU_TRADITIONAL], [1], [Qemu traditional enabled])
     qemu_traditional=y],[
@@ -138,10 +128,40 @@ AC_DEFINE([HAVE_QEMU_TRADITIONAL], [1],
 ])
 AC_SUBST(qemu_traditional)
 
+AC_ARG_ENABLE([ipxe],
+    AS_HELP_STRING([--enable-ipxe],
+                   [Enable in-tree IPXE,
+                    (DEFAULT is off, see also --with-system-ipxe)]),,[
+    AS_IF([test "x$enable_qemu_traditional" = "xyes"], [
+        enable_ipxe="yes"
+    ], [
+        enable_ipxe="no"
+    ])
+])
+AS_IF([test "x$enable_ipxe" = "xno"], [ipxe=n], [ipxe=y])
+AC_ARG_WITH([system-ipxe],
+    AS_HELP_STRING([--with-system-ipxe@<:@=PATH@:>@],
+       [Use system supplied IPXE PATH instead of building and installing
+        our own version, it takes precedence over --{en,dis}able-ipxe,
+        --without-system-ipxe is an error]),[
+    case $withval in
+        no) AC_MSG_ERROR([--without-system-ipxe has no effect]) ;;
+        /*)  ipxe_path=$withval; ipxe=n ;;
+        *) AC_MSG_ERROR([IPXE specified, but is not an absolute path]) ;;
+    esac
+],[])
+AS_IF([test "x$ipxe" = "xy" -o -n "$ipxe_path" ], [
+    AC_DEFINE_UNQUOTED([IPXE_PATH],
+                       ["${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"],
+                       [IPXE path])
+])
+AC_SUBST(ipxe)
+
 AC_ARG_ENABLE([rombios],
     AS_HELP_STRING([--enable-rombios],
-                   [Enable ROMBIOS, (DEFAULT is on if qemu-traditional is enabled, otherwise off)]),,[
-    AS_IF([test "x$enable_qemu_traditional" = "xyes"], [
+                   [Enable ROMBIOS, (DEFAULT is on if qemu-traditional or ipxe is enabled,
+                    otherwise off)]),,[
+    AS_IF([test "x$enable_qemu_traditional" = "xyes" -o "x$enable_ipxe" = "xyes"], [
         enable_rombios="yes"
     ], [
         enable_rombios="no"
@@ -239,39 +259,6 @@ AS_IF([test "x$ovmf" = "xy" -o -n "$ovmf
                        [OVMF path])
 ])
 
-AC_ARG_ENABLE([ipxe],
-    AS_HELP_STRING([--disable-ipxe],
-                   [Enable in-tree IPXE, (DEFAULT is on if rombios is enabled,
-                    otherwise off, see also --with-system-ipxe)]),
-    [
-     AS_IF([test "x$enable_ipxe" = "xno"], [ipxe=n], [ipxe=y])
-    ],
-    [
-    AS_IF([test "x$enable_rombios" = "xno"], [ipxe=n], [ipxe=y])
-])
-AC_ARG_WITH([system-ipxe],
-    AS_HELP_STRING([--with-system-ipxe@<:@=PATH@:>@],
-       [Use system supplied IPXE PATH instead of building and installing
-        our own version, it takes precedence over --{en,dis}able-ipxe and is
-        bound by the presence of rombios, --without-system-ipxe is an error]),[
-    case $withval in
-        no) AC_MSG_ERROR([--without-system-ipxe has no effect]) ;;
-        /*)  ipxe_path=$withval; ipxe=n ;;
-        *) AC_MSG_ERROR([IPXE specified, but is not an absolute path]) ;;
-    esac
-],[])
-AS_IF([test "x$ipxe" = "xy" -o -n "$ipxe_path" ], [
-
-    AS_IF([test "x$enable_rombios" = "xno"], [
-        AC_MSG_ERROR([Rombios is required to use IPXE])
-    ], [])
-
-    AC_DEFINE_UNQUOTED([IPXE_PATH],
-                       ["${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"],
-                       [IPXE path])
-])
-AC_SUBST(ipxe)
-
 AC_ARG_WITH([extra-qemuu-configure-args],
     AS_HELP_STRING([--with-extra-qemuu-configure-args@<:@="--ARG1 ..."@:>@],
        [List of additional configure options for upstream qemu]),[
@@ -297,8 +284,6 @@ AC_ARG_VAR([PYTHON], [Path to the Python
 AC_ARG_VAR([PERL], [Path to Perl parser])
 AC_ARG_VAR([BISON], [Path to Bison parser generator])
 AC_ARG_VAR([FLEX], [Path to Flex lexical analyser generator])
-AC_ARG_VAR([BASH], [Path to bash shell])
-AC_ARG_VAR([XGETTEXT], [Path to xgetttext tool])
 AC_ARG_VAR([AS86], [Path to as86 tool])
 AC_ARG_VAR([LD86], [Path to ld86 tool])
 AC_ARG_VAR([BCC], [Path to bcc tool])
@@ -309,8 +294,8 @@ AC_ARG_VAR([AWK], [Path to awk tool])
 AC_PROG_CC
 AC_PROG_MAKE_SET
 AC_PROG_INSTALL
-AC_PATH_PROG([BISON], [bison])
 AC_PATH_PROG([FLEX], [flex])
+AC_PATH_PROG([ABI_DUMPER], [abi-dumper])
 AX_PATH_PROG_OR_FAIL([PERL], [perl])
 AX_PATH_PROG_OR_FAIL([AWK], [awk])
 
@@ -381,7 +366,6 @@ AS_IF([test "$cross_compiling" != yes],
 
 if ! $rump; then
 
-AX_PATH_PROG_OR_FAIL([XGETTEXT], [xgettext])
 dnl as86, ld86, bcc and iasl are only required when the host system is x86*.
 dnl "host" here means the platform on which the hypervisor and tools is
 dnl going to run, not the platform on which we are building (known as
@@ -415,6 +399,8 @@ AC_CHECK_LIB([lzma], [lzma_stream_decode
 AC_CHECK_HEADER([lzo/lzo1x.h], [
 AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"])
 ])
+PKG_CHECK_MODULES([libzstd], [libzstd],
+    [zlib="$zlib -DHAVE_ZSTD $libzstd_CFLAGS $libzstd_LIBS"], [true])
 AC_SUBST(zlib)
 AC_SUBST(system_aio)
 AX_CHECK_EXTFS
@@ -515,5 +501,12 @@ AC_ARG_ENABLE([pvshim],
     esac
 ])
 AC_SUBST(pvshim)
+AS_IF([test "x$pvshim" = "xy"], [
+    AX_PATH_PROG_OR_FAIL([BISON], [bison])
+], [
+    AC_PATH_PROG([BISON], [bison])
+])
+
+AX_FIND_HEADER([INCLUDE_ENDIAN_H], [endian.h sys/endian.h])
 
 AC_OUTPUT()
diff -pruN 4.14.3+32-g9de3671772-1/tools/console/client/main.c 4.16.1-1/tools/console/client/main.c
--- 4.14.3+32-g9de3671772-1/tools/console/client/main.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/console/client/main.c	2022-04-12 12:21:23.000000000 +0000
@@ -325,7 +325,7 @@ int main(int argc, char **argv)
 {
 	struct termios attr;
 	int domid;
-	char *sopt = "hn:";
+	const char *sopt = "hn:";
 	int ch;
 	unsigned int num = 0;
 	int opt_ind=0;
@@ -345,7 +345,7 @@ int main(int argc, char **argv)
 	char *end;
 	console_type type = CONSOLE_INVAL;
 	bool interactive = 0;
-	char *console_names = "serial, pv, vuart";
+	const char *console_names = "serial, pv, vuart";
 
 	while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
 		switch(ch) {
@@ -398,7 +398,7 @@ int main(int argc, char **argv)
 		exit(EINVAL);
 	}
 
-	xs = xs_daemon_open();
+	xs = xs_open(0);
 	if (xs == NULL) {
 		err(errno, "Could not contact XenStore");
 	}
diff -pruN 4.14.3+32-g9de3671772-1/tools/console/daemon/io.c 4.16.1-1/tools/console/daemon/io.c
--- 4.14.3+32-g9de3671772-1/tools/console/daemon/io.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/console/daemon/io.c	2022-04-12 12:21:23.000000000 +0000
@@ -22,6 +22,7 @@
 #include "utils.h"
 #include "io.h"
 #include <xenevtchn.h>
+#include <xenforeignmemory.h>
 #include <xengnttab.h>
 #include <xenstore.h>
 #include <xen/io/console.h>
@@ -49,9 +50,7 @@
 #include <sys/ioctl.h>
 #include <libutil.h>
 #endif
-
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#include <xen-tools/libs.h>
 
 /* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
 #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
@@ -75,13 +74,12 @@ static int log_time_guest_needts = 1;
 static int log_hv_fd = -1;
 
 static xengnttab_handle *xgt_handle = NULL;
+static xenforeignmemory_handle *xfm_handle;
 
 static struct pollfd  *fds;
 static unsigned int current_array_size;
 static unsigned int nr_fds;
 
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 struct buffer {
 	char *data;
 	size_t consumed;
@@ -91,14 +89,14 @@ struct buffer {
 };
 
 struct console {
-	char *ttyname;
+	const char *ttyname;
 	int master_fd;
 	int master_pollfd_idx;
 	int slave_fd;
 	int log_fd;
 	struct buffer buffer;
 	char *xspath;
-	char *log_suffix;
+	const char *log_suffix;
 	int ring_ref;
 	xenevtchn_handle *xce_handle;
 	int xce_pollfd_idx;
@@ -113,9 +111,9 @@ struct console {
 };
 
 struct console_type {
-	char *xsname;
-	char *ttyname;
-	char *log_suffix;
+	const char *xsname;
+	const char *ttyname;
+	const char *log_suffix;
 	bool optional;
 	bool use_gnttab;
 };
@@ -679,7 +677,7 @@ static void console_unmap_interface(stru
 	if (xgt_handle && con->ring_ref == -1)
 		xengnttab_unmap(xgt_handle, con->interface, 1);
 	else
-		munmap(con->interface, XC_PAGE_SIZE);
+		xenforeignmemory_unmap(xfm_handle, con->interface, 1);
 	con->interface = NULL;
 	con->ring_ref = -1;
 }
@@ -726,11 +724,12 @@ static int console_create_ring(struct co
 		con->ring_ref = -1;
 	}
 	if (!con->interface) {
+		xen_pfn_t pfn = ring_ref;
+
 		/* Fall back to xc_map_foreign_range */
-		con->interface = xc_map_foreign_range(
-			xc, dom->domid, XC_PAGE_SIZE,
-			PROT_READ|PROT_WRITE,
-			(unsigned long)ring_ref);
+		con->interface = xenforeignmemory_map(
+			xfm_handle, dom->domid,	PROT_READ|PROT_WRITE, 1,
+			&pfn, NULL);
 		if (con->interface == NULL) {
 			err = EINVAL;
 			goto out;
@@ -817,7 +816,8 @@ static int console_init(struct console *
 	int err = -1;
 	struct timespec ts;
 	struct console_type **con_type = (struct console_type **)data;
-	char *xsname, *xspath;
+	const char *xsname;
+	char *xspath;
 
 	if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
 		dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d",
@@ -839,7 +839,7 @@ static int console_init(struct console *
 	con->log_suffix = (*con_type)->log_suffix;
 	con->optional = (*con_type)->optional;
 	con->use_gnttab = (*con_type)->use_gnttab;
-	xsname = (char *)(*con_type)->xsname;
+	xsname = (*con_type)->xsname;
 	xspath = xs_get_domain_path(xs, dom->domid);
 	s = realloc(xspath, strlen(xspath) +
 		    strlen(xsname) + 1);
@@ -1344,6 +1344,14 @@ void handle_io(void)
 		      errno, strerror(errno));
 	}
 
+	xfm_handle = xenforeignmemory_open(NULL, 0);
+	if (xfm_handle == NULL) {
+		dolog(LOG_ERR,
+		      "Failed to open xen foreign memory handle: %d (%s)",
+		      errno, strerror(errno));
+		goto out;
+	}
+
 	enum_domains();
 
 	for (;;) {
@@ -1465,6 +1473,10 @@ void handle_io(void)
 		xengnttab_close(xgt_handle);
 		xgt_handle = NULL;
 	}
+	if (xfm_handle != NULL) {
+		xenforeignmemory_close(xfm_handle);
+		xfm_handle = NULL;
+	}
 	log_hv_evtchn = -1;
 }
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/console/daemon/utils.c 4.16.1-1/tools/console/daemon/utils.c
--- 4.14.3+32-g9de3671772-1/tools/console/daemon/utils.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/console/daemon/utils.c	2022-04-12 12:21:23.000000000 +0000
@@ -104,7 +104,7 @@ void daemonize(const char *pidfile)
 bool xen_setup(void)
 {
 	
-	xs = xs_daemon_open();
+	xs = xs_open(0);
 	if (xs == NULL) {
 		dolog(LOG_ERR,
 		      "Failed to contact xenstore (%m).  Is it running?");
@@ -131,7 +131,7 @@ bool xen_setup(void)
 
  out:
 	if (xs)
-		xs_daemon_close(xs);
+		xs_close(xs);
 	if (xc)
 		xc_interface_close(xc);
 	return false;
diff -pruN 4.14.3+32-g9de3671772-1/tools/console/Makefile 4.16.1-1/tools/console/Makefile
--- 4.14.3+32-g9de3671772-1/tools/console/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/console/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -29,9 +29,9 @@ clean:
 distclean: clean
 
 daemon/main.o: daemon/_paths.h
-daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CONSOLE_CFLAGS-y)
+daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) $(CFLAGS_libxenforeignmemory) $(CONSOLE_CFLAGS-y)
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxenforeignmemory) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS)
 
 client/main.o: client/_paths.h
 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
diff -pruN 4.14.3+32-g9de3671772-1/tools/debugger/gdbsx/xg/Makefile 4.16.1-1/tools/debugger/gdbsx/xg/Makefile
--- 4.14.3+32-g9de3671772-1/tools/debugger/gdbsx/xg/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/debugger/gdbsx/xg/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -12,7 +12,7 @@ CFLAGS += $(CFLAGS_xeninclude)
 all: build
 
 .PHONY: build
-build: xen-headers xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile
+build: xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile
 # build: mk-symlinks xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile
 # build: mk-symlinks xg_all.a
 
@@ -21,9 +21,6 @@ xg_all.a: $(XG_OBJS) Makefile $(XG_HDRS)
 #	$(LD) -b elf32-i386 $(LDFLAGS) -r -o $@ $^
 #	$(CC) -m32 -c -o $@ $^
 
-xen-headers:
-	$(MAKE) -C ../../../include
-
 # xg_main.o: xg_main.c Makefile $(XG_HDRS)
 #$(CC) -c $(CFLAGS) -o $@ $<
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/debugger/gdbsx/xg/xg_main.c 4.16.1-1/tools/debugger/gdbsx/xg/xg_main.c
--- 4.14.3+32-g9de3671772-1/tools/debugger/gdbsx/xg/xg_main.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/debugger/gdbsx/xg/xg_main.c	2022-04-12 12:21:23.000000000 +0000
@@ -126,11 +126,11 @@ xg_init()
     int flags, saved_errno;
 
     XGTRC("E\n");
-    if ((_dom0_fd=open("/dev/xen/privcmd", O_RDWR)) == -1) {
-        if ((_dom0_fd=open("/proc/xen/privcmd", O_RDWR)) == -1) {
-            perror("Failed to open /dev/xen/privcmd or /proc/xen/privcmd\n");
-            return -1;
-        }
+    if ((_dom0_fd=open("/dev/xen/privcmd", O_RDWR)) == -1 &&
+        (_dom0_fd=open("/proc/xen/privcmd", O_RDWR)) == -1 &&
+        (_dom0_fd=open("/kern/xen/privcmd", O_RDWR)) == -1) {
+        perror("Failed to open privcmd\n");
+        return -1;
     }
     /* Although we return the file handle as the 'xc handle' the API
      * does not specify / guarentee that this integer is in fact
diff -pruN 4.14.3+32-g9de3671772-1/tools/debugger/kdd/kdd.c 4.16.1-1/tools/debugger/kdd/kdd.c
--- 4.14.3+32-g9de3671772-1/tools/debugger/kdd/kdd.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/debugger/kdd/kdd.c	2022-04-12 12:21:23.000000000 +0000
@@ -67,7 +67,7 @@ typedef struct {
     uint32_t build;             
     int w64;
     int mp;
-    char *name;
+    const char *name;
     uint64_t base;              /* KernBase: start looking here */
     uint32_t range;             /* |         and search an area this size */
     uint32_t version;           /* +-> NtBuildNumber */
@@ -237,7 +237,7 @@ static size_t blocking_write(int fd, con
 }
 
 /* Dump the contents of a complete serial packet into a log file. */
-static void kdd_log_pkt(kdd_state *s, char *name, kdd_pkt *p)
+static void kdd_log_pkt(kdd_state *s, const char *name, kdd_pkt *p)
 {
     uint32_t sum = 0;
     unsigned int i, j;
@@ -288,9 +288,6 @@ static void kdd_log_pkt(kdd_state *s, ch
  *  Memory access: virtual addresses and syntactic sugar.
  */
 
-#define PAGE_SHIFT (12)
-#define PAGE_SIZE (1ULL << PAGE_SHIFT) 
-
 static uint32_t kdd_read_physical(kdd_state *s, uint64_t addr, 
                                   uint32_t len, void *buf)
 {
@@ -352,7 +349,7 @@ static uint64_t v2p(kdd_state *s, int cp
 
     /* Walk the appropriate number of levels */
     for (i = levels; i > 0; i--) {
-        shift = PAGE_SHIFT + bits * (i-1);
+        shift = KDD_PAGE_SHIFT + bits * (i-1);
         mask = ((1ULL << bits) - 1) << shift;
         offset = ((va & mask) >> shift) * width;
         KDD_DEBUG(s, "level %i: mask 0x%16.16"PRIx64" pa 0x%16.16"PRIx64
@@ -364,12 +361,12 @@ static uint64_t v2p(kdd_state *s, int cp
             return -1ULL; // Not present
         pa = entry & 0x000ffffffffff000ULL;
         if (pse && (i == 2) && (entry & 0x80)) { // Superpage
-            mask = ((1ULL << (PAGE_SHIFT + bits)) - 1);
+            mask = ((1ULL << (KDD_PAGE_SHIFT + bits)) - 1);
             return (pa & ~mask) + (va & mask);
         }
     }
 
-    return pa + (va & (PAGE_SIZE - 1));
+    return pa + (va & (KDD_PAGE_SIZE - 1));
 }
 
 static uint32_t kdd_access_virtual(kdd_state *s, int cpuid, uint64_t addr,
@@ -380,7 +377,7 @@ static uint32_t kdd_access_virtual(kdd_s
     
     /* Process one page at a time */
     while (len > 0) {
-        chunk = PAGE_SIZE - (addr & (PAGE_SIZE - 1));
+        chunk = KDD_PAGE_SIZE - (addr & (KDD_PAGE_SIZE - 1));
         if (chunk > len) 
             chunk = len;
         pa = v2p(s, cpuid, addr);
@@ -504,8 +501,8 @@ static int check_os(kdd_state *s)
  * @return -1 on failure to find the section name
  * @return 0 on success
  */
-static int get_pe64_sections(kdd_state *s, uint64_t filebase, char *sectname,
-        uint64_t *vaddr, uint32_t *vsize)
+static int get_pe64_sections(kdd_state *s, uint64_t filebase,
+        const char *sectname, uint64_t *vaddr, uint32_t *vsize)
 {
     uint64_t pe_hdr = 0;
     uint64_t sect_start = 0;
@@ -591,7 +588,7 @@ static void get_os_info_64(kdd_state *s)
     uint64_t dbgkd_addr;
     DBGKD_GET_VERSION64 dbgkd_get_version64;
     /* Maybe 1GB is too big for the limit to search? */
-    uint32_t search_limit = (1024 * 1024 * 1024) / PAGE_SIZE; /*1GB/PageSize*/
+    uint32_t search_limit = (1024 * 1024 * 1024) / KDD_PAGE_SIZE; /*1GB/PageSize*/
     uint64_t efer;
 
     /* if we are not in 64-bit mode, fail */
@@ -620,7 +617,7 @@ static void get_os_info_64(kdd_state *s)
      * in 1GB range above the current page base address
      */
 
-    base = idt0_addr & ~(PAGE_SIZE - 1);
+    base = idt0_addr & ~(KDD_PAGE_SIZE - 1);
 
     while (search_limit) {
         uint16_t val;
@@ -633,7 +630,7 @@ static void get_os_info_64(kdd_state *s)
         if (val == MZ_HEADER) // MZ
             break;
 
-        base -= PAGE_SIZE;
+        base -= KDD_PAGE_SIZE;
         search_limit -= 1;
     }
 
@@ -720,7 +717,7 @@ static void find_os(kdd_state *s)
         /* Try each page in the potential range of kernel load addresses */
         for (limit = s->os.base + s->os.range;
              s->os.base <= limit;
-             s->os.base += PAGE_SIZE)
+             s->os.base += KDD_PAGE_SIZE)
             if (check_os(s))
                 return;
     }
@@ -781,7 +778,7 @@ static void kdd_send_cmd(kdd_state *s, u
 }
 
 /* Cause the client to print a string */
-static void kdd_send_string(kdd_state *s, char *fmt, ...)
+static void kdd_send_string(kdd_state *s, const char *fmt, ...)
 {
     uint32_t len = 0xffff - sizeof (kdd_msg);
     char *buf = (char *) s->txb + sizeof (kdd_hdr) + sizeof (kdd_msg);
diff -pruN 4.14.3+32-g9de3671772-1/tools/debugger/kdd/kdd.h 4.16.1-1/tools/debugger/kdd/kdd.h
--- 4.14.3+32-g9de3671772-1/tools/debugger/kdd/kdd.h	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/debugger/kdd/kdd.h	2022-04-12 12:21:23.000000000 +0000
@@ -39,6 +39,13 @@
 
 #define PACKED __attribute__((packed))
 
+/* We define our page related constants here in order to specifically
+ * avoid using the Xen page macros (this is a restriction for the code
+ * in kdd.c which should not include any Xen headers) and to add
+ * consistency for code in both kdd.c and kdd-xen.c. */
+#define KDD_PAGE_SHIFT 12
+#define KDD_PAGE_SIZE (1U << KDD_PAGE_SHIFT)
+
 /*****************************************************************************
  * Serial line protocol: Sender sends a 16-byte header with an optional
  * payload following it.  Receiver responds to each packet with an
diff -pruN 4.14.3+32-g9de3671772-1/tools/debugger/kdd/kdd-xen.c 4.16.1-1/tools/debugger/kdd/kdd-xen.c
--- 4.14.3+32-g9de3671772-1/tools/debugger/kdd/kdd-xen.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/debugger/kdd/kdd-xen.c	2022-04-12 12:21:23.000000000 +0000
@@ -48,9 +48,6 @@
 
 #define MAPSIZE 4093 /* Prime */
 
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1U << PAGE_SHIFT)
-
 struct kdd_guest {
     struct xentoollog_logger xc_log; /* Must be first for xc log callbacks */
     xc_interface *xc_handle;
@@ -72,7 +69,7 @@ static void flush_maps(kdd_guest *g)
     int i;
     for (i = 0; i < MAPSIZE; i++) {
         if (g->maps[i] != NULL)
-            munmap(g->maps[i], PAGE_SIZE);
+            munmap(g->maps[i], KDD_PAGE_SIZE);
         g->maps[i] = NULL;
     }
 }
@@ -490,13 +487,13 @@ static uint32_t kdd_access_physical_page
     uint32_t map_pfn, map_offset;
     uint8_t *map;
 
-    map_pfn = (addr >> PAGE_SHIFT);
-    map_offset = addr & (PAGE_SIZE - 1);
+    map_pfn = (addr >> KDD_PAGE_SHIFT);
+    map_offset = addr & (KDD_PAGE_SIZE - 1);
 
     /* Evict any mapping of the wrong frame from our slot */ 
     if (g->pfns[map_pfn % MAPSIZE] != map_pfn
         && g->maps[map_pfn % MAPSIZE] != NULL) {
-        munmap(g->maps[map_pfn % MAPSIZE], PAGE_SIZE);
+        munmap(g->maps[map_pfn % MAPSIZE], KDD_PAGE_SIZE);
         g->maps[map_pfn % MAPSIZE] = NULL;
     }
     g->pfns[map_pfn % MAPSIZE] = map_pfn;
@@ -507,7 +504,7 @@ static uint32_t kdd_access_physical_page
     else {
         map = xc_map_foreign_range(g->xc_handle,
                                    g->domid,
-                                   PAGE_SIZE,
+                                   KDD_PAGE_SIZE,
                                    PROT_READ|PROT_WRITE,
                                    map_pfn);
 
@@ -533,7 +530,7 @@ uint32_t kdd_access_physical(kdd_guest *
 {
     uint32_t chunk, rv, done = 0;
     while (len > 0) {
-        chunk = PAGE_SIZE - (addr & (PAGE_SIZE - 1));
+        chunk = KDD_PAGE_SIZE - (addr & (KDD_PAGE_SIZE - 1));
         if (chunk > len) 
             chunk = len;
         rv = kdd_access_physical_page(g, addr, chunk, buf, write);
diff -pruN 4.14.3+32-g9de3671772-1/tools/examples/Makefile 4.16.1-1/tools/examples/Makefile
--- 4.14.3+32-g9de3671772-1/tools/examples/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/examples/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -3,10 +3,10 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen configuration dir and configs to go there.
 XEN_READMES = README
-XEN_READMES += README.incompatibilities
 
 XEN_CONFIGS += xlexample.hvm
 XEN_CONFIGS += xlexample.pvlinux
+XEN_CONFIGS += xlexample.pvhlinux
 XEN_CONFIGS += xl.conf
 XEN_CONFIGS += cpupool
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/examples/README.incompatibilities 4.16.1-1/tools/examples/README.incompatibilities
--- 4.14.3+32-g9de3671772-1/tools/examples/README.incompatibilities	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/examples/README.incompatibilities	1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-Command Incompatibilities
-=========================
-
-Known incompatibilities with various commands on various distributions, and
-the workarounds we use.
-
-
-brctl
------
-
-brctl show <bridge> fails on SLES9 SP2.  Workaround is to use brctl show
-without arguments, and grep, though this would be difficult were you to need
-to check for a specific bridge-interface pair, since brctl does not show the 
-bridge name on every line.
-
-
-ifup / ifdown
--------------
-
-SuSE requires an extra parameter to ifup, which is created by calling getcfg
-appropriately.  See xen-network-common.sh for details.
-
-Gentoo doesn't have ifup/ifdown; appropriate alternatives are defined in
-xen-network-common.sh.
-
-
-ip
---
-
-Newer ip commands (from iproute2) do not accept the abbreviated syntax "ip r a
-..." etc.  "ip route add ..." must be used instead.
-
-
-sed
----
-
-\s is not supported in regexps on Debian etch (sed 4.1.2), Ubuntu 4.10.  We
-hand-craft character classes instead.
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/etherboot/Makefile 4.16.1-1/tools/firmware/etherboot/Makefile
--- 4.14.3+32-g9de3671772-1/tools/firmware/etherboot/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/etherboot/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -10,7 +10,8 @@ else
 IPXE_GIT_URL ?= git://git.ipxe.org/ipxe.git
 endif
 
-IPXE_GIT_TAG := 1dd56dbd11082fb622c2ed21cfaced4f47d798a6
+# put an updated tar.gz on xenbits after changes to this variable
+IPXE_GIT_TAG := 3c040ad387099483102708bb1839110bc788cefb
 
 IPXE_TARBALL_URL ?= $(XEN_EXTFILES_URL)/ipxe-git-$(IPXE_GIT_TAG).tar.gz
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/32bitbios_support.c 4.16.1-1/tools/firmware/hvmloader/32bitbios_support.c
--- 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/32bitbios_support.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/hvmloader/32bitbios_support.c	2022-04-12 12:21:23.000000000 +0000
@@ -20,11 +20,8 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <inttypes.h>
-#include <elf.h>
-#ifdef __sun__
-#include <sys/machelf.h>
-#endif
+#include <stdint.h>
+#include <xen/libelf/elfstructs.h>
 
 #include "util.h"
 #include "config.h"
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/cacheattr.c 4.16.1-1/tools/firmware/hvmloader/cacheattr.c
--- 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/cacheattr.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/hvmloader/cacheattr.c	2022-04-12 12:21:23.000000000 +0000
@@ -98,12 +98,12 @@ void cacheattr_init(void)
     {
         uint64_t base = pci_mem_start, size;
 
-        for ( i = 0; !(base >> 32) && (i < nr_var_ranges); i++ )
+        for ( i = 0; (base != pci_mem_end) && (i < nr_var_ranges); i++ )
         {
             size = PAGE_SIZE;
             while ( !(base & size) )
                 size <<= 1;
-            while ( ((base + size) < base) || ((base + size - 1) >> 32) )
+            while ( ((base + size) < base) || ((base + size) > pci_mem_end) )
                 size >>= 1;
 
             wrmsr(MSR_MTRRphysBase(i), base);
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/util.c 4.16.1-1/tools/firmware/hvmloader/util.c
--- 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/util.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/hvmloader/util.c	2022-04-12 12:21:23.000000000 +0000
@@ -722,14 +722,14 @@ static void __attribute__((noreturn)) cr
         asm volatile ( "hlt" );
 }
 
-void __assert_failed(char *assertion, char *file, int line)
+void __assert_failed(const char *assertion, const char *file, int line)
 {
     printf("*** HVMLoader assertion '%s' failed at %s:%d\n",
            assertion, file, line);
     crash();
 }
 
-void __bug(char *file, int line)
+void __bug(const char *file, int line)
 {
     printf("*** HVMLoader bug at %s:%d\n", file, line);
     crash();
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/util.h 4.16.1-1/tools/firmware/hvmloader/util.h
--- 4.14.3+32-g9de3671772-1/tools/firmware/hvmloader/util.h	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/hvmloader/util.h	2022-04-12 12:21:23.000000000 +0000
@@ -34,11 +34,11 @@ enum {
 #undef NULL
 #define NULL ((void*)0)
 
-void __assert_failed(char *assertion, char *file, int line)
+void __assert_failed(const char *assertion, const char *file, int line)
     __attribute__((noreturn));
 #define ASSERT(p) \
     do { if (!(p)) __assert_failed(#p, __FILE__, __LINE__); } while (0)
-void __bug(char *file, int line) __attribute__((noreturn));
+void __bug(const char *file, int line) __attribute__((noreturn));
 #define BUG() __bug(__FILE__, __LINE__)
 #define BUG_ON(p) do { if (p) BUG(); } while (0)
 #define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
@@ -133,7 +133,7 @@ static inline void cpu_relax(void)
 #define barrier() asm volatile ( "" : : : "memory" )
 #define rmb()     barrier()
 #define wmb()     barrier()
-#define mb()      asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define mb()      asm volatile ( "lock addl $0, -4(%%esp)" ::: "memory" )
 
 /*
  * Divide a 64-bit dividend by a 32-bit divisor.
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/include/stdarg.h 4.16.1-1/tools/firmware/include/stdarg.h
--- 4.14.3+32-g9de3671772-1/tools/firmware/include/stdarg.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/firmware/include/stdarg.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,10 @@
+#ifndef _STDARG_H_
+#define _STDARG_H_
+
+typedef __builtin_va_list va_list;
+#define va_copy(dest, src) __builtin_va_copy(dest, src)
+#define va_start(ap, last) __builtin_va_start(ap, last)
+#define va_end(ap) __builtin_va_end(ap)
+#define va_arg __builtin_va_arg
+
+#endif
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/include/stdbool.h 4.16.1-1/tools/firmware/include/stdbool.h
--- 4.14.3+32-g9de3671772-1/tools/firmware/include/stdbool.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/firmware/include/stdbool.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,9 @@
+#ifndef _STDBOOL_H_
+#define _STDBOOL_H_
+
+#define bool _Bool
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+
+#endif
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/include/stddef.h 4.16.1-1/tools/firmware/include/stddef.h
--- 4.14.3+32-g9de3671772-1/tools/firmware/include/stddef.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/firmware/include/stddef.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,10 @@
+#ifndef _STDDEF_H_
+#define _STDDEF_H_
+
+typedef __SIZE_TYPE__ size_t;
+
+#define NULL ((void*)0)
+
+#define offsetof(t, m) __builtin_offsetof(t, m)
+
+#endif
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/include/stdint.h 4.16.1-1/tools/firmware/include/stdint.h
--- 4.14.3+32-g9de3671772-1/tools/firmware/include/stdint.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/firmware/include/stdint.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,39 @@
+#ifndef _STDINT_H_
+#define _STDINT_H_
+
+#if defined(__LP64__) || defined(__P64__)
+#error "32bit only header"
+#endif
+
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+
+typedef unsigned int uint32_t;
+typedef signed int int32_t;
+
+typedef unsigned long long uint64_t;
+typedef signed long long int64_t;
+
+#define INT8_MIN        (-0x7f-1)
+#define INT16_MIN       (-0x7fff-1)
+#define INT32_MIN       (-0x7fffffff-1)
+#define INT64_MIN       (-0x7fffffffffffffffll-1)
+
+#define INT8_MAX        0x7f
+#define INT16_MAX       0x7fff
+#define INT32_MAX       0x7fffffff
+#define INT64_MAX       0x7fffffffffffffffll
+
+#define UINT8_MAX       0xff
+#define UINT16_MAX      0xffff
+#define UINT32_MAX      0xffffffffu
+#define UINT64_MAX      0xffffffffffffffffull
+
+typedef uint32_t uintptr_t;
+
+#define UINTPTR_MAX     UINT32_MAX
+
+#endif
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/Makefile 4.16.1-1/tools/firmware/Makefile
--- 4.14.3+32-g9de3671772-1/tools/firmware/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -72,7 +72,7 @@ ifeq ($(CONFIG_OVMF),y)
 	rm -f $(INST_DIR)/ovmf.bin
 endif
 ifeq ($(CONFIG_IPXE),y)
-	rm -r $(INST_DIR)/ipxe.bin
+	rm -f $(INST_DIR)/ipxe.bin
 endif
 ifeq ($(CONFIG_PV_SHIM),y)
 	rm -f $(INST_DIR)/xen-shim
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/ovmf-makefile 4.16.1-1/tools/firmware/ovmf-makefile
--- 4.14.3+32-g9de3671772-1/tools/firmware/ovmf-makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/ovmf-makefile	2022-04-12 12:21:23.000000000 +0000
@@ -19,7 +19,7 @@ build:
 	if test -e .git ; then $(GIT) submodule update --init --recursive ; fi
 	set -ex; \
 	if test -e OvmfPkg/OvmfXen.dsc; then \
-	  OvmfPkg/build.sh -a X64 -b $(TARGET) -n 4 -p OvmfPkg/OvmfXen.dsc; \
+	  OvmfPkg/build.sh -a X64 -b $(TARGET) -p OvmfPkg/OvmfXen.dsc; \
 	  cp Build/OvmfXen/$(TARGET)_GCC*/FV/OVMF.fd ovmf.bin; \
 	else \
 	  OvmfPkg/build.sh -a X64 -b $(TARGET) -n 4; \
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/rombios/32bit/rombios_compat.h 4.16.1-1/tools/firmware/rombios/32bit/rombios_compat.h
--- 4.14.3+32-g9de3671772-1/tools/firmware/rombios/32bit/rombios_compat.h	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/rombios/32bit/rombios_compat.h	2022-04-12 12:21:23.000000000 +0000
@@ -8,9 +8,7 @@
 
 #define ADDR_FROM_SEG_OFF(seg, off)  (void *)((((uint32_t)(seg)) << 4) + (off))
 
-typedef unsigned char uint8_t;
-typedef unsigned short int uint16_t;
-typedef unsigned int uint32_t;
+#include <stdint.h>
 
 typedef uint8_t  Bit8u;
 typedef uint16_t Bit16u;
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/rombios/rombios.c 4.16.1-1/tools/firmware/rombios/rombios.c
--- 4.14.3+32-g9de3671772-1/tools/firmware/rombios/rombios.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/rombios/rombios.c	2022-04-12 12:21:23.000000000 +0000
@@ -2607,7 +2607,7 @@ void ata_detect( )
   write_byte(ebda_seg,&EbdaData->ata.channels[3].irq,11);
 #endif
 #if BX_MAX_ATA_INTERFACES > 4
-#error Please fill the ATA interface informations
+#error Please fill the ATA interface information
 #endif
 
   // Device detection
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/Rules.mk 4.16.1-1/tools/firmware/Rules.mk
--- 4.14.3+32-g9de3671772-1/tools/firmware/Rules.mk	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/Rules.mk	2022-04-12 12:21:23.000000000 +0000
@@ -15,5 +15,24 @@ CFLAGS += -Werror
 
 $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
 
+$(call cc-option-add,CFLAGS,CC,-fcf-protection=none)
+
+# Do not add the .note.gnu.property section to any of the firmware objects: it
+# breaks the rombios binary and is not useful for firmware anyway.
+$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)-mx86-used-note=no)
+
 # Extra CFLAGS suitable for an embedded type of environment.
-CFLAGS += -fno-builtin -msoft-float
+CFLAGS += -ffreestanding -msoft-float
+
+# Use our own set of stand alone headers to build firmware.
+#
+# Ideally using -ffreestanding should be enough, but that relies on the
+# compiler having the right order for include paths (ie: compiler private
+# headers before system ones) or the libc headers having proper arch-agnostic
+# freestanding support. This is not the case in Alpine at least which searches
+# system headers before compiler ones and has arch-specific libc headers. This
+# has been reported upstream:
+# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
+# In the meantime (and for resilience against broken systems) use our own set
+# of headers that provide what's needed for the firmware build.
+CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include
diff -pruN 4.14.3+32-g9de3671772-1/tools/firmware/xen-dir/Makefile 4.16.1-1/tools/firmware/xen-dir/Makefile
--- 4.14.3+32-g9de3671772-1/tools/firmware/xen-dir/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/firmware/xen-dir/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -15,9 +15,19 @@ DEP_DIRS=$(foreach i, $(LINK_DIRS), $(XE
 DEP_FILES=$(foreach i, $(LINK_FILES), $(XEN_ROOT)/$(i))
 
 # Exclude some intermediate files and final build products
-LINK_EXCLUDES := '*.[isoa]' '.*.d' '.*.d2' '.config'
-LINK_EXCLUDES += '*.map' 'xen' 'xen.gz' 'xen.efi' 'xen-syms'
-LINK_EXCLUDES += '.*.tmp'
+LINK_EXCLUDES := '*.[isoa]' '*.bin' '*.chk' '*.lnk' '*.gz' '.*'
+LINK_EXCLUDES += lexer.lex.? parser.tab.? conf
+LINK_EXCLUDES += asm-offsets.h asm-macros.h compile.h '*-autogen.h'
+LINK_EXCLUDES += mkelf32 mkreloc symbols config_data.S xen.lds efi.lds
+LINK_EXCLUDES += '*.map' xen xen.gz xen.efi xen-syms check.efi
+
+# To exclude full subtrees or individual files of not sufficiently specific
+# names, regular expressions are used:
+LINK_EXCLUDE_PATHS := xen/include/compat/.*
+LINK_EXCLUDE_PATHS += xen/include/config/.*
+LINK_EXCLUDE_PATHS += xen/include/generated/.*
+LINK_EXCLUDE_PATHS += xen/arch/x86/boot/reloc[.]S
+LINK_EXCLUDE_PATHS += xen/arch/x86/boot/cmdline[.]S
 
 # This is all a giant mess and doesn't really work.
 #
@@ -32,9 +42,10 @@ LINK_EXCLUDES += '.*.tmp'
 # support easy development of the shim, but has a side effect of clobbering
 # the already-built shim.
 #
-# $(LINK_EXCLUDES) should be set such that a parallel build of shim and xen/
-# doesn't cause a subsequent `make install` to decide to regenerate the
-# linkfarm.  This means that all final build artefacts must be excluded.
+# $(LINK_EXCLUDES) and $(LINK_EXCLUDE_DIRS) should be set such that a parallel
+# build of shim and xen/ doesn't cause a subsequent `make install` to decide to
+# regenerate the linkfarm.  This means that all intermediate and final build
+# artefacts must be excluded.
 linkfarm.stamp: $(DEP_DIRS) $(DEP_FILES) FORCE
 	mkdir -p $(D)
 	rm -f linkfarm.stamp.tmp
@@ -46,7 +57,8 @@ linkfarm.stamp: $(DEP_DIRS) $(DEP_FILES)
 			sed 's,^$(XEN_ROOT)/$(d)/,,g' | xargs mkdir -p .);) \
 	$(foreach d, $(LINK_DIRS), \
 		(cd $(XEN_ROOT); \
-		 find $(d) ! -type l -type f $(addprefix ! -name ,$(LINK_EXCLUDES))) \
+		 find $(d) ! -type l -type f $(addprefix ! -name ,$(LINK_EXCLUDES)) \
+		 | grep -v $(patsubst %,-e '^%$$',$(LINK_EXCLUDE_PATHS))) \
 		 >> linkfarm.stamp.tmp ; ) \
 	$(foreach f, $(LINK_FILES), \
 		echo $(f) >> linkfarm.stamp.tmp ;)
@@ -62,10 +74,10 @@ $(D): linkfarm.stamp
 	$(MAKE) -C $(D)/xen distclean
 
 $(D)/xen/.config: $(D)
-	$(MAKE) -C $(@D) KBUILD_DEFCONFIG=pvshim_defconfig XEN_CONFIG_EXPERT=y defconfig
+	$(MAKE) -C $(@D) KBUILD_DEFCONFIG=pvshim_defconfig defconfig
 
 xen-shim: $(D)/xen/.config
-	$(MAKE) -C $(<D) build XEN_CONFIG_EXPERT=y
+	$(MAKE) -C $(<D) build
 	ln -sf $(D)/xen/xen $@
 	ln -sf $(D)/xen/xen-syms $@-syms
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/flask/policy/Makefile.common 4.16.1-1/tools/flask/policy/Makefile.common
--- 4.14.3+32-g9de3671772-1/tools/flask/policy/Makefile.common	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/flask/policy/Makefile.common	2022-04-12 12:21:23.000000000 +0000
@@ -35,7 +35,7 @@ OUTPUT_POLICY ?= $(BEST_POLICY_VER)
 #
 ########################################
 
-POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(shell $(MAKE) -C $(XEN_ROOT)/xen xenversion --no-print-directory)
+POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(XEN_FULLVERSION)
 POLICY_LOADPATH = /boot
 
 # List of policy versions supported by the hypervisor
diff -pruN 4.14.3+32-g9de3671772-1/tools/flask/policy/modules/xen.if 4.16.1-1/tools/flask/policy/modules/xen.if
--- 4.14.3+32-g9de3671772-1/tools/flask/policy/modules/xen.if	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/flask/policy/modules/xen.if	2022-04-12 12:21:23.000000000 +0000
@@ -59,7 +59,7 @@ define(`create_domain_common', `
 	allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage mmuext_op updatemp };
 	allow $1 $2:grant setup;
 	allow $1 $2:hvm { getparam hvmctl sethvmc
-			setparam nested altp2mhvm altp2mhvm_op dm };
+			setparam altp2mhvm altp2mhvm_op dm };
 ')
 
 # create_domain(priv, target)
diff -pruN 4.14.3+32-g9de3671772-1/tools/fuzz/libelf/libelf-fuzzer.c 4.16.1-1/tools/fuzz/libelf/libelf-fuzzer.c
--- 4.14.3+32-g9de3671772-1/tools/fuzz/libelf/libelf-fuzzer.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/fuzz/libelf/libelf-fuzzer.c	2022-04-12 12:21:23.000000000 +0000
@@ -17,7 +17,8 @@ int LLVMFuzzerTestOneInput(const uint8_t
         return -1;
 
     elf_parse_binary(elf);
-    elf_xen_parse(elf, &parms);
+    elf_xen_parse(elf, &parms, false);
+    elf_xen_parse(elf, &parms, true);
 
     return 0;
 }
diff -pruN 4.14.3+32-g9de3671772-1/tools/golang/xenlight/gengotypes.py 4.16.1-1/tools/golang/xenlight/gengotypes.py
--- 4.14.3+32-g9de3671772-1/tools/golang/xenlight/gengotypes.py	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/golang/xenlight/gengotypes.py	2022-04-12 12:21:23.000000000 +0000
@@ -3,7 +3,14 @@
 import os
 import sys
 
-sys.path.append('{0}/tools/libxl'.format(os.environ['XEN_ROOT']))
+try:
+    sys.path.append(os.environ['LIBXL_SRC_DIR'])
+except:
+    # If we get here, then we expect the 'import idl'
+    # expression to fail. That error is more informative,
+    # so let it happen.
+    pass
+
 import idl
 
 # Go versions of some builtin types.
@@ -152,7 +159,7 @@ def xenlight_golang_define_union(ty = No
     extras = []
 
     interface_name = '{0}_{1}_union'.format(struct_name, ty.keyvar.name)
-    interface_name = xenlight_golang_fmt_name(interface_name, exported=False)
+    interface_name = xenlight_golang_fmt_name(interface_name)
 
     s += 'type {0} interface {{\n'.format(interface_name)
     s += 'is{0}()\n'.format(interface_name)
@@ -334,7 +341,7 @@ def xenlight_golang_union_from_C(ty = No
     field_name = xenlight_golang_fmt_name('{0}_union'.format(keyname))
 
     interface_name = '{0}_{1}_union'.format(struct_name, keyname)
-    interface_name = xenlight_golang_fmt_name(interface_name, exported=False)
+    interface_name = xenlight_golang_fmt_name(interface_name)
 
     cgo_keyname = keyname
     if cgo_keyname in go_keywords:
@@ -397,7 +404,7 @@ def xenlight_golang_union_from_C(ty = No
         s += 'if err := {0}.fromC(xc);'.format(goname)
         s += 'err != nil {{\n return fmt.Errorf("converting field {0}: %v", err)\n}}\n'.format(goname)
 
-        s += 'x.{0} = {1}\n'.format(field_name, goname)
+        s += 'x.{0} = &{1}\n'.format(field_name, goname)
 
     # End switch statement
     s += 'default:\n'
@@ -538,7 +545,7 @@ def xenlight_golang_union_to_C(ty = None
     gokeytype = xenlight_golang_fmt_name(keytype)
 
     interface_name = '{0}_{1}_union'.format(struct_name, keyname)
-    interface_name = xenlight_golang_fmt_name(interface_name, exported=False)
+    interface_name = xenlight_golang_fmt_name(interface_name)
 
     cgo_keyname = keyname
     if cgo_keyname in go_keywords:
@@ -563,7 +570,7 @@ def xenlight_golang_union_to_C(ty = None
         gotype  = xenlight_golang_fmt_name(cgotype)
 
         field_name = xenlight_golang_fmt_name('{0}_union'.format(keyname))
-        s += 'tmp, ok := x.{0}.({1})\n'.format(field_name,gotype)
+        s += 'tmp, ok := x.{0}.(*{1})\n'.format(field_name,gotype)
         s += 'if !ok {\n'
         s += 'return errors.New("wrong type for union key {0}")\n'.format(keyname)
         s += '}\n'
@@ -724,13 +731,11 @@ if __name__ == '__main__':
         name = b.typename
         builtin_type_names[name] = xenlight_golang_fmt_name(name)
 
-    header_comment="""// DO NOT EDIT.
-//
-// This file is generated by:
-// {0}
-//
+    header_comment="""// Code generated by {}. DO NOT EDIT.
+// source: {}
 
-""".format(' '.join(sys.argv))
+""".format(os.path.basename(sys.argv[0]),
+           ' '.join([os.path.basename(a) for a in sys.argv[1:]]))
 
     xenlight_golang_generate_types(types=types,
                                    comment=header_comment)
diff -pruN 4.14.3+32-g9de3671772-1/tools/golang/xenlight/helpers.gen.go 4.16.1-1/tools/golang/xenlight/helpers.gen.go
--- 4.14.3+32-g9de3671772-1/tools/golang/xenlight/helpers.gen.go	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/golang/xenlight/helpers.gen.go	2022-04-12 12:21:23.000000000 +0000
@@ -1,8 +1,5 @@
-// DO NOT EDIT.
-//
-// This file is generated by:
-// gengotypes.py ../../libxl/libxl_types.idl
-//
+// Code generated by gengotypes.py. DO NOT EDIT.
+// source: libxl_types.idl
 
 package xenlight
 
@@ -326,6 +323,7 @@ x.CpuTime = uint64(xc.cpu_time)
 x.VcpuMaxId = uint32(xc.vcpu_max_id)
 x.VcpuOnline = uint32(xc.vcpu_online)
 x.Cpupool = uint32(xc.cpupool)
+x.GpaddrBits = byte(xc.gpaddr_bits)
 x.DomainType = DomainType(xc.domain_type)
 
  return nil}
@@ -358,6 +356,7 @@ xc.cpu_time = C.uint64_t(x.CpuTime)
 xc.vcpu_max_id = C.uint32_t(x.VcpuMaxId)
 xc.vcpu_online = C.uint32_t(x.VcpuOnline)
 xc.cpupool = C.uint32_t(x.Cpupool)
+xc.gpaddr_bits = C.uint8_t(x.GpaddrBits)
 xc.domain_type = C.libxl_domain_type(x.DomainType)
 
  return nil
@@ -436,7 +435,7 @@ var connectionPty ChannelinfoConnectionU
 if err := connectionPty.fromC(xc);err != nil {
  return fmt.Errorf("converting field connectionPty: %v", err)
 }
-x.ConnectionUnion = connectionPty
+x.ConnectionUnion = &connectionPty
 case ChannelConnectionSocket:
 x.ConnectionUnion = nil
 case ChannelConnectionUnknown:
@@ -476,7 +475,7 @@ switch x.Connection{
 case ChannelConnectionUnknown:
 break
 case ChannelConnectionPty:
-tmp, ok := x.ConnectionUnion.(ChannelinfoConnectionUnionPty)
+tmp, ok := x.ConnectionUnion.(*ChannelinfoConnectionUnionPty)
 if !ok {
 return errors.New("wrong type for union key connection")
 }
@@ -1015,12 +1014,14 @@ return fmt.Errorf("converting field Vnum
 }
 x.MaxGrantFrames = uint32(xc.max_grant_frames)
 x.MaxMaptrackFrames = uint32(xc.max_maptrack_frames)
+x.MaxGrantVersion = int(xc.max_grant_version)
 x.DeviceModelVersion = DeviceModelVersion(xc.device_model_version)
 if err := x.DeviceModelStubdomain.fromC(&xc.device_model_stubdomain);err != nil {
 return fmt.Errorf("converting field DeviceModelStubdomain: %v", err)
 }
 x.StubdomainMemkb = uint64(xc.stubdomain_memkb)
 x.StubdomainKernel = C.GoString(xc.stubdomain_kernel)
+x.StubdomainCmdline = C.GoString(xc.stubdomain_cmdline)
 x.StubdomainRamdisk = C.GoString(xc.stubdomain_ramdisk)
 x.DeviceModel = C.GoString(xc.device_model)
 x.DeviceModelSsidref = uint32(xc.device_model_ssidref)
@@ -1097,7 +1098,7 @@ var typeHvm DomainBuildInfoTypeUnionHvm
 if err := typeHvm.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeHvm: %v", err)
 }
-x.TypeUnion = typeHvm
+x.TypeUnion = &typeHvm
 case DomainTypeInvalid:
 x.TypeUnion = nil
 case DomainTypePv:
@@ -1105,18 +1106,25 @@ var typePv DomainBuildInfoTypeUnionPv
 if err := typePv.fromC(xc);err != nil {
  return fmt.Errorf("converting field typePv: %v", err)
 }
-x.TypeUnion = typePv
+x.TypeUnion = &typePv
 case DomainTypePvh:
 var typePvh DomainBuildInfoTypeUnionPvh
 if err := typePvh.fromC(xc);err != nil {
  return fmt.Errorf("converting field typePvh: %v", err)
 }
-x.TypeUnion = typePvh
+x.TypeUnion = &typePvh
 default:
 return fmt.Errorf("invalid union key '%v'", x.Type)}
 x.ArchArm.GicVersion = GicVersion(xc.arch_arm.gic_version)
 x.ArchArm.Vuart = VuartType(xc.arch_arm.vuart)
+if err := x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err != nil {
+return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
+}
 x.Altp2M = Altp2MMode(xc.altp2m)
+x.VmtraceBufKb = int(xc.vmtrace_buf_kb)
+if err := x.Vpmu.fromC(&xc.vpmu);err != nil {
+return fmt.Errorf("converting field Vpmu: %v", err)
+}
 
  return nil}
 
@@ -1336,6 +1344,7 @@ return fmt.Errorf("converting field Vnum
 }
 xc.max_grant_frames = C.uint32_t(x.MaxGrantFrames)
 xc.max_maptrack_frames = C.uint32_t(x.MaxMaptrackFrames)
+xc.max_grant_version = C.int(x.MaxGrantVersion)
 xc.device_model_version = C.libxl_device_model_version(x.DeviceModelVersion)
 if err := x.DeviceModelStubdomain.toC(&xc.device_model_stubdomain); err != nil {
 return fmt.Errorf("converting field DeviceModelStubdomain: %v", err)
@@ -1343,6 +1352,8 @@ return fmt.Errorf("converting field Devi
 xc.stubdomain_memkb = C.uint64_t(x.StubdomainMemkb)
 if x.StubdomainKernel != "" {
 xc.stubdomain_kernel = C.CString(x.StubdomainKernel)}
+if x.StubdomainCmdline != "" {
+xc.stubdomain_cmdline = C.CString(x.StubdomainCmdline)}
 if x.StubdomainRamdisk != "" {
 xc.stubdomain_ramdisk = C.CString(x.StubdomainRamdisk)}
 if x.DeviceModel != "" {
@@ -1426,7 +1437,7 @@ xc.tee = C.libxl_tee_type(x.Tee)
 xc._type = C.libxl_domain_type(x.Type)
 switch x.Type{
 case DomainTypeHvm:
-tmp, ok := x.TypeUnion.(DomainBuildInfoTypeUnionHvm)
+tmp, ok := x.TypeUnion.(*DomainBuildInfoTypeUnionHvm)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -1544,7 +1555,7 @@ hvm.mca_caps = C.uint64_t(tmp.McaCaps)
 hvmBytes := C.GoBytes(unsafe.Pointer(&hvm),C.sizeof_libxl_domain_build_info_type_union_hvm)
 copy(xc.u[:],hvmBytes)
 case DomainTypePv:
-tmp, ok := x.TypeUnion.(DomainBuildInfoTypeUnionPv)
+tmp, ok := x.TypeUnion.(*DomainBuildInfoTypeUnionPv)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -1569,7 +1580,7 @@ return fmt.Errorf("converting field E820
 pvBytes := C.GoBytes(unsafe.Pointer(&pv),C.sizeof_libxl_domain_build_info_type_union_pv)
 copy(xc.u[:],pvBytes)
 case DomainTypePvh:
-tmp, ok := x.TypeUnion.(DomainBuildInfoTypeUnionPvh)
+tmp, ok := x.TypeUnion.(*DomainBuildInfoTypeUnionPvh)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -1591,7 +1602,14 @@ default:
 return fmt.Errorf("invalid union key '%v'", x.Type)}
 xc.arch_arm.gic_version = C.libxl_gic_version(x.ArchArm.GicVersion)
 xc.arch_arm.vuart = C.libxl_vuart_type(x.ArchArm.Vuart)
+if err := x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err != nil {
+return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
+}
 xc.altp2m = C.libxl_altp2m_mode(x.Altp2M)
+xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb)
+if err := x.Vpmu.toC(&xc.vpmu); err != nil {
+return fmt.Errorf("converting field Vpmu: %v", err)
+}
 
  return nil
  }
@@ -2028,6 +2046,7 @@ x.PowerMgmt = bool(xc.power_mgmt)
 x.Permissive = bool(xc.permissive)
 x.Seize = bool(xc.seize)
 x.RdmPolicy = RdmReservePolicy(xc.rdm_policy)
+x.Name = C.GoString(xc.name)
 
  return nil}
 
@@ -2047,6 +2066,8 @@ xc.power_mgmt = C.bool(x.PowerMgmt)
 xc.permissive = C.bool(x.Permissive)
 xc.seize = C.bool(x.Seize)
 xc.rdm_policy = C.libxl_rdm_reserve_policy(x.RdmPolicy)
+if x.Name != "" {
+xc.name = C.CString(x.Name)}
 
  return nil
  }
@@ -2149,7 +2170,7 @@ var typeHostdev DeviceUsbdevTypeUnionHos
 if err := typeHostdev.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeHostdev: %v", err)
 }
-x.TypeUnion = typeHostdev
+x.TypeUnion = &typeHostdev
 default:
 return fmt.Errorf("invalid union key '%v'", x.Type)}
 
@@ -2176,7 +2197,7 @@ xc.port = C.int(x.Port)
 xc._type = C.libxl_usbdev_type(x.Type)
 switch x.Type{
 case UsbdevTypeHostdev:
-tmp, ok := x.TypeUnion.(DeviceUsbdevTypeUnionHostdev)
+tmp, ok := x.TypeUnion.(*DeviceUsbdevTypeUnionHostdev)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -2367,7 +2388,7 @@ var connectionSocket DeviceChannelConnec
 if err := connectionSocket.fromC(xc);err != nil {
  return fmt.Errorf("converting field connectionSocket: %v", err)
 }
-x.ConnectionUnion = connectionSocket
+x.ConnectionUnion = &connectionSocket
 case ChannelConnectionUnknown:
 x.ConnectionUnion = nil
 default:
@@ -2403,7 +2424,7 @@ break
 case ChannelConnectionPty:
 break
 case ChannelConnectionSocket:
-tmp, ok := x.ConnectionUnion.(DeviceChannelConnectionUnionSocket)
+tmp, ok := x.ConnectionUnion.(*DeviceChannelConnectionUnionSocket)
 if !ok {
 return errors.New("wrong type for union key connection")
 }
@@ -3348,6 +3369,10 @@ x.CapHvmDirectio = bool(xc.cap_hvm_direc
 x.CapHap = bool(xc.cap_hap)
 x.CapShadow = bool(xc.cap_shadow)
 x.CapIommuHapPtShare = bool(xc.cap_iommu_hap_pt_share)
+x.CapVmtrace = bool(xc.cap_vmtrace)
+x.CapVpmu = bool(xc.cap_vpmu)
+x.CapGnttabV1 = bool(xc.cap_gnttab_v1)
+x.CapGnttabV2 = bool(xc.cap_gnttab_v2)
 
  return nil}
 
@@ -3378,6 +3403,10 @@ xc.cap_hvm_directio = C.bool(x.CapHvmDir
 xc.cap_hap = C.bool(x.CapHap)
 xc.cap_shadow = C.bool(x.CapShadow)
 xc.cap_iommu_hap_pt_share = C.bool(x.CapIommuHapPtShare)
+xc.cap_vmtrace = C.bool(x.CapVmtrace)
+xc.cap_vpmu = C.bool(x.CapVpmu)
+xc.cap_gnttab_v1 = C.bool(x.CapGnttabV1)
+xc.cap_gnttab_v2 = C.bool(x.CapGnttabV2)
 
  return nil
  }
@@ -3938,7 +3967,7 @@ var typeDiskEject EventTypeUnionDiskEjec
 if err := typeDiskEject.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeDiskEject: %v", err)
 }
-x.TypeUnion = typeDiskEject
+x.TypeUnion = &typeDiskEject
 case EventTypeDomainCreateConsoleAvailable:
 x.TypeUnion = nil
 case EventTypeDomainDeath:
@@ -3948,13 +3977,13 @@ var typeDomainShutdown EventTypeUnionDom
 if err := typeDomainShutdown.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeDomainShutdown: %v", err)
 }
-x.TypeUnion = typeDomainShutdown
+x.TypeUnion = &typeDomainShutdown
 case EventTypeOperationComplete:
 var typeOperationComplete EventTypeUnionOperationComplete
 if err := typeOperationComplete.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeOperationComplete: %v", err)
 }
-x.TypeUnion = typeOperationComplete
+x.TypeUnion = &typeOperationComplete
 default:
 return fmt.Errorf("invalid union key '%v'", x.Type)}
 
@@ -4009,7 +4038,7 @@ xc.for_user = C.uint64_t(x.ForUser)
 xc._type = C.libxl_event_type(x.Type)
 switch x.Type{
 case EventTypeDomainShutdown:
-tmp, ok := x.TypeUnion.(EventTypeUnionDomainShutdown)
+tmp, ok := x.TypeUnion.(*EventTypeUnionDomainShutdown)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -4020,7 +4049,7 @@ copy(xc.u[:],domain_shutdownBytes)
 case EventTypeDomainDeath:
 break
 case EventTypeDiskEject:
-tmp, ok := x.TypeUnion.(EventTypeUnionDiskEject)
+tmp, ok := x.TypeUnion.(*EventTypeUnionDiskEject)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -4033,7 +4062,7 @@ return fmt.Errorf("converting field Disk
 disk_ejectBytes := C.GoBytes(unsafe.Pointer(&disk_eject),C.sizeof_libxl_event_type_union_disk_eject)
 copy(xc.u[:],disk_ejectBytes)
 case EventTypeOperationComplete:
-tmp, ok := x.TypeUnion.(EventTypeUnionOperationComplete)
+tmp, ok := x.TypeUnion.(*EventTypeUnionOperationComplete)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -4108,13 +4137,13 @@ var typeCat PsrHwInfoTypeUnionCat
 if err := typeCat.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeCat: %v", err)
 }
-x.TypeUnion = typeCat
+x.TypeUnion = &typeCat
 case PsrFeatTypeMba:
 var typeMba PsrHwInfoTypeUnionMba
 if err := typeMba.fromC(xc);err != nil {
  return fmt.Errorf("converting field typeMba: %v", err)
 }
-x.TypeUnion = typeMba
+x.TypeUnion = &typeMba
 default:
 return fmt.Errorf("invalid union key '%v'", x.Type)}
 
@@ -4153,7 +4182,7 @@ xc.id = C.uint32_t(x.Id)
 xc._type = C.libxl_psr_feat_type(x.Type)
 switch x.Type{
 case PsrFeatTypeCat:
-tmp, ok := x.TypeUnion.(PsrHwInfoTypeUnionCat)
+tmp, ok := x.TypeUnion.(*PsrHwInfoTypeUnionCat)
 if !ok {
 return errors.New("wrong type for union key type")
 }
@@ -4164,7 +4193,7 @@ cat.cdp_enabled = C.bool(tmp.CdpEnabled)
 catBytes := C.GoBytes(unsafe.Pointer(&cat),C.sizeof_libxl_psr_hw_info_type_union_cat)
 copy(xc.u[:],catBytes)
 case PsrFeatTypeMba:
-tmp, ok := x.TypeUnion.(PsrHwInfoTypeUnionMba)
+tmp, ok := x.TypeUnion.(*PsrHwInfoTypeUnionMba)
 if !ok {
 return errors.New("wrong type for union key type")
 }
diff -pruN 4.14.3+32-g9de3671772-1/tools/golang/xenlight/Makefile 4.16.1-1/tools/golang/xenlight/Makefile
--- 4.14.3+32-g9de3671772-1/tools/golang/xenlight/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/golang/xenlight/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -8,33 +8,26 @@ GOXL_INSTALL_DIR = $(GOCODE_DIR)/src/$(X
 
 GO ?= go
 
-LIBXL_SRC_DIR = ../../libxl
+LIBXL_SRC_DIR = $(XEN_ROOT)/tools/libs/light
 
 .PHONY: all
 all: build
 
 GOXL_GEN_FILES = types.gen.go helpers.gen.go
 
-# NOTE: This target is called from libxl/Makefile:all.  Since that
-# target must finish before golang/Makefile is called, this is
-# currently safe.  It must not be called from anywhere else in the
-# Makefile system without careful thought about races with
-# xenlight/Makefile:all
-idl-gen: $(GOXL_GEN_FILES)
-
 %.gen.go: gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl $(LIBXL_SRC_DIR)/idl.py
-	XEN_ROOT=$(XEN_ROOT) $(PYTHON) gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl
+	LIBXL_SRC_DIR=$(LIBXL_SRC_DIR) $(PYTHON) gengotypes.py $(LIBXL_SRC_DIR)/libxl_types.idl
 
 # Go will do its own dependency checking, and not actuall go through
 # with the build if none of the input files have changed.
 #
 # NB that because the users of this library need to be able to
 # recompile the library from source, it needs to include '-lxenlight'
-# in the LDFLAGS; and thus we need to add -L$(XEN_XENLIGHT) here
+# in the LDFLAGS; and thus we need to add -L$(XEN_libxenlight) here
 # so that it can find the actual library.
 .PHONY: build
 build: xenlight.go $(GOXL_GEN_FILES)
-	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_XENLIGHT) -L$(XEN_LIBXENTOOLLOG)" $(GO) build -x
+	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
 
 .PHONY: install
 install: build
diff -pruN 4.14.3+32-g9de3671772-1/tools/golang/xenlight/types.gen.go 4.16.1-1/tools/golang/xenlight/types.gen.go
--- 4.14.3+32-g9de3671772-1/tools/golang/xenlight/types.gen.go	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/golang/xenlight/types.gen.go	2022-04-12 12:21:23.000000000 +0000
@@ -1,8 +1,5 @@
-// DO NOT EDIT.
-//
-// This file is generated by:
-// gengotypes.py ../../libxl/libxl_types.idl
-//
+// Code generated by gengotypes.py. DO NOT EDIT.
+// source: libxl_types.idl
 
 package xenlight
 
@@ -213,6 +210,9 @@ ViridianEnlightenmentCrashCtl ViridianEn
 ViridianEnlightenmentSynic ViridianEnlightenment = 7
 ViridianEnlightenmentStimer ViridianEnlightenment = 8
 ViridianEnlightenmentHcallIpi ViridianEnlightenment = 9
+ViridianEnlightenmentExProcessorMasks ViridianEnlightenment = 10
+ViridianEnlightenmentNoVpLimit ViridianEnlightenment = 11
+ViridianEnlightenmentCpuHotplug ViridianEnlightenment = 12
 )
 
 type Hdtype int
@@ -316,6 +316,7 @@ CpuTime uint64
 VcpuMaxId uint32
 VcpuOnline uint32
 Cpupool uint32
+GpaddrBits byte
 DomainType DomainType
 }
 
@@ -337,18 +338,18 @@ State int
 Evtch int
 Rref int
 Connection ChannelConnection
-ConnectionUnion channelinfoConnectionUnion
+ConnectionUnion ChannelinfoConnectionUnion
 }
 
-type channelinfoConnectionUnion interface {
-ischannelinfoConnectionUnion()
+type ChannelinfoConnectionUnion interface {
+isChannelinfoConnectionUnion()
 }
 
 type ChannelinfoConnectionUnionPty struct {
 Path string
 }
 
-func (x ChannelinfoConnectionUnionPty) ischannelinfoConnectionUnion(){}
+func (x ChannelinfoConnectionUnionPty) isChannelinfoConnectionUnion(){}
 
 type Vminfo struct {
 Uuid Uuid
@@ -479,10 +480,12 @@ BlkdevStart string
 VnumaNodes []VnodeInfo
 MaxGrantFrames uint32
 MaxMaptrackFrames uint32
+MaxGrantVersion int
 DeviceModelVersion DeviceModelVersion
 DeviceModelStubdomain Defbool
 StubdomainMemkb uint64
 StubdomainKernel string
+StubdomainCmdline string
 StubdomainRamdisk string
 DeviceModel string
 DeviceModelSsidref uint32
@@ -510,16 +513,21 @@ Apic Defbool
 DmRestrict Defbool
 Tee TeeType
 Type DomainType
-TypeUnion domainBuildInfoTypeUnion
+TypeUnion DomainBuildInfoTypeUnion
 ArchArm struct {
 GicVersion GicVersion
 Vuart VuartType
 }
+ArchX86 struct {
+MsrRelaxed Defbool
+}
 Altp2M Altp2MMode
+VmtraceBufKb int
+Vpmu Defbool
 }
 
-type domainBuildInfoTypeUnion interface {
-isdomainBuildInfoTypeUnion()
+type DomainBuildInfoTypeUnion interface {
+isDomainBuildInfoTypeUnion()
 }
 
 type DomainBuildInfoTypeUnionHvm struct {
@@ -571,7 +579,7 @@ RdmMemBoundaryMemkb uint64
 McaCaps uint64
 }
 
-func (x DomainBuildInfoTypeUnionHvm) isdomainBuildInfoTypeUnion(){}
+func (x DomainBuildInfoTypeUnionHvm) isDomainBuildInfoTypeUnion(){}
 
 type DomainBuildInfoTypeUnionPv struct {
 Kernel string
@@ -584,7 +592,7 @@ Features string
 E820Host Defbool
 }
 
-func (x DomainBuildInfoTypeUnionPv) isdomainBuildInfoTypeUnion(){}
+func (x DomainBuildInfoTypeUnionPv) isDomainBuildInfoTypeUnion(){}
 
 type DomainBuildInfoTypeUnionPvh struct {
 Pvshim Defbool
@@ -593,7 +601,7 @@ PvshimCmdline string
 PvshimExtra string
 }
 
-func (x DomainBuildInfoTypeUnionPvh) isdomainBuildInfoTypeUnion(){}
+func (x DomainBuildInfoTypeUnionPvh) isDomainBuildInfoTypeUnion(){}
 
 type DeviceVfb struct {
 BackendDomid Domid
@@ -722,6 +730,7 @@ PowerMgmt bool
 Permissive bool
 Seize bool
 RdmPolicy RdmReservePolicy
+Name string
 }
 
 type DeviceRdm struct {
@@ -756,11 +765,11 @@ type DeviceUsbdev struct {
 Ctrl Devid
 Port int
 Type UsbdevType
-TypeUnion deviceUsbdevTypeUnion
+TypeUnion DeviceUsbdevTypeUnion
 }
 
-type deviceUsbdevTypeUnion interface {
-isdeviceUsbdevTypeUnion()
+type DeviceUsbdevTypeUnion interface {
+isDeviceUsbdevTypeUnion()
 }
 
 type DeviceUsbdevTypeUnionHostdev struct {
@@ -768,7 +777,7 @@ Hostbus byte
 Hostaddr byte
 }
 
-func (x DeviceUsbdevTypeUnionHostdev) isdeviceUsbdevTypeUnion(){}
+func (x DeviceUsbdevTypeUnionHostdev) isDeviceUsbdevTypeUnion(){}
 
 type DeviceDtdev struct {
 Path string
@@ -802,18 +811,18 @@ BackendDomname string
 Devid Devid
 Name string
 Connection ChannelConnection
-ConnectionUnion deviceChannelConnectionUnion
+ConnectionUnion DeviceChannelConnectionUnion
 }
 
-type deviceChannelConnectionUnion interface {
-isdeviceChannelConnectionUnion()
+type DeviceChannelConnectionUnion interface {
+isDeviceChannelConnectionUnion()
 }
 
 type DeviceChannelConnectionUnionSocket struct {
 Path string
 }
 
-func (x DeviceChannelConnectionUnionSocket) isdeviceChannelConnectionUnion(){}
+func (x DeviceChannelConnectionUnionSocket) isDeviceChannelConnectionUnion(){}
 
 type ConnectorParam struct {
 UniqueId string
@@ -1001,6 +1010,10 @@ CapHvmDirectio bool
 CapHap bool
 CapShadow bool
 CapIommuHapPtShare bool
+CapVmtrace bool
+CapVpmu bool
+CapGnttabV1 bool
+CapGnttabV2 bool
 }
 
 type Connectorinfo struct {
@@ -1110,31 +1123,31 @@ Domid Domid
 Domuuid Uuid
 ForUser uint64
 Type EventType
-TypeUnion eventTypeUnion
+TypeUnion EventTypeUnion
 }
 
-type eventTypeUnion interface {
-iseventTypeUnion()
+type EventTypeUnion interface {
+isEventTypeUnion()
 }
 
 type EventTypeUnionDomainShutdown struct {
 ShutdownReason byte
 }
 
-func (x EventTypeUnionDomainShutdown) iseventTypeUnion(){}
+func (x EventTypeUnionDomainShutdown) isEventTypeUnion(){}
 
 type EventTypeUnionDiskEject struct {
 Vdev string
 Disk DeviceDisk
 }
 
-func (x EventTypeUnionDiskEject) iseventTypeUnion(){}
+func (x EventTypeUnionDiskEject) isEventTypeUnion(){}
 
 type EventTypeUnionOperationComplete struct {
 Rc int
 }
 
-func (x EventTypeUnionOperationComplete) iseventTypeUnion(){}
+func (x EventTypeUnionOperationComplete) isEventTypeUnion(){}
 
 type PsrCmtType int
 const(
@@ -1169,11 +1182,11 @@ PsrFeatTypeMba PsrFeatType = 2
 type PsrHwInfo struct {
 Id uint32
 Type PsrFeatType
-TypeUnion psrHwInfoTypeUnion
+TypeUnion PsrHwInfoTypeUnion
 }
 
-type psrHwInfoTypeUnion interface {
-ispsrHwInfoTypeUnion()
+type PsrHwInfoTypeUnion interface {
+isPsrHwInfoTypeUnion()
 }
 
 type PsrHwInfoTypeUnionCat struct {
@@ -1182,7 +1195,7 @@ CbmLen uint32
 CdpEnabled bool
 }
 
-func (x PsrHwInfoTypeUnionCat) ispsrHwInfoTypeUnion(){}
+func (x PsrHwInfoTypeUnionCat) isPsrHwInfoTypeUnion(){}
 
 type PsrHwInfoTypeUnionMba struct {
 CosMax uint32
@@ -1190,5 +1203,5 @@ ThrtlMax uint32
 Linear bool
 }
 
-func (x PsrHwInfoTypeUnionMba) ispsrHwInfoTypeUnion(){}
+func (x PsrHwInfoTypeUnionMba) isPsrHwInfoTypeUnion(){}
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/golang/xenlight/xenlight.go 4.16.1-1/tools/golang/xenlight/xenlight.go
--- 4.14.3+32-g9de3671772-1/tools/golang/xenlight/xenlight.go	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/golang/xenlight/xenlight.go	2022-04-12 12:21:23.000000000 +0000
@@ -203,13 +203,13 @@ type Domid uint32
 // NameToDomid does not guarantee that the domid associated with name at
 // the time NameToDomid is called is the same as the domid associated with
 // name at the time NameToDomid returns.
-func (Ctx *Context) NameToDomid(name string) (Domid, error) {
+func (ctx *Context) NameToDomid(name string) (Domid, error) {
 	var domid C.uint32_t
 
 	cname := C.CString(name)
 	defer C.free(unsafe.Pointer(cname))
 
-	if ret := C.libxl_name_to_domid(Ctx.ctx, cname, &domid); ret != 0 {
+	if ret := C.libxl_name_to_domid(ctx.ctx, cname, &domid); ret != 0 {
 		return DomidInvalid, Error(ret)
 	}
 
@@ -223,8 +223,8 @@ func (Ctx *Context) NameToDomid(name str
 // DomidToName does not guarantee that the name (if any) associated with domid
 // at the time DomidToName is called is the same as the name (if any) associated
 // with domid at the time DomidToName returns.
-func (Ctx *Context) DomidToName(domid Domid) string {
-	cname := C.libxl_domid_to_name(Ctx.ctx, C.uint32_t(domid))
+func (ctx *Context) DomidToName(domid Domid) string {
+	cname := C.libxl_domid_to_name(ctx.ctx, C.uint32_t(domid))
 	defer C.free(unsafe.Pointer(cname))
 
 	return C.GoString(cname)
@@ -491,13 +491,14 @@ func (sl *StringList) fromC(csl *C.libxl
 
 func (sl StringList) toC(csl *C.libxl_string_list) error {
 	var char *C.char
-	size := len(sl)
+	size := len(sl) + 1
 	*csl = (C.libxl_string_list)(C.malloc(C.ulong(size) * C.ulong(unsafe.Sizeof(char))))
-	clist := (*[1 << 30]*C.char)(unsafe.Pointer(csl))[:size:size]
+	clist := (*[1 << 30]*C.char)(unsafe.Pointer(*csl))[:size:size]
 
 	for i, v := range sl {
 		clist[i] = C.CString(v)
 	}
+	clist[len(clist)-1] = nil
 
 	return nil
 }
@@ -582,7 +583,7 @@ func SchedulerFromString(name string) (s
 
 	ret := C.libxl_scheduler_from_string(cname, &cs)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -593,10 +594,10 @@ func SchedulerFromString(name string) (s
 
 // libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool_out);
 // void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nb_pool);
-func (Ctx *Context) ListCpupool() (list []Cpupoolinfo) {
+func (ctx *Context) ListCpupool() (list []Cpupoolinfo) {
 	var nbPool C.int
 
-	c_cpupool_list := C.libxl_list_cpupool(Ctx.ctx, &nbPool)
+	c_cpupool_list := C.libxl_list_cpupool(ctx.ctx, &nbPool)
 
 	defer C.libxl_cpupoolinfo_list_free(c_cpupool_list, nbPool)
 
@@ -616,12 +617,12 @@ func (Ctx *Context) ListCpupool() (list
 }
 
 // int libxl_cpupool_info(libxl_ctx *ctx, libxl_cpupoolinfo *info, uint32_t poolid);
-func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool Cpupoolinfo, err error) {
+func (ctx *Context) CpupoolInfo(Poolid uint32) (pool Cpupoolinfo, err error) {
 	var c_cpupool C.libxl_cpupoolinfo
 
-	ret := C.libxl_cpupool_info(Ctx.ctx, &c_cpupool, C.uint32_t(Poolid))
+	ret := C.libxl_cpupool_info(ctx.ctx, &c_cpupool, C.uint32_t(Poolid))
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 	defer C.libxl_cpupoolinfo_dispose(&c_cpupool)
@@ -637,7 +638,7 @@ func (Ctx *Context) CpupoolInfo(Poolid u
 //                          uint32_t *poolid);
 // FIXME: uuid
 // FIXME: Setting poolid
-func (Ctx *Context) CpupoolCreate(Name string, Scheduler Scheduler, Cpumap Bitmap) (err error, Poolid uint32) {
+func (ctx *Context) CpupoolCreate(Name string, Scheduler Scheduler, Cpumap Bitmap) (err error, Poolid uint32) {
 	poolid := C.uint32_t(C.LIBXL_CPUPOOL_POOLID_ANY)
 	name := C.CString(Name)
 	defer C.free(unsafe.Pointer(name))
@@ -652,10 +653,10 @@ func (Ctx *Context) CpupoolCreate(Name s
 	}
 	defer C.libxl_bitmap_dispose(&cbm)
 
-	ret := C.libxl_cpupool_create(Ctx.ctx, name, C.libxl_scheduler(Scheduler),
+	ret := C.libxl_cpupool_create(ctx.ctx, name, C.libxl_scheduler(Scheduler),
 		cbm, &uuid, &poolid)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -665,10 +666,10 @@ func (Ctx *Context) CpupoolCreate(Name s
 }
 
 // int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
-func (Ctx *Context) CpupoolDestroy(Poolid uint32) (err error) {
-	ret := C.libxl_cpupool_destroy(Ctx.ctx, C.uint32_t(Poolid))
+func (ctx *Context) CpupoolDestroy(Poolid uint32) (err error) {
+	ret := C.libxl_cpupool_destroy(ctx.ctx, C.uint32_t(Poolid))
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -676,10 +677,10 @@ func (Ctx *Context) CpupoolDestroy(Pooli
 }
 
 // int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
-func (Ctx *Context) CpupoolCpuadd(Poolid uint32, Cpu int) (err error) {
-	ret := C.libxl_cpupool_cpuadd(Ctx.ctx, C.uint32_t(Poolid), C.int(Cpu))
+func (ctx *Context) CpupoolCpuadd(Poolid uint32, Cpu int) (err error) {
+	ret := C.libxl_cpupool_cpuadd(ctx.ctx, C.uint32_t(Poolid), C.int(Cpu))
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -688,16 +689,16 @@ func (Ctx *Context) CpupoolCpuadd(Poolid
 
 // int libxl_cpupool_cpuadd_cpumap(libxl_ctx *ctx, uint32_t poolid,
 //                                 const libxl_bitmap *cpumap);
-func (Ctx *Context) CpupoolCpuaddCpumap(Poolid uint32, Cpumap Bitmap) (err error) {
+func (ctx *Context) CpupoolCpuaddCpumap(Poolid uint32, Cpumap Bitmap) (err error) {
 	var cbm C.libxl_bitmap
 	if err = Cpumap.toC(&cbm); err != nil {
 		return
 	}
 	defer C.libxl_bitmap_dispose(&cbm)
 
-	ret := C.libxl_cpupool_cpuadd_cpumap(Ctx.ctx, C.uint32_t(Poolid), &cbm)
+	ret := C.libxl_cpupool_cpuadd_cpumap(ctx.ctx, C.uint32_t(Poolid), &cbm)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -705,10 +706,10 @@ func (Ctx *Context) CpupoolCpuaddCpumap(
 }
 
 // int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu);
-func (Ctx *Context) CpupoolCpuremove(Poolid uint32, Cpu int) (err error) {
-	ret := C.libxl_cpupool_cpuremove(Ctx.ctx, C.uint32_t(Poolid), C.int(Cpu))
+func (ctx *Context) CpupoolCpuremove(Poolid uint32, Cpu int) (err error) {
+	ret := C.libxl_cpupool_cpuremove(ctx.ctx, C.uint32_t(Poolid), C.int(Cpu))
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -717,16 +718,16 @@ func (Ctx *Context) CpupoolCpuremove(Poo
 
 // int libxl_cpupool_cpuremove_cpumap(libxl_ctx *ctx, uint32_t poolid,
 //                                    const libxl_bitmap *cpumap);
-func (Ctx *Context) CpupoolCpuremoveCpumap(Poolid uint32, Cpumap Bitmap) (err error) {
+func (ctx *Context) CpupoolCpuremoveCpumap(Poolid uint32, Cpumap Bitmap) (err error) {
 	var cbm C.libxl_bitmap
 	if err = Cpumap.toC(&cbm); err != nil {
 		return
 	}
 	defer C.libxl_bitmap_dispose(&cbm)
 
-	ret := C.libxl_cpupool_cpuremove_cpumap(Ctx.ctx, C.uint32_t(Poolid), &cbm)
+	ret := C.libxl_cpupool_cpuremove_cpumap(ctx.ctx, C.uint32_t(Poolid), &cbm)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -734,13 +735,13 @@ func (Ctx *Context) CpupoolCpuremoveCpum
 }
 
 // int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
-func (Ctx *Context) CpupoolRename(Name string, Poolid uint32) (err error) {
+func (ctx *Context) CpupoolRename(Name string, Poolid uint32) (err error) {
 	name := C.CString(Name)
 	defer C.free(unsafe.Pointer(name))
 
-	ret := C.libxl_cpupool_rename(Ctx.ctx, name, C.uint32_t(Poolid))
+	ret := C.libxl_cpupool_rename(ctx.ctx, name, C.uint32_t(Poolid))
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -748,12 +749,12 @@ func (Ctx *Context) CpupoolRename(Name s
 }
 
 // int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
-func (Ctx *Context) CpupoolCpuaddNode(Poolid uint32, Node int) (Cpus int, err error) {
+func (ctx *Context) CpupoolCpuaddNode(Poolid uint32, Node int) (Cpus int, err error) {
 	ccpus := C.int(0)
 
-	ret := C.libxl_cpupool_cpuadd_node(Ctx.ctx, C.uint32_t(Poolid), C.int(Node), &ccpus)
+	ret := C.libxl_cpupool_cpuadd_node(ctx.ctx, C.uint32_t(Poolid), C.int(Node), &ccpus)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -763,12 +764,12 @@ func (Ctx *Context) CpupoolCpuaddNode(Po
 }
 
 // int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
-func (Ctx *Context) CpupoolCpuremoveNode(Poolid uint32, Node int) (Cpus int, err error) {
+func (ctx *Context) CpupoolCpuremoveNode(Poolid uint32, Node int) (Cpus int, err error) {
 	ccpus := C.int(0)
 
-	ret := C.libxl_cpupool_cpuremove_node(Ctx.ctx, C.uint32_t(Poolid), C.int(Node), &ccpus)
+	ret := C.libxl_cpupool_cpuremove_node(ctx.ctx, C.uint32_t(Poolid), C.int(Node), &ccpus)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -778,10 +779,10 @@ func (Ctx *Context) CpupoolCpuremoveNode
 }
 
 // int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid);
-func (Ctx *Context) CpupoolMovedomain(Poolid uint32, Id Domid) (err error) {
-	ret := C.libxl_cpupool_movedomain(Ctx.ctx, C.uint32_t(Poolid), C.uint32_t(Id))
+func (ctx *Context) CpupoolMovedomain(Poolid uint32, Id Domid) (err error) {
+	ret := C.libxl_cpupool_movedomain(ctx.ctx, C.uint32_t(Poolid), C.uint32_t(Id))
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -791,8 +792,8 @@ func (Ctx *Context) CpupoolMovedomain(Po
 //
 // Utility functions
 //
-func (Ctx *Context) CpupoolFindByName(name string) (info Cpupoolinfo, found bool) {
-	plist := Ctx.ListCpupool()
+func (ctx *Context) CpupoolFindByName(name string) (info Cpupoolinfo, found bool) {
+	plist := ctx.ListCpupool()
 
 	for i := range plist {
 		if plist[i].PoolName == name {
@@ -804,14 +805,14 @@ func (Ctx *Context) CpupoolFindByName(na
 	return
 }
 
-func (Ctx *Context) CpupoolMakeFree(Cpumap Bitmap) (err error) {
-	plist := Ctx.ListCpupool()
+func (ctx *Context) CpupoolMakeFree(Cpumap Bitmap) (err error) {
+	plist := ctx.ListCpupool()
 
 	for i := range plist {
 		var Intersection Bitmap
 		Intersection = Cpumap.And(plist[i].Cpumap)
 		if !Intersection.IsEmpty() {
-			err = Ctx.CpupoolCpuremoveCpumap(plist[i].Poolid, Intersection)
+			err = ctx.CpupoolCpuremoveCpumap(plist[i].Poolid, Intersection)
 			if err != nil {
 				return
 			}
@@ -939,10 +940,10 @@ func (bm Bitmap) String() (s string) {
 }
 
 //int libxl_get_max_cpus(libxl_ctx *ctx);
-func (Ctx *Context) GetMaxCpus() (maxCpus int, err error) {
-	ret := C.libxl_get_max_cpus(Ctx.ctx)
+func (ctx *Context) GetMaxCpus() (maxCpus int, err error) {
+	ret := C.libxl_get_max_cpus(ctx.ctx)
 	if ret < 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 	maxCpus = int(ret)
@@ -950,10 +951,10 @@ func (Ctx *Context) GetMaxCpus() (maxCpu
 }
 
 //int libxl_get_online_cpus(libxl_ctx *ctx);
-func (Ctx *Context) GetOnlineCpus() (onCpus int, err error) {
-	ret := C.libxl_get_online_cpus(Ctx.ctx)
+func (ctx *Context) GetOnlineCpus() (onCpus int, err error) {
+	ret := C.libxl_get_online_cpus(ctx.ctx)
 	if ret < 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 	onCpus = int(ret)
@@ -961,10 +962,10 @@ func (Ctx *Context) GetOnlineCpus() (onC
 }
 
 //int libxl_get_max_nodes(libxl_ctx *ctx);
-func (Ctx *Context) GetMaxNodes() (maxNodes int, err error) {
-	ret := C.libxl_get_max_nodes(Ctx.ctx)
+func (ctx *Context) GetMaxNodes() (maxNodes int, err error) {
+	ret := C.libxl_get_max_nodes(ctx.ctx)
 	if ret < 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 	maxNodes = int(ret)
@@ -972,12 +973,12 @@ func (Ctx *Context) GetMaxNodes() (maxNo
 }
 
 //int libxl_get_free_memory(libxl_ctx *ctx, uint64_t *memkb);
-func (Ctx *Context) GetFreeMemory() (memkb uint64, err error) {
+func (ctx *Context) GetFreeMemory() (memkb uint64, err error) {
 	var cmem C.uint64_t
-	ret := C.libxl_get_free_memory(Ctx.ctx, &cmem)
+	ret := C.libxl_get_free_memory(ctx.ctx, &cmem)
 
 	if ret < 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -987,12 +988,12 @@ func (Ctx *Context) GetFreeMemory() (mem
 }
 
 //int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
-func (Ctx *Context) GetPhysinfo() (physinfo *Physinfo, err error) {
+func (ctx *Context) GetPhysinfo() (physinfo *Physinfo, err error) {
 	var cphys C.libxl_physinfo
 	C.libxl_physinfo_init(&cphys)
 	defer C.libxl_physinfo_dispose(&cphys)
 
-	ret := C.libxl_get_physinfo(Ctx.ctx, &cphys)
+	ret := C.libxl_get_physinfo(ctx.ctx, &cphys)
 
 	if ret < 0 {
 		err = Error(ret)
@@ -1004,25 +1005,25 @@ func (Ctx *Context) GetPhysinfo() (physi
 }
 
 //const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx);
-func (Ctx *Context) GetVersionInfo() (info *VersionInfo, err error) {
+func (ctx *Context) GetVersionInfo() (info *VersionInfo, err error) {
 	var cinfo *C.libxl_version_info
 
-	cinfo = C.libxl_get_version_info(Ctx.ctx)
+	cinfo = C.libxl_get_version_info(ctx.ctx)
 
 	err = info.fromC(cinfo)
 
 	return
 }
 
-func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo, err error) {
+func (ctx *Context) DomainInfo(Id Domid) (di *Dominfo, err error) {
 	var cdi C.libxl_dominfo
 	C.libxl_dominfo_init(&cdi)
 	defer C.libxl_dominfo_dispose(&cdi)
 
-	ret := C.libxl_domain_info(Ctx.ctx, &cdi, C.uint32_t(Id))
+	ret := C.libxl_domain_info(ctx.ctx, &cdi, C.uint32_t(Id))
 
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 
@@ -1031,50 +1032,50 @@ func (Ctx *Context) DomainInfo(Id Domid)
 	return
 }
 
-func (Ctx *Context) DomainUnpause(Id Domid) (err error) {
-	ret := C.libxl_domain_unpause(Ctx.ctx, C.uint32_t(Id), nil)
+func (ctx *Context) DomainUnpause(Id Domid) (err error) {
+	ret := C.libxl_domain_unpause(ctx.ctx, C.uint32_t(Id), nil)
 
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 	}
 	return
 }
 
 //int libxl_domain_pause(libxl_ctx *ctx, uint32_t domain);
-func (Ctx *Context) DomainPause(id Domid) (err error) {
-	ret := C.libxl_domain_pause(Ctx.ctx, C.uint32_t(id), nil)
+func (ctx *Context) DomainPause(id Domid) (err error) {
+	ret := C.libxl_domain_pause(ctx.ctx, C.uint32_t(id), nil)
 
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 	}
 	return
 }
 
 //int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid);
-func (Ctx *Context) DomainShutdown(id Domid) (err error) {
-	ret := C.libxl_domain_shutdown(Ctx.ctx, C.uint32_t(id), nil)
+func (ctx *Context) DomainShutdown(id Domid) (err error) {
+	ret := C.libxl_domain_shutdown(ctx.ctx, C.uint32_t(id), nil)
 
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 	}
 	return
 }
 
 //int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid);
-func (Ctx *Context) DomainReboot(id Domid) (err error) {
-	ret := C.libxl_domain_reboot(Ctx.ctx, C.uint32_t(id), nil)
+func (ctx *Context) DomainReboot(id Domid) (err error) {
+	ret := C.libxl_domain_reboot(ctx.ctx, C.uint32_t(id), nil)
 
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 	}
 	return
 }
 
 //libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain_out);
 //void libxl_dominfo_list_free(libxl_dominfo *list, int nb_domain);
-func (Ctx *Context) ListDomain() (glist []Dominfo) {
+func (ctx *Context) ListDomain() (glist []Dominfo) {
 	var nbDomain C.int
-	clist := C.libxl_list_domain(Ctx.ctx, &nbDomain)
+	clist := C.libxl_list_domain(ctx.ctx, &nbDomain)
 	defer C.libxl_dominfo_list_free(clist, nbDomain)
 
 	if int(nbDomain) == 0 {
@@ -1094,11 +1095,11 @@ func (Ctx *Context) ListDomain() (glist
 //libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
 //				int *nb_vcpu, int *nr_cpus_out);
 //void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
-func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpuinfo) {
+func (ctx *Context) ListVcpu(id Domid) (glist []Vcpuinfo) {
 	var nbVcpu C.int
 	var nrCpu C.int
 
-	clist := C.libxl_list_vcpu(Ctx.ctx, C.uint32_t(id), &nbVcpu, &nrCpu)
+	clist := C.libxl_list_vcpu(ctx.ctx, C.uint32_t(id), &nbVcpu, &nrCpu)
 	defer C.libxl_vcpuinfo_list_free(clist, nbVcpu)
 
 	if int(nbVcpu) == 0 {
@@ -1124,11 +1125,11 @@ func (ct ConsoleType) String() (str stri
 
 //int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num,
 //libxl_console_type type, char **path);
-func (Ctx *Context) ConsoleGetTty(id Domid, consNum int, conType ConsoleType) (path string, err error) {
+func (ctx *Context) ConsoleGetTty(id Domid, consNum int, conType ConsoleType) (path string, err error) {
 	var cpath *C.char
-	ret := C.libxl_console_get_tty(Ctx.ctx, C.uint32_t(id), C.int(consNum), C.libxl_console_type(conType), &cpath)
+	ret := C.libxl_console_get_tty(ctx.ctx, C.uint32_t(id), C.int(consNum), C.libxl_console_type(conType), &cpath)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 	defer C.free(unsafe.Pointer(cpath))
@@ -1139,11 +1140,11 @@ func (Ctx *Context) ConsoleGetTty(id Dom
 
 //int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm,
 //					char **path);
-func (Ctx *Context) PrimaryConsoleGetTty(domid uint32) (path string, err error) {
+func (ctx *Context) PrimaryConsoleGetTty(domid uint32) (path string, err error) {
 	var cpath *C.char
-	ret := C.libxl_primary_console_get_tty(Ctx.ctx, C.uint32_t(domid), &cpath)
+	ret := C.libxl_primary_console_get_tty(ctx.ctx, C.uint32_t(domid), &cpath)
 	if ret != 0 {
-		err = Error(-ret)
+		err = Error(ret)
 		return
 	}
 	defer C.free(unsafe.Pointer(cpath))
@@ -1153,7 +1154,7 @@ func (Ctx *Context) PrimaryConsoleGetTty
 }
 
 // DeviceNicAdd adds a nic to a domain.
-func (Ctx *Context) DeviceNicAdd(domid Domid, nic *DeviceNic) error {
+func (ctx *Context) DeviceNicAdd(domid Domid, nic *DeviceNic) error {
 	var cnic C.libxl_device_nic
 
 	if err := nic.toC(&cnic); err != nil {
@@ -1161,7 +1162,7 @@ func (Ctx *Context) DeviceNicAdd(domid D
 	}
 	defer C.libxl_device_nic_dispose(&cnic)
 
-	ret := C.libxl_device_nic_add(Ctx.ctx, C.uint32_t(domid), &cnic, nil)
+	ret := C.libxl_device_nic_add(ctx.ctx, C.uint32_t(domid), &cnic, nil)
 	if ret != 0 {
 		return Error(ret)
 	}
@@ -1170,7 +1171,7 @@ func (Ctx *Context) DeviceNicAdd(domid D
 }
 
 // DeviceNicRemove removes a nic from a domain.
-func (Ctx *Context) DeviceNicRemove(domid Domid, nic *DeviceNic) error {
+func (ctx *Context) DeviceNicRemove(domid Domid, nic *DeviceNic) error {
 	var cnic C.libxl_device_nic
 
 	if err := nic.toC(&cnic); err != nil {
@@ -1178,7 +1179,7 @@ func (Ctx *Context) DeviceNicRemove(domi
 	}
 	defer C.libxl_device_nic_dispose(&cnic)
 
-	ret := C.libxl_device_nic_remove(Ctx.ctx, C.uint32_t(domid), &cnic, nil)
+	ret := C.libxl_device_nic_remove(ctx.ctx, C.uint32_t(domid), &cnic, nil)
 	if ret != 0 {
 		return Error(ret)
 	}
@@ -1187,7 +1188,7 @@ func (Ctx *Context) DeviceNicRemove(domi
 }
 
 // DevicePciAdd is used to passthrough a PCI device to a domain.
-func (Ctx *Context) DevicePciAdd(domid Domid, pci *DevicePci) error {
+func (ctx *Context) DevicePciAdd(domid Domid, pci *DevicePci) error {
 	var cpci C.libxl_device_pci
 
 	if err := pci.toC(&cpci); err != nil {
@@ -1195,7 +1196,7 @@ func (Ctx *Context) DevicePciAdd(domid D
 	}
 	defer C.libxl_device_pci_dispose(&cpci)
 
-	ret := C.libxl_device_pci_add(Ctx.ctx, C.uint32_t(domid), &cpci, nil)
+	ret := C.libxl_device_pci_add(ctx.ctx, C.uint32_t(domid), &cpci, nil)
 	if ret != 0 {
 		return Error(ret)
 	}
@@ -1204,7 +1205,7 @@ func (Ctx *Context) DevicePciAdd(domid D
 }
 
 // DevicePciRemove removes a PCI device from a domain.
-func (Ctx *Context) DevicePciRemove(domid Domid, pci *DevicePci) error {
+func (ctx *Context) DevicePciRemove(domid Domid, pci *DevicePci) error {
 	var cpci C.libxl_device_pci
 
 	if err := pci.toC(&cpci); err != nil {
@@ -1212,7 +1213,7 @@ func (Ctx *Context) DevicePciRemove(domi
 	}
 	defer C.libxl_device_pci_dispose(&cpci)
 
-	ret := C.libxl_device_pci_remove(Ctx.ctx, C.uint32_t(domid), &cpci, nil)
+	ret := C.libxl_device_pci_remove(ctx.ctx, C.uint32_t(domid), &cpci, nil)
 	if ret != 0 {
 		return Error(ret)
 	}
@@ -1221,7 +1222,7 @@ func (Ctx *Context) DevicePciRemove(domi
 }
 
 // DeviceUsbdevAdd adds a USB device to a domain.
-func (Ctx *Context) DeviceUsbdevAdd(domid Domid, usbdev *DeviceUsbdev) error {
+func (ctx *Context) DeviceUsbdevAdd(domid Domid, usbdev *DeviceUsbdev) error {
 	var cusbdev C.libxl_device_usbdev
 
 	if err := usbdev.toC(&cusbdev); err != nil {
@@ -1229,7 +1230,7 @@ func (Ctx *Context) DeviceUsbdevAdd(domi
 	}
 	defer C.libxl_device_usbdev_dispose(&cusbdev)
 
-	ret := C.libxl_device_usbdev_add(Ctx.ctx, C.uint32_t(domid), &cusbdev, nil)
+	ret := C.libxl_device_usbdev_add(ctx.ctx, C.uint32_t(domid), &cusbdev, nil)
 	if ret != 0 {
 		return Error(ret)
 	}
@@ -1238,7 +1239,7 @@ func (Ctx *Context) DeviceUsbdevAdd(domi
 }
 
 // DeviceUsbdevRemove removes a USB device from a domain.
-func (Ctx *Context) DeviceUsbdevRemove(domid Domid, usbdev *DeviceUsbdev) error {
+func (ctx *Context) DeviceUsbdevRemove(domid Domid, usbdev *DeviceUsbdev) error {
 	var cusbdev C.libxl_device_usbdev
 
 	if err := usbdev.toC(&cusbdev); err != nil {
@@ -1246,7 +1247,7 @@ func (Ctx *Context) DeviceUsbdevRemove(d
 	}
 	defer C.libxl_device_usbdev_dispose(&cusbdev)
 
-	ret := C.libxl_device_usbdev_remove(Ctx.ctx, C.uint32_t(domid), &cusbdev, nil)
+	ret := C.libxl_device_usbdev_remove(ctx.ctx, C.uint32_t(domid), &cusbdev, nil)
 	if ret != 0 {
 		return Error(ret)
 	}
@@ -1255,7 +1256,7 @@ func (Ctx *Context) DeviceUsbdevRemove(d
 }
 
 // DomainCreateNew creates a new domain.
-func (Ctx *Context) DomainCreateNew(config *DomainConfig) (Domid, error) {
+func (ctx *Context) DomainCreateNew(config *DomainConfig) (Domid, error) {
 	var cdomid C.uint32_t
 	var cconfig C.libxl_domain_config
 	err := config.toC(&cconfig)
@@ -1264,10 +1265,31 @@ func (Ctx *Context) DomainCreateNew(conf
 	}
 	defer C.libxl_domain_config_dispose(&cconfig)
 
-	ret := C.libxl_domain_create_new(Ctx.ctx, &cconfig, &cdomid, nil, nil)
+	ret := C.libxl_domain_create_new(ctx.ctx, &cconfig, &cdomid, nil, nil)
 	if ret != 0 {
 		return Domid(0), Error(ret)
 	}
 
 	return Domid(cdomid), nil
 }
+
+// DomainDestroy destroys a domain given a domid.
+func (ctx *Context) DomainDestroy(domid Domid) error {
+	ret := C.libxl_domain_destroy(ctx.ctx, C.uint32_t(domid), nil)
+	if ret != 0 {
+		return Error(ret)
+	}
+
+	return nil
+}
+
+// SendTrigger sends a Trigger to the domain specified by domid.
+func (ctx *Context) SendTrigger(domid Domid, trigger Trigger, vcpuid int) error {
+	ret := C.libxl_send_trigger(ctx.ctx, C.uint32_t(domid),
+		C.libxl_trigger(trigger), C.uint32_t(vcpuid), nil)
+	if ret != 0 {
+		return Error(ret)
+	}
+
+	return nil
+}
diff -pruN 4.14.3+32-g9de3671772-1/tools/helpers/init-xenstore-domain.c 4.16.1-1/tools/helpers/init-xenstore-domain.c
--- 4.14.3+32-g9de3671772-1/tools/helpers/init-xenstore-domain.c	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/helpers/init-xenstore-domain.c	2022-04-12 12:21:23.000000000 +0000
@@ -8,8 +8,9 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <xenctrl.h>
-#include <xc_dom.h>
+#include <xenguest.h>
 #include <xenstore.h>
+#include <xentoollog.h>
 #include <xen/sys/xenbus_dev.h>
 #include <xen-xsm/flask/flask.h>
 #include <xen/io/xenbus.h>
@@ -17,6 +18,10 @@
 #include "init-dom-json.h"
 #include "_paths.h"
 
+#define LAPIC_BASE_ADDRESS  0xfee00000UL
+#define MB(x)               ((uint64_t)x << 20)
+#define GB(x)               ((uint64_t)x << 30)
+
 static uint32_t domid = ~0;
 static char *kernel;
 static char *ramdisk;
@@ -36,6 +41,7 @@ static struct option options[] = {
     { "param", 1, NULL, 'p' },
     { "name", 1, NULL, 'n' },
     { "maxmem", 1, NULL, 'M' },
+    { "verbose", 0, NULL, 'v' },
     { NULL, 0, NULL, 0 }
 };
 
@@ -57,7 +63,8 @@ static void usage(void)
 "  --maxmem <max size>        maximum memory size in the format:\n"
 "                             <MB val>|<a>/<b>|<MB val>:<a>/<b>\n"
 "                             (an absolute value in MB, a fraction a/b of\n"
-"                             the host memory, or the maximum of both)\n");
+"                             the host memory, or the maximum of both)\n"
+"  -v[v[v]]                   verbosity of domain building\n");
 }
 
 static int build(xc_interface *xch)
@@ -66,6 +73,8 @@ static int build(xc_interface *xch)
     int rv, xs_fd;
     struct xc_dom_image *dom = NULL;
     int limit_kb = (maxmem ? : (memory + 1)) * 1024;
+    uint64_t mem_size = MB(memory);
+    struct e820entry e820[3];
     struct xen_domctl_createdomain config = {
         .ssidref = SECINITSID_DOMU,
         .flags = XEN_DOMCTL_CDF_xs_domain,
@@ -76,9 +85,11 @@ static int build(xc_interface *xch)
          * 1 grant frame is enough: we don't need many grants.
          * Mini-OS doesn't like less than 4, though, so use 4.
          * 128 maptrack frames: 256 entries per frame, enough for 32768 domains.
+         * Currently Mini-OS only supports grant v1.
          */
         .max_grant_frames = 4,
         .max_maptrack_frames = 128,
+        .grant_opts = XEN_DOMCTL_GRANT_version(1),
     };
 
     xs_fd = open("/dev/xen/xenbus_backend", O_RDWR);
@@ -98,6 +109,73 @@ static int build(xc_interface *xch)
         }
     }
 
+    dom = xc_dom_allocate(xch, NULL, NULL);
+    if ( !dom )
+    {
+        fprintf(stderr, "xc_dom_allocate failed\n");
+        rv = -1;
+        goto err;
+    }
+
+    rv = xc_dom_kernel_file(dom, kernel);
+    if ( rv )
+    {
+        fprintf(stderr, "xc_dom_kernel_file failed\n");
+        goto err;
+    }
+
+    if ( ramdisk )
+    {
+        rv = xc_dom_module_file(dom, ramdisk, NULL);
+        if ( rv )
+        {
+            fprintf(stderr, "xc_dom_module_file failed\n");
+            goto err;
+        }
+    }
+
+    rv = xc_dom_boot_xen_init(dom, xch, domid);
+    if ( rv )
+    {
+        fprintf(stderr, "xc_dom_boot_xen_init failed\n");
+        goto err;
+    }
+
+    dom->container_type = XC_DOM_HVM_CONTAINER;
+    rv = xc_dom_parse_image(dom);
+    if ( rv )
+    {
+        dom->container_type = XC_DOM_PV_CONTAINER;
+        rv = xc_dom_parse_image(dom);
+        if ( rv )
+        {
+            fprintf(stderr, "xc_dom_parse_image failed\n");
+            goto err;
+        }
+    }
+    else
+    {
+        config.flags |= XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap;
+        config.arch.emulation_flags = XEN_X86_EMU_LAPIC;
+        dom->target_pages = mem_size >> XC_PAGE_SHIFT;
+        dom->mmio_size = GB(4) - LAPIC_BASE_ADDRESS;
+        dom->lowmem_end = (mem_size > LAPIC_BASE_ADDRESS) ?
+                          LAPIC_BASE_ADDRESS : mem_size;
+        dom->highmem_end = (mem_size > LAPIC_BASE_ADDRESS) ?
+                           GB(4) + mem_size - LAPIC_BASE_ADDRESS : 0;
+        dom->mmio_start = LAPIC_BASE_ADDRESS;
+        dom->max_vcpus = 1;
+        e820[0].addr = 0;
+        e820[0].size = dom->lowmem_end;
+        e820[0].type = E820_RAM;
+        e820[1].addr = LAPIC_BASE_ADDRESS;
+        e820[1].size = dom->mmio_size;
+        e820[1].type = E820_RESERVED;
+        e820[2].addr = GB(4);
+        e820[2].size = dom->highmem_end - GB(4);
+        e820[2].type = E820_RAM;
+    }
+
     rv = xc_domain_create(xch, &domid, &config);
     if ( rv )
     {
@@ -122,11 +200,15 @@ static int build(xc_interface *xch)
         fprintf(stderr, "xc_evtchn_alloc_unbound failed\n");
         goto err;
     }
-    rv = xc_domain_set_memmap_limit(xch, domid, limit_kb);
-    if ( rv )
+
+    if ( dom->container_type == XC_DOM_PV_CONTAINER )
     {
-        fprintf(stderr, "xc_domain_set_memmap_limit failed\n");
-        goto err;
+        rv = xc_domain_set_memmap_limit(xch, domid, limit_kb);
+        if ( rv )
+        {
+            fprintf(stderr, "xc_domain_set_memmap_limit failed\n");
+            goto err;
+        }
     }
 
     rv = ioctl(xs_fd, IOCTL_XENBUS_BACKEND_SETUP, domid);
@@ -141,45 +223,11 @@ static int build(xc_interface *xch)
     else
         snprintf(cmdline, 512, "--event %d --internal-db", rv);
 
-    dom = xc_dom_allocate(xch, cmdline, NULL);
-    if ( !dom )
-    {
-        fprintf(stderr, "xc_dom_allocate failed\n");
-        goto err;
-    }
-    dom->container_type = XC_DOM_PV_CONTAINER;
+    dom->guest_domid = domid;
+    dom->cmdline = xc_dom_strdup(dom, cmdline);
     dom->xenstore_domid = domid;
     dom->console_evtchn = console_evtchn;
 
-    rv = xc_dom_kernel_file(dom, kernel);
-    if ( rv )
-    {
-        fprintf(stderr, "xc_dom_kernel_file failed\n");
-        goto err;
-    }
-
-    if ( ramdisk )
-    {
-        rv = xc_dom_module_file(dom, ramdisk, NULL);
-        if ( rv )
-        {
-            fprintf(stderr, "xc_dom_module_file failed\n");
-            goto err;
-        }
-    }
-
-    rv = xc_dom_boot_xen_init(dom, xch, domid);
-    if ( rv )
-    {
-        fprintf(stderr, "xc_dom_boot_xen_init failed\n");
-        goto err;
-    }
-    rv = xc_dom_parse_image(dom);
-    if ( rv )
-    {
-        fprintf(stderr, "xc_dom_parse_image failed\n");
-        goto err;
-    }
     rv = xc_dom_mem_init(dom, memory);
     if ( rv )
     {
@@ -192,6 +240,16 @@ static int build(xc_interface *xch)
         fprintf(stderr, "xc_dom_boot_mem_init failed\n");
         goto err;
     }
+    if ( dom->container_type == XC_DOM_HVM_CONTAINER )
+    {
+        rv = xc_domain_set_memory_map(xch, domid, e820,
+                                      dom->highmem_end ? 3 : 2);
+        if ( rv )
+        {
+            fprintf(stderr, "xc_domain_set_memory_map failed\n");
+            goto err;
+        }
+    }
     rv = xc_dom_build_image(dom);
     if ( rv )
     {
@@ -349,8 +407,10 @@ int main(int argc, char** argv)
     char buf[16], be_path[64], fe_path[64];
     int rv, fd;
     char *maxmem_str = NULL;
+    xentoollog_level minmsglevel = XTL_PROGRESS;
+    xentoollog_logger *logger = NULL;
 
-    while ( (opt = getopt_long(argc, argv, "", options, NULL)) != -1 )
+    while ( (opt = getopt_long(argc, argv, "v", options, NULL)) != -1 )
     {
         switch ( opt )
         {
@@ -375,6 +435,10 @@ int main(int argc, char** argv)
         case 'M':
             maxmem_str = optarg;
             break;
+        case 'v':
+            if ( minmsglevel )
+                minmsglevel--;
+            break;
         default:
             usage();
             return 2;
@@ -387,11 +451,15 @@ int main(int argc, char** argv)
         return 2;
     }
 
-    xch = xc_interface_open(NULL, NULL, 0);
+    logger = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr,
+                                                               minmsglevel, 0);
+
+    xch = xc_interface_open(logger, logger, 0);
     if ( !xch )
     {
         fprintf(stderr, "xc_interface_open() failed\n");
-        return 1;
+        rv = 1;
+        goto out;
     }
 
     if ( maxmem_str )
@@ -400,7 +468,8 @@ int main(int argc, char** argv)
         if ( maxmem < 0 )
         {
             xc_interface_close(xch);
-            return 1;
+            rv = 1;
+            goto out;
         }
     }
 
@@ -414,17 +483,24 @@ int main(int argc, char** argv)
     xc_interface_close(xch);
 
     if ( rv )
-        return 1;
+    {
+        rv = 1;
+        goto out;
+    }
 
     rv = gen_stub_json_config(domid, NULL);
     if ( rv )
-        return 3;
+    {
+        rv = 3;
+        goto out;
+    }
 
     xsh = xs_open(0);
     if ( !xsh )
     {
         fprintf(stderr, "xs_open() failed.\n");
-        return 3;
+        rv = 3;
+        goto out;
     }
     snprintf(buf, 16, "%d", domid);
     do_xs_write(xsh, "/tool/xenstored/domid", buf);
@@ -460,7 +536,8 @@ int main(int argc, char** argv)
     if ( fd < 0 )
     {
         fprintf(stderr, "Creating " XEN_RUN_DIR "/xenstored.pid failed\n");
-        return 3;
+        rv = 3;
+        goto out;
     }
     rv = snprintf(buf, 16, "domid:%d\n", domid);
     rv = write(fd, buf, rv);
@@ -469,10 +546,17 @@ int main(int argc, char** argv)
     {
         fprintf(stderr,
                 "Writing domid to " XEN_RUN_DIR "/xenstored.pid failed\n");
-        return 3;
+        rv = 3;
+        goto out;
     }
 
-    return 0;
+    rv = 0;
+
+ out:
+    if ( logger )
+        xtl_logger_destroy(logger);
+
+    return rv;
 }
 
 /*
diff -pruN 4.14.3+32-g9de3671772-1/tools/helpers/Makefile 4.16.1-1/tools/helpers/Makefile
--- 4.14.3+32-g9de3671772-1/tools/helpers/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/helpers/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -7,8 +7,10 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 PROGS += xen-init-dom0
 ifeq ($(CONFIG_Linux),y)
+ifeq ($(CONFIG_X86),y)
 PROGS += init-xenstore-domain
 endif
+endif
 
 XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
 $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
@@ -37,17 +39,11 @@ init-xenstore-domain: $(INIT_XENSTORE_DO
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-	$(INSTALL_PROG) xen-init-dom0 $(DESTDIR)$(LIBEXEC_BIN)
-ifeq ($(CONFIG_Linux),y)
-	$(INSTALL_PROG) init-xenstore-domain $(DESTDIR)$(LIBEXEC_BIN)
-endif
+	for i in $(PROGS); do $(INSTALL_PROG) $$i $(DESTDIR)$(LIBEXEC_BIN); done
 
 .PHONY: uninstall
 uninstall:
-ifeq ($(CONFIG_Linux),y)
-	rm -f $(DESTDIR)$(LIBEXEC_BIN)/init-xenstore-domain
-endif
-	rm -f $(DESTDIR)$(LIBEXEC_BIN)/xen-init-dom0
+	for i in $(PROGS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
 
 .PHONY: clean
 clean:
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/FreeBSD/rc.d/xencommons.in 4.16.1-1/tools/hotplug/FreeBSD/rc.d/xencommons.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/FreeBSD/rc.d/xencommons.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/FreeBSD/rc.d/xencommons.in	2022-04-12 12:21:23.000000000 +0000
@@ -21,9 +21,10 @@ status_cmd="xen_status"
 extra_commands="status"
 required_files="/dev/xen/xenstored"
 
-XENSTORED_PIDFILE="@XEN_RUN_DIR@/xenstored.pid"
 XENCONSOLED_PIDFILE="@XEN_RUN_DIR@/xenconsoled.pid"
-#XENCONSOLED_TRACE="@XEN_LOG_DIR@/xenconsole-trace.log"
+#XENCONSOLED_TRACE="none|guest|hv|all"
+
+XENSTORED_PIDFILE="@XEN_RUN_DIR@/xenstored.pid"
 #XENSTORED_TRACE="@XEN_LOG_DIR@/xen/xenstore-trace.log"
 
 load_rc_config $name
@@ -41,11 +42,6 @@ xen_startcmd()
 
 	xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${XENSTORED})
 	if test -z "$xenstored_pid"; then
-		printf "Cleaning xenstore database.\n"
-		if [ -z "${XENSTORED_ROOTDIR}" ]; then
-			XENSTORED_ROOTDIR="@XEN_LIB_STORED@"
-		fi
-		rm -f ${XENSTORED_ROOTDIR}/tdb* >/dev/null 2>&1
 		printf "Starting xenservices: xenstored, xenconsoled."
 		XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}"
 		if [ -n "${XENSTORED_TRACE}" ]; then
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/init.d/sysconfig.xencommons.in 4.16.1-1/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/init.d/sysconfig.xencommons.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/init.d/sysconfig.xencommons.in	2022-04-12 12:21:23.000000000 +0000
@@ -33,6 +33,19 @@
 #XENSTORED=@XENSTORED@
 
 ## Type: string
+## Default: unlimited
+#
+# Select maximum number of file descriptors xenstored is allowed to have
+# opened at one time.
+# For each HVM domain xenstored might need up to 5 open file descriptors,
+# PVH and PV domains will require up to 3 open file descriptors. Additionally
+# 20-30 file descriptors will be opened for internal uses.
+# The specified value (including "unlimited") will be capped by the contents
+# of /proc/sys/fs/nr_open if existing.
+# Only evaluated if XENSTORETYPE is "daemon".
+#XENSTORED_MAX_OPEN_FDS=unlimited
+
+## Type: string
 ## Default: ""
 #
 # Additional commandline arguments to start xenstored,
@@ -48,12 +61,14 @@ XENSTORED_ARGS=
 # Only evaluated if XENSTORETYPE is "daemon".
 #XENSTORED_TRACE=[yes|on|1]
 
-## Type: string
-## Default: "@XEN_LIB_STORED@"
+## Type: integer
+## Default: 50
 #
-# Running xenstored on XENSTORED_ROOTDIR
-# Only evaluated if XENSTORETYPE is "daemon".
-#XENSTORED_ROOTDIR=@XEN_LIB_STORED@
+# Percentage of dom0 memory size the xenstore daemon can use before the
+# OOM killer is allowed to kill it.
+# The specified value is multiplied by -10 and echoed to
+# /proc/PID/oom_score_adj.
+#XENSTORED_OOM_MEM_THRESHOLD=50
 
 ## Type: string
 ## Default: @LIBEXEC@/boot/xenstore-stubdom.gz
@@ -87,12 +102,6 @@ XENSTORED_ARGS=
 # Only evaluated if XENSTORETYPE is "domain".
 XENSTORE_DOMAIN_ARGS=
 
-## Type: string
-## Default: Not defined, xenbackendd debug mode off
-#
-# Running xenbackendd in debug mode
-#XENBACKENDD_DEBUG=[yes|on|1]
-
 # qemu path
 #QEMU_XEN=@qemu_xen_path@
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/init.d/xen-watchdog.in 4.16.1-1/tools/hotplug/Linux/init.d/xen-watchdog.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/init.d/xen-watchdog.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/init.d/xen-watchdog.in	2022-04-12 12:21:23.000000000 +0000
@@ -19,6 +19,11 @@
 
 . @XEN_SCRIPT_DIR@/hotplugpath.sh
 
+xencommons_config=@CONFIG_DIR@/@CONFIG_LEAF_DIR@
+
+test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
+
+test -n "$XENWATCHDOGD_ARGS" || XENWATCHDOGD_ARGS='30 15'
 DAEMON=${sbindir}/xenwatchdogd
 base=$(basename $DAEMON)
 
@@ -46,7 +51,7 @@ start() {
 	local r
 	echo -n $"Starting domain watchdog daemon: "
 
-	$DAEMON 30 15
+	$DAEMON $XENWATCHDOGD_ARGS
 	r=$?
 	[ "$r" -eq 0 ] && success $"$base startup" || failure $"$base startup"
 	echo
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/launch-xenstore.in 4.16.1-1/tools/hotplug/Linux/launch-xenstore.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/launch-xenstore.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/launch-xenstore.in	2022-04-12 12:21:23.000000000 +0000
@@ -53,18 +53,41 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/x
 /bin/mkdir -p @XEN_RUN_DIR@
 
 [ "$XENSTORETYPE" = "daemon" ] && {
-	[ -z "$XENSTORED_ROOTDIR" ] && XENSTORED_ROOTDIR="@XEN_LIB_STORED@"
 	[ -z "$XENSTORED_TRACE" ] || XENSTORED_ARGS="$XENSTORED_ARGS -T @XEN_LOG_DIR@/xenstored-trace.log"
+	[ -z "$XENSTORED_MAX_OPEN_FDS" ] && XENSTORED_MAX_OPEN_FDS=unlimited
 	[ -z "$XENSTORED" ] && XENSTORED=@XENSTORED@
 	[ -x "$XENSTORED" ] || {
 		echo "No xenstored found"
 		exit 1
 	}
+	XS_OOM_SCORE=-$((${XENSTORED_OOM_MEM_THRESHOLD:-50} * 10))
+
+	[ "$XENSTORED_MAX_OPEN_FDS" = "unlimited" ] || {
+		[ -z "${XENSTORED_MAX_OPEN_FDS//[0-9]}" ] &&
+		[ -n "$XENSTORED_MAX_OPEN_FDS" ] || {
+			echo "XENSTORED_MAX_OPEN_FDS=$XENSTORED_MAX_OPEN_FDS invalid"
+			echo "Setting to default \"unlimited\"."
+			XENSTORED_MAX_OPEN_FDS=unlimited
+		}
+	}
+	[ -r /proc/sys/fs/nr_open ] && {
+		MAX_FDS=`cat /proc/sys/fs/nr_open`
+		[ "$XENSTORED_MAX_OPEN_FDS" = "unlimited" ] && XENSTORED_MAX_OPEN_FDS=$MAX_FDS
+		[ $XENSTORED_MAX_OPEN_FDS -gt $MAX_FDS ] && {
+			echo "XENSTORED_MAX_OPEN_FDS exceeds system limit."
+			echo "Setting to \"$MAX_FDS\"."
+			XENSTORED_MAX_OPEN_FDS=$MAX_FDS
+		}
+	}
+
+	rm -f @XEN_RUN_DIR@/xenstored.pid
 
 	echo -n Starting $XENSTORED...
-	$XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
+	prlimit --nofile=$XENSTORED_MAX_OPEN_FDS $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
 
 	systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1
+	XS_PID=`cat @XEN_RUN_DIR@/xenstored.pid`
+	echo $XS_OOM_SCORE >/proc/$XS_PID/oom_score_adj
 
 	exit 0
 }
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/Makefile 4.16.1-1/tools/hotplug/Linux/Makefile
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -6,7 +6,6 @@ XEN_SCRIPTS = vif-bridge
 XEN_SCRIPTS += vif-route
 XEN_SCRIPTS += vif-nat
 XEN_SCRIPTS += vif-openvswitch
-XEN_SCRIPTS += vif2
 XEN_SCRIPTS += vif-setup
 XEN_SCRIPTS-$(CONFIG_LIBNL) += remus-netbuf-setup
 XEN_SCRIPTS += block
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/systemd/xenconsoled.service.in 4.16.1-1/tools/hotplug/Linux/systemd/xenconsoled.service.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/systemd/xenconsoled.service.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/systemd/xenconsoled.service.in	2022-04-12 12:21:23.000000000 +0000
@@ -9,7 +9,7 @@ Type=simple
 Environment=XENCONSOLED_ARGS=
 Environment=XENCONSOLED_TRACE=none
 Environment=XENCONSOLED_LOG_DIR=@XEN_LOG_DIR@/console
-EnvironmentFile=@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
+EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
 ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
 ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR}
 ExecStart=@sbindir@/xenconsoled -i --log=${XENCONSOLED_TRACE} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/systemd/xen-init-dom0.service.in 4.16.1-1/tools/hotplug/Linux/systemd/xen-init-dom0.service.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/systemd/xen-init-dom0.service.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/systemd/xen-init-dom0.service.in	2022-04-12 12:21:23.000000000 +0000
@@ -7,7 +7,7 @@ ConditionPathExists=/proc/xen/capabiliti
 [Service]
 Type=oneshot
 RemainAfterExit=true
-EnvironmentFile=@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
+EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
 ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
 ExecStart=@LIBEXEC_BIN@/xen-init-dom0 $XEN_DOM0_UUID
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/systemd/xen-watchdog.service.in 4.16.1-1/tools/hotplug/Linux/systemd/xen-watchdog.service.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/systemd/xen-watchdog.service.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/systemd/xen-watchdog.service.in	2022-04-12 12:21:23.000000000 +0000
@@ -6,7 +6,9 @@ ConditionPathExists=/proc/xen/capabiliti
 
 [Service]
 Type=forking
-ExecStart=@sbindir@/xenwatchdogd 30 15
+Environment="XENWATCHDOGD_ARGS=30 15"
+EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
+ExecStart=@sbindir@/xenwatchdogd $XENWATCHDOGD_ARGS
 KillSignal=USR1
 
 [Install]
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif2 4.16.1-1/tools/hotplug/Linux/vif2
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif2	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/vif2	1970-01-01 00:00:00.000000000 +0000
@@ -1,54 +0,0 @@
-#!/bin/bash
-
-dir=$(dirname "$0")
-. "$dir/xen-hotplug-common.sh"
-. "$dir/xen-network-common.sh"
-
-bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
-if [ -z "$bridge" ]
-    then
-    if which brctl >&/dev/null; then
-        nr_bridges=$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1))
-    else
-        nr_bridges=$(bridge link | wc -l)
-    fi
-    if [ "$nr_bridges" != 1 ]
-	then
-	fatal "no bridge specified, and don't know which one to use ($nr_bridges found)"
-    fi
-    if which brctl >&/dev/null; then
-        bridge=$(brctl show | cut -d "
-" -f 2 | cut -f 1)
-    else
-        bridge=$(bridge link | cut -d" " -f6)
-    fi
-fi
-
-command="$1"
-shift
-
-case "$command" in
-    "online")
-	if [ "$bridge" != "-" ]
-	    then
-	    setup_virtual_bridge_port "$vif"
-	    add_to_bridge "$bridge" "$vif"
-	else
-	    # Just let the normal udev rules for interfaces handle it.
-	    true
-	fi
-	success
-	;;
-
-    "add")
-	success
-	;;
-
-    "remove")
-	;;
-
-    *)
-	echo "Unknown command: $command"
-	echo 'Valid commands are: add, remove, online'
-	exit 1
-esac
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif-bridge 4.16.1-1/tools/hotplug/Linux/vif-bridge
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif-bridge	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/vif-bridge	2022-04-12 12:21:23.000000000 +0000
@@ -77,25 +77,13 @@ then
 fi
 
 case "$command" in
-    online)
+    add|online)
         setup_virtual_bridge_port "$dev"
-        set_mtu "$bridge" "$dev"
+        set_mtu "$bridge" "$dev" "$type_if"
         add_to_bridge "$bridge" "$dev"
         ;;
-
-    offline)
-        if which brctl >&/dev/null; then
-            do_without_error brctl delif "$bridge" "$dev"
-        else
-            do_without_error ip link set "$dev" nomaster
-        fi
-        do_without_error ifconfig "$dev" down
-        ;;
-
-    add)
-        setup_virtual_bridge_port "$dev"
-        set_mtu "$bridge" "$dev"
-        add_to_bridge "$bridge" "$dev"
+    remove|offline)
+        remove_from_bridge "$bridge" "$dev"
         ;;
 esac
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif-nat 4.16.1-1/tools/hotplug/Linux/vif-nat
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif-nat	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/vif-nat	2022-04-12 12:21:23.000000000 +0000
@@ -85,7 +85,7 @@ router_ip=$(routing_ip "$ip")
 # Split the given IP/bits pair.
 vif_ip=`echo ${ip} | awk -F/ '{print $1}'`
 
-hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----')
+hostname=dom$domid
 if [ "$vifid" != "1" ]
 then
   hostname="$hostname-$vifid"
@@ -95,12 +95,11 @@ dhcparg_remove_entry()
 {
   local tmpfile=$(mktemp)
   sed -e "s/${dev} //" "$dhcpd_arg_file" >"$tmpfile"
-  if diff "$tmpfile" "$dhcpd_arg_file" >/dev/null
+  if ! diff "$tmpfile" "$dhcpd_arg_file" >/dev/null
   then
-    rm "$tmpfile"
-  else
-    mv "$tmpfile" "$dhcpd_arg_file"
+    cp "$tmpfile" "$dhcpd_arg_file"
   fi
+  rm "$tmpfile"
 }
 
 dhcparg_add_entry()
@@ -109,11 +108,11 @@ dhcparg_add_entry()
   local tmpfile=$(mktemp)
   # handle Red Hat, SUSE, and Debian styles, with or without quotes
   sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
+     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
   sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
+     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
   sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
+     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
   rm -f "$tmpfile"
 }
 
@@ -121,12 +120,11 @@ dhcp_remove_entry()
 {
   local tmpfile=$(mktemp)
   grep -v "host $hostname" "$dhcpd_conf_file" >"$tmpfile"
-  if diff "$tmpfile" "$dhcpd_conf_file" >/dev/null
+  if ! diff "$tmpfile" "$dhcpd_conf_file" >/dev/null
   then
-    rm "$tmpfile"
-  else
-    mv "$tmpfile" "$dhcpd_conf_file"
+    cp "$tmpfile" "$dhcpd_conf_file"
   fi
+  rm "$tmpfile"
   dhcparg_remove_entry
 }
 
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif-route 4.16.1-1/tools/hotplug/Linux/vif-route
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/vif-route	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/vif-route	2022-04-12 12:21:23.000000000 +0000
@@ -22,17 +22,13 @@ dir=$(dirname "$0")
 main_ip=$(dom0_ip)
 
 case "${command}" in
-    add)
-        ;&
-    online)
+    add|online)
         ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
         echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
         ipcmd='add'
         cmdprefix=''
         ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
         do_without_error ifdown ${dev}
         ipcmd='del'
         cmdprefix='do_without_error'
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/xen-network-common.sh 4.16.1-1/tools/hotplug/Linux/xen-network-common.sh
--- 4.14.3+32-g9de3671772-1/tools/hotplug/Linux/xen-network-common.sh	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/Linux/xen-network-common.sh	2022-04-12 12:21:23.000000000 +0000
@@ -64,18 +64,18 @@ first_file()
 
 find_dhcpd_conf_file()
 {
-  first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf
+  first_file -f /etc/dhcp/dhcpd.conf /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf
 }
 
 
 find_dhcpd_init_file()
 {
-  first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd}
+  first_file -x /etc/init.d/{isc-dhcp-server,dhcp-server,dhcp3-server,dhcp,dhcpd}
 }
 
 find_dhcpd_arg_file()
 {
-  first_file -f /etc/sysconfig/dhcpd /etc/defaults/dhcp /etc/default/dhcp3-server
+  first_file -f /etc/sysconfig/dhcpd /etc/defaults/dhcp /etc/default/dhcp-server /etc/default/dhcp3-server
 }
 
 # configure interfaces which act as pure bridge ports:
@@ -126,26 +126,71 @@ add_to_bridge () {
     local bridge=$1
     local dev=$2
 
-    # Don't add $dev to $bridge if it's already on a bridge.
-    if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
-	ip link set dev ${dev} up || true
-	return
-    fi
-    if which brctl >&/dev/null; then
-        brctl addif ${bridge} ${dev}
+    # Don't add $dev to $bridge if it's already on the bridge.
+    if [ ! -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
+        log debug "adding $dev to bridge $bridge"
+        if which brctl >&/dev/null; then
+            brctl addif ${bridge} ${dev}
+        else
+            ip link set ${dev} master ${bridge}
+        fi
     else
-        ip link set ${dev} master ${bridge}
+        log debug "$dev already on bridge $bridge"
     fi
+
     ip link set dev ${dev} up
 }
 
+remove_from_bridge () {
+    local bridge=$1
+    local dev=$2
+
+    do_without_error ip link set dev ${dev} down
+
+    # Don't remove $dev from $bridge if it's not on the bridge.
+    if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
+        log debug "removing $dev from bridge $bridge"
+        if which brctl >&/dev/null; then
+            do_without_error brctl delif ${bridge} ${dev}
+        else
+            do_without_error ip link set ${dev} nomaster
+        fi
+    else
+        log debug "$dev not on bridge $bridge"
+    fi
+}
+
 # Usage: set_mtu bridge dev
 set_mtu () {
     local bridge=$1
     local dev=$2
-    mtu="`ip link show dev ${bridge}| awk '/mtu/ { print $5 }'`"
+    local type_if=$3
+
+    XENBUS_PATH="${XENBUS_PATH:?}"
+
+    local mtu=$(xenstore_read_default "$XENBUS_PATH/mtu" "")
+    if [ -z "$mtu" ]
+    then
+        mtu="`ip link show dev ${bridge}| awk '/mtu/ { print $5 }'`"
+        if [ -n "$mtu" ]
+        then
+            log debug "$bridge MTU is $mtu"
+        fi
+    fi
     if [ -n "$mtu" ] && [ "$mtu" -gt 0 ]
     then
-            ip link set dev ${dev} mtu $mtu || :
+        log debug "setting $dev MTU to $mtu"
+        ip link set dev ${dev} mtu ${mtu} || :
+
+        if [ ${type_if} = vif ]
+        then
+            local dev_=${dev#vif}
+            local domid=${dev_%.*}
+            local devid=${dev_#*.}
+
+            local FRONTEND_PATH="/local/domain/$domid/device/vif/$devid"
+
+            xenstore_write "$FRONTEND_PATH/mtu" ${mtu}
+        fi
     fi
 }
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/block 4.16.1-1/tools/hotplug/NetBSD/block
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/block	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/block	2022-04-12 12:21:23.000000000 +0000
@@ -1,11 +1,11 @@
 #!/bin/sh -e
 
 # $NetBSD: block-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $
-# Called by xenbackendd
 # Usage: block xsdir_backend_path state
 
 DIR=$(dirname "$0")
 . "${DIR}/hotplugpath.sh"
+. "${DIR}/locking.sh"
 
 PATH=${bindir}:${sbindir}:${LIBEXEC_BIN}:/bin:/usr/bin:/sbin:/usr/sbin
 export PATH
@@ -21,37 +21,28 @@ error() {
 xpath=$1
 xstatus=$2
 xparams=$(xenstore-read "$xpath/params")
-if [ -b "$xparams" ]; then
-	xtype="phy"
-elif [ -f "$xparams" ]; then
-	xtype="file"
-elif [ -z "$xparams" ]; then
-	error "$xpath/params is empty, unable to attach block device."
-else
-	error "$xparams is not a valid file type to use as block device." \
-	      "Only block and regular image files accepted."
-fi
 
 case $xstatus in
 6)
 	# device removed
-	case $xtype in
-	file)
-		vnd=$(xenstore-read "$xpath/vnd" || echo none)
-		if [ $vnd != none ]; then
-			vnconfig -u $vnd
-		fi
-		;;
-	phy)
-		;;
-	*)
-		echo "unknown type $xtype" >&2
-		;;
-	esac
+	vnd=$(xenstore-read "$xpath/vnd" || echo none)
+	if [ $vnd != none ]; then
+		vnconfig -u $vnd
+	fi
 	xenstore-rm $xpath
 	exit 0
 	;;
 2)
+	if [ -b "$xparams" ]; then
+		xtype="phy"
+	elif [ -f "$xparams" ]; then
+		xtype="file"
+	elif [ -z "$xparams" ]; then
+		error "$xpath/params is empty, unable to attach block device."
+	else
+		error "$xparams is not a valid file type to use as block device." \
+		      "Only block and regular image files accepted."
+	fi
 	case $xtype in
 	file)
 		# Store the list of available vnd(4) devices in
@@ -62,6 +53,7 @@ case $xstatus in
 			available_disks="$available_disks $disk"
 			eval $disk=free
 		done
+		claim_lock block
 		# Mark the used vnd(4) devices as ``used''.
 		for disk in `sysctl hw.disknames`; do
 			case $disk in
@@ -77,6 +69,7 @@ case $xstatus in
 				break	
 			fi
 		done
+		release_lock block
 		if [ x$device = x ] ; then
 			error "no available vnd device"
 		fi
@@ -86,7 +79,7 @@ case $xstatus in
 		device=$xparams
 		;;
 	esac
-	physical_device=$(stat -f '%r' "$device")
+	physical_device=$(stat -L -f '%r' "$device")
 	xenstore-write $xpath/physical-device $physical_device
 	xenstore-write $xpath/hotplug-status connected
 	exit 0
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/locking.sh 4.16.1-1/tools/hotplug/NetBSD/locking.sh
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/locking.sh	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/locking.sh	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,121 @@
+#
+# Copyright (c) 2005 XenSource Ltd.
+# Copyright (c) 2007 Red Hat
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; If not, see <http://www.gnu.org/licenses/>.
+#
+
+#
+# Serialisation
+#
+
+LOCK_BASEDIR=$XEN_LOCK_DIR/xen-hotplug
+
+_setlockfd()
+{
+    _lockfd=9
+    _lockfile="$LOCK_BASEDIR/$1"
+}
+
+
+claim_lock()
+{
+    mkdir -p "$LOCK_BASEDIR"
+    _setlockfd $1
+    # The locking strategy is identical to that from with-lock-ex(1)
+    # from chiark-utils, except using flock.  It has the benefit of
+    # it being possible to safely remove the lockfile when done.
+    # See below for a correctness proof.
+    local stat
+    while true; do
+        eval "exec $_lockfd<> $_lockfile"
+	# we can't flock $_lockfd here, as the shell closes it on exec.
+	# Workaround by redirecting to 0 for the command, and flock 0 instead.
+        flock -v -x 0  0<& $_lockfd|| exit 1
+        local file_stat
+        local fd_stat
+        if fd_stat=$(stat -f '%d.%i' 0<&$_lockfd 2>/dev/null) && file_stat=$(stat -f '%d.%i' $_lockfile 2>/dev/null )
+        then
+            if [ "$fd_stat" = "$file_stat" ] ; then break; fi
+        fi
+        # Some versions of bash appear to be buggy if the same
+        # $_lockfile is opened repeatedly. Close the current fd here.
+        eval "exec $_lockfd<&-"
+    done
+}
+
+
+release_lock()
+{
+    _setlockfd $1
+    rm "$_lockfile"
+}
+
+# Protocol and correctness proof:
+#
+# * The lock is owned not by a process but by an open-file (informally
+#   an fd).  Any process with an fd onto this open-file is a
+#   lockholder and may perform the various operations; such a process
+#   should only do so when its co-lockholder processes expect.  Ie, we
+#   will treat all processes holding fds onto the open-file as acting
+#   in concert and not distinguish between them.
+#
+# * You are a lockholder if
+#     - You have an fd onto an open-file which
+#       currently holds an exclusive flock lock on its inum
+#     - and that inum is currently linked at the lockfile path
+#
+# * The rules are:
+#     - No-one but a lockholder may unlink the lockfile path
+#       (or otherwise cause it to stop referring to a file it
+#       refers to).
+#     - Anyone may open the lockfile with O_CREAT
+#
+# * The protocol for locking is:
+#     - Open the file (O_CREAT)
+#     - flock it
+#     - fstat the fd you have open
+#     - stat the lockfile path
+#     - if both are equal you have the lock, otherwise try again.
+#
+# * Informal proof of exclusivity:
+#     - No two open-files can hold an fcntl lock onto the same file
+#       at the same time
+#     - No two files can have the same name at the same time
+#
+# * Informal proof of correctness of locking protocol:
+#     - After you call flock successfully no-one other than you
+#       (someone with the same open-file) can stop you having
+#       that flock lock.
+#     - Obviously the inum you get from the fstat is fixed
+#     - At the point where you call stat there are two
+#       possibilities:
+#         (i) the lockfile path referred to some other inum
+#             in which case you have failed
+#         (ii) the lockfile path referred to the same file
+#             in which case at that point you were the
+#             lockholder (by definition).
+#
+# * Informal proof that no-one else can steal the lock:
+#     - After you call flock successfully no-one other than you
+#       can stop you having that flock lock
+#     - No-one other than the lockholder is permitted to stop
+#       the path referring to a particular inum.  So if you
+#       hold the lock then only you are allowed to stop the
+#       path referring to the file whose flock you hold; so
+#       it will continue to refer to that file.
+#   That's both the conditions for being the lockholder.
+#
+#   Thus once you hold the lock at any instant, you will
+#   continue to do so until you voluntarily stop doing so
+#   (eg by unlinking the lockfile or closing the fd).
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/Makefile 4.16.1-1/tools/hotplug/NetBSD/Makefile
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -3,9 +3,11 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
 XEN_SCRIPTS =
+XEN_SCRIPTS += locking.sh
 XEN_SCRIPTS += block
 XEN_SCRIPTS += vif-bridge
 XEN_SCRIPTS += vif-ip
+XEN_SCRIPTS += qemu-ifup
 
 XEN_SCRIPT_DATA =
 XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/qemu-ifup 4.16.1-1/tools/hotplug/NetBSD/qemu-ifup
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/qemu-ifup	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/qemu-ifup	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+#called by qemu when a HVM domU is started.
+# first parameter is tap interface, second is the bridge name
+# environement variable $XEN_DOMAIN_ID contains the domU's ID,
+# which can be used to retrieve extra parameters from the xenstore.
+
+ifconfig $1 up
+exec /sbin/brconfig $2 add $1
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/rc.d/xencommons.in 4.16.1-1/tools/hotplug/NetBSD/rc.d/xencommons.in
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/rc.d/xencommons.in	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/rc.d/xencommons.in	2022-04-12 12:21:23.000000000 +0000
@@ -20,11 +20,10 @@ status_cmd="xen_status"
 extra_commands="status"
 required_files="/kern/xen/privcmd"
 
-XENSTORED_PIDFILE="@XEN_RUN_DIR@/xenstored.pid"
 XENCONSOLED_PIDFILE="@XEN_RUN_DIR@/xenconsoled.pid"
-XENBACKENDD_PIDFILE="@XEN_RUN_DIR@/xenbackendd.pid"
-#XENBACKENDD_DEBUG=1
-#XENCONSOLED_TRACE="@XEN_LOG_DIR@/xenconsole-trace.log"
+#XENCONSOLED_TRACE="none|guest|hv|all"
+
+XENSTORED_PIDFILE="@XEN_RUN_DIR@/xenstored.pid"
 #XENSTORED_TRACE="@XEN_LOG_DIR@/xenstore-trace.log"
 
 xen_precmd()
@@ -39,11 +38,6 @@ xen_startcmd()
 
 	xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${sbindir}/xenstored)
 	if test -z "$xenstored_pid"; then
-		printf "Cleaning xenstore database.\n"
-		if [ -z "${XENSTORED_ROOTDIR}" ]; then
-			XENSTORED_ROOTDIR="@XEN_LIB_STORED@"
-		fi
-		rm -f ${XENSTORED_ROOTDIR}/tdb* >/dev/null 2>&1
 		printf "Starting xenservices: xenstored, xenconsoled."
 		XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}"
 		if [ -n "${XENSTORED_TRACE}" ]; then
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/vif-bridge 4.16.1-1/tools/hotplug/NetBSD/vif-bridge
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/vif-bridge	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/vif-bridge	2022-04-12 12:21:23.000000000 +0000
@@ -1,7 +1,6 @@
 #!/bin/sh -e
 
 # $NetBSD: vif-bridge-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $
-# Called by xenbackendd
 # Usage: vif-bridge xsdir_backend_path state
 
 DIR=$(dirname "$0")
diff -pruN 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/vif-ip 4.16.1-1/tools/hotplug/NetBSD/vif-ip
--- 4.14.3+32-g9de3671772-1/tools/hotplug/NetBSD/vif-ip	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/hotplug/NetBSD/vif-ip	2022-04-12 12:21:23.000000000 +0000
@@ -1,7 +1,6 @@
 #!/bin/sh -e
 
 # $NetBSD: vif-ip-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $
-# Called by xenbackendd
 # Usage: vif-ip xsdir_backend_path state
 
 DIR=$(dirname "$0")
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxenvchan.h 4.16.1-1/tools/include/libxenvchan.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxenvchan.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxenvchan.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,176 @@
+/**
+ * @file
+ * @section AUTHORS
+ *
+ * Copyright (C) 2010  Rafal Wojtczuk  <rafal@invisiblethingslab.com>
+ *
+ *  Authors:
+ *       Rafal Wojtczuk  <rafal@invisiblethingslab.com>
+ *       Daniel De Graaf <dgdegra@tycho.nsa.gov>
+ *
+ * @section LICENSE
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @section DESCRIPTION
+ *
+ *  Originally borrowed from the Qubes OS Project, http://www.qubes-os.org,
+ *  this code has been substantially rewritten to use the gntdev and gntalloc
+ *  devices instead of raw MFNs and map_foreign_range.
+ *
+ *  This is a library for inter-domain communication.  A standard Xen ring
+ *  buffer is used, with a datagram-based interface built on top.  The grant
+ *  reference and event channels are shared in XenStore under the path
+ *  /local/domain/<srv-id>/data/vchan/<cli-id>/<port>/{ring-ref,event-channel}
+ *
+ *  The ring.h macros define an asymmetric interface to a shared data structure
+ *  that assumes all rings reside in a single contiguous memory space. This is
+ *  not suitable for vchan because the interface to the ring is symmetric except
+ *  for the setup. Unlike the producer-consumer rings defined in ring.h, the
+ *  size of the rings used in vchan are determined at execution time instead of
+ *  compile time, so the macros in ring.h cannot be used to access the rings.
+ */
+
+#include <xen/io/libxenvchan.h>
+#include <xen/xen.h>
+#include <xen/sys/evtchn.h>
+#include <xenevtchn.h>
+#include <xengnttab.h>
+
+/* Callers who don't care don't need to #include <xentoollog.h> */
+struct xentoollog_logger;
+
+struct libxenvchan_ring {
+	/* Pointer into the shared page. Offsets into buffer. */
+	struct ring_shared* shr;
+	/* ring data; may be its own shared page(s) depending on order */
+	void* buffer;
+	/**
+	 * The size of the ring is (1 << order); offsets wrap around when they
+	 * exceed this. This copy is required because we can't trust the order
+	 * in the shared page to remain constant.
+	 */
+	int order;
+};
+
+/**
+ * struct libxenvchan: control structure passed to all library calls
+ */
+struct libxenvchan {
+	/* Mapping handle for shared ring page */
+	union {
+		xengntshr_handle *gntshr; /* for server */
+		xengnttab_handle *gnttab; /* for client */
+	};
+	/* Pointer to shared ring page */
+	struct vchan_interface *ring;
+	/* event channel interface */
+	xenevtchn_handle *event;
+	uint32_t event_port;
+	/* informative flags: are we acting as server? */
+	int is_server:1;
+	/* true if server remains active when client closes (allows reconnection) */
+	int server_persist:1;
+	/* true if operations should block instead of returning 0 */
+	int blocking:1;
+	/* communication rings */
+	struct libxenvchan_ring read, write;
+};
+
+/**
+ * Set up a vchan, including granting pages
+ * @param logger Logger for libxc errors
+ * @param domain The peer domain that will be connecting
+ * @param xs_path Base xenstore path for storing ring/event data
+ * @param send_min The minimum size (in bytes) of the send ring (left)
+ * @param recv_min The minimum size (in bytes) of the receive ring (right)
+ * @return The structure, or NULL in case of an error
+ */
+struct libxenvchan *libxenvchan_server_init(struct xentoollog_logger *logger,
+                                            int domain, const char* xs_path,
+                                            size_t read_min, size_t write_min);
+/**
+ * Connect to an existing vchan. Note: you can reconnect to an existing vchan
+ * safely, however no locking is performed, so you must prevent multiple clients
+ * from connecting to a single server.
+ *
+ * @param logger Logger for libxc errors
+ * @param domain The peer domain to connect to
+ * @param xs_path Base xenstore path for storing ring/event data
+ * @return The structure, or NULL in case of an error
+ */
+struct libxenvchan *libxenvchan_client_init(struct xentoollog_logger *logger,
+                                            int domain, const char* xs_path);
+/**
+ * Close a vchan. This deallocates the vchan and attempts to free its
+ * resources. The other side is notified of the close, but can still read any
+ * data pending prior to the close.
+ */
+void libxenvchan_close(struct libxenvchan *ctrl);
+
+/**
+ * Packet-based receive: always reads exactly $size bytes.
+ * @param ctrl The vchan control structure
+ * @param data Buffer for data that was read
+ * @param size Size of the buffer and amount of data to read
+ * @return -1 on error, 0 if nonblocking and insufficient data is available, or $size
+ */
+int libxenvchan_recv(struct libxenvchan *ctrl, void *data, size_t size);
+/**
+ * Stream-based receive: reads as much data as possible.
+ * @param ctrl The vchan control structure
+ * @param data Buffer for data that was read
+ * @param size Size of the buffer
+ * @return -1 on error, otherwise the amount of data read (which may be zero if
+ *         the vchan is nonblocking)
+ */
+int libxenvchan_read(struct libxenvchan *ctrl, void *data, size_t size);
+/**
+ * Packet-based send: send entire buffer if possible
+ * @param ctrl The vchan control structure
+ * @param data Buffer for data to send
+ * @param size Size of the buffer and amount of data to send
+ * @return -1 on error, 0 if nonblocking and insufficient space is available, or $size
+ */
+int libxenvchan_send(struct libxenvchan *ctrl, const void *data, size_t size);
+/**
+ * Stream-based send: send as much data as possible.
+ * @param ctrl The vchan control structure
+ * @param data Buffer for data to send
+ * @param size Size of the buffer
+ * @return -1 on error, otherwise the amount of data sent (which may be zero if
+ *         the vchan is nonblocking)
+ */
+int libxenvchan_write(struct libxenvchan *ctrl, const void *data, size_t size);
+/**
+ * Waits for reads or writes to unblock, or for a close
+ */
+int libxenvchan_wait(struct libxenvchan *ctrl);
+/**
+ * Returns the event file descriptor for this vchan. When this FD is readable,
+ * libxenvchan_wait() will not block, and the state of the vchan has changed since
+ * the last invocation of libxenvchan_wait().
+ */
+int libxenvchan_fd_for_select(struct libxenvchan *ctrl);
+/**
+ * Query the state of the vchan shared page:
+ *  return 0 when one side has called libxenvchan_close() or crashed
+ *  return 1 when both sides are open
+ *  return 2 [server only] when no client has yet connected
+ */
+int libxenvchan_is_open(struct libxenvchan* ctrl);
+/** Amount of data ready to read, in bytes */
+int libxenvchan_data_ready(struct libxenvchan *ctrl);
+/** Amount of data it is possible to send without blocking */
+int libxenvchan_buffer_space(struct libxenvchan *ctrl);
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxl_event.h 4.16.1-1/tools/include/libxl_event.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxl_event.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxl_event.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,632 @@
+/*
+ * Copyright (C) 2011      Citrix Ltd.
+ * Author Ian Jackson <ian.jackson@eu.citrix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXL_EVENT_H
+#define LIBXL_EVENT_H
+
+#include <libxl.h>
+#include <poll.h>
+#include <sys/time.h>
+
+/*======================================================================*/
+
+/*
+ * Domain event handling - getting Xen events from libxl
+ *
+ * (Callers inside libxl may not call libxl_event_check or _wait.)
+ */
+
+#define LIBXL_EVENTMASK_ALL (~(unsigned long)0)
+
+typedef int libxl_event_predicate(const libxl_event*, void *user);
+  /* Return value is 0 if the event is unwanted or non-0 if it is.
+   * Predicates are not allowed to fail.
+   */
+
+int libxl_event_check(libxl_ctx *ctx, libxl_event **event_r,
+                      uint64_t typemask,
+                      libxl_event_predicate *predicate, void *predicate_user)
+                      LIBXL_EXTERNAL_CALLERS_ONLY;
+  /* Searches for an event, already-happened, which matches typemask
+   * and predicate.  predicate==0 matches any event.
+   * libxl_event_check returns the event, which must then later be
+   * freed by the caller using libxl_event_free.
+   *
+   * Returns ERROR_NOT_READY if no such event has happened.
+   */
+
+int libxl_event_wait(libxl_ctx *ctx, libxl_event **event_r,
+                     uint64_t typemask,
+                     libxl_event_predicate *predicate, void *predicate_user)
+                     LIBXL_EXTERNAL_CALLERS_ONLY;
+  /* Like libxl_event_check but blocks if no suitable events are
+   * available, until some are.  Uses libxl_osevent_beforepoll/
+   * _afterpoll so may be inefficient if very many domains are being
+   * handled by a single program.
+   */
+
+void libxl_event_free(libxl_ctx *ctx, libxl_event *event);
+
+
+/* Alternatively or additionally, the application may also use this: */
+
+typedef struct libxl_event_hooks {
+    uint64_t event_occurs_mask;
+    void (*event_occurs)(void *user,
+#ifndef LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG
+                         const
+#endif
+                         libxl_event *event);
+    void (*disaster)(void *user, libxl_event_type type,
+                     const char *msg, int errnoval);
+} libxl_event_hooks;
+
+void libxl_event_register_callbacks(libxl_ctx *ctx,
+                                    const libxl_event_hooks *hooks, void *user);
+  /*
+   * Arranges that libxl will henceforth call event_occurs for any
+   * events whose type is set in event_occurs_mask, rather than
+   * queueing the event for retrieval by libxl_event_check/wait.
+   * Events whose bit is clear in mask are not affected.
+   *
+   * event becomes owned by the application and must be freed, either
+   * by event_occurs or later.
+   *
+   * event_occurs may be NULL if mask is 0.
+   *
+   * libxl_event_register_callback also provides a way for libxl to
+   * report to the application that there was a problem reporting
+   * events; this can occur due to lack of host memory during event
+   * handling, or other wholly unrecoverable errors from system calls
+   * made by libxl.  This will not happen for frivolous reasons - only
+   * if the system, or the Xen components of it, are badly broken.
+   *
+   * msg and errnoval will describe the action that libxl was trying
+   * to do, and type specifies the type of libxl events which may be
+   * missing.  type may be 0 in which case events of all types may be
+   * missing.
+   *
+   * disaster may be NULL.  If it is, or if _register_callbacks has
+   * not been called, errors of this kind are fatal to the entire
+   * application: libxl will print messages to its logs and to stderr
+   * and call exit(-1).
+   *
+   * If disaster returns, it may be the case that some or all future
+   * libxl calls will return errors; likewise it may be the case that
+   * no more events (of the specified type, if applicable) can be
+   * produced.  An application which supplies a disaster function
+   * should normally react either by exiting, or by (when it has
+   * returned to its main event loop) shutting down libxl with
+   * libxl_ctx_free and perhaps trying to restart it with
+   * libxl_ctx_init.
+   *
+   * In any case before calling disaster, libxl will have logged a
+   * message with level XTL_CRITICAL.
+   *
+   * Reentrancy: it IS permitted to call libxl from within
+   * event_occurs.  It is NOT permitted to call libxl from within
+   * disaster.  The event_occurs and disaster callbacks may occur on
+   * any thread in which the application calls libxl.
+   *
+   * libxl_event_register_callbacks may be called as many times, with
+   * different parameters, as the application likes; the most recent
+   * call determines the libxl behaviour.  However it is NOT safe to
+   * call _register_callbacks concurrently with, or reentrantly from,
+   * any other libxl function, nor while any event-generation
+   * facilities are enabled.
+   */
+
+
+/*
+ * Events are only generated if they have been requested.
+ * The following functions request the generation of specific events.
+ *
+ * Each set of functions for controlling event generation has this form:
+ *
+ *   typedef struct libxl__evgen_FOO libxl__evgen_FOO;
+ *   int libxl_evenable_FOO(libxl_ctx *ctx, FURTHER PARAMETERS,
+ *                          libxl_ev_user user, libxl__evgen_FOO **evgen_out);
+ *   void libxl_evdisable_FOO(libxl_ctx *ctx, libxl__evgen_FOO *evgen);
+ *
+ * The evenable function arranges that the events (as described in the
+ * doc comment for the individual function) will start to be generated
+ * by libxl.  On success, *evgen_out is set to a non-null pointer to
+ * an opaque struct.
+ *
+ * The user value is returned in the generated events and may be
+ * used by the caller for whatever it likes.  The type ev_user is
+ * guaranteed to be an unsigned integer type which is at least
+ * as big as uint64_t and is also guaranteed to be big enough to
+ * contain any intptr_t value.
+ *
+ * If it becomes desirable to stop generation of the relevant events,
+ * or to reclaim the resources in libxl associated with the evgen
+ * structure, the same evgen value should be passed to the evdisable
+ * function.  However, note that events which occurred prior to the
+ * evdisable call may still be returned.
+ *
+ * The caller may enable identical events more than once.  If they do
+ * so, each actual occurrence will generate several events to be
+ * returned by libxl_event_check, with the appropriate user value(s).
+ * Aside from this, each occurrence of each event is returned by
+ * libxl_event_check exactly once.
+ *
+ * An evgen is associated with the libxl_ctx used for its creation.
+ * After libxl_ctx_free, all corresponding evgen handles become
+ * invalid and must no longer be passed to evdisable.
+ *
+ * Applications should ensure that they eventually retrieve every
+ * event using libxl_event_check or libxl_event_wait, since events
+ * which occur but are not retrieved by the application will be queued
+ * inside libxl indefinitely.  libxl_event_check/_wait may be O(n)
+ * where n is the number of queued events which do not match the
+ * criteria specified in the arguments to check/wait.
+ */
+
+typedef struct libxl__evgen_domain_death libxl_evgen_domain_death;
+int libxl_evenable_domain_death(libxl_ctx *ctx, uint32_t domid,
+                         libxl_ev_user, libxl_evgen_domain_death **evgen_out);
+void libxl_evdisable_domain_death(libxl_ctx *ctx, libxl_evgen_domain_death*);
+  /* Arranges for the generation of DOMAIN_SHUTDOWN and DOMAIN_DEATH
+   * events.  A domain which is destroyed before it shuts down
+   * may generate only a DEATH event.
+   */
+
+typedef struct libxl__evgen_disk_eject libxl_evgen_disk_eject;
+int libxl_evenable_disk_eject(libxl_ctx *ctx, uint32_t domid, const char *vdev,
+                        libxl_ev_user, libxl_evgen_disk_eject **evgen_out);
+void libxl_evdisable_disk_eject(libxl_ctx *ctx, libxl_evgen_disk_eject*);
+  /* Arranges for the generation of DISK_EJECT events.  A copy of the
+   * string *vdev will be made for libxl's internal use, and a pointer
+   * to this (or some other) copy will be returned as the vdev
+   * member of event.u.
+   */
+
+
+/*======================================================================*/
+
+/*
+ * OS event handling - passing low-level OS events to libxl
+ *
+ * Event-driven programs must use these facilities to allow libxl
+ * to become aware of readability/writeability of file descriptors
+ * and the occurrence of timeouts.
+ *
+ * There are two approaches available.  The first is appropriate for
+ * simple programs handling reasonably small numbers of domains:
+ *
+ *   for (;;) {
+ *      libxl_osevent_beforepoll(...)
+ *      poll();
+ *      libxl_osevent_afterpoll(...);
+ *      for (;;) {
+ *          r = libxl_event_check(...);
+ *          if (r==ERROR_NOT_READY) break;
+ *          if (r) goto error_out;
+ *          do something with the event;
+ *      }
+ *   }
+ *
+ * The second approach uses libxl_osevent_register_hooks and is
+ * suitable for programs which are already using a callback-based
+ * event library.
+ *
+ * An application may freely mix the two styles of interaction.
+ *
+ * (Callers inside libxl may not call libxl_osevent_... functions.)
+ */
+
+struct pollfd;
+
+/* The caller should provide beforepoll with some space for libxl's
+ * fds, and tell libxl how much space is available by setting *nfds_io.
+ * fds points to the start of this space (and fds may be a pointer into
+ * a larger array, for example, if the application has some fds of
+ * its own that it is interested in).
+ *
+ * On return *nfds_io will in any case have been updated by libxl
+ * according to how many fds libxl wants to poll on.
+ *
+ * If the space was sufficient, libxl fills in fds[0..<new
+ * *nfds_io>] suitably for poll(2), updates *timeout_upd if needed,
+ * and returns ok.
+ *
+ * If space was insufficient, fds[0..<old *nfds_io>] is undefined on
+ * return; *nfds_io on return will be greater than the value on
+ * entry; *timeout_upd may or may not have been updated; and
+ * libxl_osevent_beforepoll returns ERROR_BUFERFULL.  In this case
+ * the application needs to make more space (enough space for
+ * *nfds_io struct pollfd) and then call beforepoll again, before
+ * entering poll(2).  Typically this will involve calling realloc.
+ *
+ * The application may call beforepoll with fds==NULL and
+ * *nfds_io==0 in order to find out how much space is needed.
+ *
+ * *timeout_upd is as for poll(2): it's in milliseconds, and
+ * negative values mean no timeout (infinity).
+ * libxl_osevent_beforepoll will only reduce the timeout, naturally.
+ */
+int libxl_osevent_beforepoll(libxl_ctx *ctx, int *nfds_io,
+                             struct pollfd *fds, int *timeout_upd,
+                             struct timeval now)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* nfds and fds[0..nfds] must be from the most recent call to
+ * _beforepoll, as modified by poll.  (It is therefore not possible
+ * to have multiple threads simultaneously polling using this
+ * interface.)
+ *
+ * This function actually performs all of the IO and other actions,
+ * and generates events (libxl_event), which are implied by either
+ * (a) the time of day or (b) both (i) the returned information from
+ * _beforepoll, and (ii) the results from poll specified in
+ * fds[0..nfds-1].  Generated events can then be retrieved by
+ * libxl_event_check.
+ */
+void libxl_osevent_afterpoll(libxl_ctx *ctx, int nfds, const struct pollfd *fds,
+                             struct timeval now)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+
+typedef struct libxl_osevent_hooks {
+  int (*fd_register)(void *user, int fd, void **for_app_registration_out,
+                     short events, void *for_libxl);
+  int (*fd_modify)(void *user, int fd, void **for_app_registration_update,
+                   short events);
+  void (*fd_deregister)(void *user, int fd, void *for_app_registration);
+  int (*timeout_register)(void *user, void **for_app_registration_out,
+                          struct timeval abs, void *for_libxl);
+  int (*timeout_modify)(void *user, void **for_app_registration_update,
+                         struct timeval abs)
+      /* only ever called with abs={0,0}, meaning ASAP */;
+  void (*timeout_deregister)(void *user, void *for_app_registration)
+      /* will never be called */;
+} libxl_osevent_hooks;
+
+/* The application which calls register_fd_hooks promises to
+ * maintain a register of fds and timeouts that libxl is interested
+ * in, and make calls into libxl (libxl_osevent_occurred_*)
+ * when those fd events and timeouts occur.  This is more efficient
+ * than _beforepoll/_afterpoll if there are many fds (which can
+ * happen if the same libxl application is managing many domains).
+ *
+ * For an fd event, events is as for poll().  register or modify may
+ * be called with events==0, in which case it must still work
+ * normally, just not generate any events.
+ *
+ * For a timeout event, milliseconds is as for poll().
+ * Specifically, negative values of milliseconds mean NO TIMEOUT.
+ * This is used by libxl to temporarily disable a timeout.
+ *
+ * If the register or modify hook succeeds it may update
+ * *for_app_registration_out/_update and must then return 0.
+ * On entry to register, *for_app_registration_out is always NULL.
+ *
+ * A registration or modification hook may fail, in which case it
+ * must leave the registration state of the fd or timeout unchanged.
+ * It may then either return ERROR_OSEVENT_REG_FAIL or any positive
+ * int.  The value returned will be passed up through libxl and
+ * eventually returned back to the application.  When register
+ * fails, any value stored into *for_registration_out is ignored by
+ * libxl; when modify fails, any changed value stored into
+ * *for_registration_update is honoured by libxl and will be passed
+ * to future modify or deregister calls.
+ *
+ * libxl may want to register more than one callback for any one fd;
+ * in that case: (i) each such registration will have at least one bit
+ * set in revents which is unique to that registration; (ii) if an
+ * event occurs which is relevant for multiple registrations the
+ * application's event system may call libxl_osevent_occurred_fd
+ * for one, some, or all of those registrations.
+ *
+ * If fd_modify is used, it is permitted for the application's event
+ * system to still make calls to libxl_osevent_occurred_fd for the
+ * "old" set of requested events; these will be safely ignored by
+ * libxl.
+ *
+ * libxl will remember the value stored in *for_app_registration_out
+ * (or *for_app_registration_update) by a successful call to
+ * register (or modify), and pass it to subsequent calls to modify
+ * or deregister.
+ *
+ * Note that the application must cope with a call from libxl to
+ * timeout_modify racing with its own call to
+ * libxl__osevent_occurred_timeout.  libxl guarantees that
+ * timeout_modify will only be called with abs={0,0} but the
+ * application must still ensure that libxl's attempt to cause the
+ * timeout to occur immediately is safely ignored even the timeout is
+ * actually already in the process of occurring.
+ *
+ * timeout_deregister is not used because it forms part of a
+ * deprecated unsafe mode of use of the API.
+ *
+ * osevent_register_hooks may be called only once for each libxl_ctx.
+ * libxl may make calls to register/modify/deregister from within
+ * any libxl function (indeed, it will usually call register from
+ * register_event_hooks).  Conversely, the application MUST NOT make
+ * the event occurrence calls (libxl_osevent_occurred_*) into libxl
+ * reentrantly from within libxl (for example, from within the
+ * register/modify functions).
+ *
+ * Lock hierarchy: the register/modify/deregister functions may be
+ * called with locks held.  These locks (the "libxl internal locks")
+ * are inside the libxl_ctx.  Therefore, if those register functions
+ * acquire any locks of their own ("caller register locks") outside
+ * libxl, to avoid deadlock one of the following must hold for each
+ * such caller register lock:
+ *  (a) "acquire libxl internal locks before caller register lock":
+ *      No libxl function may be called with the caller register
+ *      lock held.
+ *  (b) "acquire caller register lock before libxl internal locks":
+ *      No libxl function may be called _without_ the caller
+ *      register lock held.
+ * Of these we would normally recommend (a).
+ *
+ * The value *hooks is not copied and must outlast the libxl_ctx.
+ */
+void libxl_osevent_register_hooks(libxl_ctx *ctx,
+                                  const libxl_osevent_hooks *hooks,
+                                  void *user);
+
+/* It is NOT legal to call _occurred_ reentrantly within any libxl
+ * function.  Specifically it is NOT legal to call it from within
+ * a register callback.  Conversely, libxl MAY call register/deregister
+ * from within libxl_event_occurred_call_*.
+ */
+
+void libxl_osevent_occurred_fd(libxl_ctx *ctx, void *for_libxl,
+                               int fd, short events, short revents)
+                               LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* Implicitly, on entry to this function the timeout has been
+ * deregistered.  If _occurred_timeout is called, libxl will not
+ * call timeout_deregister; if it wants to requeue the timeout it
+ * will call timeout_register again.
+ */
+void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl)
+                                    LIBXL_EXTERNAL_CALLERS_ONLY;
+
+
+/*======================================================================*/
+
+/*
+ * Subprocess handling.
+ *
+ * Unfortunately the POSIX interface makes this very awkward.
+ *
+ * There are two possible arrangements for collecting statuses from
+ * wait/waitpid.
+ *
+ * For naive programs:
+ *
+ *     libxl will keep a SIGCHLD handler installed whenever it has an
+ *     active (unreaped) child.  It will reap all children with
+ *     wait(); any children it does not recognise will be passed to
+ *     the application via an optional callback (and will result in
+ *     logged warnings if no callback is provided or the callback
+ *     denies responsibility for the child).
+ *
+ *     libxl may have children whenever:
+ *
+ *       - libxl is performing an operation which can be made
+ *         asynchronous; ie one taking a libxl_asyncop_how, even
+ *         if NULL is passed indicating that the operation is
+ *         synchronous; or
+ *
+ *       - events of any kind are being generated, as requested
+ *         by libxl_evenable_....
+ *
+ *     A multithreaded application which is naive in this sense may
+ *     block SIGCHLD on some of its threads, but there must be at
+ *     least one thread that has SIGCHLD unblocked.  libxl will not
+ *     modify the blocking flag for SIGCHLD (except that it may create
+ *     internal service threads with all signals blocked).
+ *
+ *     A naive program must only have at any one time only
+ *     one libxl context which might have children.
+ *
+ * For programs which run their own children alongside libxl's:
+ *
+ *     A program which does this must call libxl_childproc_setmode.
+ *     There are three options:
+ * 
+ *     libxl_sigchld_owner_libxl:
+ *
+ *       While any libxl operation which might use child processes
+ *       is running, works like libxl_sigchld_owner_libxl_always;
+ *       but, deinstalls the handler the rest of the time.
+ *
+ *       In this mode, the application, while it uses any libxl
+ *       operation which might create or use child processes (see
+ *       above):
+ *           - Must not have any child processes running.
+ *           - Must not install a SIGCHLD handler.
+ *           - Must not reap any children.
+ *
+ *       This is the default (i.e. if setmode is not called, or 0 is
+ *       passed for hooks).
+ *
+ *     libxl_sigchld_owner_mainloop:
+ *
+ *       The application must install a SIGCHLD handler and reap (at
+ *       least) all of libxl's children and pass their exit status to
+ *       libxl by calling libxl_childproc_exited.  (If the application
+ *       has multiple libxl ctx's, it must call libxl_childproc_exited
+ *       on each ctx.)
+ *
+ *     libxl_sigchld_owner_libxl_always:
+ *
+ *       The application expects this libxl ctx to reap all of the
+ *       process's children, and provides a callback to be notified of
+ *       their exit statuses.  The application must have only one
+ *       libxl_ctx configured this way.
+ *
+ *     libxl_sigchld_owner_libxl_always_selective_reap:
+ *
+ *       The application expects to reap all of its own children
+ *       synchronously, and does not use SIGCHLD.  libxl is to install
+ *       a SIGCHLD handler.  The application may have multiple
+ *       libxl_ctxs configured this way; in which case all of its ctxs
+ *       must be so configured.
+ */
+
+
+typedef enum {
+    /* libxl owns SIGCHLD whenever it has a child, and reaps
+     * all children, including those not spawned by libxl. */
+    libxl_sigchld_owner_libxl,
+
+    /* Application promises to discover when SIGCHLD occurs and call
+     * libxl_childproc_exited or libxl_childproc_sigchld_occurred (but
+     * NOT from within a signal handler).  libxl will not itself
+     * arrange to (un)block or catch SIGCHLD. */
+    libxl_sigchld_owner_mainloop,
+
+    /* libxl owns SIGCHLD all the time, and the application is
+     * relying on libxl's event loop for reaping its children too. */
+    libxl_sigchld_owner_libxl_always,
+
+    /* libxl owns SIGCHLD all the time, but it must only reap its own
+     * children.  The application will reap its own children
+     * synchronously with waitpid, without the assistance of SIGCHLD. */
+    libxl_sigchld_owner_libxl_always_selective_reap,
+} libxl_sigchld_owner;
+
+typedef struct {
+    libxl_sigchld_owner chldowner;
+
+    /* All of these are optional: */
+
+    /* Called by libxl instead of fork.  Should behave exactly like
+     * fork, including setting errno etc.  May NOT reenter into libxl.
+     * Application may use this to discover pids of libxl's children,
+     * for example.
+     */
+    pid_t (*fork_replacement)(void *user);
+
+    /* With libxl_sigchld_owner_libxl, called by libxl when it has
+     * reaped a pid.  (Not permitted with _owner_mainloop.)
+     *
+     * Should return 0 if the child was recognised by the application
+     * (or if the application does not keep those kind of records),
+     * ERROR_UNKNOWN_CHILD if the application knows that the child is not
+     * the application's; if it returns another error code it is a
+     * disaster as described for libxl_event_register_callbacks.
+     * (libxl will report unexpected children to its error log.)
+     *
+     * If not supplied, the application is assumed not to start
+     * any children of its own.
+     *
+     * This function is NOT called from within the signal handler.
+     * Rather it will be called from inside a libxl's event handling
+     * code and thus only when libxl is running, for example from
+     * within libxl_event_wait.  (libxl uses the self-pipe trick
+     * to implement this.)
+     *
+     * childproc_exited_callback may call back into libxl, but it
+     * is best to avoid making long-running libxl calls as that might
+     * stall the calling event loop while the nested operation
+     * completes.
+     */
+    int (*reaped_callback)(pid_t, int status, void *user);
+} libxl_childproc_hooks;
+
+/* hooks may be 0 in which is equivalent to &{ libxl_sigchld_owner_libxl, 0, 0 }
+ *
+ * May not be called when libxl might have any child processes, or the
+ * behaviour is undefined.  So it is best to call this at
+ * initialisation.
+ *
+ * The value *hooks is not copied and must outlast the libxl_ctx.
+ */
+void libxl_childproc_setmode(libxl_ctx *ctx, const libxl_childproc_hooks *hooks,
+                             void *user);
+
+/*
+ * This function is for an application which owns SIGCHLD and which
+ * reaps all of the process's children, and dispatches the exit status
+ * to the correct place inside the application.
+ *
+ * May be called only by an application which has called setmode with
+ * chldowner == libxl_sigchld_owner_mainloop.  If pid was a process started
+ * by this instance of libxl, returns 0 after doing whatever
+ * processing is appropriate.  Otherwise silently returns
+ * ERROR_UNKNOWN_CHILD.  No other error returns are possible.
+ *
+ * May NOT be called from within a signal handler which might
+ * interrupt any libxl operation.  The application will almost
+ * certainly need to use the self-pipe trick (or a working pselect or
+ * ppoll) to implement this.
+ */
+int libxl_childproc_reaped(libxl_ctx *ctx, pid_t, int status)
+                           LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * This function is for an application which owns SIGCHLD but which
+ * doesn't keep track of all of its own children in a manner suitable
+ * for reaping all of them and then dispatching them.
+ *
+ * Such an the application must notify libxl, by calling this
+ * function, that a SIGCHLD occurred.  libxl will then check all its
+ * children, reap any that are ready, and take any action necessary -
+ * but it will not reap anything else.
+ *
+ * May be called only by an application which has called setmode with
+ * chldowner == libxl_sigchld_owner_mainloop.
+ *
+ * May NOT be called from within a signal handler which might
+ * interrupt any libxl operation (just like libxl_childproc_reaped).
+ */
+void libxl_childproc_sigchld_occurred(libxl_ctx *ctx)
+                           LIBXL_EXTERNAL_CALLERS_ONLY;
+
+
+/*
+ * An application which initialises a libxl_ctx in a parent process
+ * and then forks a child which does not quickly exec, must
+ * instead libxl_postfork_child_noexec in the child.  One call
+ * on any existing (or specially made) ctx is sufficient; after
+ * this all previously existing libxl_ctx's are invalidated and
+ * must not be used - or even freed.  It is harmless to call this
+ * postfork function and then exec anyway.
+ *
+ * Until libxl_postfork_child_noexec has returned:
+ *  - No other libxl calls may be made.
+ *  - If any libxl ctx was configured handle the process's SIGCHLD,
+ *    the child may not create further (grand)child processes, nor
+ *    manipulate SIGCHLD.
+ *
+ * libxl_postfork_child_noexec may not reclaim all the resources
+ * associated with the libxl ctx.  This includes but is not limited
+ * to: ordinary memory; files on disk and in /var/run; file
+ * descriptors; memory mapped into the process from domains being
+ * managed (grant maps); Xen event channels.  Use of libxl in
+ * processes which fork long-lived children is not recommended for
+ * this reason.  libxl_postfork_child_noexec is provided so that
+ * an application can make further libxl calls in a child which
+ * is going to exec or exit soon.
+ */
+void libxl_postfork_child_noexec(libxl_ctx *ctx);
+
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxl.h 4.16.1-1/tools/include/libxl.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxl.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxl.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,2837 @@
+/*
+ * Copyright (C) 2009      Citrix Ltd.
+ * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+/*
+ * libxl API compatibility
+ *
+ * From Xen 4.2 onwards the API of libxl will be maintained in a
+ * stable manner. This means that it should be possible to write an
+ * application against the API provided by libxl in Xen 4.2 and expect
+ * that it will continue to compile against future versions of Xen
+ * without source modification.
+ *
+ * In order to make such compatibility possible it is required that
+ * application which want to be exposed to a particular API #define
+ * LIBXL_API_VERSION before including libxl.h or any other libxl
+ * header. The syntax of the LIBXL_API_VERSION is:
+ *    0xVVSSEE
+ * where ($(XEN_xxx) from xen/Makefile):
+ *   VV is the Xen major release number, $(XEN_VERSION)
+ *   SS is the Xen sub version number, $(XEN_SUBVERSION)
+ *   EE is the Xen extra version digit, first numeric part of
+ *     $(XEN_EXTRAVERSION) not including the leading "."
+ * For example the first stable API version, supported by Xen 4.2.0,
+ * is 0x040200.
+ *
+ * Lack of LIBXL_API_VERSION means "the latest" which will
+ * change. Specifying an unknown LIBXL_API_VERSION will result in a
+ * compile time error.
+ *
+ * Identical versions of the libxl API will represented by the version
+ * containing the earliest instance of that API. e.g. if 4.2.0 and
+ * 4.3.0 contain an identical libxl API then only LIBXL_API_VERSION
+ * 0x040200 will be valid.
+ *
+ * We will try especially hard to avoid changing the API during a
+ * stable series, i.e. it should be unusual for the last byte of
+ * LIBXL_API_VERSION to be non-zero.
+ *
+ * In the event that a change is required which cannot be made
+ * backwards compatible in this manner a #define of the form
+ * LIBXL_HAVE_<interface> will always be added in order to make it
+ * possible to write applications which build against any version of
+ * libxl. Such changes are expected to be exceptional and used as a
+ * last resort. The barrier for backporting such a change to a stable
+ * branch will be very high.
+ *
+ * These guarantees apply only to stable releases of Xen. When an
+ * incompatible change is made in the unstable tree then
+ * LIBXL_API_VERSION will be bumped to the next expected stable
+ * release number on the first such change only. Applications which
+ * want to support building against Xen unstable are expected to track
+ * API changes in that tree until it is released as a stable release.
+ *
+ * API compatibility will be maintained for all versions of Xen using
+ * the same $(XEN_VERSION) (e.g. throughout a major release).
+ */
+
+/* LIBXL_HAVE_PHYSINFO_CAP_PV
+ *
+ * If this is defined, libxl_physinfo has a "cap_pv" field.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_PV 1
+
+/* LIBXL_HAVE_CONSOLE_NOTIFY_FD
+ *
+ * If this is defined, libxl_console_exec and
+ * libxl_primary_console_exe take a notify_fd parameter. That
+ * parameter will be used to notify the caller that the console is connected.
+ */
+#define LIBXL_HAVE_CONSOLE_NOTIFY_FD 1
+
+/* LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS
+ *
+ * If this is defined, the copy functions have constified src parameter and the
+ * length functions accept constified parameter.
+ */
+#define LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS 1
+
+/* LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO
+ *
+ * If this is defined, libxl_domain_need_memory no longer modifies
+ * the b_info paseed in.
+ */
+#define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO 1
+
+/* LIBXL_HAVE_VNUMA
+ *
+ * If this is defined the type libxl_vnode_info exists, and a
+ * field 'vnuma_nodes' is present in libxl_domain_build_info.
+ */
+#define LIBXL_HAVE_VNUMA 1
+
+/* LIBXL_HAVE_USERDATA_UNLINK
+ *
+ * If it is defined, libxl has a library function called
+ * libxl_userdata_unlink.
+ */
+#define LIBXL_HAVE_USERDATA_UNLINK 1
+
+/* LIBXL_HAVE_CPUPOOL_QUALIFIER_TO_CPUPOOLID
+ *
+ * If this is defined, libxl has a library function called
+ * libxl_cpupool_qualifier_to_cpupoolid, which takes in a CPU pool
+ * qualifier in the form of number or string, then returns the ID of
+ * that CPU pool.
+ */
+#define LIBXL_HAVE_CPUPOOL_QUALIFIER_TO_CPUPOOLID 1
+
+/* LIBXL_HAVE_CPUPOOL_ADD_REM_CPUMAP
+ *
+ * If this is defined, libxl has two library functions called
+ * libxl_cpupool_cpuadd_cpumap and libxl_cpupool_cpuremove_cpumap,
+ * which allow to add to or remove from a cpupool all the cpus
+ * specified in a bitmap.
+ */
+#define LIBXL_HAVE_CPUPOOL_ADD_REM_CPUMAP 1
+
+/*
+ *
+ * LIBXL_HAVE_BITMAP_AND_OR
+ *
+ * If this is defined, libxl has two library functions, libxl_bitmap_and
+ * and libxl_bitmap_or to compute the logical and and or of two bitmaps
+ */
+#define LIBXL_HAVE_BITMAP_AND_OR 1
+
+/*
+ * LIBXL_HAVE_FIRMWARE_PASSTHROUGH indicates the feature for
+ * passing in SMBIOS and ACPI firmware to HVM guests is present
+ * in the library.
+ */
+#define LIBXL_HAVE_FIRMWARE_PASSTHROUGH 1
+
+/*
+ * LIBXL_HAVE_DOMAIN_NODEAFFINITY indicates that a 'nodemap' field
+ * (of libxl_bitmap type) is present in libxl_domain_build_info,
+ * containing the node-affinity for the domain.
+ */
+#define LIBXL_HAVE_DOMAIN_NODEAFFINITY 1
+
+/*
+ * LIBXL_HAVE_PVUSB indicates functions for plugging in USB devices
+ * through pvusb -- both hotplug and at domain creation time..
+ */
+#define LIBXL_HAVE_PVUSB 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE indicates that the
+ * libxl_vendor_device field is present in the hvm sections of
+ * libxl_domain_build_info. This field tells libxl which
+ * flavour of xen-pvdevice to enable in QEMU.
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE 1
+
+/*
+ * The libxl_domain_build_info has the event_channels field.
+ */
+#define LIBXL_HAVE_BUILDINFO_EVENT_CHANNELS 1
+
+/*
+ * libxl_domain_build_info has the u.hvm.ms_vm_genid field.
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_MS_VM_GENID 1
+
+/*
+ * LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY indicates that a 'cpumap_soft'
+ * field (of libxl_bitmap type) is present in libxl_vcpuinfo,
+ * containing the soft affinity of a vcpu.
+ */
+#define LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY 1
+
+/*
+ * LIBXL_HAVE_SET_VCPUAFFINITY_FORCE indicates that the
+ * libxl_set_vcpuaffinity_force() library call is available.
+ */
+#define LIBXL_HAVE_SET_VCPUAFFINITY_FORCE 1
+
+/*
+ * LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE indicates that a
+ * 'direct_io_safe' field (of boolean type) is present in
+ * libxl_device_disk.
+ */
+#define LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE 1
+
+/*
+ * The libxl_device_disk has the discard_enable field.
+ */
+#define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_IOMEM_START_GFN indicates that it is possible
+ * to specify the start guest frame number used to map a range of I/O
+ * memory machine frame numbers via the 'gfn' field (of type uint64)
+ * of the 'iomem' structure. An array of iomem structures is embedded
+ * in libxl_domain_build_info and used to map the indicated memory
+ * ranges during domain build.
+ */
+#define LIBXL_HAVE_BUILDINFO_IOMEM_START_GFN 1
+
+/*
+ * LIBXL_HAVE_SCHED_RTDS indicates that the RTDS real time scheduler
+ * is available. A 'budget' field added in libxl_domain_sched_params.
+ */
+#define LIBXL_HAVE_SCHED_RTDS 1
+
+/*
+ * LIBXL_HAVE_SCHED_NULL indicates that the 'null' static scheduler
+ * is available.
+ */
+#define LIBXL_HAVE_SCHED_NULL 1
+
+/*
+ * libxl_domain_build_info has u.hvm.viridian_enable and _disable bitmaps
+ * of the specified width.
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_VIRIDIAN_ENABLE_DISABLE 1
+#define LIBXL_BUILDINFO_HVM_VIRIDIAN_ENABLE_DISABLE_WIDTH 64
+
+/*
+ * libxl_domain_build_info has the u.hvm.mmio_hole_memkb field.
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_MMIO_HOLE_MEMKB 1
+
+/*
+ * libxl_domain_info returns ERROR_DOMAIN_NOTFOUND if the domain
+ * is not present, instead of ERROR_INVAL.
+ */
+#define LIBXL_HAVE_ERROR_DOMAIN_NOTFOUND 1
+
+/*
+ * libxl_domain_build_info has device_tree and libxl_device_dtdev
+ * exists. This mean Device Tree passthrough is supported for ARM
+ */
+#define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1
+
+/*
+ * libxl_domain_build_info has device_model_user to specify the user to
+ * run the device model with. See docs/misc/qemu-deprivilege.txt.
+ */
+#define LIBXL_HAVE_DEVICE_MODEL_USER 1
+
+/*
+ * libxl_vcpu_sched_params is used to store per-vcpu params.
+ */
+#define LIBXL_HAVE_VCPU_SCHED_PARAMS 1
+
+/*
+ * LIBXL_HAVE_SCHED_RTDS_VCPU_PARAMS indicates RTDS scheduler
+ * now supports per-vcpu settings.
+ */
+#define LIBXL_HAVE_SCHED_RTDS_VCPU_PARAMS 1
+
+/*
+ * LIBXL_HAVE_SCHED_RTDS_VCPU_EXTRA indicates RTDS scheduler
+ * now supports per-vcpu extratime settings.
+ */
+#define LIBXL_HAVE_SCHED_RTDS_VCPU_EXTRA 1
+
+/*
+ * libxl_domain_build_info has the arm.gic_version field.
+ */
+#define LIBXL_HAVE_BUILDINFO_ARM_GIC_VERSION 1
+
+/*
+ * libxl_domain_build_info has the arch_arm.tee field.
+ */
+#define LIBXL_HAVE_BUILDINFO_ARCH_ARM_TEE 1
+
+/*
+ * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing
+ * 'soft reset' for domains and there is 'soft_reset' shutdown reason
+ * in enum libxl_shutdown_reason.
+ */
+#define LIBXL_HAVE_SOFT_RESET 1
+
+/*
+ * LIBXL_HAVE_APIC_ASSIST indicates that the 'apic_assist' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_APIC_ASSIST 1
+
+/*
+ * LIBXL_HAVE_BUILD_ID means that libxl_version_info has the extra
+ * field for the hypervisor build_id.
+ */
+#define LIBXL_HAVE_BUILD_ID 1
+
+/*
+ * LIBXL_HAVE_QEMU_MONITOR_COMMAND indiactes the availability of the
+ * libxl_qemu_monitor_command() function.
+ */
+#define LIBXL_HAVE_QEMU_MONITOR_COMMAND 1
+
+/*
+ * LIBXL_HAVE_SCHED_CREDIT2_PARAMS indicates the existance of a
+ * libxl_sched_credit2_params structure, containing Credit2 scheduler
+ * wide parameters (i.e., the ratelimiting value).
+ */
+#define LIBXL_HAVE_SCHED_CREDIT2_PARAMS 1
+
+/*
+ * LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY indicates that there is a field
+ * in libxl_sched_credit_params called vcpu_migr_delay_us which controls
+ * the resistance of the vCPUs of the cpupool to migrations among pCPUs.
+ */
+#define LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_CRASH_CTL indicates that the 'crash_ctl' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_CRASH_CTL 1
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_SYNIC indicates that the 'synic' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_SYNIC 1
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_STIMER indicates that the 'stimer' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_STIMER 1
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_HCALL_IPI indicates that the 'hcall_ipi' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_HCALL_IPI 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE indicates that
+ * libxl_domain_build_info has the u.hvm.acpi_laptop_slate field.
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
+
+/*
+ * LIBXL_HAVE_P9S indicates that the p9 field in IDL has been changed to p9s
+ */
+#define LIBXL_HAVE_P9S 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_ARM_VUART indicates that the toolstack supports virtual UART
+ * for ARM.
+ */
+#define LIBXL_HAVE_BUILDINFO_ARM_VUART 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_GRANT_LIMITS indicates that libxl_domain_build_info
+ * has the max_grant_frames and max_maptrack_frames fields.
+ */
+#define LIBXL_HAVE_BUILDINFO_GRANT_LIMITS 1
+
+#define LIBXL_MAX_GRANT_DEFAULT (~(uint32_t)0)
+#define LIBXL_MAX_GRANT_FRAMES_DEFAULT 32 /* deprecated */
+#define LIBXL_MAX_MAPTRACK_FRAMES_DEFAULT 1024 /* deprecated */
+/*
+ * LIBXL_HAVE_BUILDINFO_GRANT_DEFAULT indicates that the default
+ * values of max_grant_frames and max_maptrack_frames fields in
+ * libxl_domain_build_info are the special sentinel value
+ * LIBXL_MAX_GRANT_DEFAULT rather than the fixed values above.
+ * This means to use the hypervisor's default.
+ */
+#define LIBXL_HAVE_BUILDINFO_GRANT_DEFAULT 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_* indicates that libxl_domain_build_info has
+ * the field represented by the '*'. The original position of those
+ * fields is:
+ *  - u.hvm.timer_mode
+ *  - u.hvm.apic
+ *  - u.hvm.nested_hvm
+ *  - u.pv.bootloader
+ *  - u.pv.bootloader_args
+ */
+#define LIBXL_HAVE_BUILDINFO_TIMER_MODE 1
+#define LIBXL_HAVE_BUILDINFO_APIC 1
+#define LIBXL_HAVE_BUILDINFO_NESTED_HVM 1
+#define LIBXL_HAVE_BUILDINFO_BOOTLOADER 1
+#define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1
+
+/*
+ * LIBXL_HAVE_EXTENDED_VKB indicates that libxl_device_vkb has extended fields:
+ *  - unique_id;
+ *  - feature_disable_keyboard;
+ *  - feature_disable_pointer;
+ *  - feature_abs_pointer;
+ *  - feature_raw_pointer;
+ *  - feature_multi_touch;
+ *  - width;
+ *  - height;
+ *  - multi_touch_width;
+ *  - multi_touch_height;
+ *  - multi_touch_num_contacts.
+ */
+#define LIBXL_HAVE_EXTENDED_VKB 1
+
+/*
+ * LIBXL_HAVE_PHYSINFO_CAP_HAP_SHADOW indicates that libxl_physinfo has
+ * cap_hap and cap_shadow fields reflecting the hardware and Xen availability
+ * of Hardware Assisted, and Shadow paging support.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_HAP_SHADOW 1
+
+/*
+ * LIBXL_HAVE_PHYSINFO_CAP_IOMMU_HAP_PT_SHARE indicates that libxl_physinfo
+ * has a cap_iommu_hap_pt_share field that indicates whether the hardware
+ * supports sharing the IOMMU and HAP page tables.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_IOMMU_HAP_PT_SHARE 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_IOMMU_MEMKB indicates thate libxl_domain_build_info
+ * has an iommu_memkb field which should be set with the amount of memory
+ * overhead needed by the domain for populating IOMMU page tables.
+ */
+#define LIBXL_HAVE_BUILDINFO_IOMMU_MEMKB 1
+
+/*
+ * LIBXL_HAVE_CREATEINFO_PASSTHROUGH indicates that
+ * libxl_domain_create_info has a passthrough field (which is a
+ * libxl_passthrough enumeration) that indicates whether device pass-
+ * through is enabled for the domain and, if so, whether the IOMMU and
+ * HAP page tables may be shared or not.
+ */
+#define LIBXL_HAVE_CREATEINFO_PASSTHROUGH 1
+
+/*
+ * LIBXL_HAVE_DISK_SAFE_REMOVE indicates that the
+ * libxl_device_disk_safe_remove() function is defined.
+ */
+#define LIBXL_HAVE_DISK_SAFE_REMOVE 1
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_EX_PROCESSOR_MASKS indicates that the
+ * 'ex_processor_masks' value is present in the viridian enlightenment
+ * enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_EX_PROCESSOR_MASKS 1
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_NO_VP_LIMIT indicates that the 'no_vp_limit' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_NO_VP_LIMIT 1
+
+/*
+ * LIBXL_HAVE_VIRIDIAN_CPU_HOTPLUG indicates that the 'cpu_hotplug' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_CPU_HOTPLUG 1
+
+/*
+ * LIBXL_HAVE_DEVICE_PCI_LIST_FREE indicates that the
+ * libxl_device_pci_list_free() function is defined.
+ */
+#define LIBXL_HAVE_DEVICE_PCI_LIST_FREE 1
+
+/*
+ * LIBXL_HAVE_DEVICE_PCI_ASSIGNABLE_LIST_FREE indicates that the
+ * libxl_device_pci_assignable_list_free() function is defined.
+ */
+#define LIBXL_HAVE_DEVICE_PCI_ASSIGNABLE_LIST_FREE 1
+
+/*
+ * LIBXL_HAVE_DEVICE_PCI_NAME indicates that the libxl_device_pci type
+ * has a name field.
+ */
+#define LIBXL_HAVE_DEVICE_PCI_NAME 1
+
+/*
+ * LIBXL_HAVE_PHYSINFO_CAP_VMTRACE indicates that libxl_physinfo has a
+ * cap_vmtrace field, which indicates the availability of platform tracing
+ * functionality.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_VMTRACE 1
+
+/*
+ * LIBXL_HAVE_VMTRACE_BUF_KB indicates that libxl_domain_create_info has a
+ * vmtrace_buf_kb parameter, which allows to enable pre-allocation of
+ * processor tracing buffers of given size.
+ */
+#define LIBXL_HAVE_VMTRACE_BUF_KB 1
+
+/*
+ * LIBXL_HAVE_X86_MSR_RELAXED indicates the toolstack has support for switching
+ * the MSR access handling in the hypervisor to relaxed mode. This is done by
+ * setting the libxl_domain_build_info arch_x86.msr_relaxed field.
+ */
+#define LIBXL_HAVE_X86_MSR_RELAXED 1
+
+/*
+ * LIBXL_HAVE_PHYSINFO_CAP_VPMU indicates that libxl_physinfo has a cap_vpmu
+ * field, which indicates the availability of vPMU functionality.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_VPMU 1
+
+/*
+ * LIBXL_HAVE_VPMU indicates that libxl_domain_build_info has a vpmu parameter,
+ * which allows to enable the access to PMU registers.
+ */
+#define LIBXL_HAVE_VPMU 1
+
+/*
+ * LIBXL_HAVE_PHYSINFO_CAP_GNTTAB indicates that libxl_physinfo has a
+ * cap_gnttab_v1/2 fields, which indicates the available grant table ABIs.
+ */
+#define LIBXL_HAVE_PHYSINFO_CAP_GNTTAB 1
+
+/*
+ * LIBXL_HAVE_MAX_GRANT_VERSION indicates libxl_domain_build_info has a
+ * max_grant_version field for setting the max grant table version per
+ * domain.
+ */
+#define LIBXL_HAVE_MAX_GRANT_VERSION 1
+
+/*
+ * libxl ABI compatibility
+ *
+ * The only guarantee which libxl makes regarding ABI compatibility
+ * across releases is that the SONAME will always be bumped whenever
+ * the ABI is changed in an incompatible way.
+ *
+ * This applies within stable branches as well as
+ * development branches. It is possible that a new stable release of
+ * Xen may require a rebuild of applications using the
+ * library. However per the API compatibility gaurantees such a
+ * rebuild should not normally require any source level changes.
+ *
+ * As with the API compatiblity the SONAME will only be bumped for the
+ * first ABI incompatible change in a development branch.
+ */
+
+/*
+ * libxl memory management
+ *
+ * From the point of view of the application (ie, libxl's caller),
+ * struct libxl_ctx* is threadsafe, and all returned allocated
+ * structures are obtained from malloc(), and must be freed by the
+ * caller either directly or by calling an appropriate free function
+ * provided by libxl.  Ie the application does not get automatic
+ * assistance from libxl in managing these allocations.
+ *
+ * Specific details are in the header comments which should be found
+ * in libxl.h or libxlutil.h, next to the relevant function
+ * declarations.
+ *
+ * Internally, libxl has a garbage collection scheme which allows much libxl
+ * code to allocate strings etc. for internal use without needing to
+ * free them.  These are called "temporary allocations".
+ *
+ * The pool for these temporary allocations, along with any other
+ * thread-specific data which is private to libxl but shared between
+ * libxl functions (such as the current xenstore transaction), is
+ * stored in the "gc context" which is a special enhanced context
+ * structure allocated automatically by convenience macros at every
+ * entry to libxl.
+ *
+ * Every libxl function falls into one of these categories:
+ *
+ * 1. Public functions (declared in libxl.h, libxlutil.h), which may
+ *    be called by libxl applications.  If a public function returns
+ *    any allocated object to its caller, that object must have come
+ *    from malloc.
+ *
+ *    The definitions of public functions MUST use the gc context
+ *    initialisation macros (or do the equivalent work themselves).
+ *    These macros will ensure that all temporary allocations will be
+ *    automatically freed before the function returns to its caller.
+ *
+ *    A public function may be called from within libxl; the call
+ *    context initialisation macros will make sure that the internal
+ *    caller's context is reused (eg, so that the same xenstore
+ *    transaction is used).  But in-libxl callers of libxl public
+ *    functions should note that any libxl public function may cause
+ *    recursively reentry into libxl via the application's event
+ *    callback hook.
+ *
+ *    Public functions have names like libxl_foobar.
+ *
+ * 2. Private functions, which may not be called by libxl
+ *    applications; they are not declared in libxl.h or libxlutil.h
+ *    and they may not be called other than by other libxl functions.
+ *
+ *    Private functions should not use the gc context initialisation
+ *    macros.
+ *
+ *    Private functions have names like libxl__foobar (NB, two underscores).
+ *    Also the declaration of such functions must be preceeded by the _hidden
+ *    macro.
+ *
+ * Allocations made by a libxl function fall into one of the following
+ * categories (where "object" includes any memory allocation):
+ *
+ * (a) Objects which are not returned to the function's caller.
+ *     These should be allocated from the temporary pool.
+ *
+ * (b) Objects which are intended for return to the calling
+ *     application.  This includes all allocated objects returned by
+ *     any public function.
+ *
+ *     It may also include objects allocated by an internal function
+ *     specifically for eventual return by the function's external
+ *     callers, but this situation should be clearly documented in
+ *     comments.
+ *
+ *     These should be allocated from malloc() et al. and comments
+ *     near the function declaration should explain the memory
+ *     ownership.  If a simple free() by the application is not
+ *     sufficient, a suitable public freeing function should be
+ *     provided.
+ *
+ * (c) Internal objects whose size and/or lifetime dictate explicit
+ *     memory management within libxl.  This includes objects which
+ *     will be embedded in opaque structures which will be returned to
+ *     the libxl caller (more generally, any internal object whose
+ *     lifetime exceeds the libxl entrypoint which creates it) and
+ *     objects which are so large or numerous that explicit memory
+ *     management is required.
+ *
+ *     These should be allocated from malloc() et al., and freed
+ *     explicitly at the appropriate point.  The situation should be
+ *     documented in comments.
+ *
+ * (d) Objects which are allocated by internal-only functions and
+ *     returned to the function's (therefore, internal) caller but are
+ *     strictly for internal use by other parts of libxl.  These
+ *     should be allocated from the temporary pool.
+ *
+ *     Where a function's primary purpose is to return such an object,
+ *     it should have a libxl__gc * as it's first argument.
+ *
+ *     Note that there are two ways to change an allocation from this
+ *     category to the "public" category. Either the implementation
+ *     is kept internal and a wrapper function duplicates all memory
+ *     allocations so that they are suitable for return to external
+ *     callers or the implementation uses plain malloc() et al calls
+ *     and an internal wrapper adds the relevant pointers to the gc.
+ *     The latter method is preferred for obvious performance reasons.
+ *
+ * No temporary objects allocated from the pool may be explicitly freed.
+ * Therefore public functions which initialize a libxl__gc MUST call
+ * libxl__free_all() before returning.
+ *
+ * Memory allocation failures are not handled gracefully.  If malloc
+ * (or realloc) fails, libxl will cause the entire process to print
+ * a message to stderr and exit with status 255.
+ */
+/*
+ * libxl types
+ *
+ * Most libxl types are defined by the libxl IDL (see
+ * libxl_types.idl). The library provides a common set of methods for
+ * initialising and freeing these types.
+ *
+ * IDL-generated libxl types should be used as follows: the user must
+ * always call the "init" function before using a type, even if the
+ * variable is simply being passed by reference as an out parameter
+ * to a libxl function.  The user must always calls "dispose" exactly
+ * once afterwards, to clean up, regardless of whether operations on
+ * this object succeeded or failed.  See the xl code for examples.
+ *
+ * "init" and "dispose" are idempotent.
+ *
+ * void libxl_<type>_init(<type> *p):
+ *
+ *    Initialises the members of "p" to all defaults. These may either
+ *    be special value which indicates to the library that it should
+ *    select an appropriate default when using this field or actual
+ *    default values.
+ *
+ *    Some fields within a data type (e.g. unions) cannot be sensibly
+ *    initialised without further information. In these cases a
+ *    separate subfield initialisation function is provided (see
+ *    below).
+ *
+ *    An instance which has been initialised using this method can
+ *    always be safely passed to the dispose function (see
+ *    below). This is true even if the data type contains fields which
+ *    require a separate call to a subfield initialisation function.
+ *
+ *    This method is provided for any aggregate type which is used as
+ *    an input parameter.
+ *
+ * void libxl_<type>_init_<subfield>(<type> *p, subfield):
+ *
+ *    Initialise those parts of "p" which are not initialised by the
+ *    main init function due to the unknown value of "subfield". Sets
+ *    p->subfield as well as initialising any fields to their default
+ *    values.
+ *
+ *    p->subfield must not have been previously initialised.
+ *
+ *    This method is provided for any aggregate type.
+ *
+ * void libxl_<type>_dispose(instance *p):
+ *
+ *    Frees any dynamically allocated memory used by the members of
+ *    "p" but not the storage used by "p" itself (this allows for the
+ *    allocation of arrays of types and for the composition of types).
+ *
+ * char *libxl_<type>_to_json(instance *p)
+ *
+ *    Generates a JSON object from "p" in the form of a NULL terminated
+ *    string.
+ *
+ * <type *> libxl_<type>_from_json(const char *json)
+ * int      libxl_<type>_from_json(const char *json)
+ *
+ *    Parses "json" and returns:
+ *
+ *    an int value, if <type> is enumeration type. The value is the enum value
+ *    representing the respective string in "json".
+ *
+ *    an instance of <type>, if <type> is aggregate type. The returned
+ *    instance has its fields filled in by the parser according to "json".
+ *
+ *    If the parsing fails, caller cannot rely on the value / instance
+ *    returned.
+ */
+#ifndef LIBXL_H
+#define LIBXL_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <netinet/in.h>
+#include <sys/wait.h> /* for pid_t */
+
+#include <xentoollog.h>
+
+typedef struct libxl__ctx libxl_ctx;
+
+#include <libxl_uuid.h>
+#include <_libxl_list.h>
+
+/* API compatibility. */
+#ifdef LIBXL_API_VERSION
+#if LIBXL_API_VERSION != 0x040200 && LIBXL_API_VERSION != 0x040300 && \
+    LIBXL_API_VERSION != 0x040400 && LIBXL_API_VERSION != 0x040500 && \
+    LIBXL_API_VERSION != 0x040700 && LIBXL_API_VERSION != 0x040800 && \
+    LIBXL_API_VERSION != 0x041300 && LIBXL_API_VERSION != 0x041400
+#error Unknown LIBXL_API_VERSION
+#endif
+#endif
+
+/* LIBXL_HAVE_RETRIEVE_DOMAIN_CONFIGURATION
+ *
+ * If this is defined we have libxl_retrieve_domain_configuration which
+ * returns the current configuration of a domain, which can be used to
+ * rebuild a domain.
+ */
+#define LIBXL_HAVE_RETRIEVE_DOMAIN_CONFIGURATION 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_VCPU_AFFINITY_ARRAYS
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain two arrays of libxl_bitmap-s, with all the necessary information
+ * to set the hard affinity (vcpu_hard_affinity) and the soft affinity
+ * (vcpu_soft_affinity) of the VCPUs.
+ *
+ * Note that, if the vcpu_hard_affinity array is used, libxl will ignore
+ * the content of the cpumap field of libxl_domain_build_info. That is to
+ * say, if the array is allocated and used by the caller, it is it and
+ * only it that determines the hard affinity of the domain's VCPUs.
+ *
+ * The number of libxl_bitmap-s in the arrays should be equal to the
+ * maximum number of VCPUs of the domain. If there only are N elements in
+ * an array, with N smaller the the maximum number of VCPUs, the hard or
+ * soft affinity (depending on which array we are talking about) will be
+ * set only for the first N VCPUs. The other VCPUs will just have affinity,
+ * both hard and soft, with all the host PCPUs.
+ * Each bitmap should be big enough to accommodate the maximum number of
+ * PCPUs of the host.
+ */
+#define LIBXL_HAVE_BUILDINFO_VCPU_AFFINITY_ARRAYS 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_VKB_DEVICE
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain a boolean hvm.vkb_device which instructs libxl whether to include
+ * a vkbd at build time or not.
+ */
+#define LIBXL_HAVE_BUILDINFO_VKB_DEVICE 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain hvm.usbdevice_list, a libxl_string_list type that contains
+ * a list of USB devices to specify on the qemu command-line.
+ *
+ * If it is set, callers may use either hvm.usbdevice or
+ * hvm.usbdevice_list, but not both; if both are set, libxl will
+ * throw an error.
+ *
+ * If this is not defined, callers can only use hvm.usbdevice.  Note
+ * that this means only one device can be added at domain build time.
+ */
+#define LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_USBVERSION
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain hvm.usbversion, a integer type that contains a USB
+ * controller version to specify on the qemu upstream command-line.
+ *
+ * If it is set, callers may use hvm.usbversion to specify if the usb
+ * controller is usb1, usb2 or usb3.
+ *
+ * If this is not defined, the hvm.usbversion field does not exist.
+ */
+#define LIBXL_HAVE_BUILDINFO_USBVERSION 1
+
+/*
+ * LIBXL_HAVE_DEVICE_BACKEND_DOMNAME
+ *
+ * If this is defined, libxl_device_* structures containing a backend_domid
+ * field also contain a backend_domname field.  If backend_domname is set, it is
+ * resolved to a domain ID when the device is used and takes precedence over the
+ * backend_domid field.
+ *
+ * If this is not defined, the backend_domname field does not exist.
+ */
+#define LIBXL_HAVE_DEVICE_BACKEND_DOMNAME 1
+
+/*
+ * LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG
+ *
+ * This argument was erroneously "const" in the 4.2 release despite
+ * the requirement for the callback to free the event.
+ */
+#if LIBXL_API_VERSION != 0x040200
+#define LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG 1
+#endif
+
+/*
+ * LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE
+ *
+ * The return value of libxl_basename is malloc'ed but the erroneously
+ * marked as "const" in releases before 4.5.
+ */
+#if !defined(LIBXL_API_VERSION) || LIBXL_API_VERSION >= 0x040500
+#define LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE 1
+#endif
+
+/*
+ * LIBXL_HAVE_PHYSINFO_OUTSTANDING_PAGES
+ *
+ * If this is defined, libxl_physinfo structure will contain an uint64 field
+ * called outstanding_pages, containing the number of pages claimed but not
+ * yet allocated for all domains.
+ */
+#define LIBXL_HAVE_PHYSINFO_OUTSTANDING_PAGES 1
+
+/*
+ * LIBXL_HAVE_PHYSINFO_MAX_POSSIBLE_MFN
+ *
+ * If this is defined, libxl_physinfo structure will contain an uint64 field
+ * called max_possible_mfn, containing the highest possible mfn on this host,
+ * possibly taking memory hotplug into account.
+ */
+#define LIBXL_HAVE_PHYSINFO_MAX_POSSIBLE_MFN 1
+
+/*
+ * LIBXL_HAVE_DOMINFO_OUTSTANDING_MEMKB 1
+ *
+ * If this is defined, libxl_dominfo will contain a MemKB type field called
+ * outstanding_memkb, containing the amount of claimed but not yet allocated
+ * memory for a specific domain.
+ */
+#define LIBXL_HAVE_DOMINFO_OUTSTANDING_MEMKB 1
+
+/*
+ * LIBXL_HAVE_DOMINFO_NEVER_STOP
+ *
+ * If this is defined, libxl_dominfo will contain a flag called never_stop
+ * indicating that the specific domain should never be stopped by the
+ * toolstack.
+ */
+#define LIBXL_HAVE_DOMINFO_NEVER_STOP 1
+
+/*
+ * LIBXL_HAVE_DOMINFO_GPADDR_BITS
+ *
+ * If this is defined, libxl_dominfo will contain an uint8 field called
+ * gpaddr_bits, containing the guest physical address space size.
+ */
+#define LIBXL_HAVE_DOMINFO_GPADDR_BITS 1
+
+/*
+ * LIBXL_HAVE_QXL
+ *
+ * If defined, then the libxl_vga_interface_type will contain another value:
+ * "QXL". This value define if qxl vga is supported.
+ *
+ * If this is not defined, the qxl vga support is missed.
+ */
+#define LIBXL_HAVE_QXL 1
+
+/*
+ * LIBXL_HAVE_SPICE_VDAGENT
+ *
+ * If defined, then the libxl_spice_info structure will contain a boolean type:
+ * vdagent and clipboard_sharing. These values define if Spice vdagent and
+ * clipboard sharing are enabled.
+ *
+ * If this is not defined, the Spice vdagent support is ignored.
+ */
+#define LIBXL_HAVE_SPICE_VDAGENT 1
+
+/*
+ * LIBXL_HAVE_SPICE_USBREDIRECTION
+ *
+ * If defined, then the libxl_spice_info structure will contain an integer type
+ * field: usbredirection. This value defines if Spice usbredirection is enabled
+ * and with how much channels.
+ *
+ * If this is not defined, the Spice usbredirection support is ignored.
+ */
+#define LIBXL_HAVE_SPICE_USBREDIREDIRECTION 1
+
+/*
+ * LIBXL_HAVE_SPICE_IMAGECOMPRESSION
+ *
+ * If defined, then the libxl_spice_info structure will contain a string type
+ * field: image_compression. This value defines what Spice image compression
+ * is used.
+ *
+ * If this is not defined, the Spice image compression setting support is ignored.
+ */
+#define LIBXL_HAVE_SPICE_IMAGECOMPRESSION 1
+
+/*
+ * LIBXL_HAVE_SPICE_STREAMINGVIDEO
+ *
+ * If defined, then the libxl_spice_info structure will contain a string type
+ * field: streaming_video. This value defines what Spice streaming video setting
+ * is used.
+ *
+ * If this is not defined, the Spice streaming video setting support is ignored.
+ */
+#define LIBXL_HAVE_SPICE_STREAMINGVIDEO 1
+
+/*
+ * LIBXL_HAVE_HVM_HDTYPE
+ *
+ * If defined, then the u.hvm structure will contain a enum type
+ * hdtype.
+ */
+#define LIBXL_HAVE_HVM_HDTYPE 1
+
+/*
+ * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
+ *
+ * If this is defined, libxl_domain_create_restore()'s API has changed to
+ * include a params structure.
+ */
+#define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
+
+/*
+ * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD 1
+ *
+ * If this is defined, libxl_domain_create_restore()'s API includes the
+ * send_back_fd param. This is used only with COLO, for the libxl migration
+ * back channel; other callers should pass -1.
+ */
+#define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD 1
+
+/*
+ * LIBXL_HAVE_DRIVER_DOMAIN_CREATION 1
+ *
+ * If this is defined, libxl_domain_create_info contains a driver_domain
+ * field that can be used to tell libxl that the domain that is going
+ * to be created is a driver domain, so the necessary actions are taken.
+ */
+#define LIBXL_HAVE_DRIVER_DOMAIN_CREATION 1
+
+/*
+ * LIBXL_HAVE_SIGCHLD_SELECTIVE_REAP
+ *
+ * If this is defined:
+ *
+ * Firstly, the enum libxl_sigchld_owner (in libxl_event.h) has the
+ * value libxl_sigchld_owner_libxl_always_selective_reap which may be
+ * passed to libxl_childproc_setmode in hooks->chldmode.
+ *
+ * Secondly, the function libxl_childproc_sigchld_occurred exists.
+ */
+#define LIBXL_HAVE_SIGCHLD_OWNER_SELECTIVE_REAP 1
+
+/*
+ * LIBXL_HAVE_SIGCHLD_SHARING
+ *
+ * If this is defined, it is permissible for multiple libxl ctxs
+ * to simultaneously "own" SIGCHLD.  See "Subprocess handling"
+ * in libxl_event.h.
+ */
+#define LIBXL_HAVE_SIGCHLD_SHARING 1
+
+/*
+ * LIBXL_HAVE_NO_SUSPEND_RESUME
+ *
+ * Is this is defined then the platform has no support for saving,
+ * restoring or migrating a domain. In this case the related functions
+ * should be expected to return failure. That is:
+ *  - libxl_domain_suspend
+ *  - libxl_domain_resume
+ *  - libxl_domain_remus_start
+ */
+#if defined(__arm__) || defined(__aarch64__)
+#define LIBXL_HAVE_NO_SUSPEND_RESUME 1
+#endif
+
+/*
+ * LIBXL_HAVE_DOMAIN_SUSPEND_ONLY
+ *
+ * If this is defined, function libxl_domains_suspend_only() is available.
+ */
+
+#define LIBXL_HAVE_DOMAIN_SUSPEND_ONLY 1
+
+/*
+ * LIBXL_HAVE_DEVICE_PCI_SEIZE
+ *
+ * If this is defined, then the libxl_device_pci struct will contain
+ * the "seize" boolean field.  If this field is set, libxl_pci_add will
+ * check to see if the device is currently assigned to pciback, and if not,
+ * it will attempt to do so (unbinding the device from the existing driver).
+ */
+#define LIBXL_HAVE_DEVICE_PCI_SEIZE 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_KERNEL
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain 'kernel', 'ramdisk', 'cmdline' fields. 'kernel' is a string
+ * to indicate kernel image location, 'ramdisk' is a string to indicate
+ * ramdisk location, 'cmdline' is a string to indicate the paramters which
+ * would be appended to kernel image.
+ *
+ * Both PV guest and HVM guest can use these fields for direct kernel boot.
+ * But for compatibility reason, u.pv.kernel, u.pv.ramdisk and u.pv.cmdline
+ * still exist.
+ */
+#define LIBXL_HAVE_BUILDINFO_KERNEL 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_DEVICE_MODEL_STUBDOMAIN
+ *
+ * If this is defined, then the libxl_domain_build_info structure will contain
+ * the following fields that specify options for device model stubdomains:
+ *  - stubdomain_memkb:   integer indicating stubdomain RAM size
+ *  - stubdomain_kernel:  string indicating stubdomain kernel image location
+ *  - stubdomain_cmdline: string of parameters to pass to the stubdomain kernel
+ *  - stubdomain_ramdisk: string indicating stubdomain ramdisk location
+ */
+#define LIBXL_HAVE_BUILDINFO_DEVICE_MODEL_STUBDOMAIN 1
+
+/*
+ * LIBXL_HAVE_DEVICE_CHANNEL
+ *
+ * If this is defined, then the libxl_device_channel struct exists
+ * and channels can be attached to a domain. Channels manifest as consoles
+ * with names, see docs/misc/console.txt.
+ */
+#define LIBXL_HAVE_DEVICE_CHANNEL 1
+
+/*
+ * LIBXL_HAVE_AO_ABORT indicates the availability of libxl_ao_abort
+ */
+#define LIBXL_HAVE_AO_ABORT 1
+
+/* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be
+ * called from within libxl itself. Callers outside libxl, who
+ * do not #include libxl_internal.h, are fine. */
+#ifndef LIBXL_EXTERNAL_CALLERS_ONLY
+#define LIBXL_EXTERNAL_CALLERS_ONLY /* disappears for callers outside libxl */
+#endif
+
+/*
+ *  LIBXL_HAVE_UUID_COPY_CTX_PARAM
+ *
+ * If this is defined, libxl_uuid_copy has changed to take a libxl_ctx
+ * structure.
+ */
+#define LIBXL_HAVE_UUID_COPY_CTX_PARAM 1
+
+/*
+ * LIBXL_HAVE_SSID_LABEL
+ *
+ * If this is defined, then libxl IDL contains string of XSM security
+ * label in all XSM related structures.
+ *
+ * If set this string takes precedence over the numeric field.
+ */
+#define LIBXL_HAVE_SSID_LABEL 1
+
+/*
+ * LIBXL_HAVE_CPUPOOL_NAME
+ *
+ * If this is defined, then libxl IDL contains string of CPU pool
+ * name in all CPU pool related structures.
+ *
+ * If set this string takes precedence over the numeric field.
+ */
+#define LIBXL_HAVE_CPUPOOL_NAME 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_SERIAL_LIST
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain hvm.serial_list, a libxl_string_list type that contains
+ * a list of serial ports to specify on the qemu command-line.
+ *
+ * If it is set, callers may use either hvm.serial or
+ * hvm.serial_list, but not both; if both are set, libxl will
+ * throw an error.
+ *
+ * If this is not defined, callers can only use hvm.serial.  Note
+ * that this means only one serial port can be added at domain build time.
+ */
+#define LIBXL_HAVE_BUILDINFO_SERIAL_LIST 1
+
+/*
+ * LIBXL_HAVE_ALTP2M
+ * If this is defined, then libxl supports alternate p2m functionality.
+ */
+#define LIBXL_HAVE_ALTP2M 1
+
+/*
+ * LIBXL_HAVE_REMUS
+ * If this is defined, then libxl supports remus.
+ */
+#define LIBXL_HAVE_REMUS 1
+
+/*
+ * LIBXL_HAVE_COLO_USERSPACE_PROXY
+ * If this is defined, then libxl supports COLO userspace proxy.
+ */
+#define LIBXL_HAVE_COLO_USERSPACE_PROXY 1
+
+typedef uint8_t libxl_mac[6];
+#define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
+#define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
+#define LIBXL_MAC_BYTES(mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
+void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
+
+#if defined(__i386__) || defined(__x86_64__)
+/*
+ * LIBXL_HAVE_PSR_CMT
+ *
+ * If this is defined, the Cache Monitoring Technology feature is supported.
+ */
+#define LIBXL_HAVE_PSR_CMT 1
+
+/*
+ * LIBXL_HAVE_PSR_MBM
+ *
+ * If this is defined, the Memory Bandwidth Monitoring feature is supported.
+ */
+#define LIBXL_HAVE_PSR_MBM 1
+
+/*
+ * LIBXL_HAVE_PSR_CAT
+ *
+ * If this is defined, the Cache Allocation Technology feature is supported.
+ */
+#define LIBXL_HAVE_PSR_CAT 1
+
+/*
+ * LIBXL_HAVE_PSR_CDP
+ *
+ * If this is defined, the Code and Data Prioritization feature is supported.
+ */
+#define LIBXL_HAVE_PSR_CDP 1
+
+/*
+ * LIBXL_HAVE_PSR_L2_CAT
+ *
+ * If this is defined, the L2 Cache Allocation Technology feature is supported.
+ */
+#define LIBXL_HAVE_PSR_L2_CAT 1
+
+/*
+ * LIBXL_HAVE_PSR_GENERIC
+ *
+ * If this is defined, the Memory Bandwidth Allocation feature is supported.
+ * The following public functions are available:
+ *   libxl_psr_{set/get}_val
+ *   libxl_psr_get_hw_info
+ *   libxl_psr_hw_info_list_free
+ */
+#define LIBXL_HAVE_PSR_GENERIC 1
+
+/*
+ * LIBXL_HAVE_MCA_CAPS
+ *
+ * If this is defined, setting MCA capabilities for HVM domain is supported.
+ */
+#define LIBXL_HAVE_MCA_CAPS 1
+#endif
+
+/*
+ * LIBXL_HAVE_PCITOPOLOGY
+ *
+ * If this is defined, then interface to query hypervisor about PCI device
+ * topology is available.
+ */
+#define LIBXL_HAVE_PCITOPOLOGY 1
+
+/*
+ * LIBXL_HAVE_SOCKET_BITMAP
+ *
+ * If this is defined, then libxl_socket_bitmap_alloc and
+ * libxl_get_online_socketmap exist.
+ */
+#define LIBXL_HAVE_SOCKET_BITMAP 1
+
+/*
+ * LIBXL_HAVE_SRM_V2
+ *
+ * If this is defined, then the libxl_domain_create_restore() interface takes
+ * a "stream_version" parameter and supports a value of 2.
+ *
+ * libxl_domain_suspend() will produce a v2 stream.
+ */
+#define LIBXL_HAVE_SRM_V2 1
+
+/*
+ * LIBXL_HAVE_SRM_V1
+ *
+ * In the case that LIBXL_HAVE_SRM_V2 is set, LIBXL_HAVE_SRM_V1
+ * indicates that libxl_domain_create_restore() can handle a "stream_version"
+ * parameter of 1, and convert the stream format automatically.
+ */
+#define LIBXL_HAVE_SRM_V1 1
+
+/*
+ * libxl_domain_build_info has the u.hvm.gfx_passthru_kind field and
+ * the libxl_gfx_passthru_kind enumeration is defined.
+*/
+#define LIBXL_HAVE_GFX_PASSTHRU_KIND
+
+/*
+ * LIBXL_HAVE_CHECKPOINTED_STREAM
+ *
+ * If this is defined, then libxl_checkpointed_stream exists.
+ */
+#define LIBXL_HAVE_CHECKPOINTED_STREAM 1
+
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE
+ *
+ * libxl_domain_build_info has u.hvm.system_firmware field which can be use
+ * to provide a different firmware blob (like SeaBIOS or OVMF).
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE
+
+/*
+ * ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it
+ * is changed to ERROR_CHECKPOINT_XXX in Xen 4.7
+ */
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040500 \
+                               && LIBXL_API_VERSION < 0x040700
+#define ERROR_REMUS_DEVOPS_DOES_NOT_MATCH \
+        ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH
+#define ERROR_REMUS_DEVICE_NOT_SUPPORTED \
+        ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED
+#endif
+
+/*
+ * LIBXL_HAVE_VGA_INTERFACE_TYPE_UNKNOWN
+ *
+ * In the case that LIBXL_HAVE_VGA_INTERFACE_TYPE_UNKNOWN is set the
+ * libxl_vga_interface_type enumeration type contains a
+ * LIBXL_VGA_INTERFACE_TYPE_UNKNOWN identifier. This is used to signal
+ * that a libxl_vga_interface_type type has not been initialized yet.
+ */
+#define LIBXL_HAVE_VGA_INTERFACE_TYPE_UNKNOWN 1
+
+/*
+ * LIBXL_HAVE_BYTEARRAY_UUID
+ *
+ * If this is defined, the internal member of libxl_uuid is defined
+ * as a 16 byte array that contains the UUID in big endian format.
+ * Also, the same structure layout is used across all OSes.
+ */
+#define LIBXL_HAVE_BYTEARRAY_UUID 1
+
+/*
+ * LIBXL_HAVE_MEMKB_64BITS
+ *
+ * If this is defined libxl_set_memory_target(), libxl_domain_setmaxmem()
+ * and libxl_wait_for_free_memory()  will take a 64 bit value for the memory
+ * size parameter.
+ * From Xen 4.8 on libxl_get_memory_target(), libxl_domain_need_memory() and
+ * libxl_get_free_memory() return the memory size in a 64 bit value, too.
+ */
+#define LIBXL_HAVE_MEMKB_64BITS 1
+
+/*
+ * LIBXL_HAVE_QED
+ *
+ * If this is defined QED disk formats can be used for both HVM and PV guests.
+ */
+#define LIBXL_HAVE_QED 1
+
+/*
+ * LIBXL_HAVE_SET_PARAMETERS
+ *
+ * If this is defined setting hypervisor parameters is supported.
+ */
+#define LIBXL_HAVE_SET_PARAMETERS 1
+
+/*
+ * LIBXL_HAVE_PV_SHIM
+ *
+ * If this is defined, libxl_domain_build_info's pvh type information
+ * contains members pvshim, pvshim_path, pvshim_cmdline, pvshim_extra.
+ */
+#define LIBXL_HAVE_PV_SHIM 1
+
+/*
+ * LIBXL_HAVE_PVCALLS
+ *
+ * If this is defined, libxl supports creating pvcalls interfaces.
+ */
+#define LIBXL_HAVE_PVCALLS 1
+
+/*
+ * LIBXL_HAVE_FN_USING_QMP_ASYNC
+ *
+ * This define indicates that some function's API has changed and have an
+ * extra parameter "ao_how" which means that the function can be executed
+ * asynchronously. Those functions are:
+ *   libxl_domain_pause()
+ *   libxl_domain_unpause()
+ *   libxl_send_trigger()
+ *   libxl_set_vcpuonline()
+ *   libxl_retrieve_domain_configuration()
+ *   libxl_qemu_monitor_command()
+ *   libxl_domain_shutdown()
+ *   libxl_domain_reboot()
+ */
+#define LIBXL_HAVE_FN_USING_QMP_ASYNC 1
+
+/*
+ * LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG
+ *
+ * If this is set, libxl_domain_need_memory takes a
+ * libxl_domain_config* (non-const) and uint32_t domid_for_logging
+ * (instead of a const libxl_domain_build_info*).
+ *
+ * If this is set, there is no need to call
+ * libxl_get_required_shadow_memory and instead the caller should
+ * simply leave shadow_memkb set to LIBXL_MEMKB_DEFAULT and allow
+ * libxl to fill in a suitable default in the usual way.
+ */
+#define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG
+
+/*
+ * LIBXL_HAVE_CREATEINFO_DOMID
+ *
+ * libxl_domain_create_new() and libxl_domain_create_restore() will use
+ * a domid specified in libxl_domain_create_info.
+ */
+#define LIBXL_HAVE_CREATEINFO_DOMID
+
+/*
+ * LIBXL_HAVE_CREATEINFO_XEND_SUSPEND_EVTCHN_COMPAT
+ *
+ * libxl_domain_create_info contains a boolean 'xend_suspend_evtchn_compat'
+ * value to control creation of the xenstore path for a domain's suspend
+ * event channel.
+ */
+#define LIBXL_HAVE_CREATEINFO_XEND_SUSPEND_EVTCHN_COMPAT
+
+typedef char **libxl_string_list;
+void libxl_string_list_dispose(libxl_string_list *sl);
+int libxl_string_list_length(const libxl_string_list *sl);
+void libxl_string_list_copy(libxl_ctx *ctx, libxl_string_list *dst,
+                            const libxl_string_list *src);
+
+typedef char **libxl_key_value_list;
+void libxl_key_value_list_dispose(libxl_key_value_list *kvl);
+int libxl_key_value_list_length(const libxl_key_value_list *kvl);
+void libxl_key_value_list_copy(libxl_ctx *ctx,
+                               libxl_key_value_list *dst,
+                               const libxl_key_value_list *src);
+
+typedef uint32_t libxl_hwcap[8];
+void libxl_hwcap_copy(libxl_ctx *ctx, libxl_hwcap *dst, const libxl_hwcap *src);
+
+typedef uint64_t libxl_ev_user;
+
+typedef struct {
+    uint32_t size;          /* number of bytes in map */
+    uint8_t *map;
+} libxl_bitmap;
+void libxl_bitmap_init(libxl_bitmap *map);
+void libxl_bitmap_dispose(libxl_bitmap *map);
+
+/*
+ * libxl_cpuid_policy is opaque in the libxl ABI.  Users of both libxl and
+ * libxc may not make assumptions about xc_xend_cpuid.
+ */
+typedef struct xc_xend_cpuid libxl_cpuid_policy;
+typedef libxl_cpuid_policy * libxl_cpuid_policy_list;
+void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list);
+int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *l);
+void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
+                                  libxl_cpuid_policy_list *dst,
+                                  const libxl_cpuid_policy_list *src);
+
+#define LIBXL_PCI_FUNC_ALL (~0U)
+
+typedef uint32_t libxl_domid;
+typedef int libxl_devid;
+
+/*
+ * Formatting Enumerations.
+ *
+ * Each enumeration type libxl_E declares an associated lookup table
+ * libxl_E_string_table and a lookup function libxl_E_from_string.
+ */
+typedef struct {
+    const char *s;
+    int v;
+} libxl_enum_string_table;
+
+struct libxl_event;
+typedef LIBXL_TAILQ_ENTRY(struct libxl_event) libxl_ev_link;
+
+/*
+ * A boolean variable with an explicit default state.
+ *
+ * Users should treat this struct as opaque and use the following
+ * defined macros and accessor functions.
+ *
+ * To allow users of the library to naively select all defaults this
+ * state is represented as 0. False is < 0 and True is > 0.
+ */
+typedef struct {
+    int val;
+} libxl_defbool;
+
+void libxl_defbool_set(libxl_defbool *db, bool b);
+/* Resets to default */
+void libxl_defbool_unset(libxl_defbool *db);
+/* Sets db only if it is currently == default */
+void libxl_defbool_setdefault(libxl_defbool *db, bool b);
+bool libxl_defbool_is_default(libxl_defbool db);
+/* db must not be == default */
+bool libxl_defbool_val(libxl_defbool db);
+
+const char *libxl_defbool_to_string(libxl_defbool b);
+
+#define LIBXL_TIMER_MODE_DEFAULT -1
+#define LIBXL_MEMKB_DEFAULT ~0ULL
+
+/*
+ * We'd like to set a memory boundary to determine if we need to check
+ * any overlap with reserved device memory.
+ */
+#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)
+
+#define LIBXL_MS_VM_GENID_LEN 16
+typedef struct {
+    uint8_t bytes[LIBXL_MS_VM_GENID_LEN];
+} libxl_ms_vm_genid;
+
+#include "_libxl_types.h"
+
+const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx);
+
+/*
+ * Some libxl operations can take a long time.  These functions take a
+ * parameter to control their concurrency:
+ *     libxl_asyncop_how *ao_how
+ *
+ * If ao_how==NULL, the function will be synchronous.
+ *
+ * If ao_how!=NULL, the function will set the operation going, and if
+ * this is successful will return 0.  In this case the zero error
+ * response does NOT mean that the operation was successful; it just
+ * means that it has been successfully started.  It will finish later,
+ * perhaps with an error.
+ *
+ * If ao_how->callback!=NULL, the callback will be called when the
+ * operation completes.  The same rules as for libxl_event_hooks
+ * apply, including the reentrancy rules and the possibility of
+ * "disaster", except that libxl calls ao_how->callback instead of
+ * libxl_event_hooks.event_occurs.  (See libxl_event.h.)
+ *
+ * If ao_how->callback==NULL, a libxl_event will be generated which
+ * can be obtained from libxl_event_wait or libxl_event_check.  The
+ * event will have type OPERATION_COMPLETE (which is not used
+ * elsewhere).
+ *
+ * Note that it is possible for an asynchronous operation which is to
+ * result in a callback to complete during its initiating function
+ * call.  In this case the initiating function will return 0
+ * indicating the at the operation is "in progress", even though by
+ * the time it returns the operation is complete and the callback has
+ * already happened.
+ *
+ * The application must set and use ao_how->for_event (which will be
+ * copied into libxl_event.for_user) or ao_how->for_callback (passed
+ * to the callback) to determine which operation finished, and it must
+ * of course check the rc value for errors.
+ *
+ * *ao_how does not need to remain valid after the initiating function
+ * returns. All other parameters must remain valid for the lifetime of
+ * the asynchronous operation, unless otherwise specified.
+ *
+ * Callbacks may occur on any thread in which the application calls
+ * libxl.
+ */
+
+typedef struct {
+    void (*callback)(libxl_ctx *ctx, int rc, void *for_callback);
+    union {
+        libxl_ev_user for_event; /* used if callback==NULL */
+        void *for_callback; /* passed to callback */
+    } u;
+} libxl_asyncop_how;
+
+/*
+ * Some more complex asynchronous operations can report intermediate
+ * progress.  How this is to be reported is controlled, for each
+ * function, by a parameter
+ *    libxl_asyncprogress_how *aop_FOO_how;
+ * for each kind of progress FOO supported by that function.  Each
+ * such kind of progress is associated with an event type.
+ *
+ * The function description will document whether, when, and how
+ * many times, the intermediate progress will be reported, and
+ * what the corresponding event type(s) are.
+ *
+ * If aop_FOO_how==NULL, intermediate progress reports are discarded.
+ *
+ * If aop_FOO_how->callback==NULL, intermediate progress reports
+ * generate libxl events which can be obtained from libxl_event_wait
+ * or libxl_event_check.
+ *
+ * If aop_FOO_how->callback!=NULL, libxl will report intermediate
+ * progress by calling callback(ctx, &event, for_callback).
+ *
+ * The rules for these events are otherwise the same as those for
+ * ordinary events.  The reentrancy and threading rules for the
+ * callback are the same as those for ao completion callbacks.
+ *
+ * Note that the callback, if provided, is responsible for freeing
+ * the event.
+ *
+ * If callbacks are requested, they will be made, and returned, before
+ * the long-running libxl operation is considered finished (so if the
+ * long-running libxl operation was invoked with ao_how==NULL then any
+ * callbacks will occur strictly before the long-running operation
+ * returns).  However, the callbacks may occur on any thread.
+ *
+ * In general, otherwise, no promises are made about the relative
+ * order of callbacks in a multithreaded program.  In particular
+ * different callbacks relating to the same long-running operation may
+ * be delivered out of order.
+ */
+
+typedef struct {
+    void (*callback)(libxl_ctx *ctx, libxl_event*, void *for_callback);
+    libxl_ev_user for_event; /* always used */
+    void *for_callback; /* passed to callback */
+} libxl_asyncprogress_how;
+
+/*
+ * It is sometimes possible to abort an asynchronous operation.
+ *
+ * libxl_ao_abort searches for an ongoing asynchronous operation whose
+ * ao_how is identical to *how, and tries to abort it.  The return
+ * values from libxl_ao_abort are as follows:
+ *
+ *  0
+ *
+ *     The operation was found, and attempts are being made to cut it
+ *     short.  However, it may still take some time to stop.  It is
+ *     also possible that the operation will nevertheless complete
+ *     successfully.
+ *
+ *  ERROR_NOTFOUND
+ *
+ *      No matching ongoing operation was found.  This might happen
+ *      for an actual operation if the operation has already completed
+ *      (perhaps on another thread).  The call to libxl_ao_abort has
+ *      had no effect.
+ *
+ *  ERROR_ABORTED
+ *
+ *     The operation has already been the subject of at least one
+ *     call to libxl_ao_abort.
+ *
+ * If the operation was indeed cut short due to the abort request, it
+ * will complete, at some point in the future, with ERROR_ABORTED.  In
+ * that case, depending on the operation it have performed some of the
+ * work in question and left the operation half-done.  Consult the
+ * documentation for individual operations.
+ *
+ * Note that an aborted operation might still fail for other reasons
+ * even after the abort was requested.
+ *
+ * If your application is multithreaded you must not reuse an
+ * ao_how->for_event or ao_how->for_callback value (with a particular
+ * ao_how->callback) unless you are sure that none of your other
+ * threads are going to abort the previous operation using that
+ * value; otherwise you risk aborting the wrong operation if the
+ * intended target of the abort request completes in the meantime.
+ *
+ * It is possible to abort even an operation which is being performed
+ * synchronously, but since in that case how==NULL you had better only
+ * have one such operation, because it is not possible to tell them
+ * apart (and libxl_ao_abort will abort only the first one it finds).
+ * (And, if you want to do this, obviously the abort would have to be
+ * requested on a different thread.)
+ */
+int libxl_ao_abort(libxl_ctx *ctx, const libxl_asyncop_how *how)
+                   LIBXL_EXTERNAL_CALLERS_ONLY;
+
+
+#define LIBXL_VERSION 0
+
+/* context functions */
+int libxl_ctx_alloc(libxl_ctx **pctx, int version,
+                    unsigned flags /* none currently defined */,
+                    xentoollog_logger *lg);
+int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */);
+
+/* domain related functions */
+
+#define INVALID_DOMID ~0
+#define RANDOM_DOMID (INVALID_DOMID - 1)
+
+/* If the result is ERROR_ABORTED, the domain may or may not exist
+ * (in a half-created state).  *domid will be valid and will be the
+ * domain id, or INVALID_DOMID, as appropriate */
+
+int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
+                            uint32_t *domid,
+                            const libxl_asyncop_how *ao_how,
+                            const libxl_asyncprogress_how *aop_console_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
+                                uint32_t *domid, int restore_fd,
+                                int send_back_fd,
+                                const libxl_domain_restore_params *params,
+                                const libxl_asyncop_how *ao_how,
+                                const libxl_asyncprogress_how *aop_console_how)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040400
+
+static inline int libxl_domain_create_restore_0x040200(
+    libxl_ctx *ctx, libxl_domain_config *d_config,
+    uint32_t *domid, int restore_fd,
+    const libxl_asyncop_how *ao_how,
+    const libxl_asyncprogress_how *aop_console_how)
+    LIBXL_EXTERNAL_CALLERS_ONLY
+{
+    libxl_domain_restore_params params;
+    int ret;
+
+    libxl_domain_restore_params_init(&params);
+
+    ret = libxl_domain_create_restore(
+        ctx, d_config, domid, restore_fd, -1, &params, ao_how, aop_console_how);
+
+    libxl_domain_restore_params_dispose(&params);
+    return ret;
+}
+
+#define libxl_domain_create_restore libxl_domain_create_restore_0x040200
+
+#elif defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040400 \
+                                 && LIBXL_API_VERSION < 0x040700
+
+static inline int libxl_domain_create_restore_0x040400(
+    libxl_ctx *ctx, libxl_domain_config *d_config,
+    uint32_t *domid, int restore_fd,
+    const libxl_domain_restore_params *params,
+    const libxl_asyncop_how *ao_how,
+    const libxl_asyncprogress_how *aop_console_how)
+    LIBXL_EXTERNAL_CALLERS_ONLY
+{
+    return libxl_domain_create_restore(ctx, d_config, domid, restore_fd,
+                                       -1, params, ao_how, aop_console_how);
+}
+
+#define libxl_domain_create_restore libxl_domain_create_restore_0x040400
+
+#endif
+
+int libxl_domain_soft_reset(libxl_ctx *ctx,
+                            libxl_domain_config *d_config,
+                            uint32_t domid,
+                            const libxl_asyncop_how *ao_how,
+                            const libxl_asyncprogress_how
+                            *aop_console_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+
+  /* A progress report will be made via ao_console_how, of type
+   * domain_create_console_available, when the domain's primary
+   * console is available and can be connected to.
+   */
+
+void libxl_domain_config_init(libxl_domain_config *d_config);
+void libxl_domain_config_dispose(libxl_domain_config *d_config);
+
+/*
+ * Retrieve domain configuration and filled it in d_config. The
+ * returned configuration can be used to rebuild a domain. It only
+ * works with DomU.
+ */
+int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
+                                        libxl_domain_config *d_config,
+                                        const libxl_asyncop_how *ao_how)
+                                        LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_retrieve_domain_configuration_0x041200(
+    libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config)
+{
+    return libxl_retrieve_domain_configuration(ctx, domid, d_config, NULL);
+}
+#define libxl_retrieve_domain_configuration \
+    libxl_retrieve_domain_configuration_0x041200
+#endif
+
+int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd,
+                         int flags, /* LIBXL_SUSPEND_* */
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+#define LIBXL_SUSPEND_DEBUG 1
+#define LIBXL_SUSPEND_LIVE 2
+
+/*
+ * Only suspend domain, do not save its state to file, do not destroy it.
+ * Suspended domain can be resumed with libxl_domain_resume()
+ */
+int libxl_domain_suspend_only(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* @param suspend_cancel [from xenctrl.h:xc_domain_resume( @param fast )]
+ *   If this parameter is true, use co-operative resume. The guest
+ *   must support this.
+ */
+int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel,
+                        const libxl_asyncop_how *ao_how)
+                        LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * This function doesn't return unless something has gone wrong with
+ * the replication to the secondary. If this function returns then the
+ * caller should resume the (primary) domain.
+ */
+int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
+                             uint32_t domid, int send_fd, int recv_fd,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid,
+                          const libxl_asyncop_how *ao_how)
+                          LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid,
+                        const libxl_asyncop_how *ao_how)
+                        LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_domain_shutdown_0x041200(libxl_ctx *ctx,
+                                                 uint32_t domid)
+{
+    return libxl_domain_shutdown(ctx, domid, NULL);
+}
+#define libxl_domain_shutdown libxl_domain_shutdown_0x041200
+static inline int libxl_domain_reboot_0x041200(libxl_ctx *ctx,
+                                               uint32_t domid)
+{
+    return libxl_domain_reboot(ctx, domid, NULL);
+}
+#define libxl_domain_reboot libxl_domain_reboot_0x041200
+#endif
+
+int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
+
+/* get max. number of cpus supported by hypervisor */
+int libxl_get_max_cpus(libxl_ctx *ctx);
+
+/* get the actual number of currently online cpus on the host */
+int libxl_get_online_cpus(libxl_ctx *ctx);
+  /* Beware that no locking or serialization is provided by libxl,
+   * so the information can be outdated as far as the function
+   * returns. If there are other entities in the system capable
+   * of onlining/offlining CPUs, it is up to the application
+   * to guarantee consistency, if that is important. */
+
+/* get max. number of NUMA nodes supported by hypervisor */
+int libxl_get_max_nodes(libxl_ctx *ctx);
+
+int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
+                        const char *old_name, const char *new_name);
+
+  /* if old_name is NULL, any old name is OK; otherwise we check
+   * transactionally that the domain has the old old name; if
+   * trans is not 0 we use caller's transaction and caller must do retries */
+
+int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid,
+                       const libxl_asyncop_how *ao_how)
+                       LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_domain_pause_0x041200(
+    libxl_ctx *ctx, uint32_t domid)
+{
+    return libxl_domain_pause(ctx, domid, NULL);
+}
+static inline int libxl_domain_unpause_0x041200(
+    libxl_ctx *ctx, uint32_t domid)
+{
+    return libxl_domain_unpause(ctx, domid, NULL);
+}
+#define libxl_domain_pause libxl_domain_pause_0x041200
+#define libxl_domain_unpause libxl_domain_unpause_0x041200
+#endif
+
+
+int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid,
+                           const char *filename,
+                           const libxl_asyncop_how *ao_how)
+                           LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t target_memkb);
+int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, int64_t target_memkb, int relative, int enforce);
+int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint64_t *out_target);
+int libxl_get_memory_target_0x040700(libxl_ctx *ctx, uint32_t domid,
+                                     uint32_t *out_target)
+    LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * WARNING
+ * This memory management API is unstable even in Xen 4.2.
+ * It has a numer of deficiencies and we intend to replace it.
+ *
+ * The semantics of these functions should not be relied on to be very
+ * coherent or stable.  We will however endeavour to keep working
+ * existing programs which use them in roughly the same way as libxl.
+ */
+/* how much free memory in the system a domain needs to be built */
+int libxl_domain_need_memory(libxl_ctx *ctx,
+                             libxl_domain_config *config
+                             /* ^ will be partially defaulted */,
+                             uint32_t domid_for_logging /* INVALID_DOMID ok */,
+                             uint64_t *need_memkb);
+int libxl_domain_need_memory_0x041200(libxl_ctx *ctx,
+                                      const libxl_domain_build_info *b_info_in,
+                                      uint64_t *need_memkb);
+int libxl_domain_need_memory_0x040700(libxl_ctx *ctx,
+                                      const libxl_domain_build_info *b_info_in,
+                                      uint32_t *need_memkb)
+    LIBXL_EXTERNAL_CALLERS_ONLY;
+/* how much free memory is available in the system */
+int libxl_get_free_memory(libxl_ctx *ctx, uint64_t *memkb);
+int libxl_get_free_memory_0x040700(libxl_ctx *ctx, uint32_t *memkb)
+    LIBXL_EXTERNAL_CALLERS_ONLY;
+/* wait for a given amount of memory to be free in the system */
+int libxl_wait_for_free_memory(libxl_ctx *ctx, uint32_t domid, uint64_t memory_kb, int wait_secs);
+/*
+ * Wait for the memory target of a domain to be reached. Does not
+ * decrement wait_secs if the domain is making progress toward reaching
+ * the target. If the domain is not making progress, wait_secs is
+ * decremented. If the timeout expires before the target is reached, the
+ * function returns ERROR_FAIL.
+ *
+ * Older versions of this function (Xen 4.5 and older), decremented
+ * wait_secs even if the domain was making progress, resulting in far
+ * lower overall wait times. To make sure that your calling routine
+ * works with new and old implementations of the function, pass enough
+ * time for the guest to reach its target as an argument.
+ */
+int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs);
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
+#define libxl_get_memory_target libxl_get_memory_target_0x040700
+#define libxl_domain_need_memory libxl_domain_need_memory_0x040700
+#define libxl_get_free_memory libxl_get_free_memory_0x040700
+#elif defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+#define libxl_domain_need_memory libxl_domain_need_memory_0x041200
+#endif
+
+int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
+
+/*
+ * If notify_fd is not -1, xenconsole will write 0x00 to it to nofity
+ * the caller that it has connected to the guest console.
+ */
+int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
+                       libxl_console_type type, int notify_fd);
+/* libxl_primary_console_exec finds the domid and console number
+ * corresponding to the primary console of the given vm, then calls
+ * libxl_console_exec with the right arguments (domid might be different
+ * if the guest is using stubdoms).
+ * This function can be called after creating the device model, in
+ * case of HVM guests, and before libxl_run_bootloader in case of PV
+ * guests using pygrub.
+ * If notify_fd is not -1, xenconsole will write 0x00 to it to nofity
+ * the caller that it has connected to the guest console.
+ */
+int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm,
+                               int notify_fd);
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
+
+static inline int libxl_console_exec_0x040700(libxl_ctx *ctx,
+                                              uint32_t domid, int cons_num,
+                                              libxl_console_type type)
+{
+    return libxl_console_exec(ctx, domid, cons_num, type, -1);
+}
+#define libxl_console_exec libxl_console_exec_0x040700
+
+static inline int libxl_primary_console_exec_0x040700(libxl_ctx *ctx,
+                                                      uint32_t domid_vm)
+{
+    return libxl_primary_console_exec(ctx, domid_vm, -1);
+}
+#define libxl_primary_console_exec libxl_primary_console_exec_0x040700
+
+#endif
+
+/* libxl_console_get_tty retrieves the specified domain's console tty path
+ * and stores it in path. Caller is responsible for freeing the memory.
+ */
+int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num,
+                          libxl_console_type type, char **path);
+
+/* libxl_primary_console_get_tty retrieves the specified domain's primary
+ * console tty path and stores it in path. Caller is responsible for freeing
+ * the memory.
+ */
+int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, char **path);
+
+/* May be called with info_r == NULL to check for domain's existence.
+ * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return
+ * ERROR_INVAL for this scenario). */
+int libxl_domain_info(libxl_ctx*, libxl_dominfo *info_r,
+                      uint32_t domid);
+
+/* These functions each return (on success) an array of elements,
+ * and the length via the int* out parameter.  These arrays and
+ * their contents come from malloc, and must be freed with the
+ * corresponding libxl_THING_list_free function.
+ */
+libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain_out);
+void libxl_dominfo_list_free(libxl_dominfo *list, int nb_domain);
+
+libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool_out);
+void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nb_pool);
+
+libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm_out);
+void libxl_vminfo_list_free(libxl_vminfo *list, int nb_vm);
+
+#define LIBXL_CPUTOPOLOGY_INVALID_ENTRY (~(uint32_t)0)
+libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out);
+void libxl_cputopology_list_free(libxl_cputopology *, int nb_cpu);
+
+#define LIBXL_PCITOPOLOGY_INVALID_ENTRY (~(uint32_t)0)
+libxl_pcitopology *libxl_get_pci_topology(libxl_ctx *ctx, int *num_devs);
+void libxl_pcitopology_list_free(libxl_pcitopology *, int num_devs);
+
+#define LIBXL_NUMAINFO_INVALID_ENTRY (~(uint32_t)0)
+libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr);
+void libxl_numainfo_list_free(libxl_numainfo *, int nr);
+
+libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
+                                int *nb_vcpu, int *nr_cpus_out);
+void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
+
+/*
+ * Devices
+ * =======
+ *
+ * Each device is represented by a libxl_device_<TYPE> data structure
+ * which is defined via the IDL. In addition some devices have an
+ * additional data type libxl_device_<TYPE>_getinfo which contains
+ * further runtime information about the device.
+ *
+ * In addition to the general methods available for libxl types (see
+ * "libxl types" above) a common set of methods are available for each
+ * device type. These are described below.
+ *
+ * Querying
+ * --------
+ *
+ * libxl_device_<type>_list(ctx, domid, nr):
+ *
+ *   Returns an array of libxl_device_<type> length nr representing
+ *   the devices attached to the specified domain.
+ *
+ * libxl_device_<type>_getinfo(ctx, domid, device, info):
+ *
+ *   Initialises info with details of the given device which must be
+ *   attached to the specified domain.
+ *
+ * Creation / Control
+ * ------------------
+ *
+ * libxl_device_<type>_add(ctx, domid, device):
+ *
+ *   Adds the given device to the specified domain. This can be called
+ *   while the guest is running (hotplug) or before boot (coldplug).
+ *
+ *   This function only sets up the device but does not wait for the
+ *   domain to connect to the device and therefore cannot block on the
+ *   guest.
+ *
+ *   device is an in/out parameter:  fields left unspecified when the
+ *   structure is passed in are filled in with appropriate values for
+ *   the device created.
+ *
+ * libxl_device_<type>_destroy(ctx, domid, device):
+ *
+ *   Removes the given device from the specified domain without guest
+ *   co-operation. It is guest specific what affect this will have on
+ *   a running guest.
+ *
+ *   This function does not interact with the guest and therefore
+ *   cannot block on the guest.
+ *
+ * libxl_device_<type>_remove(ctx, domid, device):
+ *
+ *   Removes the given device from the specified domain by performing
+ *   an orderly unplug with guest co-operation. This requires that the
+ *   guest is running.
+ *
+ *   This method is currently synchronous and therefore can block
+ *   while interacting with the guest. There is a time-out of 10s on
+ *   this interaction after which libxl_device_<type>_destroy()
+ *   semantics apply.
+ *
+ * libxl_device_<type>_safe_remove(ctx, domid, device):
+ *
+ *   This has the same semantics as libxl_device_<type>_remove() but,
+ *   in the event of hitting the 10s time-out, this function will fail.
+ *
+ * Controllers
+ * -----------
+ *
+ * Most devices are treated individually.  Some classes of device,
+ * however, like USB or SCSI, inherently have the need to have a
+ * hierarchy of different levels, with lower-level devices "attached"
+ * to higher-level ones.  USB for instance has "controllers" at the
+ * top, which have buses, on which are devices, which consist of
+ * multiple interfaces.  SCSI has "hosts" at the top, then buses,
+ * targets, and LUNs.
+ *
+ * In that case, for each <class>, there will be a set of functions
+ * and types for each <level>.  For example, for <class>=usb, there
+ * may be <levels> ctrl (controller) and dev (device), with ctrl being
+ * level 0.
+ *
+ * libxl_device_<class><level0>_<function> will act more or
+ * less like top-level non-bus devices: they will either create or
+ * accept a libxl_devid which will be unique within the
+ * <class><level0> libxl_devid namespace.
+ *
+ * Lower-level devices must have a unique way to be identified.  One
+ * way to do this would be to name it via the name of the next level
+ * up plus an index; for instance, <ctrl devid, port number>.  Another
+ * way would be to have another devid namespace for that level.  This
+ * identifier will be used for queries and removals.
+ *
+ * Lower-level devices will include in their
+ * libxl_device_<class><level> struct a field referring to the unique
+ * index of the level above.  For instance, libxl_device_usbdev might
+ * contain the controller devid.
+ *
+ * In the case where there are multiple different ways to implement a
+ * given device -- for instance, one which is fully PV and one which
+ * uses an emulator -- the controller will contain a field which
+ * specifies what type of implementation is used.  The implementations
+ * of individual devices will be known by the controller to which they
+ * are attached.
+ *
+ * If libxl_device_<class><level>_add receives an empty reference to
+ * the level above, it may return an error.  Or it may (but is not
+ * required to) automatically choose a suitable device in the level
+ * above to which to attach the new device at this level.  It may also
+ * (but is not required to) automatically create a new device at the
+ * level above if no suitable devices exist.  Each class should
+ * document its behavior.
+ *
+ * libxl_device_<class><level>_list will list all devices of <class>
+ * at <level> in the domain.  For example, libxl_device_usbctrl_list
+ * will list all usb controllers; libxl_class_usbdev_list will list
+ * all usb devices across all controllers.
+ *
+ * For each class, the domain config file will contain a single list
+ * for each level.  libxl will first iterate through the list of
+ * top-level devices, then iterate through each level down in turn,
+ * adding devices to devices in the level above.  For instance, there
+ * will be one list for all usb controllers, and one list for all usb
+ * devices.
+ *
+ * If libxl_device_<class><level>_add automatically creates
+ * higher-level devices as necessary, then it is permissible for the
+ * higher-level lists to be empty and the device list to have devices
+ * with the field containing a reference to the higher level device
+ * uninitialized.
+ */
+
+/* Disks */
+int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid,
+                          libxl_device_disk *disk,
+                          const libxl_asyncop_how *ao_how)
+                          LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_disk_remove(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_disk *disk,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_disk_destroy(libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_disk *disk,
+                              const libxl_asyncop_how *ao_how)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_disk_safe_remove(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_device_disk *disk,
+                                  const libxl_asyncop_how *ao_how)
+                                  LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx,
+                                          uint32_t domid, int *num)
+                                          LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_disk_list_free(libxl_device_disk* list, int num)
+                                 LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
+                              const libxl_device_disk *disk, libxl_diskinfo *diskinfo)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * Insert a CD-ROM device. A device corresponding to disk must already
+ * be attached to the guest.
+ */
+int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
+                       const libxl_asyncop_how *ao_how)
+                       LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * USB
+ *
+ * For each device removed or added, one of these protocols is available:
+ * - PV (i.e., PVUSB)
+ * - DEVICEMODEL (i.e, qemu)
+ *
+ * PV is available for either PV or HVM domains.  DEVICEMODEL is only
+ * available for HVM domains.  The caller can additionally specify
+ * "AUTO", in which case the library will try to determine the best
+ * protocol automatically.
+ *
+ * At the moment, the only protocol implemented is PV.
+ *
+ * One can add/remove USB controllers to/from guest, and attach/detach USB
+ * devices to/from USB controllers.
+ *
+ * To add USB controllers and USB devices, one can adding USB controllers
+ * first and then attaching USB devices to some USB controller, or adding
+ * USB devices to guest directly, it will automatically create a USB
+ * controller for USB devices to attach.
+ *
+ * To remove USB controllers or USB devices, one can remove USB devices
+ * under USB controller one by one and then remove USB controller, or
+ * remove USB controller directly, it will remove all USB devices under
+ * it automatically.
+ *
+ */
+/* USB Controllers*/
+int libxl_device_usbctrl_add(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_usbctrl *usbctrl,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_device_usbctrl_remove(libxl_ctx *ctx, uint32_t domid,
+                                libxl_device_usbctrl *usbctrl,
+                                const libxl_asyncop_how *ao_how)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_device_usbctrl_destroy(libxl_ctx *ctx, uint32_t domid,
+                                 libxl_device_usbctrl *usbctrl,
+                                 const libxl_asyncop_how *ao_how)
+                                 LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_usbctrl *libxl_device_usbctrl_list(libxl_ctx *ctx,
+                                                uint32_t domid, int *num);
+
+void libxl_device_usbctrl_list_free(libxl_device_usbctrl *list, int nr);
+
+
+int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid,
+                                 const libxl_device_usbctrl *usbctrl,
+                                 libxl_usbctrlinfo *usbctrlinfo);
+
+/* USB Devices */
+
+int libxl_device_usbdev_add(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_usbdev *usbdev,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_device_usbdev_remove(libxl_ctx *ctx, uint32_t domid,
+                               libxl_device_usbdev *usbdev,
+                               const libxl_asyncop_how *ao_how)
+                               LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_usbdev *
+libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num);
+
+void libxl_device_usbdev_list_free(libxl_device_usbdev *list, int nr);
+
+/* Network Interfaces */
+int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_nic_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_nic *nic,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_nic_destroy(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_nic *nic,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx,
+                                        uint32_t domid, int *num)
+                                        LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_nic_list_free(libxl_device_nic* list, int num)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
+                             const libxl_device_nic *nic, libxl_nicinfo *nicinfo)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * Virtual Channels
+ * Channels manifest as consoles with names, see docs/misc/channels.txt
+ */
+libxl_device_channel *libxl_device_channel_list(libxl_ctx *ctx,
+                                                uint32_t domid,
+                                                int *num);
+int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid,
+                                 const libxl_device_channel *channel,
+                                 libxl_channelinfo *channelinfo);
+
+/* Virtual TPMs */
+int libxl_device_vtpm_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vtpm *vtpm,
+                          const libxl_asyncop_how *ao_how)
+                          LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vtpm_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_vtpm *vtpm,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vtpm_destroy(libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_vtpm *vtpm,
+                              const libxl_asyncop_how *ao_how)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx,
+                                          uint32_t domid, int *num)
+                                          LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vtpm_list_free(libxl_device_vtpm*, int num)
+                                 LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vtpm_getinfo(libxl_ctx *ctx, uint32_t domid,
+                              const libxl_device_vtpm *vtpm, libxl_vtpminfo *vtpminfo)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* Virtual displays */
+int libxl_device_vdispl_add(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_vdispl *displ,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vdispl_remove(libxl_ctx *ctx, uint32_t domid,
+                               libxl_device_vdispl *vdispl,
+                               const libxl_asyncop_how *ao_how)
+                               LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vdispl_destroy(libxl_ctx *ctx, uint32_t domid,
+                                libxl_device_vdispl *vdispl,
+                                const libxl_asyncop_how *ao_how)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_vdispl *libxl_device_vdispl_list(libxl_ctx *ctx,
+                                              uint32_t domid, int *num)
+                                              LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vdispl_list_free(libxl_device_vdispl* list, int num)
+                                   LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t domid,
+                                const libxl_device_vdispl *vdispl,
+                                libxl_vdisplinfo *vdisplinfo)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* Virtual sounds */
+int libxl_device_vsnd_add(libxl_ctx *ctx, uint32_t domid,
+                          libxl_device_vsnd *vsnd,
+                          const libxl_asyncop_how *ao_how)
+                          LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_remove(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_vsnd *vsnd,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t domid,
+                              libxl_device_vsnd *vsnd,
+                              const libxl_asyncop_how *ao_how)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_vsnd *libxl_device_vsnd_list(libxl_ctx *ctx,
+                                          uint32_t domid, int *num)
+                                          LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vsnd_list_free(libxl_device_vsnd* list, int num)
+                                 LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_getinfo(libxl_ctx *ctx, uint32_t domid,
+                              const libxl_device_vsnd *vsnd,
+                              libxl_vsndinfo *vsndlinfo)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* Keyboard */
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_vkb *vkb,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_vkb *vkb,
+                             const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_vkb *libxl_device_vkb_list(libxl_ctx *ctx,
+                                        uint32_t domid, int *num)
+                                        LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vkb_list_free(libxl_device_vkb* list, int num)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid,
+                             const libxl_device_vkb *vkb,
+                             libxl_vkbinfo *vkbinfo)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* Framebuffer */
+int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_vfb *vfb,
+                            const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vfb_destroy(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_vfb *vfb,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* 9pfs */
+int libxl_device_p9_remove(libxl_ctx *ctx, uint32_t domid,
+                           libxl_device_p9 *p9,
+                           const libxl_asyncop_how *ao_how)
+                           LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_p9_destroy(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_p9 *p9,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* pvcalls interface */
+int libxl_device_pvcallsif_remove(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_device_pvcallsif *pvcallsif,
+                                  const libxl_asyncop_how *ao_how)
+                                  LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pvcallsif_destroy(libxl_ctx *ctx, uint32_t domid,
+                                   libxl_device_pvcallsif *pvcallsif,
+                                   const libxl_asyncop_how *ao_how)
+                                   LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* PCI Passthrough */
+int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
+                         libxl_device_pci *pci,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_pci *pci,
+                            const libxl_asyncop_how *ao_how)
+                            LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_pci *pci,
+                             const libxl_asyncop_how *ao_how)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid,
+                                        int *num);
+void libxl_device_pci_list_free(libxl_device_pci* list, int num);
+
+/*
+ * Turns the current process into a backend device service daemon
+ * for a driver domain.
+ *
+ * From a libxl API point of view, this starts a long-running
+ * operation.  That operation consists of "being a driver domain"
+ * and never completes.
+ *
+ * Attempting to abort this operation is not advisable; proper
+ * shutdown of the driver domain task is not supported.
+ */
+int libxl_device_events_handler(libxl_ctx *ctx,
+                                const libxl_asyncop_how *ao_how)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/*
+ * Functions related to making devices assignable -- that is, bound to
+ * the pciback driver, ready to be given to a guest via
+ * libxl_pci_device_add.
+ *
+ * - ..._add() will unbind the device from its current driver (if
+ * already bound) and re-bind it to pciback; at that point it will be
+ * ready to be assigned to a VM.  If rebind is set, it will store the
+ * path to the old driver in xenstore so that it can be handed back to
+ * dom0 on restore.
+ *
+ * - ..._remove() will unbind the device from pciback, and if
+ * rebind is non-zero, attempt to assign it back to the driver
+ * from whence it came.
+ *
+ * - ..._list() will return a list of the PCI devices available to be
+ * assigned.
+ *
+ * add and remove are idempotent: if the device in question is already
+ * added or is not bound, the functions will emit a warning but return
+ * SUCCESS.
+ */
+int libxl_device_pci_assignable_add(libxl_ctx *ctx, libxl_device_pci *pci, int rebind);
+int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *pci, int rebind);
+libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *num);
+void libxl_device_pci_assignable_list_free(libxl_device_pci *list, int num);
+
+/* CPUID handling */
+int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str);
+int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
+                                  const char* str);
+#if LIBXL_API_VERSION < 0x041400
+/*
+ * Dropped from the API in Xen 4.14.  At the time of writing, these functions
+ * don't appear to ever have had external callers.
+ *
+ * These have always been used internally during domain construction, and
+ * can't easily be used externally because of their implicit parameters in
+ * other pieces of global state.
+ *
+ * Furthermore, an API user can't usefully determine whether they get
+ * libxl_cpuid (the real implementation) or libxl_nocpuid (no-op stubs).
+ *
+ * The internal behaviour of these functions also needs to change.  Therefore
+ * for simplicitly, provide the no-op stubs.  Yes technically this is an API
+ * change in some cases for existing software, but there is 0 of that in
+ * practice.
+ */
+static inline void libxl_cpuid_apply_policy(libxl_ctx *ctx __attribute__((unused)),
+                                            uint32_t domid __attribute__((unused)))
+{}
+static inline void libxl_cpuid_set(libxl_ctx *ctx __attribute__((unused)),
+                                   uint32_t domid __attribute__((unused)),
+                                   libxl_cpuid_policy_list cpuid __attribute__((unused)))
+{}
+#endif
+
+/*
+ * Functions for allowing users of libxl to store private data
+ * relating to a domain.  The data is an opaque sequence of bytes and
+ * is not interpreted or used by libxl.
+ *
+ * Data is indexed by the userdata userid, which is a short printable
+ * ASCII string.  The following list is a registry of userdata userids
+ * (the registry may be updated by posting a patch to xen-devel):
+ *
+ *  userid        Data contents
+ *  "xl"          domain config file in xl format, Unix line endings
+ *  "libvirt-xml" domain config file in libvirt XML format.  See
+ *                http://libvirt.org/formatdomain.html
+ *  "domain-userdata-lock"  lock file to protect domain userdata in libxl.
+ *                          It's a per-domain lock. Applications should
+ *                          not touch this file.
+ *  "libxl-json"  libxl_domain_config object in JSON format, generated
+ *                by libxl. Applications should not access this file
+ *                directly. This file is protected by domain-userdata-lock
+ *                for against Read-Modify-Write operation and domain
+ *                destruction.
+ *
+ * libxl does not enforce the registration of userdata userids or the
+ * semantics of the data.  For specifications of the data formats
+ * see the code or documentation for the libxl caller in question.
+ */
+int libxl_userdata_store(libxl_ctx *ctx, uint32_t domid,
+                              const char *userdata_userid,
+                              const uint8_t *data, int datalen)
+                              LIBXL_EXTERNAL_CALLERS_ONLY;
+  /* If datalen==0, data is not used and the user data for
+   * that domain and userdata_userid is deleted. */
+int libxl_userdata_retrieve(libxl_ctx *ctx, uint32_t domid,
+                                 const char *userdata_userid,
+                                 uint8_t **data_r, int *datalen_r)
+                                 LIBXL_EXTERNAL_CALLERS_ONLY;
+  /* On successful return, *data_r is from malloc.
+   * If there is no data for that domain and userdata_userid,
+   * *data_r and *datalen_r will be set to 0.
+   * data_r and datalen_r may be 0.
+   * On error return, *data_r and *datalen_r are undefined.
+   */
+int libxl_userdata_unlink(libxl_ctx *ctx, uint32_t domid,
+                          const char *userdata_userid);
+
+
+int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
+int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
+                           const libxl_bitmap *cpumap_hard,
+                           const libxl_bitmap *cpumap_soft);
+int libxl_set_vcpuaffinity_force(libxl_ctx *ctx, uint32_t domid,
+                                 uint32_t vcpuid,
+                                 const libxl_bitmap *cpumap_hard,
+                                 const libxl_bitmap *cpumap_soft);
+int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
+                               unsigned int max_vcpus,
+                               const libxl_bitmap *cpumap_hard,
+                               const libxl_bitmap *cpumap_soft);
+
+#if defined (LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
+
+#define libxl_set_vcpuaffinity(ctx, domid, vcpuid, map) \
+    libxl_set_vcpuaffinity((ctx), (domid), (vcpuid), (map), NULL)
+#define libxl_set_vcpuaffinity_all(ctx, domid, max_vcpus, map) \
+    libxl_set_vcpuaffinity_all((ctx), (domid), (max_vcpus), (map), NULL)
+
+#endif
+
+int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_bitmap *nodemap);
+int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_bitmap *nodemap);
+int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid,
+                         libxl_bitmap *cpumap,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_set_vcpuonline_0x041200(libxl_ctx *ctx,
+                                                uint32_t domid,
+                                                libxl_bitmap *cpumap)
+{
+    return libxl_set_vcpuonline(ctx, domid, cpumap, NULL);
+}
+#define libxl_set_vcpuonline libxl_set_vcpuonline_0x041200
+#endif
+
+/* A return value less than 0 should be interpreted as a libxl_error, while a
+ * return value greater than or equal to 0 should be interpreted as a
+ * libxl_scheduler. */
+int libxl_get_scheduler(libxl_ctx *ctx);
+
+/* Per-scheduler parameters */
+int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid,
+                                  libxl_sched_credit_params *scinfo);
+int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid,
+                                  libxl_sched_credit_params *scinfo);
+int libxl_sched_credit2_params_get(libxl_ctx *ctx, uint32_t poolid,
+                                   libxl_sched_credit2_params *scinfo);
+int libxl_sched_credit2_params_set(libxl_ctx *ctx, uint32_t poolid,
+                                   libxl_sched_credit2_params *scinfo);
+
+/* Scheduler Per-domain parameters */
+
+#define LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT    -1
+#define LIBXL_DOMAIN_SCHED_PARAM_CAP_DEFAULT       -1
+#define LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT    -1
+#define LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT     -1
+#define LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT   -1
+#define LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT -1
+#define LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT    -1
+
+/* Per-VCPU parameters */
+#define LIBXL_SCHED_PARAM_VCPU_INDEX_DEFAULT   -1
+
+/* Get the per-domain scheduling parameters.
+ * For schedulers that support per-vcpu settings (e.g., RTDS),
+ * calling *_domain_get functions will get default scheduling
+ * parameters.
+ */
+int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_domain_sched_params *params);
+
+/* Set the per-domain scheduling parameters.
+ * For schedulers that support per-vcpu settings (e.g., RTDS),
+ * calling *_domain_set functions will set all vcpus with the same
+ * scheduling parameters.
+ */
+int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
+                                  const libxl_domain_sched_params *params);
+
+/* Get the per-vcpu scheduling parameters */
+int libxl_vcpu_sched_params_get(libxl_ctx *ctx, uint32_t domid,
+                                libxl_vcpu_sched_params *params);
+
+/* Get the per-vcpu scheduling parameters of all vcpus of a domain */
+int libxl_vcpu_sched_params_get_all(libxl_ctx *ctx, uint32_t domid,
+                                    libxl_vcpu_sched_params *params);
+
+/* Set the per-vcpu scheduling parameters */
+int libxl_vcpu_sched_params_set(libxl_ctx *ctx, uint32_t domid,
+                                const libxl_vcpu_sched_params *params);
+
+/* Set the per-vcpu scheduling parameters of all vcpus of a domain */
+int libxl_vcpu_sched_params_set_all(libxl_ctx *ctx, uint32_t domid,
+                                    const libxl_vcpu_sched_params *params);
+
+int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
+                       libxl_trigger trigger, uint32_t vcpuid,
+                       const libxl_asyncop_how *ao_how)
+                       LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_send_trigger_0x041200(
+    libxl_ctx *ctx, uint32_t domid, libxl_trigger trigger, uint32_t vcpuid)
+{
+    return libxl_send_trigger(ctx, domid, trigger, vcpuid, NULL);
+}
+#define libxl_send_trigger libxl_send_trigger_0x041200
+#endif
+int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
+int libxl_send_debug_keys(libxl_ctx *ctx, char *keys);
+int libxl_set_parameters(libxl_ctx *ctx, char *params);
+
+typedef struct libxl__xen_console_reader libxl_xen_console_reader;
+
+libxl_xen_console_reader *
+    libxl_xen_console_read_start(libxl_ctx *ctx, int clear);
+int libxl_xen_console_read_line(libxl_ctx *ctx,
+                                libxl_xen_console_reader *cr,
+                                char **line_r);
+void libxl_xen_console_read_finish(libxl_ctx *ctx,
+                                   libxl_xen_console_reader *cr);
+
+uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t domid);
+
+char *libxl_tmem_list(libxl_ctx *ctx, uint32_t domid, int use_long);
+int libxl_tmem_freeze(libxl_ctx *ctx, uint32_t domid);
+int libxl_tmem_thaw(libxl_ctx *ctx, uint32_t domid);
+int libxl_tmem_set(libxl_ctx *ctx, uint32_t domid, char* name,
+                   uint32_t set);
+int libxl_tmem_shared_auth(libxl_ctx *ctx, uint32_t domid, char* uuid,
+                           int auth);
+int libxl_tmem_freeable(libxl_ctx *ctx);
+
+int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap);
+
+/*
+ * Set poolid to LIBXL_CPUOOL_POOLID_ANY to have Xen choose a
+ * free poolid for you.
+ */
+#define LIBXL_CPUPOOL_POOLID_ANY 0xFFFFFFFF
+int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
+                         libxl_scheduler sched,
+                         libxl_bitmap cpumap, libxl_uuid *uuid,
+                         uint32_t *poolid);
+int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
+int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
+int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
+int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
+int libxl_cpupool_cpuadd_cpumap(libxl_ctx *ctx, uint32_t poolid,
+                                const libxl_bitmap *cpumap);
+int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu);
+int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
+int libxl_cpupool_cpuremove_cpumap(libxl_ctx *ctx, uint32_t poolid,
+                                   const libxl_bitmap *cpumap);
+int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid);
+int libxl_cpupool_info(libxl_ctx *ctx, libxl_cpupoolinfo *info, uint32_t poolid);
+
+int libxl_domid_valid_guest(uint32_t domid);
+
+int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
+                               uint32_t *ssidref);
+int libxl_flask_sid_to_context(libxl_ctx *ctx, uint32_t ssidref, char **buf,
+                               size_t *len);
+int libxl_flask_getenforce(libxl_ctx *ctx);
+int libxl_flask_setenforce(libxl_ctx *ctx, int mode);
+int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
+
+int libxl_ms_vm_genid_generate(libxl_ctx *ctx, libxl_ms_vm_genid *id);
+bool libxl_ms_vm_genid_is_zero(const libxl_ms_vm_genid *id);
+void libxl_ms_vm_genid_copy(libxl_ctx *ctx, libxl_ms_vm_genid *dst,
+                            const libxl_ms_vm_genid *src);
+
+#if defined(__i386__) || defined(__x86_64__)
+int libxl_psr_cmt_attach(libxl_ctx *ctx, uint32_t domid);
+int libxl_psr_cmt_detach(libxl_ctx *ctx, uint32_t domid);
+int libxl_psr_cmt_domain_attached(libxl_ctx *ctx, uint32_t domid);
+int libxl_psr_cmt_enabled(libxl_ctx *ctx);
+int libxl_psr_cmt_get_total_rmid(libxl_ctx *ctx, uint32_t *total_rmid);
+int libxl_psr_cmt_get_l3_cache_size(libxl_ctx *ctx,
+                                    uint32_t socketid,
+                                    uint32_t *l3_cache_size);
+int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx,
+                                      uint32_t domid,
+                                      uint32_t socketid,
+                                      uint32_t *l3_cache_occupancy);
+
+int libxl_psr_cmt_type_supported(libxl_ctx *ctx, libxl_psr_cmt_type type);
+int libxl_psr_cmt_get_sample(libxl_ctx *ctx,
+                             uint32_t domid,
+                             libxl_psr_cmt_type type,
+                             uint64_t scope,
+                             uint64_t *sample_r,
+                             uint64_t *tsc_r);
+
+/*
+ * Function to set a domain's cbm. It operates on a single or multiple
+ * target(s) defined in 'target_map'. The definition of 'target_map' is
+ * related to 'type':
+ * 'L3_CBM': 'target_map' specifies all the sockets to be operated on.
+ */
+int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
+                          libxl_psr_cbm_type type, libxl_bitmap *target_map,
+                          uint64_t cbm);
+/*
+ * Function to get a domain's cbm. It operates on a single 'target'.
+ * The definition of 'target' is related to 'type':
+ * 'L3_CBM': 'target' specifies which socket to be operated on.
+ */
+int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
+                          libxl_psr_cbm_type type, uint32_t target,
+                          uint64_t *cbm_r);
+
+/*
+ * On success, the function returns an array of elements in 'info',
+ * and the length in 'nr'.
+ */
+int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
+                           unsigned int *nr, unsigned int lvl);
+int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
+                              int *nr);
+void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);
+
+typedef enum libxl_psr_cbm_type libxl_psr_type;
+
+/*
+ * Function to set a domain's value. It operates on a single or multiple
+ * target(s) defined in 'target_map'. 'target_map' specifies all the sockets
+ * to be operated on.
+ */
+int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
+                      libxl_psr_type type, libxl_bitmap *target_map,
+                      uint64_t val);
+/*
+ * Function to get a domain's cbm. It operates on a single 'target'.
+ * 'target' specifies which socket to be operated on.
+ */
+int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
+                      libxl_psr_type type, unsigned int target,
+                      uint64_t *val);
+/*
+ * On success, the function returns an array of elements in 'info',
+ * and the length in 'nr'.
+ */
+int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_feat_type type,
+                          unsigned int lvl, unsigned int *nr,
+                          libxl_psr_hw_info **info);
+void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr);
+#endif
+
+/* misc */
+
+/* Each of these sets or clears the flag according to whether the
+ * 2nd parameter is nonzero.  On failure, they log, and
+ * return ERROR_FAIL, but also leave errno valid. */
+int libxl_fd_set_cloexec(libxl_ctx *ctx, int fd, int cloexec);
+int libxl_fd_set_nonblock(libxl_ctx *ctx, int fd, int nonblock);
+
+/*
+ * Issue a qmp monitor command to the device model of the specified domain.
+ * The function returns the output of the command in a new allocated buffer
+ * via output.
+ */
+int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid,
+                               const char *command_line, char **output,
+                               const libxl_asyncop_how *ao_how)
+                               LIBXL_EXTERNAL_CALLERS_ONLY;
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
+static inline int libxl_qemu_monitor_command_0x041200(libxl_ctx *ctx,
+    uint32_t domid, const char *command_line, char **output)
+{
+    return libxl_qemu_monitor_command(ctx, domid, command_line, output,
+                                      NULL);
+}
+#define libxl_qemu_monitor_command libxl_qemu_monitor_command_0x041200
+#endif
+
+#include <libxl_event.h>
+
+/*
+ * This function is for use only during host initialisation. If it is
+ * invoked on a host with running domains, or concurrent libxl
+ * processes then the system may malfuntion.
+ */
+int libxl_clear_domid_history(libxl_ctx *ctx);
+
+#endif /* LIBXL_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxl_json.h 4.16.1-1/tools/include/libxl_json.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxl_json.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxl_json.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011      Citrix Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXL_JSON_H
+#define LIBXL_JSON_H
+
+#include <yajl/yajl_gen.h>
+#include <yajl/yajl_parse.h>
+
+#ifdef HAVE_YAJL_YAJL_VERSION_H
+#  include <yajl/yajl_version.h>
+#endif
+
+yajl_gen_status libxl__uint64_gen_json(yajl_gen hand, uint64_t val);
+yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, libxl_defbool *p);
+yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, libxl_uuid *p);
+yajl_gen_status libxl_mac_gen_json(yajl_gen hand, libxl_mac *p);
+yajl_gen_status libxl_bitmap_gen_json(yajl_gen hand, libxl_bitmap *p);
+yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
+                                                 libxl_cpuid_policy_list *p);
+yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, libxl_string_list *p);
+yajl_gen_status libxl_key_value_list_gen_json(yajl_gen hand,
+                                              libxl_key_value_list *p);
+yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, libxl_hwcap *p);
+yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, libxl_ms_vm_genid *p);
+
+#include <_libxl_types_json.h>
+
+/* YAJL version check */
+#if defined(YAJL_MAJOR) && (YAJL_MAJOR > 1)
+#  define HAVE_YAJL_V2 1
+#endif
+
+#ifdef HAVE_YAJL_V2
+
+typedef size_t libxl_yajl_length;
+
+static inline yajl_handle libxl__yajl_alloc(const yajl_callbacks *callbacks,
+                                            yajl_alloc_funcs *allocFuncs,
+                                            void *ctx)
+{
+    yajl_handle hand = yajl_alloc(callbacks, allocFuncs, ctx);
+    if (hand)
+        yajl_config(hand, yajl_allow_trailing_garbage, 1);
+    return hand;
+}
+
+static inline yajl_gen libxl_yajl_gen_alloc(const yajl_alloc_funcs *allocFuncs)
+{
+    yajl_gen g;
+    g = yajl_gen_alloc(allocFuncs);
+    if (g)
+        yajl_gen_config(g, yajl_gen_beautify, 1);
+    return g;
+}
+
+#else /* !HAVE_YAJL_V2 */
+
+#define yajl_complete_parse yajl_parse_complete
+
+typedef unsigned int libxl_yajl_length;
+
+static inline yajl_handle libxl__yajl_alloc(const yajl_callbacks *callbacks,
+                                            const yajl_alloc_funcs *allocFuncs,
+                                            void *ctx)
+{
+    yajl_parser_config cfg = {
+        .allowComments = 1,
+        .checkUTF8 = 1,
+    };
+    return yajl_alloc(callbacks, &cfg, allocFuncs, ctx);
+}
+
+static inline yajl_gen libxl_yajl_gen_alloc(const yajl_alloc_funcs *allocFuncs)
+{
+    yajl_gen_config conf = { 1, "    " };
+    return yajl_gen_alloc(&conf, allocFuncs);
+}
+
+#endif /* !HAVE_YAJL_V2 */
+
+yajl_gen_status libxl_domain_config_gen_json(yajl_gen hand,
+                                             libxl_domain_config *p);
+
+#endif /* LIBXL_JSON_H */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxlutil.h 4.16.1-1/tools/include/libxlutil.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxlutil.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxlutil.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2010      Citrix Ltd.
+ * Author Ian Jackson <ian.jackson@eu.citrix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXLUTIL_H
+#define LIBXLUTIL_H
+
+#include <stdio.h>
+
+#include "libxl.h"
+
+enum XLU_ConfigValueType {
+    XLU_STRING,
+    XLU_LIST,
+};
+
+enum XLU_Operation {
+    XLU_OP_ASSIGNMENT = 0,
+    XLU_OP_ADDITION,
+};
+
+/* Unless otherwise stated, all functions return an errno value. */
+typedef struct XLU_Config XLU_Config;
+typedef struct XLU_ConfigList XLU_ConfigList;
+typedef struct XLU_ConfigValue XLU_ConfigValue;
+
+XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename);
+  /* 0 means we got ENOMEM. */
+  /* report_filename is copied; report is saved and must remain valid
+   *  until the Config is destroyed. */
+
+int xlu_cfg_readfile(XLU_Config*, const char *real_filename);
+int xlu_cfg_readdata(XLU_Config*, const char *data, int length);
+  /* If these fail, then it is undefined behaviour to call xlu_cfg_get_...
+   * functions.  You have to just xlu_cfg_destroy. */
+
+void xlu_cfg_destroy(XLU_Config*);
+
+
+/* All of the following print warnings to "report" if there is a problem.
+ * Return values are:
+ *   0        OK
+ *   ESRCH    not defined
+ *   EINVAL   value found but wrong format for request (prints warning unless dont_warn=true)
+ *   ERANGE   value out of range (from strtol)
+ */
+
+int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **value_r,
+                       int dont_warn);
+/* free/strdup version */
+int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n,
+                           char **value_r, int dont_warn);
+int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r,
+                     int dont_warn);
+int xlu_cfg_get_bounded_long(const XLU_Config*, const char *n, long min,
+                             long max, long *value_r, int dont_warn);
+int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b,
+                     int dont_warn);
+
+int xlu_cfg_get_list(const XLU_Config*, const char *n,
+                     XLU_ConfigList **list_r /* may be 0 */,
+                     int *entries_r /* may be 0 */,
+                     int dont_warn);
+  /* there is no need to free *list_r; lifetime is that of the XLU_Config */
+int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n,
+                                    libxl_string_list *sl, int dont_warn);
+const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int entry);
+  /* xlu_cfg_get_listitem cannot fail, except that if entry is
+   * out of range it returns 0 (not setting errno) */
+
+enum XLU_ConfigValueType xlu_cfg_value_type(const XLU_ConfigValue *value);
+int xlu_cfg_value_get_string(const XLU_Config *cfg,  XLU_ConfigValue *value,
+                             char **value_r, int dont_warn);
+int xlu_cfg_value_get_list(const XLU_Config *cfg, XLU_ConfigValue *value,
+                           XLU_ConfigList **value_r, int dont_warn);
+XLU_ConfigValue *xlu_cfg_get_listitem2(const XLU_ConfigList *list,
+                                       int entry);
+
+/*
+ * Disk specification parsing.
+ */
+
+int xlu_disk_parse(XLU_Config *cfg, int nspecs, const char *const *specs,
+                   libxl_device_disk *disk);
+  /* disk must have been initialised.
+   *
+   * On error, returns errno value.  Bad strings cause EINVAL and
+   * print a message to cfg's report (that's all cfg is used for).
+   *
+   * Normally one would pass nspecs==1 and only specs[0].  But it is
+   * permitted to pass more strings in which case each is parsed as a
+   * string containing a collection of parameters (but they all refer
+   * to of the configuration for a single disk).
+   *
+   * nspecs==0 is permitted but since it does not specify some mandatory
+   * properties, it produces a run-time configuration error if the
+   * resulting disk struct is used with libxl.
+   */
+
+/*
+ * PCI BDF
+ */
+int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_pci *pci, const char *str);
+
+/*
+ * PCI specification parsing
+ */
+int xlu_pci_parse_spec_string(XLU_Config *cfg, libxl_device_pci *pci,
+                              const char *str);
+
+/*
+ * RDM parsing
+ */
+int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *rdm, const char *str);
+
+/*
+ * Vif rate parsing.
+ */
+
+int xlu_vif_parse_rate(XLU_Config *cfg, const char *rate,
+                       libxl_device_nic *nic);
+
+#endif /* LIBXLUTIL_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxl_utils.h 4.16.1-1/tools/include/libxl_utils.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxl_utils.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxl_utils.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2009      Citrix Ltd.
+ * Author Stefano Stabellini <stefano.stabellini@eu.citrix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef LIBXL_UTILS_H
+#define LIBXL_UTILS_H
+
+#include "libxl.h"
+
+#ifndef LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE
+const
+#endif
+char *libxl_basename(const char *name); /* returns string from strdup */
+
+unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned int smp_cpus);
+  /* deprecated; see LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG in libxl.h */
+int libxl_name_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid);
+int libxl_domain_qualifier_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid);
+char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);
+int libxl_cpupool_qualifier_to_cpupoolid(libxl_ctx *ctx, const char *p,
+                                         uint32_t *poolid_r,
+                                         int *was_name_r);
+int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name, uint32_t *poolid);
+char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid);
+int libxl_cpupoolid_is_valid(libxl_ctx *ctx, uint32_t poolid);
+int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid);
+int libxl_is_stubdom(libxl_ctx *ctx, uint32_t domid, uint32_t *target_domid);
+int libxl_create_logfile(libxl_ctx *ctx, const char *name, char **full_name);
+int libxl_string_to_backend(libxl_ctx *ctx, char *s, libxl_disk_backend *backend);
+
+int libxl_read_file_contents(libxl_ctx *ctx, const char *filename,
+                             void **data_r, int *datalen_r);
+  /* Reads the contents of the plain file filename into a mallocd
+   * buffer.  Returns 0 or errno.  Any errors other than ENOENT are logged.
+   * If the file is empty, *data_r and *datalen_r are set to 0.
+   * On error, *data_r and *datalen_r are unchanged.
+   * data_r and/or datalen_r may be 0.
+   */
+
+int libxl_read_exactly(libxl_ctx *ctx, int fd, void *data, ssize_t sz,
+                       const char *filename, const char *what);
+int libxl_write_exactly(libxl_ctx *ctx, int fd, const void *data,
+                        ssize_t sz, const char *filename, const char *what);
+  /* Returns 0 or errno.  If file is truncated on reading, returns
+   * EPROTO and you have no way to tell how much was read.  Errors are
+   * logged using filename (which is only used for logging) and what
+   * (which may be 0). */
+
+int libxl_pipe(libxl_ctx *ctx, int pipes[2]);
+  /* Just like pipe(2), but log errors. */
+
+void libxl_report_child_exitstatus(libxl_ctx *ctx, xentoollog_level,
+                                   const char *what, pid_t pid, int status);
+    /* treats all exit statuses as errors; if that's not what you want,
+     * check status yourself first */
+
+int libxl_mac_to_device_nic(libxl_ctx *ctx, uint32_t domid,
+                            const char *mac, libxl_device_nic *nic);
+int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid, int devid,
+                              libxl_device_nic *nic);
+
+int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid, const char *vdev,
+                               libxl_device_disk *disk);
+
+int libxl_uuid_to_device_vtpm(libxl_ctx *ctx, uint32_t domid,
+                               libxl_uuid *uuid, libxl_device_vtpm *vtpm);
+int libxl_devid_to_device_vtpm(libxl_ctx *ctx, uint32_t domid,
+                               int devid, libxl_device_vtpm *vtpm);
+int libxl_devid_to_device_usbctrl(libxl_ctx *ctx, uint32_t domid,
+                                  int devid, libxl_device_usbctrl *usbctrl);
+
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+                              int devid, libxl_device_vkb *vkb);
+
+int libxl_devid_to_device_vdispl(libxl_ctx *ctx, uint32_t domid,
+                                 int devid, libxl_device_vdispl *vdispl);
+
+int libxl_devid_to_device_vsnd(libxl_ctx *ctx, uint32_t domid,
+                               int devid, libxl_device_vsnd *vsnd);
+
+int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx, uint32_t domid,
+                                    int ctrl, int port,
+                                    libxl_device_usbdev *usbdev);
+
+int libxl_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *bitmap, int n_bits);
+    /* Allocated bimap is from malloc, libxl_bitmap_dispose() to be
+     * called by the application when done. */
+void libxl_bitmap_copy_alloc(libxl_ctx *ctx, libxl_bitmap *dptr,
+                             const libxl_bitmap *sptr);
+void libxl_bitmap_copy(libxl_ctx *ctx, libxl_bitmap *dptr,
+                       const libxl_bitmap *sptr);
+int libxl_bitmap_is_full(const libxl_bitmap *bitmap);
+int libxl_bitmap_is_empty(const libxl_bitmap *bitmap);
+int libxl_bitmap_test(const libxl_bitmap *bitmap, int bit);
+void libxl_bitmap_set(libxl_bitmap *bitmap, int bit);
+void libxl_bitmap_reset(libxl_bitmap *bitmap, int bit);
+int libxl_bitmap_count_set(const libxl_bitmap *bitmap);
+int libxl_bitmap_or(libxl_ctx *ctx, libxl_bitmap *or_map,
+                    const libxl_bitmap *map1,
+                    const libxl_bitmap *map2);
+int libxl_bitmap_and(libxl_ctx *ctx, libxl_bitmap *and_map,
+                     const libxl_bitmap *map1,
+                     const libxl_bitmap *map2);
+char *libxl_bitmap_to_hex_string(libxl_ctx *ctx, const libxl_bitmap *bitmap);
+static inline void libxl_bitmap_set_any(libxl_bitmap *bitmap)
+{
+    memset(bitmap->map, -1, bitmap->size);
+}
+static inline void libxl_bitmap_set_none(libxl_bitmap *bitmap)
+{
+    memset(bitmap->map, 0, bitmap->size);
+}
+static inline int libxl_bitmap_cpu_valid(libxl_bitmap *bitmap, int bit)
+{
+    return bit >= 0 && bit < (bitmap->size * 8);
+}
+#define libxl_for_each_bit(var, map) for (var = 0; var < (map).size * 8; var++)
+#define libxl_for_each_set_bit(v, m) for (v = 0; v < (m).size * 8; v++) \
+                                             if (libxl_bitmap_test(&(m), v))
+
+/*
+ * Compares two bitmaps bit by bit, up to nr_bits or, if nr_bits is 0, up
+ * to the size of the largest bitmap. If sizes does not match, bits past the
+ * of a bitmap are considered as being 0, which matches with the semantic and
+ * implementation of libxl_bitmap_test I think().
+ *
+ * So, basically, [0,1,0] and [0,1] are considered equal, while [0,1,1] and
+ * [0,1] are different.
+ */
+static inline int libxl_bitmap_equal(const libxl_bitmap *ba,
+                                     const libxl_bitmap *bb,
+                                     int nr_bits)
+{
+    int i;
+
+    if (nr_bits == 0)
+        nr_bits = ba->size > bb->size ? ba->size * 8 : bb->size * 8;
+
+    for (i = 0; i < nr_bits; i++) {
+        if (libxl_bitmap_test(ba, i) != libxl_bitmap_test(bb, i))
+            return 0;
+    }
+    return 1;
+}
+
+int libxl_cpu_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *cpumap, int max_cpus);
+int libxl_node_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *nodemap,
+                            int max_nodes);
+int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap,
+                              int max_sockets);
+/* Fill socketmap with the CPU topology information on the system. */
+int libxl_get_online_socketmap(libxl_ctx *ctx, libxl_bitmap *socketmap);
+
+/* Populate cpumap with the cpus spanned by the nodes in nodemap */
+int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
+                            const libxl_bitmap *nodemap,
+                            libxl_bitmap *cpumap);
+/* Populate cpumap with the cpus spanned by node */
+int libxl_node_to_cpumap(libxl_ctx *ctx, int node,
+                         libxl_bitmap *cpumap);
+/* Populate nodemap with the nodes of the cpus in cpumap */
+int libxl_cpumap_to_nodemap(libxl_ctx *ctx,
+                            const libxl_bitmap *cpumap,
+                            libxl_bitmap *nodemap);
+
+ static inline uint32_t libxl__sizekb_to_mb(uint32_t s) {
+    return (s + 1023) / 1024;
+}
+
+void libxl_string_copy(libxl_ctx *ctx, char **dst, char * const*src);
+
+
+#define LIBXL_FILLZERO(object) (memset(&(object), 0, sizeof((object))))
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/libxl_uuid.h 4.16.1-1/tools/include/libxl_uuid.h
--- 4.14.3+32-g9de3671772-1/tools/include/libxl_uuid.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/libxl_uuid.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2008,2010 Citrix Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#ifndef __LIBXL_UUID_H__
+#define __LIBXL_UUID_H__
+
+#define LIBXL_UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+#define LIBXL_UUID_FMTLEN ((2*16)+4) /* 16 hex bytes plus 4 hypens */
+#define LIBXL__UUID_BYTES(uuid) uuid[0], uuid[1], uuid[2], uuid[3], \
+                                uuid[4], uuid[5], uuid[6], uuid[7], \
+                                uuid[8], uuid[9], uuid[10], uuid[11], \
+                                uuid[12], uuid[13], uuid[14], uuid[15]
+#define LIBXL_UUID_BYTES(arg) LIBXL__UUID_BYTES((arg).uuid)
+
+typedef struct {
+    /* UUID as an octet stream in big-endian byte-order. */
+    unsigned char uuid[16];
+} libxl_uuid;
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040700
+#if defined(__linux__)
+
+#include <uuid/uuid.h>
+#include <stdint.h>
+
+#elif defined(__FreeBSD__) || defined(__NetBSD__)
+
+#include <uuid.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+#else
+
+#error "Please update libxl_uuid.h for your OS"
+
+#endif
+#endif
+
+int libxl_uuid_is_nil(const libxl_uuid *uuid);
+void libxl_uuid_generate(libxl_uuid *uuid);
+int libxl_uuid_from_string(libxl_uuid *uuid, const char *in);
+void libxl_uuid_copy(libxl_ctx *ctx_opt, libxl_uuid *dst,
+                     const libxl_uuid *src);
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
+static inline void libxl_uuid_copy_0x040400(libxl_uuid *dst,
+                                            const libxl_uuid *src)
+{
+    libxl_uuid_copy(NULL, dst, src);
+}
+#define libxl_uuid_copy libxl_uuid_copy_0x040400
+#endif
+
+void libxl_uuid_clear(libxl_uuid *uuid);
+int libxl_uuid_compare(const libxl_uuid *uuid1, const libxl_uuid *uuid2);
+const uint8_t *libxl_uuid_bytearray_const(const libxl_uuid *uuid);
+uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid);
+
+#endif /* __LIBXL_UUID_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/Makefile 4.16.1-1/tools/include/Makefile
--- 4.14.3+32-g9de3671772-1/tools/include/Makefile	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/include/Makefile	2022-04-12 12:21:23.000000000 +0000
@@ -1,40 +1,42 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+# Caution: some tools/libs/*/Makefile generate header files directly in
+# tools/include, and they do the [un]install actions for those, too.
+# In case other headers need to be built cwin tools/include this should be
+# taken into account, i.e. there should be no rules added here for generating
+# any tools/include/*.h files.
+
 # Relative to $(XEN_ROOT)/xen/xsm/flask
 FLASK_H_DEPEND := policy/initial_sids
 
-.PHONY: all all-y build
-all build: all-y xen-foreign xen/.dir xen-xsm/.dir
+.PHONY: all all-y build xen-dir
+all build: all-y xen-foreign xen-dir xen-xsm/.dir
 all-y:
 
 .PHONY: xen-foreign
 xen-foreign:
 	$(MAKE) -C xen-foreign
 
-XEN_PUBLIC_INCLUDES = $(wildcard $(XEN_ROOT)/xen/include/public/*.h)
-XEN_LIB_X86_INCLUDES = $(filter-out %autogen.h, $(XEN_ROOT)/xen/include/xen/lib/x86/Makefile $(wildcard $(XEN_ROOT)/xen/include/xen/lib/x86/*.h))
-
-xen/.dir: $(XEN_PUBLIC_INCLUDES) $(XEN_LIB_X86_INCLUDES)
-	@rm -rf xen
-	mkdir -p xen/libelf
-	ln -sf $(XEN_ROOT)/xen/include/public/COPYING xen
-	ln -sf $(XEN_PUBLIC_INCLUDES) xen
-	ln -sf $(addprefix $(XEN_ROOT)/xen/include/public/,arch-x86 arch-arm hvm io xsm) xen
-	ln -sf ../xen-sys/$(XEN_OS) xen/sys
-	ln -sf $(addprefix $(XEN_ROOT)/xen/include/xen/,libelf.h elfstructs.h) xen/libelf/
+xen-dir:
+	mkdir -p xen/libelf acpi
+	find xen/ acpi/ -type l -exec rm '{}' +
+	ln -s $(XEN_ROOT)/xen/include/public/COPYING xen/
+	ln -s $(XEN_ROOT)/xen/include/public/*.h xen/
+	ln -s $(XEN_ROOT)/xen/include/public/*/ xen/
+	ln -s ../xen-sys/$(XEN_OS) xen/sys
+	ln -s $(addprefix $(XEN_ROOT)/xen/include/xen/,libelf.h elfstructs.h) xen/libelf/
 	ln -s ../xen-foreign xen/foreign
-	ln -sf $(XEN_ROOT)/xen/include/acpi acpi
+	ln -s $(XEN_ROOT)/xen/include/acpi/platform acpi/
+	ln -s $(XEN_ROOT)/xen/include/acpi/ac*.h acpi/
 ifeq ($(CONFIG_X86),y)
-	ln -sf $(XEN_ROOT)/xen/include/asm-x86 xen/asm
+	ln -s $(XEN_ROOT)/xen/include/asm-x86 xen/asm
 	mkdir -p xen/lib/x86
-	for f in $(patsubst $(XEN_ROOT)/xen/include/xen/lib/x86/%,%,$(XEN_LIB_X86_INCLUDES)); do \
-		ln -sf $(XEN_ROOT)/xen/include/xen/lib/x86/$$f xen/lib/x86/$$f; \
-	done
+	ln -s $(filter-out %autogen.h,$(wildcard $(XEN_ROOT)/xen/include/xen/lib/x86/*.h)) xen/lib/x86/
+	ln -s $(XEN_ROOT)/xen/include/xen/lib/x86/Makefile xen/lib/x86/
 endif
-	touch $@
 
-all-$(CONFIG_X86): xen/.dir
+all-$(CONFIG_X86): xen-dir
 	$(MAKE) -C xen/lib/x86 all XEN_ROOT=$(XEN_ROOT) PYTHON=$(PYTHON)
 
 # Not xen/xsm as that clashes with link to
@@ -61,10 +63,7 @@ install: all
 	$(INSTALL_DATA) xen/*.h $(DESTDIR)$(includedir)/xen
 	$(INSTALL_DATA) xen/arch-x86/*.h $(DESTDIR)$(includedir)/xen/arch-x86
 	$(INSTALL_DATA) xen/arch-x86/hvm/*.h $(DESTDIR)$(includedir)/xen/arch-x86/hvm
-
-# 	xen/arch-arm doesn't contains headers for now. Uncommented the line
-# 	as soon as a new header is added
-#	$(INSTALL_DATA) xen/arch-arm/*.h $(DESTDIR)$(includedir)/xen/arch-arm
+	$(INSTALL_DATA) xen/arch-arm/*.h $(DESTDIR)$(includedir)/xen/arch-arm
 	$(INSTALL_DATA) xen/arch-arm/hvm/*.h $(DESTDIR)$(includedir)/xen/arch-arm/hvm
 	$(INSTALL_DATA) xen/foreign/*.h $(DESTDIR)$(includedir)/xen/foreign
 	$(INSTALL_DATA) xen/hvm/*.h $(DESTDIR)$(includedir)/xen/hvm
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xencall.h 4.16.1-1/tools/include/xencall.h
--- 4.14.3+32-g9de3671772-1/tools/include/xencall.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xencall.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,147 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef XENCALL_H
+#define XENCALL_H
+
+/*
+ * This library allows you to make arbitrary hypercalls (subject to
+ * sufficient permission for the process and the domain itself). Note
+ * that while the library interface is stable the hypercalls are
+ * subject to their own rules.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* Callers who don't care don't need to #include <xentoollog.h> */
+struct xentoollog_logger;
+
+typedef struct xencall_handle xencall_handle;
+
+/*
+ */
+#define XENCALL_OPENFLAG_NON_REENTRANT (1U<<0)
+
+/*
+ * Return a handle onto the hypercall driver.  Logs errors.
+ * *
+ * Note: After fork(2) a child process must not use any opened
+ * xencall handle inherited from their parent, nor access any
+ * hypercall argument buffers associated with that handle.
+ *
+ * The child must open a new handle if they want to interact with
+ * xencall.
+ *
+ * Calling exec(2) in a child will safely (and reliably) reclaim any
+ * resources which were allocated via a xencall_handle in the parent.
+ *
+ * A child which does not call exec(2) may safely call xencall_close()
+ * on a xencall_handle inherited from their parent. This will attempt
+ * to reclaim any resources associated with that handle. Note that in
+ * some implementations this reclamation may not be completely
+ * effective, in this case any affected resources remain allocated.
+ *
+ * Calling xencall_close() is the only safe operation on a
+ * xencall_handle which has been inherited.
+ */
+xencall_handle *xencall_open(struct xentoollog_logger *logger,
+                             unsigned open_flags);
+
+/*
+ * Close a handle previously allocated with xencall_open().
+ *
+ * Under normal circumstances (i.e. not in the child after a fork) any
+ * allocated hypercall argument buffers should be freed using the
+ * appropriate xencall_free_*() prior to closing the handle in order
+ * to free up resources associated with those mappings.
+ *
+ * This is the only function which may be safely called on a
+ * xencall_handle in a child after a fork. xencall_free_*() must not
+ * be called under such circumstances.
+ */
+int xencall_close(xencall_handle *xcall);
+
+/*
+ * Return the fd used internally by xencall.  selecting on it is not
+ * useful.  But it could be useful for unusual use cases; perhaps,
+ * passing to other programs, calling ioctls on directly, or maybe
+ * calling fcntl.
+ */
+int xencall_fd(xencall_handle *xcall);
+
+/*
+ * Call hypercalls with varying numbers of arguments.
+ *
+ * On success the return value of the hypercall is the return value of
+ * the xencall function.  On error these functions set errno and
+ * return -1.
+ *
+ * The errno values will be either:
+ * - The Xen hypercall error return (from xen/include/public/errno.h)
+ *   translated into the corresponding local value for that POSIX error.
+ * - An errno value produced by the OS driver or the library
+ *   implementation. Such values may be defined by POSIX or by the OS.
+ *
+ * Note that under some circumstances it will not be possible to tell
+ * whether an error came from Xen or from the OS/library.
+ *
+ * These functions never log.
+ */
+int xencall0(xencall_handle *xcall, unsigned int op);
+int xencall1(xencall_handle *xcall, unsigned int op,
+             uint64_t arg1);
+int xencall2(xencall_handle *xcall, unsigned int op,
+             uint64_t arg1, uint64_t arg2);
+int xencall3(xencall_handle *xcall, unsigned int op,
+             uint64_t arg1, uint64_t arg2, uint64_t arg3);
+int xencall4(xencall_handle *xcall, unsigned int op,
+             uint64_t arg1, uint64_t arg2, uint64_t arg3,
+             uint64_t arg4);
+int xencall5(xencall_handle *xcall, unsigned int op,
+             uint64_t arg1, uint64_t arg2, uint64_t arg3,
+             uint64_t arg4, uint64_t arg5);
+
+/* Variant(s) of the above, as needed, returning "long" instead of "int". */
+long xencall2L(xencall_handle *xcall, unsigned int op,
+               uint64_t arg1, uint64_t arg2);
+
+/*
+ * Allocate and free memory which is suitable for use as a pointer
+ * argument to a hypercall.
+ */
+void *xencall_alloc_buffer_pages(xencall_handle *xcall, size_t nr_pages);
+void xencall_free_buffer_pages(xencall_handle *xcall, void *p, size_t nr_pages);
+
+void *xencall_alloc_buffer(xencall_handle *xcall, size_t size);
+void xencall_free_buffer(xencall_handle *xcall, void *p);
+
+/*
+ * Are allocated hypercall buffers safe to be accessed by the hypervisor all
+ * the time?
+ * Returns 0 if EFAULT might be possible.
+ */
+int xencall_buffers_never_fault(xencall_handle *xcall);
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xenctrl_compat.h 4.16.1-1/tools/include/xenctrl_compat.h
--- 4.14.3+32-g9de3671772-1/tools/include/xenctrl_compat.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xenctrl_compat.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,183 @@
+/*
+ * Compat shims for use of 3rd party consumers of libxenctrl
+ * functionality which has been split into separate libraries.
+ *
+ * New code should use the separate libraries.
+ *
+ * Each interface must be opted-into separately by defining:
+ *
+ * XC_WANT_COMPAT_EVTCHN_API
+ *  - Functions relating to /dev/xen/evtchn
+ */
+#ifndef XENCTRL_COMPAT_H
+#define XENCTRL_COMPAT_H
+
+#ifdef XC_WANT_COMPAT_MAP_FOREIGN_API
+/**
+ * Memory maps a range within one domain to a local address range.  Mappings
+ * should be unmapped with munmap and should follow the same rules as mmap
+ * regarding page alignment.  Returns NULL on failure.
+ *
+ * @parm xch a handle on an open hypervisor interface
+ * @parm dom the domain to map memory from
+ * @parm size the amount of memory to map (in multiples of page size)
+ * @parm prot same flag as in mmap().
+ * @parm mfn the frame address to map.
+ */
+void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
+                            int size, int prot,
+                            unsigned long mfn );
+
+void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
+                           const xen_pfn_t *arr, int num );
+
+/* Nothing within the library itself other than the compat wrapper
+ * itself should be using this, everything inside has access to
+ * xenforeignmemory_map().
+ */
+#if !defined(XC_INTERNAL_COMPAT_MAP_FOREIGN_API) || \
+     defined(XC_BUILDING_COMPAT_MAP_FOREIGN_API)
+/**
+ * Like xc_map_foreign_pages(), except it can succeed partially.
+ * When a page cannot be mapped, its respective field in @err is
+ * set to the corresponding errno value.
+ */
+void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
+                          const xen_pfn_t *arr, int *err, unsigned int num);
+#endif
+
+#endif
+
+#ifdef XC_WANT_COMPAT_EVTCHN_API
+
+typedef struct xenevtchn_handle xc_evtchn;
+typedef xc_evtchn_port_or_error_t evtchn_port_or_error_t;
+
+xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
+                             unsigned open_flags);
+int xc_evtchn_close(xc_evtchn *xce);
+int xc_evtchn_fd(xc_evtchn *xce);
+int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port);
+xc_evtchn_port_or_error_t
+xc_evtchn_bind_unbound_port(xc_evtchn *xce, uint32_t domid);
+xc_evtchn_port_or_error_t
+xc_evtchn_bind_interdomain(xc_evtchn *xce, uint32_t domid,
+                           evtchn_port_t remote_port);
+xc_evtchn_port_or_error_t
+xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq);
+int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port);
+xc_evtchn_port_or_error_t
+xc_evtchn_pending(xc_evtchn *xce);
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port);
+
+#endif /* XC_WANT_COMPAT_EVTCHN_API */
+
+#ifdef XC_WANT_COMPAT_GNTTAB_API
+
+typedef struct xengntdev_handle xc_gnttab;
+
+xc_gnttab *xc_gnttab_open(xentoollog_logger *logger,
+                          unsigned open_flags);
+int xc_gnttab_close(xc_gnttab *xcg);
+void *xc_gnttab_map_grant_ref(xc_gnttab *xcg,
+                              uint32_t domid,
+                              uint32_t ref,
+                              int prot);
+void *xc_gnttab_map_grant_refs(xc_gnttab *xcg,
+                               uint32_t count,
+                               uint32_t *domids,
+                               uint32_t *refs,
+                               int prot);
+void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
+                                      uint32_t count,
+                                      uint32_t domid,
+                                      uint32_t *refs,
+                                      int prot);
+void *xc_gnttab_map_grant_ref_notify(xc_gnttab *xcg,
+                                     uint32_t domid,
+                                     uint32_t ref,
+                                     int prot,
+                                     uint32_t notify_offset,
+                                     evtchn_port_t notify_port);
+int xc_gnttab_munmap(xc_gnttab *xcg,
+                     void *start_address,
+                     uint32_t count);
+int xc_gnttab_set_max_grants(xc_gnttab *xcg,
+                             uint32_t count);
+
+typedef struct xengntdev_handle xc_gntshr;
+
+xc_gntshr *xc_gntshr_open(xentoollog_logger *logger,
+                          unsigned open_flags);
+int xc_gntshr_close(xc_gntshr *xcg);
+void *xc_gntshr_share_pages(xc_gntshr *xcg, uint32_t domid,
+                            int count, uint32_t *refs, int writable);
+void *xc_gntshr_share_page_notify(xc_gntshr *xcg, uint32_t domid,
+                                  uint32_t *ref, int writable,
+                                  uint32_t notify_offset,
+                                  evtchn_port_t notify_port);
+int xc_gntshr_munmap(xc_gntshr *xcg, void *start_address, uint32_t count);
+
+#endif /* XC_WANT_COMPAT_GNTTAB_API */
+
+#ifdef XC_WANT_COMPAT_DEVICEMODEL_API
+
+int xc_hvm_create_ioreq_server(
+    xc_interface *xch, uint32_t domid, int handle_bufioreq,
+    ioservid_t *id);
+int xc_hvm_get_ioreq_server_info(
+    xc_interface *xch, uint32_t domid, ioservid_t id, xen_pfn_t *ioreq_pfn,
+    xen_pfn_t *bufioreq_pfn, evtchn_port_t *bufioreq_port);
+int xc_hvm_map_io_range_to_ioreq_server(
+    xc_interface *xch, uint32_t domid, ioservid_t id, int is_mmio,
+    uint64_t start, uint64_t end);
+int xc_hvm_unmap_io_range_from_ioreq_server(
+    xc_interface *xch, uint32_t domid, ioservid_t id, int is_mmio,
+    uint64_t start, uint64_t end);
+int xc_hvm_map_pcidev_to_ioreq_server(
+    xc_interface *xch, uint32_t domid, ioservid_t id, uint16_t segment,
+    uint8_t bus, uint8_t device, uint8_t function);
+int xc_hvm_unmap_pcidev_from_ioreq_server(
+    xc_interface *xch, uint32_t domid, ioservid_t id, uint16_t segment,
+    uint8_t bus, uint8_t device, uint8_t function);
+int xc_hvm_destroy_ioreq_server(
+    xc_interface *xch, uint32_t domid, ioservid_t id);
+int xc_hvm_set_ioreq_server_state(
+    xc_interface *xch, uint32_t domid, ioservid_t id, int enabled);
+int xc_hvm_set_pci_intx_level(
+    xc_interface *xch, uint32_t domid, uint16_t segment, uint8_t bus,
+    uint8_t device, uint8_t intx, unsigned int level);
+int xc_hvm_set_isa_irq_level(
+    xc_interface *xch, uint32_t domid, uint8_t irq, unsigned int level);
+int xc_hvm_set_pci_link_route(
+    xc_interface *xch, uint32_t domid, uint8_t link, uint8_t irq);
+int xc_hvm_inject_msi(
+    xc_interface *xch, uint32_t domid, uint64_t msi_addr, uint32_t msi_data);
+int xc_hvm_track_dirty_vram(
+    xc_interface *xch, uint32_t domid, uint64_t first_pfn, uint32_t nr,
+    unsigned long *dirty_bitmap);
+int xc_hvm_modified_memory(
+    xc_interface *xch, uint32_t domid, uint64_t first_pfn, uint32_t nr);
+int xc_hvm_set_mem_type(
+    xc_interface *xch, uint32_t domid, hvmmem_type_t type,
+    uint64_t first_pfn, uint32_t nr);
+int xc_hvm_inject_trap(
+    xc_interface *xch, uint32_t domid, int vcpu, uint8_t vector,
+    uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2);
+int xc_domain_pin_memory_cacheattr(
+    xc_interface *xch, uint32_t domid, uint64_t start, uint64_t end,
+    uint32_t type);
+
+#endif /* XC_WANT_COMPAT_DEVICEMODEL_API */
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xenctrl.h 4.16.1-1/tools/include/xenctrl.h
--- 4.14.3+32-g9de3671772-1/tools/include/xenctrl.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xenctrl.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,2700 @@
+/******************************************************************************
+ * xenctrl.h
+ *
+ * A library for low-level access to the Xen control interfaces.
+ *
+ * Copyright (c) 2003-2004, K A Fraser.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef XENCTRL_H
+#define XENCTRL_H
+
+/* Tell the Xen public headers we are a user-space tools build. */
+#ifndef __XEN_TOOLS__
+#define __XEN_TOOLS__ 1
+#endif
+
+#include <unistd.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <xen/xen.h>
+#include <xen/domctl.h>
+#include <xen/physdev.h>
+#include <xen/sysctl.h>
+#include <xen/version.h>
+#include <xen/event_channel.h>
+#include <xen/sched.h>
+#include <xen/memory.h>
+#include <xen/grant_table.h>
+#include <xen/hvm/dm_op.h>
+#include <xen/hvm/params.h>
+#include <xen/xsm/flask_op.h>
+#include <xen/kexec.h>
+#include <xen/platform.h>
+
+#include "xentoollog.h"
+
+#if defined(__i386__) || defined(__x86_64__)
+#include <xen/foreign/x86_32.h>
+#include <xen/foreign/x86_64.h>
+#include <xen/arch-x86/xen-mca.h>
+#endif
+
+#define XC_PAGE_SHIFT           12
+#define XC_PAGE_SIZE            (1UL << XC_PAGE_SHIFT)
+#define XC_PAGE_MASK            (~(XC_PAGE_SIZE-1))
+
+#define INVALID_MFN  (~0UL)
+
+/*
+ *  DEFINITIONS FOR CPU BARRIERS
+ */
+
+#define xen_barrier() asm volatile ( "" : : : "memory")
+
+#if defined(__i386__)
+#define xen_mb()  asm volatile ( "lock addl $0, -4(%%esp)" ::: "memory" )
+#define xen_rmb() xen_barrier()
+#define xen_wmb() xen_barrier()
+#elif defined(__x86_64__)
+#define xen_mb()  asm volatile ( "lock addl $0, -32(%%rsp)" ::: "memory" )
+#define xen_rmb() xen_barrier()
+#define xen_wmb() xen_barrier()
+#elif defined(__arm__)
+#define xen_mb()   asm volatile ("dmb" : : : "memory")
+#define xen_rmb()  asm volatile ("dmb" : : : "memory")
+#define xen_wmb()  asm volatile ("dmb" : : : "memory")
+#elif defined(__aarch64__)
+#define xen_mb()   asm volatile ("dmb sy" : : : "memory")
+#define xen_rmb()  asm volatile ("dmb sy" : : : "memory")
+#define xen_wmb()  asm volatile ("dmb sy" : : : "memory")
+#else
+#error "Define barriers"
+#endif
+
+
+#define XENCTRL_HAS_XC_INTERFACE 1
+/* In Xen 4.0 and earlier, xc_interface_open and xc_evtchn_open would
+ * both return ints being the file descriptor.  In 4.1 and later, they
+ * return an xc_interface* and xc_evtchn*, respectively - ie, a
+ * pointer to an opaque struct.  This #define is provided in 4.1 and
+ * later, allowing out-of-tree callers to more easily distinguish
+ * between, and be compatible with, both versions.
+ */
+
+
+/*
+ *  GENERAL
+ *
+ * Unless otherwise specified, each function here returns zero or a
+ * non-null pointer on success; or in case of failure, sets errno and
+ * returns -1 or a null pointer.
+ *
+ * Unless otherwise specified, errors result in a call to the error
+ * handler function, which by default prints a message to the
+ * FILE* passed as the caller_data, which by default is stderr.
+ * (This is described below as "logging errors".)
+ *
+ * The error handler can safely trash errno, as libxc saves it across
+ * the callback.
+ */
+
+typedef struct xc_interface_core xc_interface;
+
+enum xc_error_code {
+  XC_ERROR_NONE = 0,
+  XC_INTERNAL_ERROR = 1,
+  XC_INVALID_KERNEL = 2,
+  XC_INVALID_PARAM = 3,
+  XC_OUT_OF_MEMORY = 4,
+  /* new codes need to be added to xc_error_level_to_desc too */
+};
+
+typedef enum xc_error_code xc_error_code;
+
+
+/*
+ *  INITIALIZATION FUNCTIONS
+ */
+
+/**
+ * This function opens a handle to the hypervisor interface.  This function can
+ * be called multiple times within a single process.  Multiple processes can
+ * have an open hypervisor interface at the same time.
+ *
+ * Note:
+ * After fork a child process must not use any opened xc interface
+ * handle inherited from their parent. They must open a new handle if
+ * they want to interact with xc.
+ *
+ * Each call to this function should have a corresponding call to
+ * xc_interface_close().
+ *
+ * This function can fail if the caller does not have superuser permission or
+ * if a Xen-enabled kernel is not currently running.
+ *
+ * @return a handle to the hypervisor interface
+ */
+xc_interface *xc_interface_open(xentoollog_logger *logger,
+                                xentoollog_logger *dombuild_logger,
+                                unsigned open_flags);
+  /* if logger==NULL, will log to stderr
+   * if dombuild_logger=NULL, will log to a file
+   */
+
+/*
+ * Note: if XC_OPENFLAG_NON_REENTRANT is passed then libxc must not be
+ * called reentrantly and the calling application is responsible for
+ * providing mutual exclusion surrounding all libxc calls itself.
+ *
+ * In particular xc_{get,clear}_last_error only remain valid for the
+ * duration of the critical section containing the call which failed.
+ */
+enum xc_open_flags {
+    XC_OPENFLAG_DUMMY =  1<<0, /* do not actually open a xenctrl interface */
+    XC_OPENFLAG_NON_REENTRANT = 1<<1, /* assume library is only every called from a single thread */
+};
+
+/**
+ * This function closes an open hypervisor interface.
+ *
+ * This function can fail if the handle does not represent an open interface or
+ * if there were problems closing the interface.  In the latter case
+ * the interface is still closed.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @return 0 on success, -1 otherwise.
+ */
+int xc_interface_close(xc_interface *xch);
+
+/**
+ * Return the handles which xch has opened and will use for
+ * hypercalls, foreign memory accesses and device model operations.
+ * These may be used with the corresponding libraries so long as the
+ * xch itself remains open.
+ */
+struct xencall_handle *xc_interface_xcall_handle(xc_interface *xch);
+struct xenforeignmemory_handle *xc_interface_fmem_handle(xc_interface *xch);
+struct xendevicemodel_handle *xc_interface_dmod_handle(xc_interface *xch);
+
+/*
+ * HYPERCALL SAFE MEMORY BUFFER
+ *
+ * Ensure that memory which is passed to a hypercall has been
+ * specially allocated in order to be safe to access from the
+ * hypervisor.
+ *
+ * Each user data pointer is shadowed by an xc_hypercall_buffer data
+ * structure. You should never define an xc_hypercall_buffer type
+ * directly, instead use the DECLARE_HYPERCALL_BUFFER* macros below.
+ *
+ * The strucuture should be considered opaque and all access should be
+ * via the macros and helper functions defined below.
+ *
+ * Once the buffer is declared the user is responsible for explicitly
+ * allocating and releasing the memory using
+ * xc_hypercall_buffer_alloc(_pages) and
+ * xc_hypercall_buffer_free(_pages).
+ *
+ * Once the buffer has been allocated the user can initialise the data
+ * via the normal pointer. The xc_hypercall_buffer structure is
+ * transparently referenced by the helper macros (such as
+ * xen_set_guest_handle) in order to check at compile time that the
+ * correct type of memory is being used.
+ */
+struct xc_hypercall_buffer {
+    /* Hypercall safe memory buffer. */
+    void *hbuf;
+
+    /*
+     * Reference to xc_hypercall_buffer passed as argument to the
+     * current function.
+     */
+    struct xc_hypercall_buffer *param_shadow;
+
+    /*
+     * Direction of copy for bounce buffering.
+     */
+    int dir;
+
+    /* Used iff dir != 0. */
+    void *ubuf;
+    size_t sz;
+};
+typedef struct xc_hypercall_buffer xc_hypercall_buffer_t;
+
+/*
+ * Construct the name of the hypercall buffer for a given variable.
+ * For internal use only
+ */
+#define XC__HYPERCALL_BUFFER_NAME(_name) xc__hypercall_buffer_##_name
+
+/*
+ * Returns the hypercall_buffer associated with a variable.
+ */
+#define HYPERCALL_BUFFER(_name)                                \
+    ({  xc_hypercall_buffer_t *_hcbuf_buf =                    \
+                &XC__HYPERCALL_BUFFER_NAME(_name);             \
+        _hcbuf_buf->param_shadow ?: _hcbuf_buf;                \
+     })
+
+#define HYPERCALL_BUFFER_INIT_NO_BOUNCE .dir = 0, .sz = 0, .ubuf = (void *)-1
+
+/*
+ * Defines a hypercall buffer and user pointer with _name of _type.
+ *
+ * The user accesses the data as normal via _name which will be
+ * transparently converted to the hypercall buffer as necessary.
+ */
+#define DECLARE_HYPERCALL_BUFFER(_type, _name)                 \
+    _type *(_name) = NULL;                                     \
+    xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
+        .hbuf = NULL,                                          \
+        .param_shadow = NULL,                                  \
+        HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
+    }
+
+/*
+ * Like DECLARE_HYPERCALL_BUFFER() but using an already allocated
+ * hypercall buffer, _hbuf.
+ *
+ * Useful when a hypercall buffer is passed to a function and access
+ * via the user pointer is required.
+ *
+ * See DECLARE_HYPERCALL_BUFFER_ARGUMENT() if the user pointer is not
+ * required.
+ */
+#define DECLARE_HYPERCALL_BUFFER_SHADOW(_type, _name, _hbuf)   \
+    _type *(_name) = (_hbuf)->hbuf;                            \
+    __attribute__((unused))                                    \
+    xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
+        .hbuf = (void *)-1,                                    \
+        .param_shadow = (_hbuf),                               \
+        HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
+    }
+
+/*
+ * Declare the necessary data structure to allow a hypercall buffer
+ * passed as an argument to a function to be used in the normal way.
+ */
+#define DECLARE_HYPERCALL_BUFFER_ARGUMENT(_name)               \
+    xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
+        .hbuf = (void *)-1,                                    \
+        .param_shadow = (_name),                               \
+        HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
+    }
+
+/*
+ * Get the hypercall buffer data pointer in a form suitable for use
+ * directly as a hypercall argument.
+ */
+#define HYPERCALL_BUFFER_AS_ARG(_name)                          \
+    ({  xc_hypercall_buffer_t _hcbuf_arg1;                      \
+        typeof(XC__HYPERCALL_BUFFER_NAME(_name)) *_hcbuf_arg2 = \
+                HYPERCALL_BUFFER(_name);                        \
+        (void)(&_hcbuf_arg1 == _hcbuf_arg2);                    \
+        (unsigned long)(_hcbuf_arg2)->hbuf;                     \
+     })
+
+/*
+ * Set a xen_guest_handle in a type safe manner, ensuring that the
+ * data pointer has been correctly allocated.
+ */
+#define set_xen_guest_handle_impl(_hnd, _val, _byte_off)        \
+    do {                                                        \
+        xc_hypercall_buffer_t _hcbuf_hnd1;                      \
+        typeof(XC__HYPERCALL_BUFFER_NAME(_val)) *_hcbuf_hnd2 =  \
+                HYPERCALL_BUFFER(_val);                         \
+        (void) (&_hcbuf_hnd1 == _hcbuf_hnd2);                   \
+        set_xen_guest_handle_raw(_hnd,                          \
+                (_hcbuf_hnd2)->hbuf + (_byte_off));             \
+    } while (0)
+
+#undef set_xen_guest_handle
+#define set_xen_guest_handle(_hnd, _val)                        \
+    set_xen_guest_handle_impl(_hnd, _val, 0)
+
+#define set_xen_guest_handle_offset(_hnd, _val, _off)           \
+    set_xen_guest_handle_impl(_hnd, _val,                       \
+            ((sizeof(*_val)*(_off))))
+
+/* Use with set_xen_guest_handle in place of NULL */
+extern xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(HYPERCALL_BUFFER_NULL);
+
+/*
+ * Allocate and free hypercall buffers with byte granularity.
+ */
+void *xc__hypercall_buffer_alloc(xc_interface *xch, xc_hypercall_buffer_t *b, size_t size);
+#define xc_hypercall_buffer_alloc(_xch, _name, _size) xc__hypercall_buffer_alloc(_xch, HYPERCALL_BUFFER(_name), _size)
+void xc__hypercall_buffer_free(xc_interface *xch, xc_hypercall_buffer_t *b);
+#define xc_hypercall_buffer_free(_xch, _name) xc__hypercall_buffer_free(_xch, HYPERCALL_BUFFER(_name))
+
+/*
+ * Allocate and free hypercall buffers with page alignment.
+ */
+void *xc__hypercall_buffer_alloc_pages(xc_interface *xch, xc_hypercall_buffer_t *b, int nr_pages);
+#define xc_hypercall_buffer_alloc_pages(_xch, _name, _nr) xc__hypercall_buffer_alloc_pages(_xch, HYPERCALL_BUFFER(_name), _nr)
+void xc__hypercall_buffer_free_pages(xc_interface *xch, xc_hypercall_buffer_t *b, int nr_pages);
+#define xc_hypercall_buffer_free_pages(_xch, _name, _nr)                    \
+    do {                                                                    \
+        if ( _name )                                                        \
+            xc__hypercall_buffer_free_pages(_xch, HYPERCALL_BUFFER(_name),  \
+                                            _nr);                           \
+    } while (0)
+
+/*
+ * Array of hypercall buffers.
+ *
+ * Create an array with xc_hypercall_buffer_array_create() and
+ * populate it by declaring one hypercall buffer in a loop and
+ * allocating the buffer with xc_hypercall_buffer_array_alloc().
+ *
+ * To access a previously allocated buffers, declare a new hypercall
+ * buffer and call xc_hypercall_buffer_array_get().
+ *
+ * Destroy the array with xc_hypercall_buffer_array_destroy() to free
+ * the array and all its allocated hypercall buffers.
+ */
+struct xc_hypercall_buffer_array;
+typedef struct xc_hypercall_buffer_array xc_hypercall_buffer_array_t;
+
+xc_hypercall_buffer_array_t *xc_hypercall_buffer_array_create(xc_interface *xch, unsigned n);
+void *xc__hypercall_buffer_array_alloc(xc_interface *xch, xc_hypercall_buffer_array_t *array,
+                                       unsigned index, xc_hypercall_buffer_t *hbuf, size_t size);
+#define xc_hypercall_buffer_array_alloc(_xch, _array, _index, _name, _size) \
+    xc__hypercall_buffer_array_alloc(_xch, _array, _index, HYPERCALL_BUFFER(_name), _size)
+void *xc__hypercall_buffer_array_get(xc_interface *xch, xc_hypercall_buffer_array_t *array,
+                                     unsigned index, xc_hypercall_buffer_t *hbuf);
+#define xc_hypercall_buffer_array_get(_xch, _array, _index, _name, _size) \
+    xc__hypercall_buffer_array_get(_xch, _array, _index, HYPERCALL_BUFFER(_name))
+void xc_hypercall_buffer_array_destroy(xc_interface *xc, xc_hypercall_buffer_array_t *array);
+
+/*
+ * CPUMAP handling
+ */
+typedef uint8_t *xc_cpumap_t;
+
+/* return maximum number of cpus the hypervisor supports */
+int xc_get_max_cpus(xc_interface *xch);
+
+/* return the number of online cpus */
+int xc_get_online_cpus(xc_interface *xch);
+
+/* return array size for cpumap */
+int xc_get_cpumap_size(xc_interface *xch);
+
+/* allocate a cpumap */
+xc_cpumap_t xc_cpumap_alloc(xc_interface *xch);
+
+/* clear an CPU from the cpumap. */
+void xc_cpumap_clearcpu(int cpu, xc_cpumap_t map);
+
+/* set an CPU in the cpumap. */
+void xc_cpumap_setcpu(int cpu, xc_cpumap_t map);
+
+/* Test whether the CPU in cpumap is set. */
+int xc_cpumap_testcpu(int cpu, xc_cpumap_t map);
+
+/*
+ * NODEMAP handling
+ */
+typedef uint8_t *xc_nodemap_t;
+
+/* return maximum number of NUMA nodes the hypervisor supports */
+int xc_get_max_nodes(xc_interface *xch);
+
+/* return array size for nodemap */
+int xc_get_nodemap_size(xc_interface *xch);
+
+/* allocate a nodemap */
+xc_nodemap_t xc_nodemap_alloc(xc_interface *xch);
+
+/*
+ * DOMAIN DEBUGGING FUNCTIONS
+ */
+
+typedef struct xc_core_header {
+    unsigned int xch_magic;
+    unsigned int xch_nr_vcpus;
+    unsigned int xch_nr_pages;
+    unsigned int xch_ctxt_offset;
+    unsigned int xch_index_offset;
+    unsigned int xch_pages_offset;
+} xc_core_header_t;
+
+#define XC_CORE_MAGIC     0xF00FEBED
+#define XC_CORE_MAGIC_HVM 0xF00FEBEE
+
+/*
+ * DOMAIN MANAGEMENT FUNCTIONS
+ */
+
+typedef struct xc_dominfo {
+    uint32_t      domid;
+    uint32_t      ssidref;
+    unsigned int  dying:1, crashed:1, shutdown:1,
+                  paused:1, blocked:1, running:1,
+                  hvm:1, debugged:1, xenstore:1, hap:1;
+    unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
+    unsigned long nr_pages; /* current number, not maximum */
+    unsigned long nr_outstanding_pages;
+    unsigned long nr_shared_pages;
+    unsigned long nr_paged_pages;
+    unsigned long shared_info_frame;
+    uint64_t      cpu_time;
+    unsigned long max_memkb;
+    unsigned int  nr_online_vcpus;
+    unsigned int  max_vcpu_id;
+    xen_domain_handle_t handle;
+    unsigned int  cpupool;
+    uint8_t       gpaddr_bits;
+    struct xen_arch_domainconfig arch_config;
+} xc_dominfo_t;
+
+typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
+
+typedef union 
+{
+#if defined(__i386__) || defined(__x86_64__)
+    vcpu_guest_context_x86_64_t x64;
+    vcpu_guest_context_x86_32_t x32;   
+#endif
+    vcpu_guest_context_t c;
+} vcpu_guest_context_any_t;
+
+typedef union
+{
+#if defined(__i386__) || defined(__x86_64__)
+    shared_info_x86_64_t x64;
+    shared_info_x86_32_t x32;
+#endif
+    shared_info_t s;
+} shared_info_any_t;
+
+#if defined(__i386__) || defined(__x86_64__)
+typedef union
+{
+    start_info_x86_64_t x64;
+    start_info_x86_32_t x32;
+    start_info_t s;
+} start_info_any_t;
+#endif
+
+typedef struct xc_vcpu_extstate {
+    uint64_t xfeature_mask;
+    uint64_t size;
+    void *buffer;
+} xc_vcpu_extstate_t;
+
+int xc_domain_create(xc_interface *xch, uint32_t *pdomid,
+                     struct xen_domctl_createdomain *config);
+
+
+/* Functions to produce a dump of a given domain
+ *  xc_domain_dumpcore - produces a dump to a specified file
+ *  xc_domain_dumpcore_via_callback - produces a dump, using a specified
+ *                                    callback function
+ */
+int xc_domain_dumpcore(xc_interface *xch,
+                       uint32_t domid,
+                       const char *corename);
+
+/* Define the callback function type for xc_domain_dumpcore_via_callback.
+ *
+ * This function is called by the coredump code for every "write",
+ * and passes an opaque object for the use of the function and
+ * created by the caller of xc_domain_dumpcore_via_callback.
+ */
+typedef int (dumpcore_rtn_t)(xc_interface *xch,
+                             void *arg, char *buffer, unsigned int length);
+
+int xc_domain_dumpcore_via_callback(xc_interface *xch,
+                                    uint32_t domid,
+                                    void *arg,
+                                    dumpcore_rtn_t dump_rtn);
+
+/*
+ * This function sets the maximum number of vcpus that a domain may create.
+ *
+ * @parm xch a handle to an open hypervisor interface.
+ * @parm domid the domain id in which vcpus are to be created.
+ * @parm max the maximum number of vcpus that the domain may create.
+ * @return 0 on success, -1 on failure.
+ */
+int xc_domain_max_vcpus(xc_interface *xch,
+                        uint32_t domid,
+                        unsigned int max);
+
+/**
+ * This function pauses a domain. A paused domain still exists in memory
+ * however it does not receive any timeslices from the hypervisor.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to pause
+ * @return 0 on success, -1 on failure.
+ */
+int xc_domain_pause(xc_interface *xch,
+                    uint32_t domid);
+/**
+ * This function unpauses a domain.  The domain should have been previously
+ * paused.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to unpause
+ * return 0 on success, -1 on failure
+ */
+int xc_domain_unpause(xc_interface *xch,
+                      uint32_t domid);
+
+/**
+ * This function will destroy a domain.  Destroying a domain removes the domain
+ * completely from memory.  This function should be called after sending the
+ * domain a SHUTDOWN control message to free up the domain resources.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to destroy
+ * @return 0 on success, -1 on failure
+ */
+int xc_domain_destroy(xc_interface *xch,
+                      uint32_t domid);
+
+
+/**
+ * This function will shutdown a domain. This is intended for use in
+ * fully-virtualized domains where this operation is analogous to the
+ * sched_op operations in a paravirtualized domain. The caller is
+ * expected to give the reason for the shutdown.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to destroy
+ * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
+ * @return 0 on success, -1 on failure
+ */
+int xc_domain_shutdown(xc_interface *xch,
+                       uint32_t domid,
+                       int reason);
+
+int xc_watchdog(xc_interface *xch,
+		uint32_t id,
+		uint32_t timeout);
+
+/**
+ * This function explicitly sets the host NUMA nodes the domain will
+ * have affinity with.
+ *
+ * @parm xch a handle to an open hypervisor interface.
+ * @parm domid the domain id one wants to set the affinity of.
+ * @parm nodemap the map of the affine nodes.
+ * @return 0 on success, -1 on failure.
+ */
+int xc_domain_node_setaffinity(xc_interface *xch,
+                               uint32_t domind,
+                               xc_nodemap_t nodemap);
+
+/**
+ * This function retrieves the host NUMA nodes the domain has
+ * affinity with.
+ *
+ * @parm xch a handle to an open hypervisor interface.
+ * @parm domid the domain id one wants to get the node affinity of.
+ * @parm nodemap the map of the affine nodes.
+ * @return 0 on success, -1 on failure.
+ */
+int xc_domain_node_getaffinity(xc_interface *xch,
+                               uint32_t domind,
+                               xc_nodemap_t nodemap);
+
+/**
+ * This function specifies the CPU affinity for a vcpu.
+ *
+ * There are two kinds of affinity. Soft affinity is on what CPUs a vcpu
+ * prefers to run. Hard affinity is on what CPUs a vcpu is allowed to run.
+ * If flags contains XEN_VCPUAFFINITY_SOFT, the soft affinity it is set to
+ * what cpumap_soft_inout contains. If flags contains XEN_VCPUAFFINITY_HARD,
+ * the hard affinity is set to what cpumap_hard_inout contains. Both flags
+ * can be set at the same time, in which case both soft and hard affinity are
+ * set to what the respective parameter contains.
+ *
+ * The function also returns the effective hard or/and soft affinity, still
+ * via the cpumap_soft_inout and cpumap_hard_inout parameters. Effective
+ * affinity is, in case of soft affinity, the intersection of soft affinity,
+ * hard affinity and the cpupool's online CPUs for the domain, and is returned
+ * in cpumap_soft_inout, if XEN_VCPUAFFINITY_SOFT is set in flags. In case of
+ * hard affinity, it is the intersection between hard affinity and the
+ * cpupool's online CPUs, and is returned in cpumap_hard_inout, if
+ * XEN_VCPUAFFINITY_HARD is set in flags. If both flags are set, both soft
+ * and hard affinity are returned in the respective parameter.
+ *
+ * We do report it back as effective affinity is what the Xen scheduler will
+ * actually use, and we thus allow checking whether or not that matches with,
+ * or at least is good enough for, the caller's purposes.
+ *
+ * @param xch a handle to an open hypervisor interface.
+ * @param domid the id of the domain to which the vcpu belongs
+ * @param vcpu the vcpu id wihin the domain
+ * @param cpumap_hard_inout specifies(/returns) the (effective) hard affinity
+ * @param cpumap_soft_inout specifies(/returns) the (effective) soft affinity
+ * @param flags what we want to set
+ */
+int xc_vcpu_setaffinity(xc_interface *xch,
+                        uint32_t domid,
+                        int vcpu,
+                        xc_cpumap_t cpumap_hard_inout,
+                        xc_cpumap_t cpumap_soft_inout,
+                        uint32_t flags);
+
+/**
+ * This function retrieves hard and soft CPU affinity of a vcpu,
+ * depending on what flags are set.
+ *
+ * Soft affinity is returned in cpumap_soft if XEN_VCPUAFFINITY_SOFT is set.
+ * Hard affinity is returned in cpumap_hard if XEN_VCPUAFFINITY_HARD is set.
+ *
+ * @param xch a handle to an open hypervisor interface.
+ * @param domid the id of the domain to which the vcpu belongs
+ * @param vcpu the vcpu id wihin the domain
+ * @param cpumap_hard is where hard affinity is returned
+ * @param cpumap_soft is where soft affinity is returned
+ * @param flags what we want get
+ */
+int xc_vcpu_getaffinity(xc_interface *xch,
+                        uint32_t domid,
+                        int vcpu,
+                        xc_cpumap_t cpumap_hard,
+                        xc_cpumap_t cpumap_soft,
+                        uint32_t flags);
+
+
+/**
+ * This function will return the guest_width (in bytes) for the
+ * specified domain.
+ *
+ * @param xch a handle to an open hypervisor interface.
+ * @param domid the domain id one wants the address size width of.
+ * @param addr_size the address size.
+ */
+int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
+                              unsigned int *guest_width);
+
+
+/**
+ * This function will return information about one or more domains. It is
+ * designed to iterate over the list of domains. If a single domain is
+ * requested, this function will return the next domain in the list - if
+ * one exists. It is, therefore, important in this case to make sure the
+ * domain requested was the one returned.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm first_domid the first domain to enumerate information from.  Domains
+ *                   are currently enumerate in order of creation.
+ * @parm max_doms the number of elements in info
+ * @parm info an array of max_doms size that will contain the information for
+ *            the enumerated domains.
+ * @return the number of domains enumerated or -1 on error
+ */
+int xc_domain_getinfo(xc_interface *xch,
+                      uint32_t first_domid,
+                      unsigned int max_doms,
+                      xc_dominfo_t *info);
+
+
+/**
+ * This function will set the execution context for the specified vcpu.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to set the vcpu context for
+ * @parm vcpu the vcpu number for the context
+ * @parm ctxt pointer to the the cpu context with the values to set
+ * @return the number of domains enumerated or -1 on error
+ */
+int xc_vcpu_setcontext(xc_interface *xch,
+                       uint32_t domid,
+                       uint32_t vcpu,
+                       vcpu_guest_context_any_t *ctxt);
+/**
+ * This function will return information about one or more domains, using a
+ * single hypercall.  The domain information will be stored into the supplied
+ * array of xc_domaininfo_t structures.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm first_domain the first domain to enumerate information from.
+ *                    Domains are currently enumerate in order of creation.
+ * @parm max_domains the number of elements in info
+ * @parm info an array of max_doms size that will contain the information for
+ *            the enumerated domains.
+ * @return the number of domains enumerated or -1 on error
+ */
+int xc_domain_getinfolist(xc_interface *xch,
+                          uint32_t first_domain,
+                          unsigned int max_domains,
+                          xc_domaininfo_t *info);
+
+/**
+ * This function set p2m for broken page
+ * &parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id which broken page belong to
+ * @parm pfn the pfn number of the broken page
+ * @return 0 on success, -1 on failure
+ */
+int xc_set_broken_page_p2m(xc_interface *xch,
+                           uint32_t domid,
+                           unsigned long pfn);
+
+/**
+ * This function returns information about the context of a hvm domain
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to get information from
+ * @parm ctxt_buf a pointer to a structure to store the execution context of
+ *            the hvm domain
+ * @parm size the size of ctxt_buf in bytes
+ * @return 0 on success, -1 on failure
+ */
+int xc_domain_hvm_getcontext(xc_interface *xch,
+                             uint32_t domid,
+                             uint8_t *ctxt_buf,
+                             uint32_t size);
+
+
+/**
+ * This function returns one element of the context of a hvm domain
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to get information from
+ * @parm typecode which type of elemnt required 
+ * @parm instance which instance of the type
+ * @parm ctxt_buf a pointer to a structure to store the execution context of
+ *            the hvm domain
+ * @parm size the size of ctxt_buf (must be >= HVM_SAVE_LENGTH(typecode))
+ * @return 0 on success, -1 on failure
+ */
+int xc_domain_hvm_getcontext_partial(xc_interface *xch,
+                                     uint32_t domid,
+                                     uint16_t typecode,
+                                     uint16_t instance,
+                                     void *ctxt_buf,
+                                     uint32_t size);
+
+/**
+ * This function will set the context for hvm domain
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to set the hvm domain context for
+ * @parm hvm_ctxt pointer to the the hvm context with the values to set
+ * @parm size the size of hvm_ctxt in bytes
+ * @return 0 on success, -1 on failure
+ */
+int xc_domain_hvm_setcontext(xc_interface *xch,
+                             uint32_t domid,
+                             uint8_t *hvm_ctxt,
+                             uint32_t size);
+
+/**
+ * This function will return guest IO ABI protocol
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to get IO ABI protocol for
+ * @return guest protocol on success, NULL on failure
+ */
+const char *xc_domain_get_native_protocol(xc_interface *xch,
+                                          uint32_t domid);
+
+/**
+ * This function returns information about the execution context of a
+ * particular vcpu of a domain.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to get information from
+ * @parm vcpu the vcpu number
+ * @parm ctxt a pointer to a structure to store the execution context of the
+ *            domain
+ * @return 0 on success, -1 on failure
+ */
+int xc_vcpu_getcontext(xc_interface *xch,
+                       uint32_t domid,
+                       uint32_t vcpu,
+                       vcpu_guest_context_any_t *ctxt);
+
+/**
+ * This function initializes the vuart emulation and returns
+ * the event to be used by the backend for communicating with
+ * the emulation code.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * #parm type type of vuart
+ * @parm domid the domain to get information from
+ * @parm console_domid the domid of the backend console
+ * @parm gfn the guest pfn to be used as the ring buffer
+ * @parm evtchn the event channel to be used for events
+ * @return 0 on success, negative error on failure
+ */
+int xc_dom_vuart_init(xc_interface *xch,
+                      uint32_t type,
+                      uint32_t domid,
+                      uint32_t console_domid,
+                      xen_pfn_t gfn,
+                      evtchn_port_t *evtchn);
+
+/**
+ * This function returns information about the XSAVE state of a particular
+ * vcpu of a domain. If extstate->size and extstate->xfeature_mask are 0,
+ * the call is considered a query to retrieve them and the buffer is not
+ * filled.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to get information from
+ * @parm vcpu the vcpu number
+ * @parm extstate a pointer to a structure to store the XSAVE state of the
+ *                domain
+ * @return 0 on success, negative error code on failure
+ */
+int xc_vcpu_get_extstate(xc_interface *xch,
+                         uint32_t domid,
+                         uint32_t vcpu,
+                         xc_vcpu_extstate_t *extstate);
+
+typedef struct xen_domctl_getvcpuinfo xc_vcpuinfo_t;
+int xc_vcpu_getinfo(xc_interface *xch,
+                    uint32_t domid,
+                    uint32_t vcpu,
+                    xc_vcpuinfo_t *info);
+
+long long xc_domain_get_cpu_usage(xc_interface *xch,
+                                  uint32_t domid,
+                                  int vcpu);
+
+int xc_domain_sethandle(xc_interface *xch, uint32_t domid,
+                        xen_domain_handle_t handle);
+
+typedef struct xen_domctl_shadow_op_stats xc_shadow_op_stats_t;
+int xc_shadow_control(xc_interface *xch,
+                      uint32_t domid,
+                      unsigned int sop,
+                      unsigned int *mb,
+                      unsigned int mode);
+long long xc_logdirty_control(xc_interface *xch,
+                              uint32_t domid,
+                              unsigned int sop,
+                              xc_hypercall_buffer_t *dirty_bitmap,
+                              unsigned long pages,
+                              unsigned int mode,
+                              xc_shadow_op_stats_t *stats);
+
+int xc_sched_credit_domain_set(xc_interface *xch,
+                               uint32_t domid,
+                               struct xen_domctl_sched_credit *sdom);
+
+int xc_sched_credit_domain_get(xc_interface *xch,
+                               uint32_t domid,
+                               struct xen_domctl_sched_credit *sdom);
+int xc_sched_credit_params_set(xc_interface *xch,
+                               uint32_t cpupool_id,
+                               struct xen_sysctl_credit_schedule *schedule);
+int xc_sched_credit_params_get(xc_interface *xch,
+                               uint32_t cpupool_id,
+                               struct xen_sysctl_credit_schedule *schedule);
+
+int xc_sched_credit2_params_set(xc_interface *xch,
+                                uint32_t cpupool_id,
+                                struct xen_sysctl_credit2_schedule *schedule);
+int xc_sched_credit2_params_get(xc_interface *xch,
+                                uint32_t cpupool_id,
+                                struct xen_sysctl_credit2_schedule *schedule);
+int xc_sched_credit2_domain_set(xc_interface *xch,
+                                uint32_t domid,
+                                struct xen_domctl_sched_credit2 *sdom);
+int xc_sched_credit2_domain_get(xc_interface *xch,
+                                uint32_t domid,
+                                struct xen_domctl_sched_credit2 *sdom);
+
+int xc_sched_rtds_domain_set(xc_interface *xch,
+                             uint32_t domid,
+                             struct xen_domctl_sched_rtds *sdom);
+int xc_sched_rtds_domain_get(xc_interface *xch,
+                             uint32_t domid,
+                             struct xen_domctl_sched_rtds *sdom);
+int xc_sched_rtds_vcpu_set(xc_interface *xch,
+                           uint32_t domid,
+                           struct xen_domctl_schedparam_vcpu *vcpus,
+                           uint32_t num_vcpus);
+int xc_sched_rtds_vcpu_get(xc_interface *xch,
+                           uint32_t domid,
+                           struct xen_domctl_schedparam_vcpu *vcpus,
+                           uint32_t num_vcpus);
+
+int
+xc_sched_arinc653_schedule_set(
+    xc_interface *xch,
+    uint32_t cpupool_id,
+    struct xen_sysctl_arinc653_schedule *schedule);
+
+int
+xc_sched_arinc653_schedule_get(
+    xc_interface *xch,
+    uint32_t cpupool_id,
+    struct xen_sysctl_arinc653_schedule *schedule);
+
+/**
+ * This function sends a trigger to a domain.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to send trigger
+ * @parm trigger the trigger type
+ * @parm vcpu the vcpu number to send trigger 
+ * return 0 on success, -1 on failure
+ */
+int xc_domain_send_trigger(xc_interface *xch,
+                           uint32_t domid,
+                           uint32_t trigger,
+                           uint32_t vcpu);
+
+/**
+ * This function enables or disable debugging of a domain.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to send trigger
+ * @parm enable true to enable debugging
+ * return 0 on success, -1 on failure
+ */
+int xc_domain_setdebugging(xc_interface *xch,
+                           uint32_t domid,
+                           unsigned int enable);
+
+/**
+ * This function audits the (top level) p2m of a domain 
+ * and returns the different error counts, if any.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id whose top level p2m we 
+ *       want to audit
+ * @parm orphans count of m2p entries for valid
+ *       domain pages containing an invalid value
+ * @parm m2p_bad count of m2p entries mismatching the
+ *       associated p2m entry for this domain
+ * @parm p2m_bad count of p2m entries for this domain
+ *       mismatching the associated m2p entry
+ * return 0 on success, -1 on failure
+ * errno values on failure include: 
+ *          -ENOSYS: not implemented
+ *          -EFAULT: could not copy results back to guest
+ */
+int xc_domain_p2m_audit(xc_interface *xch,
+                        uint32_t domid,
+                        uint64_t *orphans,
+                        uint64_t *m2p_bad,   
+                        uint64_t *p2m_bad);
+
+/**
+ * This function sets or clears the requirement that an access memory
+ * event listener is required on the domain.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to send trigger
+ * @parm enable true to require a listener
+ * return 0 on success, -1 on failure
+ */
+int xc_domain_set_access_required(xc_interface *xch,
+				  uint32_t domid,
+				  unsigned int required);
+/**
+ * This function sets the handler of global VIRQs sent by the hypervisor
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id which will handle the VIRQ
+ * @parm virq the virq number (VIRQ_*)
+ * return 0 on success, -1 on failure
+ */
+int xc_domain_set_virq_handler(xc_interface *xch, uint32_t domid, int virq);
+
+/*
+ * CPUPOOL MANAGEMENT FUNCTIONS
+ */
+
+typedef struct xc_cpupoolinfo {
+    uint32_t cpupool_id;
+    uint32_t sched_id;
+    uint32_t n_dom;
+    xc_cpumap_t cpumap;
+} xc_cpupoolinfo_t;
+
+#define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF
+
+/**
+ * Create a new cpupool.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm ppoolid pointer to the new cpupool id (in/out)
+ * @parm sched_id id of scheduler to use for pool
+ * return 0 on success, -1 on failure
+ */
+int xc_cpupool_create(xc_interface *xch,
+                      uint32_t *ppoolid,
+                      uint32_t sched_id);
+
+/**
+ * Destroy a cpupool. Pool must be unused and have no cpu assigned.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm poolid id of the cpupool to destroy
+ * return 0 on success, -1 on failure
+ */
+int xc_cpupool_destroy(xc_interface *xch,
+                       uint32_t poolid);
+
+/**
+ * Get cpupool info. Returns info for up to the specified number of cpupools
+ * starting at the given id.
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm poolid lowest id for which info is returned
+ * return cpupool info ptr (to be freed via xc_cpupool_infofree)
+ */
+xc_cpupoolinfo_t *xc_cpupool_getinfo(xc_interface *xch,
+                       uint32_t poolid);
+
+/**
+ * Free cpupool info. Used to free info obtained via xc_cpupool_getinfo.
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm info area to free
+ */
+void xc_cpupool_infofree(xc_interface *xch,
+                         xc_cpupoolinfo_t *info);
+
+/**
+ * Add cpu to a cpupool. cpu may be -1 indicating the first unassigned.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm poolid id of the cpupool
+ * @parm cpu cpu number to add
+ * return 0 on success, -1 on failure
+ */
+int xc_cpupool_addcpu(xc_interface *xch,
+                      uint32_t poolid,
+                      int cpu);
+
+/**
+ * Remove cpu from cpupool. cpu may be -1 indicating the last cpu of the pool.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm poolid id of the cpupool
+ * @parm cpu cpu number to remove
+ * return 0 on success, -1 on failure
+ */
+int xc_cpupool_removecpu(xc_interface *xch,
+                         uint32_t poolid,
+                         int cpu);
+
+/**
+ * Move domain to another cpupool.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm poolid id of the destination cpupool
+ * @parm domid id of the domain to move
+ * return 0 on success, -1 on failure
+ */
+int xc_cpupool_movedomain(xc_interface *xch,
+                          uint32_t poolid,
+                          uint32_t domid);
+
+/**
+ * Return map of cpus not in any cpupool.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * return cpumap array on success, NULL else
+ */
+xc_cpumap_t xc_cpupool_freeinfo(xc_interface *xch);
+
+/*
+ * EVENT CHANNEL FUNCTIONS
+ *
+ * None of these do any logging.
+ */
+
+/* A port identifier is guaranteed to fit in 31 bits. */
+typedef int xc_evtchn_port_or_error_t;
+
+/**
+ * This function allocates an unbound port.  Ports are named endpoints used for
+ * interdomain communication.  This function is most useful in opening a
+ * well-known port within a domain to receive events on.
+ * 
+ * NOTE: If you are allocating a *local* unbound port, you probably want to
+ * use xc_evtchn_bind_unbound_port(). This function is intended for allocating
+ * ports *only* during domain creation.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm dom the ID of the local domain (the 'allocatee')
+ * @parm remote_dom the ID of the domain who will later bind
+ * @return allocated port (in @dom) on success, -1 on failure
+ */
+xc_evtchn_port_or_error_t
+xc_evtchn_alloc_unbound(xc_interface *xch,
+                        uint32_t dom,
+                        uint32_t remote_dom);
+
+int xc_evtchn_reset(xc_interface *xch,
+                    uint32_t dom);
+
+typedef struct evtchn_status xc_evtchn_status_t;
+int xc_evtchn_status(xc_interface *xch, xc_evtchn_status_t *status);
+
+
+
+int xc_physdev_pci_access_modify(xc_interface *xch,
+                                 uint32_t domid,
+                                 int bus,
+                                 int dev,
+                                 int func,
+                                 int enable);
+
+int xc_readconsolering(xc_interface *xch,
+                       char *buffer,
+                       unsigned int *pnr_chars,
+                       int clear, int incremental, uint32_t *pindex);
+
+int xc_send_debug_keys(xc_interface *xch, const char *keys);
+
+typedef struct xen_sysctl_physinfo xc_physinfo_t;
+typedef struct xen_sysctl_cputopo xc_cputopo_t;
+typedef struct xen_sysctl_numainfo xc_numainfo_t;
+typedef struct xen_sysctl_meminfo xc_meminfo_t;
+typedef struct xen_sysctl_pcitopoinfo xc_pcitopoinfo_t;
+
+typedef uint32_t xc_cpu_to_node_t;
+typedef uint32_t xc_cpu_to_socket_t;
+typedef uint32_t xc_cpu_to_core_t;
+typedef uint64_t xc_node_to_memsize_t;
+typedef uint64_t xc_node_to_memfree_t;
+typedef uint32_t xc_node_to_node_dist_t;
+
+int xc_physinfo(xc_interface *xch, xc_physinfo_t *info);
+int xc_cputopoinfo(xc_interface *xch, unsigned *max_cpus,
+                   xc_cputopo_t *cputopo);
+int xc_microcode_update(xc_interface *xch, const void *buf, size_t len);
+int xc_numainfo(xc_interface *xch, unsigned *max_nodes,
+                xc_meminfo_t *meminfo, uint32_t *distance);
+int xc_pcitopoinfo(xc_interface *xch, unsigned num_devs,
+                   physdev_pci_device_t *devs, uint32_t *nodes);
+
+int xc_sched_id(xc_interface *xch,
+                int *sched_id);
+
+int xc_machphys_mfn_list(xc_interface *xch,
+                         unsigned long max_extents,
+                         xen_pfn_t *extent_start);
+
+typedef struct xen_sysctl_cpuinfo xc_cpuinfo_t;
+int xc_getcpuinfo(xc_interface *xch, int max_cpus,
+                  xc_cpuinfo_t *info, int *nr_cpus); 
+
+int xc_domain_setmaxmem(xc_interface *xch,
+                        uint32_t domid,
+                        uint64_t max_memkb);
+
+int xc_domain_set_memmap_limit(xc_interface *xch,
+                               uint32_t domid,
+                               unsigned long map_limitkb);
+
+int xc_domain_setvnuma(xc_interface *xch,
+                        uint32_t domid,
+                        uint32_t nr_vnodes,
+                        uint32_t nr_regions,
+                        uint32_t nr_vcpus,
+                        xen_vmemrange_t *vmemrange,
+                        unsigned int *vdistance,
+                        unsigned int *vcpu_to_vnode,
+                        unsigned int *vnode_to_pnode);
+/*
+ * Retrieve vnuma configuration
+ * domid: IN, target domid
+ * nr_vnodes: IN/OUT, number of vnodes, not NULL
+ * nr_vmemranges: IN/OUT, number of vmemranges, not NULL
+ * nr_vcpus: IN/OUT, number of vcpus, not NULL
+ * vmemranges: OUT, an array which has length of nr_vmemranges
+ * vdistance: OUT, an array which has length of nr_vnodes * nr_vnodes
+ * vcpu_to_vnode: OUT, an array which has length of nr_vcpus
+ */
+int xc_domain_getvnuma(xc_interface *xch,
+                       uint32_t domid,
+                       uint32_t *nr_vnodes,
+                       uint32_t *nr_vmemranges,
+                       uint32_t *nr_vcpus,
+                       xen_vmemrange_t *vmemrange,
+                       unsigned int *vdistance,
+                       unsigned int *vcpu_to_vnode);
+
+int xc_domain_soft_reset(xc_interface *xch,
+                         uint32_t domid);
+
+#if defined(__i386__) || defined(__x86_64__)
+/*
+ * PC BIOS standard E820 types and structure.
+ */
+#define E820_RAM          1
+#define E820_RESERVED     2
+#define E820_ACPI         3
+#define E820_NVS          4
+#define E820_UNUSABLE     5
+
+#define E820MAX           (128)
+
+struct e820entry {
+    uint64_t addr;
+    uint64_t size;
+    uint32_t type;
+} __attribute__((packed));
+int xc_domain_set_memory_map(xc_interface *xch,
+                               uint32_t domid,
+                               struct e820entry entries[],
+                               uint32_t nr_entries);
+
+int xc_get_machine_memory_map(xc_interface *xch,
+                              struct e820entry entries[],
+                              uint32_t max_entries);
+#endif
+
+int xc_reserved_device_memory_map(xc_interface *xch,
+                                  uint32_t flags,
+                                  uint16_t seg,
+                                  uint8_t bus,
+                                  uint8_t devfn,
+                                  struct xen_reserved_device_memory entries[],
+                                  uint32_t *max_entries);
+int xc_domain_set_time_offset(xc_interface *xch,
+                              uint32_t domid,
+                              int32_t time_offset_seconds);
+
+int xc_domain_set_tsc_info(xc_interface *xch,
+                           uint32_t domid,
+                           uint32_t tsc_mode,
+                           uint64_t elapsed_nsec,
+                           uint32_t gtsc_khz,
+                           uint32_t incarnation);
+
+int xc_domain_get_tsc_info(xc_interface *xch,
+                           uint32_t domid,
+                           uint32_t *tsc_mode,
+                           uint64_t *elapsed_nsec,
+                           uint32_t *gtsc_khz,
+                           uint32_t *incarnation);
+
+int xc_domain_maximum_gpfn(xc_interface *xch, uint32_t domid, xen_pfn_t *gpfns);
+
+int xc_domain_nr_gpfns(xc_interface *xch, uint32_t domid, xen_pfn_t *gpfns);
+
+int xc_domain_increase_reservation(xc_interface *xch,
+                                   uint32_t domid,
+                                   unsigned long nr_extents,
+                                   unsigned int extent_order,
+                                   unsigned int mem_flags,
+                                   xen_pfn_t *extent_start);
+
+int xc_domain_increase_reservation_exact(xc_interface *xch,
+                                         uint32_t domid,
+                                         unsigned long nr_extents,
+                                         unsigned int extent_order,
+                                         unsigned int mem_flags,
+                                         xen_pfn_t *extent_start);
+
+int xc_domain_decrease_reservation(xc_interface *xch,
+                                   uint32_t domid,
+                                   unsigned long nr_extents,
+                                   unsigned int extent_order,
+                                   xen_pfn_t *extent_start);
+
+int xc_domain_decrease_reservation_exact(xc_interface *xch,
+                                         uint32_t domid,
+                                         unsigned long nr_extents,
+                                         unsigned int extent_order,
+                                         xen_pfn_t *extent_start);
+
+int xc_domain_add_to_physmap(xc_interface *xch,
+                             uint32_t domid,
+                             unsigned int space,
+                             unsigned long idx,
+                             xen_pfn_t gpfn);
+
+int xc_domain_add_to_physmap_batch(xc_interface *xch,
+                                   uint32_t domid,
+                                   uint32_t foreign_domid,
+                                   unsigned int space,
+                                   unsigned int size,
+                                   xen_ulong_t *idxs,
+                                   xen_pfn_t *gfpns,
+                                   int *errs);
+
+int xc_domain_remove_from_physmap(xc_interface *xch,
+                                  uint32_t domid,
+                                  xen_pfn_t gpfn);
+
+int xc_domain_populate_physmap(xc_interface *xch,
+                               uint32_t domid,
+                               unsigned long nr_extents,
+                               unsigned int extent_order,
+                               unsigned int mem_flags,
+                               xen_pfn_t *extent_start);
+
+int xc_domain_populate_physmap_exact(xc_interface *xch,
+                                     uint32_t domid,
+                                     unsigned long nr_extents,
+                                     unsigned int extent_order,
+                                     unsigned int mem_flags,
+                                     xen_pfn_t *extent_start);
+
+int xc_domain_claim_pages(xc_interface *xch,
+                               uint32_t domid,
+                               unsigned long nr_pages);
+
+int xc_domain_memory_exchange_pages(xc_interface *xch,
+                                    uint32_t domid,
+                                    unsigned long nr_in_extents,
+                                    unsigned int in_order,
+                                    xen_pfn_t *in_extents,
+                                    unsigned long nr_out_extents,
+                                    unsigned int out_order,
+                                    xen_pfn_t *out_extents);
+
+int xc_domain_set_pod_target(xc_interface *xch,
+                             uint32_t domid,
+                             uint64_t target_pages,
+                             uint64_t *tot_pages,
+                             uint64_t *pod_cache_pages,
+                             uint64_t *pod_entries);
+
+int xc_domain_get_pod_target(xc_interface *xch,
+                             uint32_t domid,
+                             uint64_t *tot_pages,
+                             uint64_t *pod_cache_pages,
+                             uint64_t *pod_entries);
+
+int xc_domain_ioport_permission(xc_interface *xch,
+                                uint32_t domid,
+                                uint32_t first_port,
+                                uint32_t nr_ports,
+                                uint32_t allow_access);
+
+int xc_domain_irq_permission(xc_interface *xch,
+                             uint32_t domid,
+                             uint32_t pirq,
+                             bool allow_access);
+
+int xc_domain_iomem_permission(xc_interface *xch,
+                               uint32_t domid,
+                               unsigned long first_mfn,
+                               unsigned long nr_mfns,
+                               uint8_t allow_access);
+
+unsigned long xc_make_page_below_4G(xc_interface *xch, uint32_t domid,
+                                    unsigned long mfn);
+
+typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t;
+typedef xen_sysctl_perfc_val_t xc_perfc_val_t;
+int xc_perfc_reset(xc_interface *xch);
+int xc_perfc_query_number(xc_interface *xch,
+                          int *nbr_desc,
+                          int *nbr_val);
+int xc_perfc_query(xc_interface *xch,
+                   xc_hypercall_buffer_t *desc,
+                   xc_hypercall_buffer_t *val);
+
+typedef xen_sysctl_lockprof_data_t xc_lockprof_data_t;
+int xc_lockprof_reset(xc_interface *xch);
+int xc_lockprof_query_number(xc_interface *xch,
+                             uint32_t *n_elems);
+int xc_lockprof_query(xc_interface *xch,
+                      uint32_t *n_elems,
+                      uint64_t *time,
+                      xc_hypercall_buffer_t *data);
+
+void *xc_memalign(xc_interface *xch, size_t alignment, size_t size);
+
+/**
+ * Avoid using this function, as it does not work for all cases (such
+ * as 4M superpages, or guests using PSE36). Only used for debugging.
+ *
+ * Translates a virtual address in the context of a given domain and
+ * vcpu returning the GFN containing the address (that is, an MFN for 
+ * PV guests, a PFN for HVM guests).  Returns 0 for failure.
+ *
+ * @parm xch a handle on an open hypervisor interface
+ * @parm dom the domain to perform the translation in
+ * @parm vcpu the vcpu to perform the translation on
+ * @parm virt the virtual address to translate
+ */
+unsigned long xc_translate_foreign_address(xc_interface *xch, uint32_t dom,
+                                           int vcpu, unsigned long long virt);
+
+
+int xc_copy_to_domain_page(xc_interface *xch, uint32_t domid,
+                           unsigned long dst_pfn, const char *src_page);
+
+int xc_clear_domain_pages(xc_interface *xch, uint32_t domid,
+                          unsigned long dst_pfn, int num);
+
+static inline int xc_clear_domain_page(xc_interface *xch, uint32_t domid,
+                                       unsigned long dst_pfn)
+{
+    return xc_clear_domain_pages(xch, domid, dst_pfn, 1);
+}
+
+int xc_mmuext_op(xc_interface *xch, struct mmuext_op *op, unsigned int nr_ops,
+                 uint32_t dom);
+
+/* System wide memory properties */
+int xc_maximum_ram_page(xc_interface *xch, unsigned long *max_mfn);
+
+/* Get current total pages allocated to a domain. */
+long xc_get_tot_pages(xc_interface *xch, uint32_t domid);
+
+/**
+ * This function retrieves the the number of bytes available
+ * in the heap in a specific range of address-widths and nodes.
+ * 
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain to query
+ * @parm min_width the smallest address width to query (0 if don't care)
+ * @parm max_width the largest address width to query (0 if don't care)
+ * @parm node the node to query (-1 for all)
+ * @parm *bytes caller variable to put total bytes counted
+ * @return 0 on success, <0 on failure.
+ */
+int xc_availheap(xc_interface *xch, int min_width, int max_width, int node,
+                 uint64_t *bytes);
+
+/*
+ * Trace Buffer Operations
+ */
+
+/**
+ * xc_tbuf_enable - enable tracing buffers
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm cnt size of tracing buffers to create (in pages)
+ * @parm mfn location to store mfn of the trace buffers to
+ * @parm size location to store the size (in bytes) of a trace buffer to
+ *
+ * Gets the machine address of the trace pointer area and the size of the
+ * per CPU buffers.
+ */
+int xc_tbuf_enable(xc_interface *xch, unsigned long pages,
+                   unsigned long *mfn, unsigned long *size);
+
+/*
+ * Disable tracing buffers.
+ */
+int xc_tbuf_disable(xc_interface *xch);
+
+/**
+ * This function sets the size of the trace buffers. Setting the size
+ * is currently a one-shot operation that may be performed either at boot
+ * time or via this interface, not both. The buffer size must be set before
+ * enabling tracing.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm size the size in pages per cpu for the trace buffers
+ * @return 0 on success, -1 on failure.
+ */
+int xc_tbuf_set_size(xc_interface *xch, unsigned long size);
+
+/**
+ * This function retrieves the current size of the trace buffers.
+ * Note that the size returned is in terms of bytes, not pages.
+
+ * @parm xch a handle to an open hypervisor interface
+ * @parm size will contain the size in bytes for the trace buffers
+ * @return 0 on success, -1 on failure.
+ */
+int xc_tbuf_get_size(xc_interface *xch, unsigned long *size);
+
+int xc_tbuf_set_cpu_mask(xc_interface *xch, xc_cpumap_t mask);
+
+int xc_tbuf_set_evt_mask(xc_interface *xch, uint32_t mask);
+
+/**
+ * Enable vmtrace for given vCPU.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid domain identifier
+ * @parm vcpu vcpu identifier
+ * @return 0 on success, -1 on failure
+ */
+int xc_vmtrace_enable(xc_interface *xch, uint32_t domid, uint32_t vcpu);
+
+/**
+ * Enable vmtrace for given vCPU.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid domain identifier
+ * @parm vcpu vcpu identifier
+ * @return 0 on success, -1 on failure
+ */
+int xc_vmtrace_disable(xc_interface *xch, uint32_t domid, uint32_t vcpu);
+
+/**
+ * Enable vmtrace for a given vCPU, along with resetting status/offset
+ * details.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid domain identifier
+ * @parm vcpu vcpu identifier
+ * @return 0 on success, -1 on failure
+ */
+int xc_vmtrace_reset_and_enable(xc_interface *xch, uint32_t domid,
+                                uint32_t vcpu);
+
+/**
+ * Get current output position inside the trace buffer.
+ *
+ * Repeated calls will return different values if tracing is enabled.  It is
+ * platform specific what happens when the buffer fills completely.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid domain identifier
+ * @parm vcpu vcpu identifier
+ * @parm pos current output position in bytes
+ * @return 0 on success, -1 on failure
+ */
+int xc_vmtrace_output_position(xc_interface *xch, uint32_t domid,
+                               uint32_t vcpu, uint64_t *pos);
+
+/**
+ * Get platform specific vmtrace options.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid domain identifier
+ * @parm vcpu vcpu identifier
+ * @parm key platform-specific input
+ * @parm value platform-specific output
+ * @return 0 on success, -1 on failure
+ */
+int xc_vmtrace_get_option(xc_interface *xch, uint32_t domid,
+                          uint32_t vcpu, uint64_t key, uint64_t *value);
+
+/**
+ * Set platform specific vmtrace options.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid domain identifier
+ * @parm vcpu vcpu identifier
+ * @parm key platform-specific input
+ * @parm value platform-specific input
+ * @return 0 on success, -1 on failure
+ */
+int xc_vmtrace_set_option(xc_interface *xch, uint32_t domid,
+                          uint32_t vcpu, uint64_t key, uint64_t value);
+
+int xc_domctl(xc_interface *xch, struct xen_domctl *domctl);
+int xc_sysctl(xc_interface *xch, struct xen_sysctl *sysctl);
+
+int xc_version(xc_interface *xch, int cmd, void *arg);
+
+int xc_flask_op(xc_interface *xch, xen_flask_op_t *op);
+
+/*
+ * Subscribe to domain suspend via evtchn.
+ * Returns -1 on failure, in which case errno will be set appropriately.
+ * Just calls XEN_DOMCTL_subscribe - see the caveats for that domctl
+ * (in its doc comment in domctl.h).
+ */
+int xc_domain_subscribe_for_suspend(
+    xc_interface *xch, uint32_t domid, evtchn_port_t port);
+
+/**************************
+ * GRANT TABLE OPERATIONS *
+ **************************/
+
+/*
+ * These functions sometimes log messages as above, but not always.
+ */
+
+
+int xc_gnttab_op(xc_interface *xch, int cmd,
+                 void * op, int op_size, int count);
+/* Logs iff hypercall bounce fails, otherwise doesn't. */
+
+int xc_gnttab_query_size(xc_interface *xch, struct gnttab_query_size *query);
+int xc_gnttab_get_version(xc_interface *xch, uint32_t domid); /* Never logs */
+grant_entry_v1_t *xc_gnttab_map_table_v1(xc_interface *xch, uint32_t domid, int *gnt_num);
+grant_entry_v2_t *xc_gnttab_map_table_v2(xc_interface *xch, uint32_t domid, int *gnt_num);
+/* Sometimes these don't set errno [fixme], and sometimes they don't log. */
+
+int xc_physdev_map_pirq(xc_interface *xch,
+                        uint32_t domid,
+                        int index,
+                        int *pirq);
+
+int xc_physdev_map_pirq_msi(xc_interface *xch,
+                            uint32_t domid,
+                            int index,
+                            int *pirq,
+                            int devfn,
+                            int bus,
+                            int entry_nr,
+                            uint64_t table_base);
+
+int xc_physdev_unmap_pirq(xc_interface *xch,
+                          uint32_t domid,
+                          int pirq);
+
+/*
+ *  LOGGING AND ERROR REPORTING
+ */
+
+
+#define XC_MAX_ERROR_MSG_LEN 1024
+typedef struct xc_error {
+  enum xc_error_code code;
+  char message[XC_MAX_ERROR_MSG_LEN];
+} xc_error;
+
+
+/*
+ * Convert an error code or level into a text description.  Return values
+ * are pointers to fixed strings and do not need to be freed.
+ * Do not fail, but return pointers to generic strings if fed bogus input.
+ */
+const char *xc_error_code_to_desc(int code);
+
+/*
+ * Convert an errno value to a text description.
+ */
+const char *xc_strerror(xc_interface *xch, int errcode);
+
+
+/*
+ * Return a pointer to the last error with level XC_REPORT_ERROR. This
+ * pointer and the data pointed to are only valid until the next call
+ * to libxc in the same thread.
+ */
+const xc_error *xc_get_last_error(xc_interface *handle);
+
+/*
+ * Clear the last error
+ */
+void xc_clear_last_error(xc_interface *xch);
+
+int xc_hvm_param_set(xc_interface *handle, uint32_t dom, uint32_t param, uint64_t value);
+int xc_hvm_param_get(xc_interface *handle, uint32_t dom, uint32_t param, uint64_t *value);
+
+/* Deprecated: use xc_hvm_param_set/get() instead. */
+int xc_set_hvm_param(xc_interface *handle, uint32_t dom, int param, unsigned long value);
+int xc_get_hvm_param(xc_interface *handle, uint32_t dom, int param, unsigned long *value);
+
+/* HVM guest pass-through */
+int xc_assign_device(xc_interface *xch,
+                     uint32_t domid,
+                     uint32_t machine_sbdf,
+                     uint32_t flag);
+
+int xc_get_device_group(xc_interface *xch,
+                     uint32_t domid,
+                     uint32_t machine_sbdf,
+                     uint32_t max_sdevs,
+                     uint32_t *num_sdevs,
+                     uint32_t *sdev_array);
+
+int xc_test_assign_device(xc_interface *xch,
+                          uint32_t domid,
+                          uint32_t machine_sbdf);
+
+int xc_deassign_device(xc_interface *xch,
+                     uint32_t domid,
+                     uint32_t machine_sbdf);
+
+int xc_assign_dt_device(xc_interface *xch,
+                        uint32_t domid,
+                        char *path);
+int xc_test_assign_dt_device(xc_interface *xch,
+                             uint32_t domid,
+                             char *path);
+int xc_deassign_dt_device(xc_interface *xch,
+                          uint32_t domid,
+                          char *path);
+
+int xc_domain_memory_mapping(xc_interface *xch,
+                             uint32_t domid,
+                             unsigned long first_gfn,
+                             unsigned long first_mfn,
+                             unsigned long nr_mfns,
+                             uint32_t add_mapping);
+
+int xc_domain_ioport_mapping(xc_interface *xch,
+                             uint32_t domid,
+                             uint32_t first_gport,
+                             uint32_t first_mport,
+                             uint32_t nr_ports,
+                             uint32_t add_mapping);
+
+int xc_domain_update_msi_irq(
+    xc_interface *xch,
+    uint32_t domid,
+    uint32_t gvec,
+    uint32_t pirq,
+    uint32_t gflags,
+    uint64_t gtable);
+
+int xc_domain_unbind_msi_irq(xc_interface *xch,
+                             uint32_t domid,
+                             uint32_t gvec,
+                             uint32_t pirq,
+                             uint32_t gflags);
+
+int xc_domain_bind_pt_irq(xc_interface *xch,
+                          uint32_t domid,
+                          uint8_t machine_irq,
+                          uint8_t irq_type,
+                          uint8_t bus,
+                          uint8_t device,
+                          uint8_t intx,
+                          uint8_t isa_irq);
+
+int xc_domain_unbind_pt_irq(xc_interface *xch,
+                          uint32_t domid,
+                          uint8_t machine_irq,
+                          uint8_t irq_type,
+                          uint8_t bus,
+                          uint8_t device,
+                          uint8_t intx,
+                          uint8_t isa_irq);
+
+int xc_domain_bind_pt_pci_irq(xc_interface *xch,
+                              uint32_t domid,
+                              uint8_t machine_irq,
+                              uint8_t bus,
+                              uint8_t device,
+                              uint8_t intx);
+
+int xc_domain_bind_pt_isa_irq(xc_interface *xch,
+                              uint32_t domid,
+                              uint8_t machine_irq);
+
+int xc_domain_bind_pt_spi_irq(xc_interface *xch,
+                              uint32_t domid,
+                              uint16_t vspi,
+                              uint16_t spi);
+
+int xc_domain_unbind_pt_spi_irq(xc_interface *xch,
+                                uint32_t domid,
+                                uint16_t vspi,
+                                uint16_t spi);
+
+/* Set the target domain */
+int xc_domain_set_target(xc_interface *xch,
+                         uint32_t domid,
+                         uint32_t target);
+
+/* Control the domain for debug */
+int xc_domain_debug_control(xc_interface *xch,
+                            uint32_t domid,
+                            uint32_t sop,
+                            uint32_t vcpu);
+
+#if defined(__i386__) || defined(__x86_64__)
+
+/*
+ * CPUID policy data, expressed in the legacy XEND format.
+ *
+ * Policy is an array of strings, 32 chars long:
+ *   policy[0] = eax
+ *   policy[1] = ebx
+ *   policy[2] = ecx
+ *   policy[3] = edx
+ *
+ * The format of the string is the following:
+ *   '1' -> force to 1
+ *   '0' -> force to 0
+ *   'x' -> we don't care (use default)
+ *   'k' -> pass through host value
+ *   's' -> legacy alias for 'k'
+ */
+struct xc_xend_cpuid {
+    union {
+        struct {
+            uint32_t leaf, subleaf;
+        };
+        uint32_t input[2];
+    };
+    char *policy[4];
+};
+
+/*
+ * Make adjustments to the CPUID settings for a domain.
+ *
+ * This path is used in two cases.  First, for fresh boots of the domain, and
+ * secondly for migrate-in/restore of pre-4.14 guests (where CPUID data was
+ * missing from the stream).  The @restore parameter distinguishes these
+ * cases, and the generated policy must be compatible with a 4.13.
+ *
+ * Either pass a full new @featureset (and @nr_features), or adjust individual
+ * features (@pae, @itsc, @nested_virt).
+ *
+ * Then (optionally) apply legacy XEND overrides (@xend) to the result.
+ */
+int xc_cpuid_apply_policy(xc_interface *xch,
+                          uint32_t domid, bool restore,
+                          const uint32_t *featureset,
+                          unsigned int nr_features, bool pae, bool itsc,
+                          bool nested_virt, const struct xc_xend_cpuid *xend);
+int xc_mca_op(xc_interface *xch, struct xen_mc *mc);
+int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags,
+                        xc_cpumap_t cpumap, unsigned int nr_cpus);
+#endif
+
+struct xc_px_val {
+    uint64_t freq;        /* Px core frequency */
+    uint64_t residency;   /* Px residency time */
+    uint64_t count;       /* Px transition count */
+};
+
+struct xc_px_stat {
+    uint8_t total;        /* total Px states */
+    uint8_t usable;       /* usable Px states */
+    uint8_t last;         /* last Px state */
+    uint8_t cur;          /* current Px state */
+    uint64_t *trans_pt;   /* Px transition table */
+    struct xc_px_val *pt;
+};
+
+int xc_pm_get_max_px(xc_interface *xch, int cpuid, int *max_px);
+int xc_pm_get_pxstat(xc_interface *xch, int cpuid, struct xc_px_stat *pxpt);
+int xc_pm_reset_pxstat(xc_interface *xch, int cpuid);
+
+struct xc_cx_stat {
+    uint32_t nr;           /* entry nr in triggers[]/residencies[], incl C0 */
+    uint32_t last;         /* last Cx state */
+    uint64_t idle_time;    /* idle time from boot */
+    uint64_t *triggers;    /* Cx trigger counts */
+    uint64_t *residencies; /* Cx residencies */
+    uint32_t nr_pc;        /* entry nr in pc[] */
+    uint32_t nr_cc;        /* entry nr in cc[] */
+    uint64_t *pc;          /* 1-biased indexing (i.e. excl C0) */
+    uint64_t *cc;          /* 1-biased indexing (i.e. excl C0) */
+};
+typedef struct xc_cx_stat xc_cx_stat_t;
+
+int xc_pm_get_max_cx(xc_interface *xch, int cpuid, int *max_cx);
+int xc_pm_get_cxstat(xc_interface *xch, int cpuid, struct xc_cx_stat *cxpt);
+int xc_pm_reset_cxstat(xc_interface *xch, int cpuid);
+
+int xc_cpu_online(xc_interface *xch, int cpu);
+int xc_cpu_offline(xc_interface *xch, int cpu);
+int xc_smt_enable(xc_interface *xch);
+int xc_smt_disable(xc_interface *xch);
+
+/* 
+ * cpufreq para name of this structure named 
+ * same as sysfs file name of native linux
+ */
+typedef struct xen_userspace xc_userspace_t;
+typedef struct xen_ondemand xc_ondemand_t;
+
+struct xc_get_cpufreq_para {
+    /* IN/OUT variable */
+    uint32_t cpu_num;
+    uint32_t freq_num;
+    uint32_t gov_num;
+
+    /* for all governors */
+    /* OUT variable */
+    uint32_t *affected_cpus;
+    uint32_t *scaling_available_frequencies;
+    char     *scaling_available_governors;
+    char scaling_driver[CPUFREQ_NAME_LEN];
+
+    uint32_t cpuinfo_cur_freq;
+    uint32_t cpuinfo_max_freq;
+    uint32_t cpuinfo_min_freq;
+    uint32_t scaling_cur_freq;
+
+    char scaling_governor[CPUFREQ_NAME_LEN];
+    uint32_t scaling_max_freq;
+    uint32_t scaling_min_freq;
+
+    /* for specific governor */
+    union {
+        xc_userspace_t userspace;
+        xc_ondemand_t ondemand;
+    } u;
+
+    int32_t turbo_enabled;
+};
+
+int xc_get_cpufreq_para(xc_interface *xch, int cpuid,
+                        struct xc_get_cpufreq_para *user_para);
+int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname);
+int xc_set_cpufreq_para(xc_interface *xch, int cpuid,
+                        int ctrl_type, int ctrl_value);
+int xc_get_cpufreq_avgfreq(xc_interface *xch, int cpuid, int *avg_freq);
+
+int xc_set_sched_opt_smt(xc_interface *xch, uint32_t value);
+
+int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t *value);
+int xc_set_cpuidle_max_cstate(xc_interface *xch, uint32_t value);
+
+int xc_get_cpuidle_max_csubstate(xc_interface *xch, uint32_t *value);
+int xc_set_cpuidle_max_csubstate(xc_interface *xch, uint32_t value);
+
+int xc_enable_turbo(xc_interface *xch, int cpuid);
+int xc_disable_turbo(xc_interface *xch, int cpuid);
+
+/**
+ * altp2m operations
+ */
+
+int xc_altp2m_get_domain_state(xc_interface *handle, uint32_t dom, bool *state);
+int xc_altp2m_set_domain_state(xc_interface *handle, uint32_t dom, bool state);
+int xc_altp2m_set_vcpu_enable_notify(xc_interface *handle, uint32_t domid,
+                                     uint32_t vcpuid, xen_pfn_t gfn);
+int xc_altp2m_set_vcpu_disable_notify(xc_interface *handle, uint32_t domid,
+                                      uint32_t vcpuid);
+int xc_altp2m_create_view(xc_interface *handle, uint32_t domid,
+                          xenmem_access_t default_access, uint16_t *view_id);
+int xc_altp2m_destroy_view(xc_interface *handle, uint32_t domid,
+                           uint16_t view_id);
+/* Switch all vCPUs of the domain to the specified altp2m view */
+int xc_altp2m_switch_to_view(xc_interface *handle, uint32_t domid,
+                             uint16_t view_id);
+int xc_altp2m_set_suppress_ve(xc_interface *handle, uint32_t domid,
+                              uint16_t view_id, xen_pfn_t gfn, bool sve);
+int xc_altp2m_set_supress_ve_multi(xc_interface *handle, uint32_t domid,
+                                   uint16_t view_id, xen_pfn_t first_gfn,
+                                   xen_pfn_t last_gfn, bool sve,
+                                   xen_pfn_t *error_gfn, int32_t *error_code);
+int xc_altp2m_get_suppress_ve(xc_interface *handle, uint32_t domid,
+                              uint16_t view_id, xen_pfn_t gfn, bool *sve);
+int xc_altp2m_set_mem_access(xc_interface *handle, uint32_t domid,
+                             uint16_t view_id, xen_pfn_t gfn,
+                             xenmem_access_t access);
+int xc_altp2m_set_mem_access_multi(xc_interface *handle, uint32_t domid,
+                                   uint16_t view_id, uint8_t *access,
+                                   uint64_t *gfns, uint32_t nr);
+int xc_altp2m_get_mem_access(xc_interface *handle, uint32_t domid,
+                             uint16_t view_id, xen_pfn_t gfn,
+                             xenmem_access_t *access);
+int xc_altp2m_change_gfn(xc_interface *handle, uint32_t domid,
+                         uint16_t view_id, xen_pfn_t old_gfn,
+                         xen_pfn_t new_gfn);
+int xc_altp2m_get_vcpu_p2m_idx(xc_interface *handle, uint32_t domid,
+                               uint32_t vcpuid, uint16_t *p2midx);
+/*
+ * Set view visibility for xc_altp2m_switch_to_view and vmfunc.
+ * Note: If altp2m mode is set to mixed the guest is able to change the view
+ * visibility and then call vmfunc.
+ */
+int xc_altp2m_set_visibility(xc_interface *handle, uint32_t domid,
+                             uint16_t view_id, bool visible);
+
+/** 
+ * Mem paging operations.
+ * Paging is supported only on the x86 architecture in 64 bit mode, with
+ * Hardware-Assisted Paging (i.e. Intel EPT, AMD NPT). Moreover, AMD NPT
+ * support is considered experimental.
+ */
+int xc_mem_paging_enable(xc_interface *xch, uint32_t domain_id, uint32_t *port);
+int xc_mem_paging_disable(xc_interface *xch, uint32_t domain_id);
+int xc_mem_paging_resume(xc_interface *xch, uint32_t domain_id);
+int xc_mem_paging_nominate(xc_interface *xch, uint32_t domain_id,
+                           uint64_t gfn);
+int xc_mem_paging_evict(xc_interface *xch, uint32_t domain_id, uint64_t gfn);
+int xc_mem_paging_prep(xc_interface *xch, uint32_t domain_id, uint64_t gfn);
+int xc_mem_paging_load(xc_interface *xch, uint32_t domain_id,
+                       uint64_t gfn, void *buffer);
+
+/** 
+ * Access tracking operations.
+ * Supported only on Intel EPT 64 bit processors.
+ */
+
+/*
+ * Set a range of memory to a specific access.
+ * Allowed types are XENMEM_access_default, XENMEM_access_n, any combination of
+ * XENMEM_access_ + (rwx), and XENMEM_access_rx2rw
+ */
+int xc_set_mem_access(xc_interface *xch, uint32_t domain_id,
+                      xenmem_access_t access, uint64_t first_pfn,
+                      uint32_t nr);
+
+/*
+ * Set an array of pages to their respective access in the access array.
+ * The nr parameter specifies the size of the pages and access arrays.
+ * The same allowed access types as for xc_set_mem_access() apply.
+ */
+int xc_set_mem_access_multi(xc_interface *xch, uint32_t domain_id,
+                            uint8_t *access, uint64_t *pages,
+                            uint32_t nr);
+
+/*
+ * Gets the mem access for the given page (returned in access on success)
+ */
+int xc_get_mem_access(xc_interface *xch, uint32_t domain_id,
+                      uint64_t pfn, xenmem_access_t *access);
+
+/*
+ * Returns the VM_EVENT_INTERFACE version.
+ */
+int xc_vm_event_get_version(xc_interface *xch);
+
+/***
+ * Monitor control operations.
+ *
+ * Enables the VM event monitor ring and returns the mapped ring page.
+ * This ring is used to deliver mem_access events, as well a set of additional
+ * events that can be enabled with the xc_monitor_* functions.
+ *
+ * Will return NULL on error.
+ * Caller has to unmap this page when done.
+ */
+void *xc_monitor_enable(xc_interface *xch, uint32_t domain_id, uint32_t *port);
+int xc_monitor_disable(xc_interface *xch, uint32_t domain_id);
+int xc_monitor_resume(xc_interface *xch, uint32_t domain_id);
+/*
+ * Get a bitmap of supported monitor events in the form
+ * (1 << XEN_DOMCTL_MONITOR_EVENT_*).
+ */
+int xc_monitor_get_capabilities(xc_interface *xch, uint32_t domain_id,
+                                uint32_t *capabilities);
+int xc_monitor_write_ctrlreg(xc_interface *xch, uint32_t domain_id,
+                             uint16_t index, bool enable, bool sync,
+                             uint64_t bitmask, bool onchangeonly);
+/*
+ * A list of MSR indices can usually be found in /usr/include/asm/msr-index.h.
+ * Please consult the Intel/AMD manuals for more information on
+ * non-architectural indices.
+ */
+int xc_monitor_mov_to_msr(xc_interface *xch, uint32_t domain_id, uint32_t msr,
+                          bool enable, bool onchangeonly);
+int xc_monitor_singlestep(xc_interface *xch, uint32_t domain_id, bool enable);
+int xc_monitor_software_breakpoint(xc_interface *xch, uint32_t domain_id,
+                                   bool enable);
+int xc_monitor_descriptor_access(xc_interface *xch, uint32_t domain_id,
+                                 bool enable);
+int xc_monitor_guest_request(xc_interface *xch, uint32_t domain_id,
+                             bool enable, bool sync, bool allow_userspace);
+/*
+ * Disables page-walk mem_access events by emulating. If the
+ * emulation can not be performed then a VM_EVENT_REASON_EMUL_UNIMPLEMENTED
+ * event will be issued.
+ */
+int xc_monitor_inguest_pagefault(xc_interface *xch, uint32_t domain_id,
+                                 bool disable);
+int xc_monitor_debug_exceptions(xc_interface *xch, uint32_t domain_id,
+                                bool enable, bool sync);
+int xc_monitor_cpuid(xc_interface *xch, uint32_t domain_id, bool enable);
+int xc_monitor_privileged_call(xc_interface *xch, uint32_t domain_id,
+                               bool enable);
+int xc_monitor_emul_unimplemented(xc_interface *xch, uint32_t domain_id,
+                                  bool enable);
+/**
+ * This function enables / disables emulation for each REP for a
+ * REP-compatible instruction.
+ *
+ * @parm xch a handle to an open hypervisor interface.
+ * @parm domain_id the domain id one wants to get the node affinity of.
+ * @parm enable if 0 optimize when possible, else emulate each REP.
+ * @return 0 on success, -1 on failure.
+ */
+int xc_monitor_emulate_each_rep(xc_interface *xch, uint32_t domain_id,
+                                bool enable);
+
+/***
+ * Memory sharing operations.
+ *
+ * Unles otherwise noted, these calls return 0 on succes, -1 and errno on
+ * failure.
+ *
+ * Sharing is supported only on the x86 architecture in 64 bit mode, with
+ * Hardware-Assisted Paging (i.e. Intel EPT, AMD NPT). Moreover, AMD NPT
+ * support is considered experimental.
+
+ * Calls below return ENOSYS if not in the x86_64 architecture.
+ * Calls below return ENODEV if the domain does not support HAP.
+ * Calls below return ESRCH if the specified domain does not exist.
+ * Calls below return EPERM if the caller is unprivileged for this domain.
+ */
+
+/* Turn on/off sharing for the domid, depending on the enable flag.
+ *
+ * Returns EXDEV if trying to enable and the domain has had a PCI device
+ * assigned for passthrough (these two features are mutually exclusive).
+ *
+ * When sharing for a domain is turned off, the domain may still reference
+ * shared pages. Unsharing happens lazily. */
+int xc_memshr_control(xc_interface *xch,
+                      uint32_t domid,
+                      int enable);
+
+/* Create a communication ring in which the hypervisor will place ENOMEM
+ * notifications.
+ *
+ * ENOMEM happens when unsharing pages: a Copy-on-Write duplicate needs to be
+ * allocated, and thus the out-of-memory error occurr.
+ *
+ * For complete examples on how to plumb a notification ring, look into
+ * xenpaging or xen-access.
+ *
+ * On receipt of a notification, the helper should ensure there is memory
+ * available to the domain before retrying.
+ *
+ * If a domain encounters an ENOMEM condition when sharing and this ring
+ * has not been set up, the hypervisor will crash the domain.
+ *
+ * Fails with:
+ *  EINVAL if port is NULL
+ *  EINVAL if the sharing ring has already been enabled
+ *  ENOSYS if no guest gfn has been specified to host the ring via an hvm param
+ *  EINVAL if the gfn for the ring has not been populated
+ *  ENOENT if the gfn for the ring is paged out, or cannot be unshared
+ *  EINVAL if the gfn for the ring cannot be written to
+ *  EINVAL if the domain is dying
+ *  ENOSPC if an event channel cannot be allocated for the ring
+ *  ENOMEM if memory cannot be allocated for internal data structures
+ *  EINVAL or EACCESS if the request is denied by the security policy
+ */
+
+int xc_memshr_ring_enable(xc_interface *xch,
+                          uint32_t domid,
+                          uint32_t *port);
+/* Disable the ring for ENOMEM communication.
+ * May fail with EINVAL if the ring was not enabled in the first place.
+ */
+int xc_memshr_ring_disable(xc_interface *xch,
+                           uint32_t domid);
+
+/*
+ * Calls below return EINVAL if sharing has not been enabled for the domain
+ * Calls below return EINVAL if the domain is dying
+ */
+/* Once a reponse to an ENOMEM notification is prepared, the tool can
+ * notify the hypervisor to re-schedule the faulting vcpu of the domain with an
+ * event channel kick and/or this call. */
+int xc_memshr_domain_resume(xc_interface *xch,
+                            uint32_t domid);
+
+/* Select a page for sharing.
+ *
+ * A 64 bit opaque handle will be stored in handle.  The hypervisor ensures
+ * that if the page is modified, the handle will be invalidated, and future
+ * users of it will fail. If the page has already been selected and is still
+ * associated to a valid handle, the existing handle will be returned.
+ *
+ * May fail with:
+ *  EINVAL if the gfn is not populated or not sharable (mmio, etc)
+ *  ENOMEM if internal data structures cannot be allocated
+ *  E2BIG if the page is being referenced by other subsytems (e.g. qemu)
+ *  ENOENT or EEXIST if there are internal hypervisor errors.
+ */
+int xc_memshr_nominate_gfn(xc_interface *xch,
+                           uint32_t domid,
+                           unsigned long gfn,
+                           uint64_t *handle);
+/* Same as above, but instead of a guest frame number, the input is a grant
+ * reference provided by the guest.
+ *
+ * May fail with EINVAL if the grant reference is invalid.
+ */
+int xc_memshr_nominate_gref(xc_interface *xch,
+                            uint32_t domid,
+                            grant_ref_t gref,
+                            uint64_t *handle);
+
+/* The three calls below may fail with
+ * 10 (or -XENMEM_SHARING_OP_S_HANDLE_INVALID) if the handle passed as source
+ * is invalid.
+ * 9 (or -XENMEM_SHARING_OP_C_HANDLE_INVALID) if the handle passed as client is
+ * invalid.
+ */
+/* Share two nominated guest pages.
+ *
+ * If the call succeeds, both pages will point to the same backing frame (or
+ * mfn). The hypervisor will verify the handles are still valid, but it will
+ * not perform any sanity checking on the contens of the pages (the selection
+ * mechanism for sharing candidates is entirely up to the user-space tool).
+ *
+ * After successful sharing, the client handle becomes invalid. Both <domain,
+ * gfn> tuples point to the same mfn with the same handle, the one specified as
+ * source. Either 3-tuple can be specified later for further re-sharing.
+ */
+int xc_memshr_share_gfns(xc_interface *xch,
+                    uint32_t source_domain,
+                    unsigned long source_gfn,
+                    uint64_t source_handle,
+                    uint32_t client_domain,
+                    unsigned long client_gfn,
+                    uint64_t client_handle);
+
+/* Same as above, but share two grant references instead.
+ *
+ * May fail with EINVAL if either grant reference is invalid.
+ */
+int xc_memshr_share_grefs(xc_interface *xch,
+                    uint32_t source_domain,
+                    grant_ref_t source_gref,
+                    uint64_t source_handle,
+                    uint32_t client_domain,
+                    grant_ref_t client_gref,
+                    uint64_t client_handle);
+
+/* Allows to add to the guest physmap of the client domain a shared frame
+ * directly.
+ *
+ * May additionally fail with
+ *  9 (-XENMEM_SHARING_OP_C_HANDLE_INVALID) if the physmap entry for the gfn is
+ *  not suitable.
+ *  ENOMEM if internal data structures cannot be allocated.
+ *  ENOENT if there is an internal hypervisor error.
+ */
+int xc_memshr_add_to_physmap(xc_interface *xch,
+                    uint32_t source_domain,
+                    unsigned long source_gfn,
+                    uint64_t source_handle,
+                    uint32_t client_domain,
+                    unsigned long client_gfn);
+
+/* Allows to deduplicate a range of memory of a client domain. Using
+ * this function is equivalent of calling xc_memshr_nominate_gfn for each gfn
+ * in the two domains followed by xc_memshr_share_gfns.
+ *
+ * May fail with -EINVAL if the source and client domain have different
+ * memory size or if memory sharing is not enabled on either of the domains.
+ * May also fail with -ENOMEM if there isn't enough memory available to store
+ * the sharing metadata before deduplication can happen.
+ */
+int xc_memshr_range_share(xc_interface *xch,
+                          uint32_t source_domain,
+                          uint32_t client_domain,
+                          uint64_t first_gfn,
+                          uint64_t last_gfn);
+
+int xc_memshr_fork(xc_interface *xch,
+                   uint32_t source_domain,
+                   uint32_t client_domain,
+                   bool allow_with_iommu,
+                   bool block_interrupts);
+
+/*
+ * Note: this function is only intended to be used on short-lived forks that
+ * haven't yet aquired a lot of memory. In case the fork has a lot of memory
+ * it is likely more performant to create a new fork with xc_memshr_fork.
+ *
+ * With VMs that have a lot of memory this call may block for a long time.
+ */
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t forked_domain);
+
+/* Debug calls: return the number of pages referencing the shared frame backing
+ * the input argument. Should be one or greater.
+ *
+ * May fail with EINVAL if there is no backing shared frame for the input
+ * argument.
+ */
+int xc_memshr_debug_gfn(xc_interface *xch,
+                        uint32_t domid,
+                        unsigned long gfn);
+/* May additionally fail with EINVAL if the grant reference is invalid. */
+int xc_memshr_debug_gref(xc_interface *xch,
+                         uint32_t domid,
+                         grant_ref_t gref);
+
+/* Audits the share subsystem.
+ *
+ * Returns ENOSYS if not supported (may not be compiled into the hypervisor).
+ *
+ * Returns the number of errors found during auditing otherwise. May be (should
+ * be!) zero.
+ *
+ * If debugtrace support has been compiled into the hypervisor and is enabled,
+ * verbose descriptions for the errors are available in the hypervisor console.
+ */
+int xc_memshr_audit(xc_interface *xch);
+
+/* Stats reporting.
+ *
+ * At any point in time, the following equality should hold for a host:
+ *
+ *  Let dominfo(d) be the xc_dominfo_t struct filled by a call to
+ *  xc_domain_getinfo(d)
+ *
+ *  The summation of dominfo(d)->shr_pages for all domains in the system
+ *      should be equal to
+ *  xc_sharing_freed_pages + xc_sharing_used_frames
+ */
+/*
+ * This function returns the total number of pages freed by using sharing
+ * on the system.  For example, if two domains contain a single entry in
+ * their p2m table that points to the same shared page (and no other pages
+ * in the system are shared), then this function should return 1.
+ */
+long xc_sharing_freed_pages(xc_interface *xch);
+
+/*
+ * This function returns the total number of frames occupied by shared
+ * pages on the system.  This is independent of the number of domains
+ * pointing at these frames.  For example, in the above scenario this
+ * should return 1. (And dominfo(d) for each of the two domains should return 1
+ * as well).
+ *
+ * Note that some of these sharing_used_frames may be referenced by
+ * a single domain page, and thus not realize any savings. The same
+ * applies to some of the pages counted in dominfo(d)->shr_pages.
+ */
+long xc_sharing_used_frames(xc_interface *xch);
+/*** End sharing interface ***/
+
+int xc_flask_load(xc_interface *xc_handle, char *buf, uint32_t size);
+int xc_flask_context_to_sid(xc_interface *xc_handle, char *buf, uint32_t size, uint32_t *sid);
+int xc_flask_sid_to_context(xc_interface *xc_handle, int sid, char *buf, uint32_t size);
+int xc_flask_getenforce(xc_interface *xc_handle);
+int xc_flask_setenforce(xc_interface *xc_handle, int mode);
+int xc_flask_getbool_byid(xc_interface *xc_handle, int id, char *name, uint32_t size, int *curr, int *pend);
+int xc_flask_getbool_byname(xc_interface *xc_handle, char *name, int *curr, int *pend);
+int xc_flask_setbool(xc_interface *xc_handle, char *name, int value, int commit);
+int xc_flask_add_pirq(xc_interface *xc_handle, unsigned int pirq, char *scontext);
+int xc_flask_add_ioport(xc_interface *xc_handle, unsigned long low, unsigned long high,
+                      char *scontext);
+int xc_flask_add_iomem(xc_interface *xc_handle, unsigned long low, unsigned long high,
+                     char *scontext);
+int xc_flask_add_device(xc_interface *xc_handle, unsigned long device, char *scontext);
+int xc_flask_del_pirq(xc_interface *xc_handle, unsigned int pirq);
+int xc_flask_del_ioport(xc_interface *xc_handle, unsigned long low, unsigned long high);
+int xc_flask_del_iomem(xc_interface *xc_handle, unsigned long low, unsigned long high);
+int xc_flask_del_device(xc_interface *xc_handle, unsigned long device);
+int xc_flask_access(xc_interface *xc_handle, const char *scon, const char *tcon,
+                  uint16_t tclass, uint32_t req,
+                  uint32_t *allowed, uint32_t *decided,
+                  uint32_t *auditallow, uint32_t *auditdeny,
+                  uint32_t *seqno);
+int xc_flask_avc_cachestats(xc_interface *xc_handle, char *buf, int size);
+int xc_flask_policyvers(xc_interface *xc_handle);
+int xc_flask_avc_hashstats(xc_interface *xc_handle, char *buf, int size);
+int xc_flask_getavc_threshold(xc_interface *xc_handle);
+int xc_flask_setavc_threshold(xc_interface *xc_handle, int threshold);
+int xc_flask_relabel_domain(xc_interface *xch, uint32_t domid, uint32_t sid);
+
+struct elf_binary;
+void xc_elf_set_logfile(xc_interface *xch, struct elf_binary *elf,
+                        int verbose);
+/* Useful for callers who also use libelf. */
+
+/*
+ * Execute an image previously loaded with xc_kexec_load().
+ *
+ * Does not return on success.
+ *
+ * Fails with:
+ *   ENOENT if the specified image has not been loaded.
+ */
+int xc_kexec_exec(xc_interface *xch, int type);
+
+/*
+ * Find the machine address and size of certain memory areas.
+ *
+ *   KEXEC_RANGE_MA_CRASH       crash area
+ *   KEXEC_RANGE_MA_XEN         Xen itself
+ *   KEXEC_RANGE_MA_CPU         CPU note for CPU number 'nr'
+ *   KEXEC_RANGE_MA_XENHEAP     xenheap
+ *   KEXEC_RANGE_MA_EFI_MEMMAP  EFI Memory Map
+ *   KEXEC_RANGE_MA_VMCOREINFO  vmcoreinfo
+ *
+ * Fails with:
+ *   EINVAL if the range or CPU number isn't valid.
+ */
+int xc_kexec_get_range(xc_interface *xch, int range,  int nr,
+                       uint64_t *size, uint64_t *start);
+
+/*
+ * Load a kexec image into memory.
+ *
+ * The image may be of type KEXEC_TYPE_DEFAULT (executed on request)
+ * or KEXEC_TYPE_CRASH (executed on a crash).
+ *
+ * The image architecture may be a 32-bit variant of the hypervisor
+ * architecture (e.g, EM_386 on a x86-64 hypervisor).
+ *
+ * Fails with:
+ *   ENOMEM if there is insufficient memory for the new image.
+ *   EINVAL if the image does not fit into the crash area or the entry
+ *          point isn't within one of segments.
+ *   EBUSY  if another image is being executed.
+ */
+int xc_kexec_load(xc_interface *xch, uint8_t type, uint16_t arch,
+                  uint64_t entry_maddr,
+                  uint32_t nr_segments, xen_kexec_segment_t *segments);
+
+/*
+ * Unload a kexec image.
+ *
+ * This prevents a KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH image from
+ * being executed.  The crash images are not cleared from the crash
+ * region.
+ */
+int xc_kexec_unload(xc_interface *xch, int type);
+
+/*
+ * Find out whether the image has been succesfully loaded.
+ *
+ * The type can be either KEXEC_TYPE_DEFAULT or KEXEC_TYPE_CRASH.
+ * If zero is returned, that means no image is loaded for the type.
+ * If one is returned, that means an image is loaded for the type.
+ * Otherwise, negative return value indicates error.
+ */
+int xc_kexec_status(xc_interface *xch, int type);
+
+typedef xenpf_resource_entry_t xc_resource_entry_t;
+
+/*
+ * Generic resource operation which contains multiple non-preemptible
+ * resource access entries that passed to xc_resource_op().
+ */
+struct xc_resource_op {
+    uint64_t result;        /* on return, check this field first */
+    uint32_t cpu;           /* which cpu to run */
+    uint32_t nr_entries;    /* number of resource entries */
+    xc_resource_entry_t *entries;
+};
+
+typedef struct xc_resource_op xc_resource_op_t;
+int xc_resource_op(xc_interface *xch, uint32_t nr_ops, xc_resource_op_t *ops);
+
+#if defined(__i386__) || defined(__x86_64__)
+enum xc_psr_cmt_type {
+    XC_PSR_CMT_L3_OCCUPANCY,
+    XC_PSR_CMT_TOTAL_MEM_COUNT,
+    XC_PSR_CMT_LOCAL_MEM_COUNT,
+};
+typedef enum xc_psr_cmt_type xc_psr_cmt_type;
+
+enum xc_psr_type {
+    XC_PSR_CAT_L3_CBM      = 1,
+    XC_PSR_CAT_L3_CBM_CODE = 2,
+    XC_PSR_CAT_L3_CBM_DATA = 3,
+    XC_PSR_CAT_L2_CBM      = 4,
+    XC_PSR_MBA_THRTL       = 5,
+};
+typedef enum xc_psr_type xc_psr_type;
+
+enum xc_psr_feat_type {
+    XC_PSR_CAT_L3,
+    XC_PSR_CAT_L2,
+    XC_PSR_MBA,
+};
+typedef enum xc_psr_feat_type xc_psr_feat_type;
+
+union xc_psr_hw_info {
+    struct {
+        uint32_t cos_max;
+        uint32_t cbm_len;
+        bool     cdp_enabled;
+    } cat;
+
+    struct {
+        uint32_t cos_max;
+        uint32_t thrtl_max;
+        bool     linear;
+    } mba;
+};
+typedef union xc_psr_hw_info xc_psr_hw_info;
+
+int xc_psr_cmt_attach(xc_interface *xch, uint32_t domid);
+int xc_psr_cmt_detach(xc_interface *xch, uint32_t domid);
+int xc_psr_cmt_get_domain_rmid(xc_interface *xch, uint32_t domid,
+                               uint32_t *rmid);
+int xc_psr_cmt_get_total_rmid(xc_interface *xch, uint32_t *total_rmid);
+int xc_psr_cmt_get_l3_upscaling_factor(xc_interface *xch,
+                                       uint32_t *upscaling_factor);
+int xc_psr_cmt_get_l3_event_mask(xc_interface *xch, uint32_t *event_mask);
+int xc_psr_cmt_get_l3_cache_size(xc_interface *xch, uint32_t cpu,
+                                 uint32_t *l3_cache_size);
+int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, uint32_t cpu,
+                        uint32_t psr_cmt_type, uint64_t *monitor_data,
+                        uint64_t *tsc);
+int xc_psr_cmt_enabled(xc_interface *xch);
+
+int xc_psr_set_domain_data(xc_interface *xch, uint32_t domid,
+                           xc_psr_type type, uint32_t target,
+                           uint64_t data);
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+                           xc_psr_type type, uint32_t target,
+                           uint64_t *data);
+int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
+                       xc_psr_feat_type type, xc_psr_hw_info *hw_info);
+
+typedef struct xc_cpu_policy xc_cpu_policy_t;
+
+/* Create and free a xc_cpu_policy object. */
+xc_cpu_policy_t *xc_cpu_policy_init(void);
+void xc_cpu_policy_destroy(xc_cpu_policy_t *policy);
+
+/* Retrieve a system policy, or get/set a domains policy. */
+int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx,
+                             xc_cpu_policy_t *policy);
+int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
+                             xc_cpu_policy_t *policy);
+int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
+                             xc_cpu_policy_t *policy);
+
+/* Manipulate a policy via architectural representations. */
+int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t *policy,
+                            xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves,
+                            xen_msr_entry_t *msrs, uint32_t *nr_msrs);
+int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t *policy,
+                               const xen_cpuid_leaf_t *leaves,
+                               uint32_t nr);
+int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy,
+                              const xen_msr_entry_t *msrs, uint32_t nr);
+
+/* Compatibility calculations. */
+bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host,
+                                 xc_cpu_policy_t *guest);
+
+int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
+int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
+                          uint32_t *nr_features, uint32_t *featureset);
+
+int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves,
+                           uint32_t *nr_msrs);
+int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid,
+                             uint32_t nr_leaves, xen_cpuid_leaf_t *leaves,
+                             uint32_t nr_msrs, xen_msr_entry_t *msrs,
+                             uint32_t *err_leaf_p, uint32_t *err_subleaf_p,
+                             uint32_t *err_msr_p);
+
+uint32_t xc_get_cpu_featureset_size(void);
+
+enum xc_static_cpu_featuremask {
+    XC_FEATUREMASK_KNOWN,
+    XC_FEATUREMASK_SPECIAL,
+    XC_FEATUREMASK_PV_MAX,
+    XC_FEATUREMASK_PV_DEF,
+    XC_FEATUREMASK_HVM_SHADOW_MAX,
+    XC_FEATUREMASK_HVM_SHADOW_DEF,
+    XC_FEATUREMASK_HVM_HAP_MAX,
+    XC_FEATUREMASK_HVM_HAP_DEF,
+};
+const uint32_t *xc_get_static_cpu_featuremask(enum xc_static_cpu_featuremask);
+
+#endif
+
+int xc_livepatch_upload(xc_interface *xch,
+                        char *name, unsigned char *payload, uint32_t size);
+
+int xc_livepatch_get(xc_interface *xch,
+                     char *name,
+                     xen_livepatch_status_t *status);
+
+/*
+ * Get a number of available payloads and get actual total size of
+ * the payloads' name and metadata arrays.
+ *
+ * This functions is typically executed first before the xc_livepatch_list()
+ * to obtain the sizes and correctly allocate all necessary data resources.
+ *
+ * The return value is zero if the hypercall completed successfully.
+ *
+ * If there was an error performing the sysctl operation, the return value
+ * will contain the hypercall error code value.
+ */
+int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
+                                uint32_t *name_total_size,
+                                uint32_t *metadata_total_size);
+
+/*
+ * The heart of this function is to get an array of the following objects:
+ *   - xen_livepatch_status_t: states and return codes of payloads
+ *   - name: names of payloads
+ *   - len: lengths of corresponding payloads' names
+ *   - metadata: payloads' metadata
+ *   - metadata_len: lengths of corresponding payloads' metadata
+ *
+ * However it is complex because it has to deal with the hypervisor
+ * returning some of the requested data or data being stale
+ * (another hypercall might alter the list).
+ *
+ * The parameters that the function expects to contain data from
+ * the hypervisor are: 'info', 'name', and 'len'. The 'done' and
+ * 'left' are also updated with the number of entries filled out
+ * and respectively the number of entries left to get from hypervisor.
+ *
+ * It is expected that the caller of this function will first issue the
+ * xc_livepatch_list_get_sizes() in order to obtain total sizes of names
+ * and all metadata as well as the current number of payload entries.
+ * The total sizes are required and supplied via the 'name_total_size' and
+ * 'metadata_total_size' parameters.
+ *
+ * The 'max' is to be provided by the caller with the maximum number of
+ * entries that 'info', 'name', 'len', 'metadata' and 'metadata_len' arrays
+ * can be filled up with.
+ *
+ * Each entry in the 'info' array is expected to be of xen_livepatch_status_t
+ * structure size.
+ *
+ * Each entry in the 'name' array may have an arbitrary size.
+ *
+ * Each entry in the 'len' array is expected to be of uint32_t size.
+ *
+ * Each entry in the 'metadata' array may have an arbitrary size.
+ *
+ * Each entry in the 'metadata_len' array is expected to be of uint32_t size.
+ *
+ * The return value is zero if the hypercall completed successfully.
+ * Note that the return value is _not_ the amount of entries filled
+ * out - that is saved in 'done'.
+ *
+ * If there was an error performing the operation, the return value
+ * will contain an negative -EXX type value. The 'done' and 'left'
+ * will contain the number of entries that had been succesfully
+ * retrieved (if any).
+ */
+int xc_livepatch_list(xc_interface *xch, const unsigned int max,
+                      const unsigned int start,
+                      struct xen_livepatch_status *info,
+                      char *name, uint32_t *len,
+                      const uint32_t name_total_size,
+                      char *metadata, uint32_t *metadata_len,
+                      const uint32_t metadata_total_size,
+                      unsigned int *done, unsigned int *left);
+
+/*
+ * The operations are asynchronous and the hypervisor may take a while
+ * to complete them. The `timeout` offers an option to expire the
+ * operation if it could not be completed within the specified time
+ * (in ns). Value of 0 means let hypervisor decide the best timeout.
+ * The `flags` allows to pass extra parameters to the actions.
+ */
+int xc_livepatch_apply(xc_interface *xch, char *name, uint32_t timeout, uint32_t flags);
+int xc_livepatch_revert(xc_interface *xch, char *name, uint32_t timeout, uint32_t flags);
+int xc_livepatch_unload(xc_interface *xch, char *name, uint32_t timeout, uint32_t flags);
+int xc_livepatch_replace(xc_interface *xch, char *name, uint32_t timeout, uint32_t flags);
+
+/*
+ * Ensure cache coherency after memory modifications. A call to this function
+ * is only required on ARM as the x86 architecture provides cache coherency
+ * guarantees. Calling this function on x86 is allowed but has no effect.
+ */
+int xc_domain_cacheflush(xc_interface *xch, uint32_t domid,
+                         xen_pfn_t start_pfn, xen_pfn_t nr_pfns);
+
+/* Compat shims */
+#include "xenctrl_compat.h"
+
+#endif /* XENCTRL_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xendevicemodel.h 4.16.1-1/tools/include/xendevicemodel.h
--- 4.14.3+32-g9de3671772-1/tools/include/xendevicemodel.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xendevicemodel.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,388 @@
+/*
+ * Copyright (c) 2017 Citrix Systems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef XENDEVICEMODEL_H
+#define XENDEVICEMODEL_H
+
+#include <stdint.h>
+
+#include <xen/xen.h>
+#include <xen/hvm/dm_op.h>
+#include <xen/hvm/hvm_op.h>
+
+/* Callers who don't care don't need to #include <xentoollog.h> */
+struct xentoollog_logger;
+
+typedef struct xendevicemodel_handle xendevicemodel_handle;
+
+xendevicemodel_handle *xendevicemodel_open(struct xentoollog_logger *logger,
+                                           unsigned int open_flags);
+
+int xendevicemodel_close(xendevicemodel_handle *dmod);
+
+/*
+ * IOREQ Server API. (See section on IOREQ Servers in public/hvm_op.h).
+ */
+
+/**
+ * This function instantiates an IOREQ Server.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm handle_bufioreq how should the IOREQ Server handle buffered
+ *                       requests (HVM_IOREQSRV_BUFIOREQ_*)?
+ * @parm id pointer to an ioservid_t to receive the IOREQ Server id.
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_create_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, int handle_bufioreq,
+    ioservid_t *id);
+
+/**
+ * This function retrieves the necessary information to allow an
+ * emulator to use an IOREQ Server.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @parm ioreq_gfn pointer to a xen_pfn_t to receive the synchronous ioreq
+ *                  gfn. (May be NULL if not required)
+ * @parm bufioreq_gfn pointer to a xen_pfn_t to receive the buffered ioreq
+ *                    gfn. (May be NULL if not required)
+ * @parm bufioreq_port pointer to a evtchn_port_t to receive the buffered
+ *                     ioreq event channel. (May be NULL if not required)
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_get_ioreq_server_info(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id,
+    xen_pfn_t *ioreq_gfn, xen_pfn_t *bufioreq_gfn,
+    evtchn_port_t *bufioreq_port);
+
+/**
+ * This function registers a range of memory or I/O ports for emulation.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @parm is_mmio is this a range of ports or memory
+ * @parm start start of range
+ * @parm end end of range (inclusive).
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_map_io_range_to_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id, int is_mmio,
+    uint64_t start, uint64_t end);
+
+/**
+ * This function deregisters a range of memory or I/O ports for emulation.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @parm is_mmio is this a range of ports or memory
+ * @parm start start of range
+ * @parm end end of range (inclusive).
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_unmap_io_range_from_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id, int is_mmio,
+    uint64_t start, uint64_t end);
+
+/**
+ * This function registers/deregisters a memory type for emulation.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced.
+ * @parm id the IOREQ Server id.
+ * @parm type the memory type to be emulated. For now, only HVMMEM_ioreq_server
+ *            is supported, and in the future new types can be introduced, e.g.
+ *            HVMMEM_ioreq_serverX mapped to ioreq server X.
+ * @parm flags operations to be emulated; 0 for unmap. For now, only write
+ *             operations will be emulated and can be extended to emulate
+ *             read ones in the future.
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_map_mem_type_to_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id, uint16_t type,
+    uint32_t flags);
+
+/**
+ * This function registers a PCI device for config space emulation.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @parm segment the PCI segment of the device
+ * @parm bus the PCI bus of the device
+ * @parm device the 'slot' number of the device
+ * @parm function the function number of the device
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_map_pcidev_to_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id,
+    uint16_t segment, uint8_t bus, uint8_t device, uint8_t function);
+
+/**
+ * This function deregisters a PCI device for config space emulation.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @parm segment the PCI segment of the device
+ * @parm bus the PCI bus of the device
+ * @parm device the 'slot' number of the device
+ * @parm function the function number of the device
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_unmap_pcidev_from_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id,
+    uint16_t segment, uint8_t bus, uint8_t device, uint8_t function);
+
+/**
+ * This function destroys an IOREQ Server.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_destroy_ioreq_server(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id);
+
+/**
+ * This function sets IOREQ Server state. An IOREQ Server
+ * will not be passed emulation requests until it is in
+ * the enabled state.
+ * Note that the contents of the ioreq_gfn and bufioreq_gfn are
+ * not meaningful until the IOREQ Server is in the enabled state.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm id the IOREQ Server id.
+ * @parm enabled the state.
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_set_ioreq_server_state(
+    xendevicemodel_handle *dmod, domid_t domid, ioservid_t id, int enabled);
+
+/**
+ * This function sets the level of INTx pin of an emulated PCI device.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm segment the PCI segment number of the emulated device
+ * @parm bus the PCI bus number of the emulated device
+ * @parm device the PCI device number of the emulated device
+ * @parm intx the INTx pin to modify (0 => A .. 3 => D)
+ * @parm level the level (1 for asserted, 0 for de-asserted)
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_set_pci_intx_level(
+    xendevicemodel_handle *dmod, domid_t domid, uint16_t segment,
+    uint8_t bus, uint8_t device, uint8_t intx, unsigned int level);
+
+/**
+ * This function sets the level of an ISA IRQ line.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm irq the IRQ number (0 - 15)
+ * @parm level the level (1 for asserted, 0 for de-asserted)
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_set_isa_irq_level(
+    xendevicemodel_handle *dmod, domid_t domid, uint8_t irq,
+    unsigned int level);
+
+int xendevicemodel_set_irq_level(
+    xendevicemodel_handle *dmod, domid_t domid, unsigned int irq,
+    unsigned int level);
+
+/**
+ * This function maps a PCI INTx line to a an IRQ line.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm line the INTx line (0 => A .. 3 => B)
+ * @parm irq the IRQ number (0 - 15)
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_set_pci_link_route(
+    xendevicemodel_handle *dmod, domid_t domid, uint8_t link, uint8_t irq);
+
+/**
+ * This function injects an MSI into a guest.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm msi_addr the MSI address (0xfeexxxxx)
+ * @parm msi_data the MSI data
+ * @return 0 on success, -1 on failure.
+*/
+int xendevicemodel_inject_msi(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t msi_addr,
+    uint32_t msi_data);
+
+/**
+ * This function enables tracking of changes in the VRAM area.
+ *
+ * The following is done atomically:
+ * - get the dirty bitmap since the last call.
+ * - set up dirty tracking area for period up to the next call.
+ * - clear the dirty tracking area.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm first_pfn the start of the area to track
+ * @parm nr the number of pages to track
+ * @parm dirty_bitmal a pointer to the bitmap to be updated
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_track_dirty_vram(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
+    uint32_t nr, unsigned long *dirty_bitmap);
+
+/**
+ * This function notifies the hypervisor that a set of contiguous
+ * domain pages have been modified.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm first_pfn the start of the modified area
+ * @parm nr the number of pages modified
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_modified_memory(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
+    uint32_t nr);
+
+/**
+ * This function notifies the hypervisor that a set of discontiguous
+ * domain pages have been modified.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm extents an array of extent structs, which each hold
+                 a start_pfn and nr (number of pfns).
+ * @parm nr the number of extents in the array
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_modified_memory_bulk(
+    xendevicemodel_handle *dmod, domid_t domid,
+    struct xen_dm_op_modified_memory_extent extents[], uint32_t nr);
+
+/**
+ * This function notifies the hypervisor that a set of domain pages
+ * are to be treated in a specific way. (See the definition of
+ * hvmmem_type_t).
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm mem_type determines how the set is to be treated
+ * @parm first_pfn the start of the set
+ * @parm nr the number of pages in the set
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_set_mem_type(
+    xendevicemodel_handle *dmod, domid_t domid, hvmmem_type_t mem_type,
+    uint64_t first_pfn, uint32_t nr);
+
+/**
+ * This function injects an event into a vCPU to take effect the next
+ * time it resumes.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm vcpu the vcpu id
+ * @parm vector the interrupt vector
+ * @parm type the event type (see the definition of enum x86_event_type)
+ * @parm error_code the error code or ~0 to skip
+ * @parm insn_len the instruction length
+ * @parm extra type-specific extra data (%cr2 for #PF, pending_dbg for #DB)
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_inject_event(
+    xendevicemodel_handle *dmod, domid_t domid, int vcpu, uint8_t vector,
+    uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t extra);
+
+/**
+ * Shuts the domain down.
+ *
+ * @parm reason usually enum sched_shutdown_reason, see xen/sched.h
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_shutdown(
+    xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);
+
+/*
+ * Relocate GFNs for the specified domain.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm size Number of GFNs to process
+ * @parm src_gfn Starting GFN to relocate
+ * @parm dst_gfn Starting GFN where GFNs should be relocated
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_relocate_memory(
+    xendevicemodel_handle *dmod, domid_t domid, uint32_t size, uint64_t src_gfn,
+    uint64_t dst_gfn);
+
+/**
+ * Pins caching type of RAM space.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm start Start gfn
+ * @parm end End gfn
+ * @parm type XEN_DMOP_MEM_CACHEATTR_*
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_pin_memory_cacheattr(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t start, uint64_t end,
+    uint32_t type);
+
+/**
+ * Query for the number of vCPUs that a domain has.
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced.
+ * @parm vcpus Number of vcpus.
+ * @return 0 on success and fills @p vcpus, or -1 on failure.
+ */
+int xendevicemodel_nr_vcpus(
+    xendevicemodel_handle *dmod, domid_t domid, unsigned int *vcpus);
+
+/**
+ * This function restricts the use of this handle to the specified
+ * domain.
+ *
+ * @parm dmod handle to the open devicemodel interface
+ * @parm domid the domain id
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_restrict(xendevicemodel_handle *dmod, domid_t domid);
+
+#endif /* XENDEVICEMODEL_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xenevtchn.h 4.16.1-1/tools/include/xenevtchn.h
--- 4.14.3+32-g9de3671772-1/tools/include/xenevtchn.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xenevtchn.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,186 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Split off from:
+ * xenctrl.h
+ *
+ * A library for low-level access to the Xen control interfaces.
+ *
+ * Copyright (c) 2003-2004, K A Fraser.
+ */
+
+#ifndef XENEVTCHN_H
+#define XENEVTCHN_H
+
+#include <stdint.h>
+
+#include <xen/event_channel.h>
+
+/* A port identifier is guaranteed to fit in 31 bits. */
+typedef int xenevtchn_port_or_error_t;
+
+typedef struct xenevtchn_handle xenevtchn_handle;
+
+/* Callers who don't care don't need to #include <xentoollog.h> */
+struct xentoollog_logger;
+
+/*
+ * EVENT CHANNEL FUNCTIONS
+ *
+ * None of these do any logging.
+ */
+
+/*
+ * Opens the evtchn device node.  Return a handle to the event channel
+ * driver, or NULL on failure, in which case errno will be set
+ * appropriately.
+ *
+ * On fork(2):
+ *
+ *   After fork, a child process must not use any opened evtchn handle
+ *   inherited from their parent.  This includes operations such as
+ *   poll() on the underlying file descriptor.  Calling xenevtchn_close()
+ *   is the only safe operation on a xenevtchn_handle which has been
+ *   inherited.
+ *
+ *   The child must open a new handle if they want to interact with
+ *   evtchn.
+ *
+ * On exec(2):
+ *
+ *   Wherever possible, the device node will be opened with O_CLOEXEC,
+ *   so it is not inherited by the subsequent program.
+ *
+ *   However the XENEVTCHN_NO_CLOEXEC flag may be used to avoid opening
+ *   the device node with O_CLOEXEC.  This is intended for use by
+ *   daemons which support a self-reexec method of updating themselves.
+ *
+ *   In this case, the updated daemon should pass the underlying file
+ *   descriptor it inherited to xenevtchn_fdopen() to reconstruct the
+ *   library handle.
+ */
+
+/* Don't set O_CLOEXEC when opening event channel driver node. */
+#define XENEVTCHN_NO_CLOEXEC (1 << 0)
+
+xenevtchn_handle *xenevtchn_open(struct xentoollog_logger *logger,
+                                 unsigned int flags);
+
+/* Flag XENEVTCHN_NO_CLOEXEC is rejected by xenevtchn_fdopen(). */
+xenevtchn_handle *xenevtchn_fdopen(struct xentoollog_logger *logger,
+                                    int fd, unsigned open_flags);
+
+/*
+ * Close a handle previously allocated with xenevtchn_{,fd}open().
+ */
+int xenevtchn_close(xenevtchn_handle *xce);
+
+/*
+ * Return an fd that can be select()ed on.
+ *
+ * Note that due to bugs, setting this fd to non blocking may not
+ * work: you would hope that it would result in xenevtchn_pending
+ * failing with EWOULDBLOCK if there are no events signaled, but in
+ * fact it may block.  (Bug is present in at least Linux 3.12, and
+ * perhaps on other platforms or later version.)
+ *
+ * To be safe, you must use poll() or select() before each call to
+ * xenevtchn_pending.  If you have multiple threads (or processes)
+ * sharing a single xce handle this will not work, and there is no
+ * straightforward workaround.  Please design your program some other
+ * way.
+ */
+int xenevtchn_fd(xenevtchn_handle *xce);
+
+/*
+ * Notify the given event channel. Returns -1 on failure, in which case
+ * errno will be set appropriately.
+ */
+int xenevtchn_notify(xenevtchn_handle *xce, evtchn_port_t port);
+
+/*
+ * Returns a new event port awaiting interdomain connection from the given
+ * domain ID, or -1 on failure, in which case errno will be set appropriately.
+ */
+xenevtchn_port_or_error_t
+xenevtchn_bind_unbound_port(xenevtchn_handle *xce, uint32_t domid);
+
+/*
+ * Returns a new event port bound to the remote port for the given domain ID,
+ * or -1 on failure, in which case errno will be set appropriately.
+ */
+xenevtchn_port_or_error_t
+xenevtchn_bind_interdomain(xenevtchn_handle *xce, uint32_t domid,
+                           evtchn_port_t remote_port);
+
+/*
+ * Bind an event channel to the given VIRQ. Returns the event channel bound to
+ * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
+ */
+xenevtchn_port_or_error_t
+xenevtchn_bind_virq(xenevtchn_handle *xce, unsigned int virq);
+
+/*
+ * Unbind the given event channel. Returns -1 on failure, in which case errno
+ * will be set appropriately.
+ */
+int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port_t port);
+
+/*
+ * Return the next event channel to become pending, or -1 on failure, in which
+ * case errno will be set appropriately.
+ *
+ * At the hypervisor level the event channel will have been masked,
+ * and then cleared, by the underlying machinery (evtchn kernel
+ * driver, or equivalent).  So if the event channel is signaled again
+ * after it is returned here, it will be queued up, and delivered
+ * again after you unmask it.  (See the documentation in the Xen
+ * public header event_channel.h.)
+ *
+ * On receiving the notification from xenevtchn_pending, you should
+ * normally: check (by other means) what work needs doing; do the
+ * necessary work (if any); unmask the event channel with
+ * xenevtchn_unmask (if you want to receive any further
+ * notifications).
+ */
+xenevtchn_port_or_error_t
+xenevtchn_pending(xenevtchn_handle *xce);
+
+/*
+ * Unmask the given event channel. Returns -1 on failure, in which case errno
+ * will be set appropriately.
+ */
+int xenevtchn_unmask(xenevtchn_handle *xce, evtchn_port_t port);
+
+/**
+ * This function restricts the use of this handle to the specified
+ * domain.
+ *
+ * @parm xce handle to the open evtchn interface
+ * @parm domid the domain id
+ * @return 0 on success, -1 on failure with errno set appropriately.
+ */
+int xenevtchn_restrict(xenevtchn_handle *xce, domid_t domid);
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xen-foreign/reference.size 4.16.1-1/tools/include/xen-foreign/reference.size
--- 4.14.3+32-g9de3671772-1/tools/include/xen-foreign/reference.size	2021-11-23 12:30:09.000000000 +0000
+++ 4.16.1-1/tools/include/xen-foreign/reference.size	2022-04-12 12:21:23.000000000 +0000
@@ -4,8 +4,8 @@ structs                   |   arm32   ar
 start_info                |       -       -    1112    1168
 trap_info                 |       -       -       8      16
 cpu_user_regs             |       -       -      68     200
-vcpu_guest_core_regs      |     304     304       -       -
-vcpu_guest_context        |     344     344    2800    5168
+vcpu_guest_core_regs      |     312     312       -       -
+vcpu_guest_context        |     352     352    2800    5168
 arch_vcpu_info            |       0       0      24      16
 vcpu_time_info            |      32      32      32      32
 vcpu_info                 |      48      48      64      64
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xenforeignmemory.h 4.16.1-1/tools/include/xenforeignmemory.h
--- 4.14.3+32-g9de3671772-1/tools/include/xenforeignmemory.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xenforeignmemory.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,207 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef XENFOREIGNMEMORY_H
+#define XENFOREIGNMEMORY_H
+
+/*
+ * This library allows you to map foreign domain memory, subject to
+ * permissions for both the process and the domain in which the
+ * process runs.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include <xen/xen.h>
+
+/* Callers who don't care don't need to #include <xentoollog.h> */
+struct xentoollog_logger;
+
+typedef struct xenforeignmemory_handle xenforeignmemory_handle;
+
+/*
+ * Return a handle onto the foreign memory mapping driver.  Logs errors.
+ *
+ * Note: After fork(2) a child process must not use any opened
+ * foreignmemory handle inherited from their parent, nor access any
+ * grant mapped areas associated with that handle.
+ *
+ * The child must open a new handle if they want to interact with
+ * foreignmemory.
+ *
+ * Calling exec(2) in a child will safely (and reliably) reclaim any
+ * resources which were allocated via a xenforeignmemory_handle in the
+ * parent.
+ *
+ * A child which does not call exec(2) may safely call
+ * xenforeignmemory_close() on a xenforeignmemory_handle inherited
+ * from their parent. This will attempt to reclaim any resources
+ * associated with that handle. Note that in some implementations this
+ * reclamation may not be completely effective, in this case any
+ * affected resources remain allocated.
+ *
+ * Calling xenforeignmemory_close() is the only safe operation on a
+ * xenforeignmemory_handle which has been inherited.
+ */
+xenforeignmemory_handle *xenforeignmemory_open(struct xentoollog_logger *logger,
+                                               unsigned open_flags);
+
+/*
+ * Close a handle previously allocated with xenforeignmemory_open().
+ *
+ * Under normal circumstances (i.e. not in the child after a fork)
+ * xenforeignmemory_unmap() should be used on all mappings allocated
+ * by xenforeignmemory_map() prior to closing the handle in order to
+ * free up resources associated with those mappings.
+ *
+ * This is the only function which may be safely called on a
+ * xenforeignmemory_handle in a child after a
+ * fork. xenforeignmemory_unmap() must not be called under such
+ * circumstances.
+ */
+int xenforeignmemory_close(xenforeignmemory_handle *fmem);
+
+/*
+ * Maps a range within one domain to a local address range.  Mappings
+ * must be unmapped with xenforeignmemory_unmap and should follow the
+ * same rules as mmap regarding page alignment.
+ *
+ * prot is as for mmap(2).
+ *
+ * @arr is an array of @pages gfns to be mapped linearly in the local
+ * address range. @err is an (optional) output array used to report
+ * per-page errors, as errno values.
+ *
+ * If @err is given (is non-NULL) then the mapping may partially
+ * succeed and return a valid pointer while also using @err to
+ * indicate the success (0) or failure (errno value) of the individual
+ * pages. The global errno thread local variable is not valid in this
+ * case.
+ *
+ * If @err is not given (is NULL) then on failure to map any page any
+ * successful mappings will be undone and NULL will be returned. errno
+ * will be set to correspond to the first failure (which may not be
+ * the most critical).
+ *
+ * It is also possible to return NULL due to a complete failure,
+ * i.e. failure to even attempt the mapping, in this case the global
+ * errno will have been set and the contents of @err (if given) is
+ * invalid.
+ *
+ * Note that it is also possible to return non-NULL with the contents
+ * of @err indicating failure to map every page.
+ */
+void *xenforeignmemory_map(xenforeignmemory_handle *fmem, uint32_t dom,
+                           int prot, size_t pages,
+                           const xen_pfn_t arr[/*pages*/], int err[/*pages*/]);
+
+/*
+ * Almost like the previous one but also accepts two additional parameters:
+ *
+ * @addr is used as a hint address for foreign map placement (see mmap(2)).
+ * @flags is a set of additional flags as for mmap(2). Not all of the flag
+ * combinations are possible due to implementation details on different
+ * platforms.
+ */
+void *xenforeignmemory_map2(xenforeignmemory_handle *fmem, uint32_t dom,
+                            void *addr, int prot, int flags, size_t pages,
+                            const xen_pfn_t arr[/*pages*/], int err[/*pages*/]);
+
+/*
+ * Unmap a mapping previous created with xenforeignmemory_map().
+ *
+ * Returns 0 on success on failure sets errno and returns -1.
+ */
+int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+                           void *addr, size_t pages);
+
+/**
+ * This function restricts the use of this handle to the specified
+ * domain.
+ *
+ * @parm fmem handle to the open foreignmemory interface
+ * @parm domid the domain id
+ * @return 0 on success, -1 on failure.
+ */
+int xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
+                              domid_t domid);
+
+typedef struct xenforeignmemory_resource_handle xenforeignmemory_resource_handle;
+
+/**
+ * This function maps a guest resource.
+ *
+ * @parm fmem handle to the open foreignmemory interface
+ * @parm domid the domain id
+ * @parm type the resource type
+ * @parm id the type-specific resource identifier
+ * @parm frame base frame index within the resource
+ * @parm nr_frames number of frames to map
+ * @parm paddr pointer to an address passed through to mmap(2)
+ * @parm prot passed through to mmap(2)
+ * @parm POSIX-only flags passed through to mmap(2)
+ * @return pointer to foreignmemory resource handle on success, NULL on
+ *         failure
+ *
+ * *paddr is used, on entry, as a hint address for foreign map placement
+ * (see mmap(2)) so should be set to NULL if no specific placement is
+ * required. On return *paddr contains the address where the resource is
+ * mapped.
+ * As for xenforeignmemory_map2() flags is a set of additional flags
+ * for mmap(2). Not all of the flag combinations are possible due to
+ * implementation details on different platforms.
+ */
+xenforeignmemory_resource_handle *xenforeignmemory_map_resource(
+    xenforeignmemory_handle *fmem, domid_t domid, unsigned int type,
+    unsigned int id, unsigned long frame, unsigned long nr_frames,
+    void **paddr, int prot, int flags);
+
+/**
+ * This function releases a previously acquired resource.
+ *
+ * @parm fmem handle to the open foreignmemory interface
+ * @parm fres handle to the acquired resource
+ *
+ * Returns 0 on success on failure sets errno and returns -1.
+ */
+int xenforeignmemory_unmap_resource(
+    xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres);
+
+/**
+ * Determine the maximum size of a specific resource.
+ *
+ * @parm fmem handle to the open foreignmemory interface
+ * @parm domid the domain id
+ * @parm type the resource type
+ * @parm id the type-specific resource identifier
+ *
+ * Return 0 on success and fills in *size, with a value in bytes.  Sets errno
+ * and return -1 on error.
+ */
+int xenforeignmemory_resource_size(
+    xenforeignmemory_handle *fmem, domid_t domid, unsigned int type,
+    unsigned int id, size_t *size);
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -pruN 4.14.3+32-g9de3671772-1/tools/include/xengnttab.h 4.16.1-1/tools/include/xengnttab.h
--- 4.14.3+32-g9de3671772-1/tools/include/xengnttab.h	1970-01-01 00:00:00.000000000 +0000
+++ 4.16.1-1/tools/include/xengnttab.h	2022-04-12 12:21:23.000000000 +0000
@@ -0,0 +1,470 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Split off from:
+ * xenctrl.h
+ *
+ * A library for low-level access to the Xen control interfaces.
+ *
+ * Copyright (c) 2007-2008, D G Murray <Derek.Murray@cl.cam.ac.uk>
+ * Copyright (c) 2018, Oleksandr Andrushchenko, EPAM Systems Inc.
+ */
+#ifndef XENGNTTAB_H
+#define XENGNTTAB_H
+
+#include <stdint.h>
+
+#include <xen/grant_table.h>
+#include <xen/event_channel.h>
+
+/* Callers who don't care don't need to #include <xentoollog.h> */
+struct xentoollog_logger;
+
+/*
+ * PRODUCING AND CONSUMING GRANT REFERENCES
+ * ========================================
+ *
+ * The xengnttab library contains two distinct interfaces, each with
+ * their own distinct handle type and entry points. The represent the
+ * two sides of the grant table interface, producer (gntshr) and
+ * consumer (gnttab).
+ *
+ * The xengnttab_* interfaces take a xengnttab_handle and provide
+ * mechanisms for consuming (i.e. mapping or copying to/from) grant
+ * references provided by a peer.
+ *
+ * The xengntshr_* interfaces take a xengntshr_handle and provide a
+ * mechanism to produce grantable memory and grant references to that
+ * memory, which can be handed to some peer.
+ *
+ * UNMAP NOTIFICATION
+ * ==================
+ *
+ * The xengnt{tab,shr}_*_notify interfaces implement a cooperative
+ * interface which is intended to allow the underlying kernel
+ * interfaces to attempt to notify the peer to perform graceful
+ * teardown upon failure (i.e. crash or exit) of the process on their
+ * end.
+ *
+ * These interfaces operate on a single page only and are intended for
+ * use on the main shared-ring page of a protocol. It is assumed that
+ * on teardown both ends would automatically teardown all grants
+ * associated with the protocol in addition to the shared ring itself.
+ *
+ * Each end is able to optionally nominate a byte offset within the
+ * shared page or an event channel or both. On exit of the process the
+ * underlying kernel driver will zero the byte at the given offset and
+ * signal the event channel.
+ *
+ * The event channel can be the same event channel used for regular
+ * ring progress notifications, or may be a dedicated event channel.
+ *
+ * Both ends may share the same notification byte offset within the
+ * shared page, or may have dedicated "client" and "server" status
+ * bytes.
+ *
+ * Since the byte is cleared on shutdown the protocol mus