summaryrefslogtreecommitdiff
path: root/libre
diff options
context:
space:
mode:
authorcoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-10-25 00:56:54 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-10-25 00:58:32 -0300
commit3e0bcc5312915db3e993fe0684fd74d0c8624e0a (patch)
tree9f728629b34b9572e9c34157209db4082c3e1abb /libre
parenta179b2d9427ed31a04a9eff96d28e36b5bbd9bda (diff)
mv xen to [libre] and mv xen-docs to [pcr]
Diffstat (limited to 'libre')
-rw-r--r--libre/xen/09_xen231
-rw-r--r--libre/xen/ChangeLog169
-rw-r--r--libre/xen/PKGBUILD340
-rw-r--r--libre/xen/ati-passthrough.patch415
-rw-r--r--libre/xen/efi-xen.cfg7
-rw-r--r--libre/xen/grub.conf3
-rw-r--r--libre/xen/ovmf.patch12
-rw-r--r--libre/xen/patch-gcc6-etherboot-ath9k-9287-array.patch68
-rw-r--r--libre/xen/patch-gcc6-etherboot-e1000_phy.c.patch20
-rw-r--r--libre/xen/patch-gcc6-etherboot-igb_phy.c.patch20
-rw-r--r--libre/xen/patch-gcc6-etherboot-rm-unused-string-functions.patch257
-rw-r--r--libre/xen/patch-gcc6-etherboot-via-rhine.c.patch21
-rw-r--r--libre/xen/patch-gcc6-etherboot-via-velocity.c.patch12
-rw-r--r--libre/xen/patch-gcc6-ovmf-build.sh.patch12
-rw-r--r--libre/xen/tmpfiles.d-xen.conf2
-rw-r--r--libre/xen/xen.conf19
-rw-r--r--libre/xen/xen.install75
17 files changed, 1683 insertions, 0 deletions
diff --git a/libre/xen/09_xen b/libre/xen/09_xen
new file mode 100644
index 000000000..47d357d99
--- /dev/null
+++ b/libre/xen/09_xen
@@ -0,0 +1,231 @@
+#!/usr/bin/env bash
+
+##
+## grub-mkconfig helper script specific to Parabola GNU/Linux-libre
+## Contributed by "Keshav Amburay" <the ddoott ridikulus ddoott rat aatt geemmayil ddoott ccoomm>
+## Rebranded for Parabola by "André Silva" <emulatorman@parabola.nu>
+## Updated on 08 February 2014
+##
+## Script based on do_grub_config() function in Arch (the GNU/Linux distribution) Archboot ISO Installer/Setup script
+## Some parts taken from /etc/grub.d/10_linux script shipped by GRUB(2) upstream
+##
+## This script can be freely distributed and/or modified
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This script 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 General Public License for more details.
+##
+
+## Adapted for use with the xen package, to ensure feature comparity
+## Modified by "David Sutton" <kantras - gmail com>
+
+_FUNC_GRUB_FILE_PRESENT() {
+
+ [[ -z "${GRUB_PLATFORM}" ]] && GRUB_PLATFORM="x86"
+
+ if [[ "${GRUB_PLATFORM}" == "x86" ]]; then
+ check="--is-x86-linux32"
+ elif [[ "${GRUB_PLATFORM}" == "i386-xen-pae" ]]; then
+ check="--is-i386-xen-pae-domu"
+ elif [[ "${GRUB_PLATFORM}" == "x86_64-xen" ]]; then
+ check="--is-x86_64-xen-domu"
+ else
+ check="--is-${GRUB_PLATFORM}-linux"
+ fi
+
+ case "${GRUB_PLATFORM}" in
+ x86)
+ list="$(for i in "${GRUB_ROOT}"/boot/vmlinuz-linux* ; do
+ if grub_file_is_not_garbage "${i}" && "${grub_file}" ${check} "${i}" ; then echo -n "${i} " ; fi
+ done)" ;;
+ *)
+ list="$(for i in "${GRUB_ROOT}"/boot/vmlinuz-linux* ; do
+ if grub_file_is_not_garbage "${i}" && "${grub_file}" ${check} "${i}" ; then echo -n "${i} " ; fi
+ done)" ;;
+ esac
+}
+
+set -e
+
+prefix="/usr"
+exec_prefix="${prefix}"
+datarootdir="/usr/share"
+datadir="${datarootdir}"
+sysconfdir="/etc"
+
+. "${datarootdir}/grub/grub-mkconfig_lib"
+
+. "${sysconfdir}/default/grub"
+
+export XEN_HYPERVISOR_CMDLINE="xsave=1"
+export XEN_LINUX_CMDLINE="console=tty0"
+
+[[ -r "${sysconfdir}/xen/grub.conf" ]] && . "${sysconfdir}/xen/grub.conf"
+
+[[ -z "${XEN_LINUX_CMDLINE_OVERRIDE}" ]] && XEN_LINUX_CMDLINE_OVERRIDE="0"
+
+export TEXTDOMAIN="grub"
+export TEXTDOMAINDIR="${datarootdir}/locale"
+
+CLASS="--class xen --class parabola --class gnu-linux --class gnu --class os"
+
+[[ "${grub_file}" != "" ]] && _FUNC_GRUB_FILE_PRESENT
+
+BOOT_PART_FS_UUID="$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null)"
+BOOT_PART_HINTS_STRING="$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null || true)"
+BOOT_PART_FS="$(${grub_probe} --target="fs" "/boot" 2>/dev/null)"
+
+ROOT_PART_GRUB_DEVICE="$(${grub_probe} --target=device / || true)"
+ROOT_PART_FS="$(${grub_probe} --device ${ROOT_PART_GRUB_DEVICE} --target=fs 2> /dev/null || echo "unknown")"
+
+if [[ "${GRUB_LINUX_ROOT_DEVICE}" == "" ]]; then
+
+ case "${ROOT_PART_FS}" in
+ btrfs)
+ rootsubvol="$(make_system_path_relative_to_its_root /)"
+ rootsubvol="${rootsubvol#/}"
+ if [[ "${rootsubvol}" != "" ]]; then
+ GRUB_LINUX_ROOT_DEVICE="subvol=${rootsubvol}"
+ fi
+ ;;
+ zfs)
+ rpool="$(${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true)"
+ bootfs="$(make_system_path_relative_to_its_root / | sed -e "s,@$,,")"
+ GRUB_LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
+ ;;
+ esac
+
+ if [[ "${GRUB_DEVICE_UUID}" == "" ]] || \
+ [[ "${GRUB_DISABLE_LINUX_UUID}" == "true" ]] || \
+ [[ ! -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ]] || \
+ uses_abstraction "${GRUB_DEVICE}" lvm ; then
+ GRUB_LINUX_ROOT_DEVICE="${GRUB_DEVICE}"
+ else
+ GRUB_LINUX_ROOT_DEVICE="UUID=${GRUB_DEVICE_UUID}"
+ fi
+fi
+
+[[ "${GRUB_LINUX_PARAMS}" == "" ]] && GRUB_LINUX_PARAMS="${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+if [[ "${XEN_LINUX_CMDLINE_OVERRIDE}" == "0" ]]; then
+ GRUB_LINUX_PARAMS="${GRUB_LINUX_PARAMS} ${XEN_LINUX_CMDLINE}"
+else
+ GRUB_LINUX_PARAMS="${XEN_LINUX_CMDLINE}"
+fi
+
+xen_list=`for i in /boot/xen-*.gz /xen-*.gz ; do
+ if grub_file_is_not_garbage "$i" ; then echo -n "$i "; fi
+done`
+
+while [ "x$xen_list" != "x" ] ; do
+ xen=`version_find_latest $xen_list`
+ echo "Found Xen hypervisor image: $xen" >&2
+ XEN_BASENAME=`basename $xen`
+ XEN_VERSION=`echo $XEN_BASENAME | sed -e "s,^[^0-9]*-,,g" | sed -e "s,.gz,,g"`
+
+ for _KERNEL_ in ${list} ; do
+
+ echo "Found linux image: ${_KERNEL_}" >&2
+
+ basename="$(basename "${_KERNEL_}")"
+ dirname="$(dirname "${_KERNEL_}")"
+ REAL_DIR="$(make_system_path_relative_to_its_root "${dirname}")"
+
+ _KERNEL_FILE_="$(echo ${_KERNEL_} | sed 's,/boot/,,g')"
+ _KERNEL_PKG_="pkg-$(echo ${_KERNEL_FILE_} | sed 's,vmlinuz-,,g')"
+
+ _INITRAMFS_="${_KERNEL_FILE_/vmlinuz-/initramfs-}.img"
+
+ if [[ -e "/boot/${_INITRAMFS_}" ]]; then
+
+ echo "Found initramfs image: /boot/${_INITRAMFS_}" >&2
+
+ cat << EOF
+
+menuentry "Xen ${XEN_VERSION} / Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel" ${CLASS} {
+ $(save_default_entry)
+ if [ x\$feature_all_video_module = xy ]; then
+ insmod all_video
+ fi
+ set gfxpayload=keep
+ insmod ${BOOT_PART_FS}
+ if [ x\$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}
+ else
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_FS_UUID}
+ fi
+ echo '$(printf "Loading Xen %s ..." ${XEN_VERSION})'
+ multiboot ${REAL_DIR}/${XEN_BASENAME} ${REAL_DIR}/${XEN_BASENAME} ${XEN_HYPERVISOR_CMDLINE}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel ...'
+ module ${REAL_DIR}/${_KERNEL_FILE_} ${REAL_DIR}/${_KERNEL_FILE_} root=${GRUB_LINUX_ROOT_DEVICE} rw ${GRUB_LINUX_PARAMS}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel initramfs ...'
+ module ${REAL_DIR}/${_INITRAMFS_}
+}
+
+EOF
+ fi
+
+ _INITRAMFS_FALLBACK_="${_KERNEL_FILE_/vmlinuz-/initramfs-}-fallback.img"
+
+ if [[ -e "/boot/${_INITRAMFS_FALLBACK_}" ]]; then
+
+ echo "Found fallback initramfs image: /boot/${_INITRAMFS_FALLBACK_}" >&2
+
+ cat << EOF
+
+menuentry "Xen ${XEN_VERSION} / Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel (fallback initramfs)" ${CLASS} {
+ $(save_default_entry)
+ if [ x\$feature_all_video_module = xy ]; then
+ insmod all_video
+ fi
+ set gfxpayload=keep
+ insmod ${BOOT_PART_FS}
+ if [ x\$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}
+ else
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_FS_UUID}
+ fi
+ echo '$(printf "Loading Xen %s ..." ${XEN_VERSION})'
+ multiboot ${REAL_DIR}/${XEN_BASENAME} ${REAL_DIR}/${XEN_BASENAME} ${XEN_HYPERVISOR_CMDLINE}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel ...'
+ module ${REAL_DIR}/${_KERNEL_FILE_} ${REAL_DIR}/${_KERNEL_FILE_} root=${GRUB_LINUX_ROOT_DEVICE} rw ${GRUB_LINUX_PARAMS}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel fallback initramfs ...'
+ module ${REAL_DIR}/${_INITRAMFS_FALLBACK_}
+}
+
+EOF
+ fi
+
+ if [[ ! -e "/boot/${_INITRAMFS_}" ]] && [[ ! -e "/boot/${_INITRAMFS_FALLBACK_}" ]]; then
+ cat << EOF
+
+menuentry "Xen ${XEN_VERSION} / Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel (no initramfs)" ${CLASS} {
+ $(save_default_entry)
+ if [ x\$feature_all_video_module = xy ]; then
+ insmod all_video
+ fi
+ set gfxpayload=keep
+ insmod ${BOOT_PART_FS}
+ if [ x\$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}
+ else
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_FS_UUID}
+ fi
+ echo '$(printf "Loading Xen %s ..." ${XEN_VERSION})'
+ multiboot ${REAL_DIR}/${XEN_BASENAME} ${REAL_DIR}/${XEN_BASENAME} ${XEN_HYPERVISOR_CMDLINE}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel ...'
+ module ${REAL_DIR}/${_KERNEL_FILE_} ${REAL_DIR}/${_KERNEL_FILE_} root=${GRUB_LINUX_ROOT_DEVICE} rw ${GRUB_LINUX_PARAMS}
+}
+
+EOF
+ fi
+
+ done
+
+ xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $xen | tr '\n' ' '`
+done
+
+
diff --git a/libre/xen/ChangeLog b/libre/xen/ChangeLog
new file mode 100644
index 000000000..b23e810df
--- /dev/null
+++ b/libre/xen/ChangeLog
@@ -0,0 +1,169 @@
+2015-06-24 John Thomson
+ * 4.7.0-1
+ Xen 4.7.0
+
+2015-06-11 John Thomson
+ * 4.6.1-7
+ Apply XSA patch: 175, 178, 181
+
+2015-05-23 John Thomson
+ * 4.6.1-6
+ Apply XSA patch: 180
+
+2015-05-19 John Thomson
+ * 4.6.1-5
+ Apply XSA patch: 176
+
+2016-05-12 John Thomson
+ * 4.6.1-4
+ Apply XSA patch: 179
+ Patches for GCC6
+
+2016-04-19 John Thomson
+ * 4.6.1-3
+ Apply XSA patch: 173
+
+2016-03-31 John Thomson
+ * 4.6.1-2
+ Apply XSA patch: 172
+
+2016-02-19 John Thomson
+ * 4.6.1-1
+ Xen source package updated to 4.6.1
+ Apply XSA patch: 170
+
+2016-02-19 John Thomson
+ * 4.5.2-1
+ Xen source package updated to 4.5.2
+ Build xen.efi with mingw-w64-binutils
+ Build ovmf
+ Apply XSA patches: 154, 156, 158 to 160, 162 to 168, and 170
+
+2015-07-04 David Sutton <kantras - gmail.com>
+ * 4.5.1-1
+ New major release from upstream
+ Added -fno-caller-saves CFLAG to PKGBUILD to work around GCC5 issues
+ Added in some compile fixes for GCC 5
+ Disabled OVMF for now until patched for GCC 5
+
+2015-05-13 David Sutton <kantras - gmail.com>
+ * 4.5.0-3
+ Added Security patches
+
+2015-04-08 David Sutton <kantras - gmail.com>
+ * 4.5.0-2
+ Updated PKGBUILD to use absolute instead of relative paths for install
+ Updated efi-xen.cfg with syntax fix
+ Added gnuttls-3.4.0 patch
+ Added security patches
+
+2015-03-01 David Sutton <kantras - gmail.com>
+ * 4.5.0-1
+ New major release from upstream
+ Cleaned up old XSA patches
+ Removed old systemd support patches and realigned with the new upstream methods
+
+2014-10-26 David Sutton <kantras - gmail.com>
+ * 4.4.1-3
+ Enabled OVMF support and added patches to fix compile
+ Enabled spice support and added patch to enable qemu support in qemu-xen
+ Added figlet as an make dependancy for the ascii art version number
+ Including an example xen.cfg package for people who will be using EFI
+ Additional cleanup (explictly disabling some unnecessary libraries)
+
+2014-10-12 David Sutton <kantras - gmail.com>
+ * 4.4.1-2:
+ Added XSA 104, 105, 106, 107 and 108 security patches
+ Added .config to resolve compile issues where /etc/sysconfig exists
+
+2014-09-04 David Sutton <kantras - gmail.com>
+ * 4.4.1-1:
+ New Upstream release
+ Cleared out unnecessary patches (security, gcc compile and pit)
+
+2014-06-22 David Sutton <kantras - gmail.com>
+ * 4.4.0-6:
+ Added additional patch to support XSA 100 on AMD platform
+
+2014-06-17 David Sutton <kantras - gmail.com>
+ * 4.4.0-5:
+ Added XSA 96 and 100 security patches
+ Added patch to explictly disable searching for bluez libs
+ Cleaned up PKGBUILD
+
+2014-05-17 David Sutton <kantras - gmail.com>
+ * 4.4.0-4:
+ Added patch to fix shutdown issues with pvh domains
+
+2014-05-01 David Sutton <kantras - gmail.com>
+ * 4.4.0-3:
+ Added XSA 92 Security patch
+ Added fix for compiling under GCC 4.9.0 (From Fedora Rawhide SRPM)
+ Added updates to 09_xen to closer match system 10_linux
+
+2014-03-11 David Sutton <kantras - gmail.com>
+ * 4.4.0-2:
+ Moved xen-syms file so 09_xen won't pick it up as a potential kernel.
+ Added XSA 89 Security patch
+ Minor PKGBUILD cleanup/changes
+
+2014-03-10 David Sutton <kantras - gmail.com>
+ * 4.4.0-1:
+ New upstream release
+ Cleaned up old unnecessary patches
+
+2014-02-19 David Sutton <kantras - gmail.com>
+ * 4.3.2-1:
+ New upstream release
+ Removed unnecessary security patches (since now integrated into source)
+ Attempts to pull down additional required source file to ensure not corrupted
+ Added missing dependancy libseccomp
+
+2013-11-25 David Sutton <kantras - gmail.com>
+ * 4.3.1-2:
+ Changed bluez dependancy from bluez4 to bluez
+ Added recent security patches
+
+2013-10-31 David Sutton <kantras - gmail.com>
+ * 4.3.1-1:
+ New upstream release
+ Removed unnecessary security patches (already merged)
+ Fixed BIOS Workaround patch to apply to the new source files
+ Fixed ATI Passthrough patch to apply to the new source files
+ Updated paths in all patches
+
+2013-09-29 David Sutton <kantras - gmail.com>
+ * 4.3.0-7:
+ Fixed optdepends in PKGBUILD
+ Added in a pre_remove function in xen.install to disable services
+ Minor text formating changes in xen.install
+ Added XSA 62,63,64 and 66 patches (Xen Security Advisories)
+
+2013-09-29 David Sutton <kantras - gmail.com>
+ * 4.3.0-6:
+ Fixed 09_xen so it can detect lts kernels
+
+2013-09-28 David Sutton <kantras - gmail.com>
+ * 4.3.0-5:
+ Fixed mount option in 09_xen from ro to rw
+ Added in dummy /etc/xen/grub.conf to control settings in 09_xen
+ Fix library sanitize so that it returns to the base directory
+ Move the syms file to /usr/share/xen so that it is out of the way of boot but still accessible
+ Added optional dependancy for openvswitch
+
+2013-08-13 David Sutton <kantras - gmail.com>
+ * 4.3.0-4 :
+ Added patch for qemu-xen to add a TOM register for PCI Hole mapping
+ Protected /etc/conf.d/xendomains from being overwritten
+ Included ATI Passthrough patch (not enabled by default, compile tested only)
+
+2013-07-23 David Sutton <kantras - gmail.com>
+
+ * 4.3.0-3 :
+ added ChangeLog.
+ Cleaned up PKGBUILD to match Arch Package Standards
+ Fixed some path references - /var/run to /run
+ Removed some unnecessary empty directories
+ Updated xenconsoled and xenstored so they use /run for pid file
+ Updated auto-created /run directories to include xenstored
+
diff --git a/libre/xen/PKGBUILD b/libre/xen/PKGBUILD
new file mode 100644
index 000000000..af74ce999
--- /dev/null
+++ b/libre/xen/PKGBUILD
@@ -0,0 +1,340 @@
+# Maintainer (Arch): David Sutton <kantras - gmail.com>
+# Contributor (Arch): Shanmu Thiagaraja <sthiagaraja+AUR@prshanmu.com>
+# Contributor (Arch): Limao Luo
+# Contributor (Arch): Luceo
+# Contributor (Arch): Revellion
+# Contributor (Arch): John Thomson
+# Maintainer: André Silva <emulatorman@parabola.nu>
+# Contributor: Márcio Silva <coadde@parabola.nu>
+
+
+_build_stubdom=${build_stubdom:-false}
+## use _build_stubdom=true to build xen with stubdom
+#_build_stubdom=true
+
+pkgname=xen
+pkgver=4.7.0
+pkgrel=1.parabola1
+pkgdesc="Virtual Machine Hypervisor & Tools (Parabola rebranded)"
+arch=(x86_64)
+url="http://www.xenproject.org/"
+license=(GPL2)
+depends=(bridge-utils curl gnutls iproute2 libaio libcap-ng libiscsi libnl libpng lzo2 pciutils python python2 sdl spice usbredir yajl
+ # seabios ovmf qemu
+ )
+[[ "$CARCH" == "x86_64" ]] && depends+=(lib32-glibc)
+makedepends=(bin86 cmake dev86 figlet git iasl markdown nasm ocaml-findlib spice-protocol wget)
+
+## For building Xen EFI boot file.
+## mingw-w64-binutils only needed if
+## binutils not built with --enable-targets=x86_64-pep
+_binutils_emulations=$(ld -V)
+_binutils_efi=false
+if [[ $_binutils_emulations == *'i386pep'* ]]
+then
+ _binutils_efi=true
+ echo 'ld has efi support'
+else
+ makedepends+=(mingw-w64-binutils)
+ echo 'ld does not have efi support, using mingw'
+fi
+
+optdepends=('xen-docs: Official Xen Documentation' 'openvswitch: Optional Networking support')
+conflicts=(xen-4.2{,-testing-hg} xen-{gdbsx,hg-unstable,rc,git,igvtg} xen-4.3{,-testing-hg} xen-4.4 xen-4.5 xen-4.6)
+backup=(
+ etc/modules-load.d/$pkgname.conf
+ etc/$pkgname/xl.conf
+ etc/conf.d/xen{stored,consoled,domains,commons}
+ etc/$pkgname/grub.conf
+ )
+options=(!buildflags !strip)
+install=$pkgname.install
+changelog=ChangeLog
+source=(
+ http://bits.xensource.com/oss-xen/release/$pkgver/$pkgname-$pkgver.tar.gz
+ http://xenbits.xen.org/xen-extfiles/ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz
+
+ ##SeaBIOS & OVMF tags are in src/xen-*/tools/Config.mk
+ ##Can be found through: grep -R 'UPSTREAM_REVISION' src/xen-*/Config.mk
+ #'seabios'::'git://xenbits.xen.org/seabios.git#tag=rel-1.9.2'
+ #'ovmf'::'git://xenbits.xen.org/ovmf.git#tag=52a99493cce88a9d4ec8a02d7f1bd1a1001ce60d'
+ ##HTTP access
+ 'seabios'::'git+http://xenbits.xen.org/git-http/seabios.git#tag=rel-1.9.2'
+ 'ovmf'::'git+http://xenbits.xen.org/git-http/ovmf.git#tag=52a99493cce88a9d4ec8a02d7f1bd1a1001ce60d'
+
+ ## Compile patches
+ ati-passthrough.patch
+ ovmf.patch
+ #patch-build-efi-with-mingw.patch::https://github.com/jakogut/xen-igvtg-aur/raw/28c81072e419d72a100ada9c393e37fae35ad263/xen_efi_build.patch
+ patch-gcc6-ovmf-build.sh.patch
+ #ipxe
+ patch-gcc6-etherboot-nonnull-compare.patch::https://git.ipxe.org/ipxe.git/patch/e2f14c2f8c10674dbbd4f1228d79dc4c9be213b5
+ patch-gcc6-etherboot-rm-unused-string-functions.patch
+ patch-gcc6-etherboot-nic.c.patch::https://git.ipxe.org/ipxe.git/patch/a5885fbc19c4b60dc1a21624d1a9d1b77a93504e
+ patch-gcc6-etherboot-ath.patch::https://git.ipxe.org/ipxe.git/patch/63037bdce4a325e5e1da85ffcdf27b77ac670c01
+ patch-gcc6-etherboot-sis190.patch::https://git.ipxe.org/ipxe.git/patch/65b32a0b7000f70a5bb1d33190d40f9b04c93172
+ patch-gcc6-etherboot-skge.patch::https://git.ipxe.org/ipxe.git/patch/76ec2a0540b25dbd183b9ce185583a4b24278cf1
+ patch-gcc6-etherboot-via-velocity.c.patch
+ patch-gcc6-etherboot-via-rhine.c.patch
+ patch-gcc6-etherboot-e1000_phy.c.patch
+ patch-gcc6-etherboot-igb_phy.c.patch
+ patch-gcc6-etherboot-eth_broadcast.patch::https://git.ipxe.org/ipxe.git/patch/1cbb1581f16e235fafc963c906ad02b38d5457bd
+ patch-gcc6-etherboot-link-header.patch::https://git.ipxe.org/ipxe.git/patch/6324bd9389521c7e86384591f41eb78a81e9af47
+ patch-gcc6-etherboot-ath9k-9287-array.patch
+
+ ## Files
+ xen.install
+ 09_xen
+ efi-xen.cfg
+ grub.conf
+ $pkgname.conf
+ tmpfiles.d-$pkgname.conf
+
+ ## XSA patches
+ )
+
+if [ "$_build_stubdom" = true ] ; then
+ echo "building with stubdom"
+ source+=(
+ http://xenbits.xen.org/xen-extfiles/lwip-1.3.0.tar.gz
+ http://xenbits.xen.org/xen-extfiles/zlib-1.2.3.tar.gz
+ http://xenbits.xen.org/xen-extfiles/newlib-1.16.0.tar.gz
+ http://xenbits.xen.org/xen-extfiles/pciutils-2.2.9.tar.bz2
+ http://xenbits.xen.org/xen-extfiles/polarssl-1.1.4-gpl.tgz
+ http://xenbits.xen.org/xen-extfiles/grub-0.97.tar.gz
+ http://xenbits.xen.org/xen-extfiles/tpm_emulator-0.7.4.tar.gz
+ http://xenbits.xen.org/xen-extfiles/gmp-4.3.2.tar.bz2
+ #http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-3.11.0.tar.gz
+ )
+fi
+
+
+noextract=(
+ ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz
+ )
+
+if [ "$_build_stubdom" = true ] ; then
+ noextract+=(
+ lwip-1.3.0.tar.gz
+ zlib-1.2.3.tar.gz
+ newlib-1.16.0.tar.gz
+ pciutils-2.2.9.tar.bz2
+ polarssl-1.1.4-gpl.tgz
+ grub-0.97.tar.gz
+ tpm_emulator-0.7.4.tar.gz
+ gmp-4.3.2.tar.bz2
+ #ocaml-3.11.0.tar.gz
+ )
+fi
+
+sha256sums=(
+ 'be5876144d49729572ae06142e0bb93f1c1f2695578141eff2931995add24623'
+ '632ce8c193ccacc3012bd354bdb733a4be126f7c098e111930aa41dad537405c'
+
+ 'SKIP'
+ 'SKIP'
+
+ 'd93c2d5bcdf0c3e4c6e8efb357cb4b9d618209025361f5ccd9d03651a8acd7a3'
+ '9cf9232c6e9a2b972cd4e1c7aacac9152bb8676db2b794381e1964c9f452e7de'
+ #'a8ce42777e22af49080131e174b6b89c6e7597539838fb8b17a12280fd10b10b'
+ '6403a0478e3cfed91dcad53b5f02e71745c98d18ab53930f87aeff1da8d71d55'
+ #ipxe
+ '17bb27d95c86af8cc5e499b1b0db9b95bba3f45910d55b420f9f1f5452355fab'
+ '5d5fe7bf52cbae9da20cfd1fc798699b2355a1af907ebf7f764e227891a759bb'
+ '9f34f8ecb9a44c688275b838c83efd233bb817f5e222629eac98e116168d704c'
+ 'cdf7c4a089fe1fe493aafaf669decc3c9e071a0950da77dce526c09088d1c931'
+ '32595581467772b9fa0fbb5384c99caefeb2cee3306b94b9bd2722084454f5a2'
+ 'c73d1653b9b1d97ddce717817dc74429cd94c7b22989a08604eaa60df63f75f8'
+ '448caed900ada2c030738218f5b82f5e29d9dc2e1beef9ebd49cbeb23734df0d'
+ '61b1518c8d41792ec3b36e0fbfc265adb6c9304945a6fa18d6cc5a197e34b94f'
+ '577f06e38a9ecbd3576907f2ba1c5040f4f1573fe92912635230702ad157b2e7'
+ '80a24e9504d3893e83dc60550ffe364a873aaf3dafb52dcdade13f61f2ec0ee5'
+ 'be05ccd8975af402dcba3a3dc78c173319b2edd636bac11ac11163091453b704'
+ 'cace870b6629003b55d9df9ef24f3445067239b913c006b6e23da511c1a21d78'
+ 'a15d73e0fb51fe3c1cf8b80a5ff17d532444016d14495d90d9e642ec60f320a6'
+ #pkgbuild files
+ '7da2db54d35914284d60bb4474aff3538897dd3cf5065347b393d6e18a029292'
+ '92b8fc6679cc75bd993c8ead946eb1f212da03a52566b1c329d248fa1cdfe879'
+ '95f09bccc104d98c14559000823cb50f0d076f6a65b9f3b4e7725762b84ab5c7'
+ '3f0af16958c3e057b9baa5afc47050d9adf7dd553274dd97ae4f35938fefb568'
+ '50a9b7fd19e8beb1dea09755f07318f36be0b7ec53d3c9e74f3266a63e682c0c'
+ '40e0760810a49f925f2ae9f986940b40eba477dc6d3e83a78baaae096513b3cf'
+
+ ## XSA patches
+ )
+if [ "$_build_stubdom" = true ] ; then
+ sha256sums+=(
+ #stubdom bits
+ '772e4d550e07826665ed0528c071dd5404ef7dbe1825a38c8adbc2a00bca948f'
+ '1795c7d067a43174113fdf03447532f373e1c6c57c08d61d9e4e9be5e244b05e'
+ 'db426394965c48c1d29023e1cc6d965ea6b9a9035d8a849be2750ca4659a3d07'
+ 'f60ae61cfbd5da1d849d0beaa21f593c38dac9359f0b3ddc612f447408265b24'
+ '2d29fd04a0d0ba29dae6bd29fb418944c08d3916665dcca74afb297ef37584b6'
+ '4e1d15d12dbd3e9208111d6b806ad5a9857ca8850c47877d36575b904559260b'
+ '4e48ea0d83dd9441cc1af04ab18cd6c961b9fa54d5cbf2c2feee038988dea459'
+ '936162c0312886c21581002b79932829aa048cfaf9937c6265aeaa14f1cd1775'
+ #'ecdd4f8473ab0dee5d3acb5c0a31a4c1dd6aa12179895cf1903dd0f455c43a4f'
+
+ #stubdom patches
+ )
+fi
+
+prepare() {
+ cd "$pkgname-$pkgver/"
+
+ ### Copy git sourced tools/firmware
+ # Copy seabios into place
+ mkdir tools/firmware/seabios-dir-remote/
+ cp -r ../seabios/* tools/firmware/seabios-dir-remote/
+ # Copy ovmf into place
+ mkdir tools/firmware/ovmf-dir-remote/
+ cp -r ../ovmf/* tools/firmware/ovmf-dir-remote/
+
+ ### Patching
+
+ # Security Patches - Base
+
+ # Security Patches - qemu-xen-traditional
+ cd 'tools/qemu-xen-traditional/'
+ cd '../../'
+
+ # Security Patches - qemu-xen (upstream)
+ cd 'tools/qemu-xen/'
+ cd '../../'
+
+ # Compile Patches
+
+ # Build EFI binary with mingw
+ if [ $_binutils_efi != true ]
+ then
+ #patch -Np1 -i "$srcdir/patch-build-efi-with-mingw.patch"
+ sed -i.bak '/ EFI_LD/s/LD/LD_EFI/' xen/arch/x86/Makefile
+ sed -i.bak 's/LD/LD_EFI/' xen/arch/x86/efi/Makefile
+ sed -i.bak '/EFI_MOUNTPOINT .*/aLD_EFI ?= $(LD)' xen/Makefile
+ fi
+
+ # OVMF Compile support (Pulls from GIT repo, so patching to patch after pull request)
+ patch -Np1 -i "$srcdir/ovmf.patch"
+ cp "$srcdir/patch-gcc6-ovmf-build.sh.patch" tools/firmware/
+
+ # Uncomment line below if you want to enable ATI Passthrough support (some reported successes, untested with 4.4)
+ #patch -Np1 -i "$srcdir/ati-passthrough.patch"
+
+ ## GCC-6
+ #etherboot
+ echo -e "patch-gcc6-etherboot-nonnull-compare.patch\npatch-gcc6-etherboot-rm-unused-string-functions.patch\npatch-gcc6-etherboot-nic.c.patch\npatch-gcc6-etherboot-ath.patch\npatch-gcc6-etherboot-sis190.patch\npatch-gcc6-etherboot-skge.patch\npatch-gcc6-etherboot-via-velocity.c.patch\npatch-gcc6-etherboot-via-rhine.c.patch\npatch-gcc6-etherboot-e1000_phy.c.patch\npatch-gcc6-etherboot-igb_phy.c.patch\npatch-gcc6-etherboot-link-header.patch\npatch-gcc6-etherboot-eth_broadcast.patch\npatch-gcc6-etherboot-ath9k-9287-array.patch" >> tools/firmware/etherboot/patches/series
+ cp ${srcdir}/patch-gcc6-etherboot-*.patch tools/firmware/etherboot/patches/
+
+ ## Fix Install Paths
+ sed -i 's:\$localstatedir/run/xen:/run/xen:' m4/paths.m4
+ sed -i 's:/var/run:/run:' tools/ocaml/xenstored/define.ml
+ sed -i 's:/var/run:/run:' tools/ocaml/xenstored/systemd_stubs.c
+
+ if [ "$_build_stubdom" = true ] ; then
+ # Copy supporting tarballs into place
+ cp "$srcdir/lwip-1.3.0.tar.gz" stubdom/
+ cp "$srcdir/zlib-1.2.3.tar.gz" stubdom/
+ cp "$srcdir/newlib-1.16.0.tar.gz" stubdom/
+ cp "$srcdir/pciutils-2.2.9.tar.bz2" stubdom/
+ cp "$srcdir/polarssl-1.1.4-gpl.tgz" stubdom/
+ cp "$srcdir/grub-0.97.tar.gz" stubdom/
+ cp "$srcdir/tpm_emulator-0.7.4.tar.gz" stubdom/
+ cp "$srcdir/gmp-4.3.2.tar.bz2" stubdom/
+ #cp "$srcdir/ocaml-3.11.0.tar.gz" stubdom/
+
+ ## Stubdom patches
+ cd 'extras/mini-os'
+ cd '../../'
+
+ fi
+
+ #etherboot
+ cp "$srcdir/ipxe-git-9a93db3f0947484e30e753bbd61a10b17336e20e.tar.gz" tools/firmware/etherboot/ipxe.tar.gz
+
+ #Workaround for cannot compute sizeof (unsigned short)
+ #Makefile:170: recipe for target 'gmp-x86_64' failed
+ #Probably not safe!
+ #sed -i.bak "/< gmp.patch/a\ sed -i.bak 's/\\\\(\\\\s*\\\\)\\\\(fprintf (f,\\\\)\\\\(.*\\\\)/\\\\1\\\\2\\\\3\\\\n\\\\1clearerr(f);/' \$@/configure" stubdom/Makefile
+
+
+}
+
+build() {
+ cd "$pkgname-$pkgver/"
+ export LD_EFI="/usr/x86_64-w64-mingw32/bin/ld"
+ ./autogen.sh
+ if [ "$_build_stubdom" = true ] ; then
+ _config_stubdom='--enable-stubdom'
+ fi
+ ./configure PYTHON=/usr/bin/python2 --prefix=/usr --sbindir=/usr/bin --with-sysconfig-leaf-dir=conf.d --with-initddir=/etc/init.d \
+ --enable-systemd --disable-docs --enable-ovmf \
+ "${_config_stubdom:---disable-stubdom}" \
+ --with-extra-qemuu-configure-args="--disable-bluez --disable-gtk --enable-spice --enable-usb-redir"
+ #--with-system-qemu --with-system-seabios --with-system-ovmf
+ #defaults --enable-qemu-traditional --enable-rombios \
+ make LANG=C PYTHON=python2 dist-misc
+ make LANG=C PYTHON=python2 dist-xen
+ make LANG=C PYTHON=python2 dist-tools
+ if [ "$_build_stubdom" = true ] ; then
+ make LANG=C PYTHON=python2 dist-stubdom
+ fi
+}
+
+package() {
+ cd "$pkgname-$pkgver/"
+
+ make DESTDIR="$pkgdir" LANG=C PYTHON=python2 install
+
+ cd "$pkgdir"
+
+ # Install files from Parabola package
+ install -Dm644 "$srcdir/tmpfiles.d-$pkgname.conf" usr/lib/tmpfiles.d/$pkgname.conf
+ install -Dm644 "$srcdir/grub.conf" etc/xen/grub.conf
+ install -Dm755 "$srcdir/09_xen" etc/grub.d/09_xen
+ install -Dm644 "$srcdir/efi-xen.cfg" etc/xen/efi-xen.cfg
+
+ # Fix paths in scripts, move to right locations and create missing directories
+ sed -i 's:/var/run:/run:' etc/init.d/xencommons
+ sed -i 's:/var/lock:/run/lock:' etc/xen/scripts/hotplugpath.sh
+ sed -i 's:/var/run:/run:' etc/xen/scripts/locking.sh
+ sed -i 's:/var/run:/run:' usr/lib/systemd/system/xenstored.service
+ sed -i 's:/var/run:/run:' usr/lib/systemd/system/xenstored.socket
+ sed -i 's:/var/run:/run:' usr/lib/systemd/system/xenstored_ro.socket
+
+ mkdir var/log/xen/console
+
+ # Sanitize library path (if lib64 exists)
+ if [[ -d usr/lib64 ]]; then
+ cd usr/
+ cp -r lib64/* lib/
+ rm -rf lib64
+ cd ../
+ fi
+
+ # If EFI binaries build, move to /boot
+ if [[ -f usr/lib/efi/xen.efi ]]; then
+ mv usr/lib/efi/xen-$pkgver.efi boot/xen-$pkgver.efi
+ rm -rf usr/lib/efi
+ fi
+
+ # Compress syms file and move to a share location
+ #gzip boot/$pkgname-syms-*
+ #mv boot/$pkgname-syms-*.gz usr/share/xen
+
+ ##### Kill unwanted stuff #####
+ # hypervisor symlinks
+ rm -f boot/xen{,-4,-4.7,-4.7-rc}.gz
+
+ # Documentation cleanup ( see xen-docs package )
+ rm -rf usr/share/doc
+ rm -rf usr/share/man
+
+ # Unnecessary qemu support files
+# rm -rf usr/bin/qemu-*-xen
+ rm usr/share/qemu-xen/qemu/{palcode,openbios}-*
+ rm usr/share/xen/qemu/openbios-*
+
+ # adhere to Static Library Packaging Guidelines
+ rm -rf usr/lib/*.a
+
+}
diff --git a/libre/xen/ati-passthrough.patch b/libre/xen/ati-passthrough.patch
new file mode 100644
index 000000000..7c20b1ecd
--- /dev/null
+++ b/libre/xen/ati-passthrough.patch
@@ -0,0 +1,415 @@
+--- xen-4.3.1/tools/qemu-xen-traditional/hw/pass-through.c Thu Sep 6 11:05:30 2012
++++ xen-4.3.1-new/tools/qemu-xen-traditional/hw/pass-through.c Sat Nov 24 08:27:07 2012
+@@ -1438,9 +1438,17 @@ static void pt_ioport_map(PCIDevice *d,
+ if (e_phys != -1)
+ {
+ /* Create new mapping */
+- ret = xc_domain_ioport_mapping(xc_handle, domid, e_phys,
+- assigned_device->bases[i].access.pio_base, e_size,
+- DPCI_ADD_MAPPING);
++ if ( vga_skip_ioport_map(d) )
++ {
++ assigned_device->bases[i].e_physbase = -1;
++ }
++ else
++ {
++ ret = xc_domain_ioport_mapping(xc_handle, domid, e_phys,
++ assigned_device->bases[i].access.pio_base, e_size,
++ DPCI_ADD_MAPPING);
++ }
++
+ if ( ret != 0 )
+ {
+ PT_LOG("Error: create new mapping failed!\n");
+--- xen-4.3.1/tools/qemu-xen-traditional/hw/pass-through.h Thu Sep 6 11:05:30 2012
++++ xen-4.3.1-new/tools/qemu-xen-traditional/hw/pass-through.h Sat Nov 24 08:27:07 2012
+@@ -419,6 +419,11 @@ int pt_pci_host_write(struct pci_dev *pc
+ void intel_pch_init(PCIBus *bus);
+ int register_vga_regions(struct pt_dev *real_device);
+ int unregister_vga_regions(struct pt_dev *real_device);
++int vga_skip_ioport_map(PCIDevice *d);
++int igd_register_vga_regions(struct pt_dev *real_device);
++int igd_unregister_vga_regions(struct pt_dev *real_device);
++int ati_register_vga_regions(struct pt_dev *real_device);
++int ati_unregister_vga_regions(struct pt_dev *real_device);
+ int setup_vga_pt(struct pt_dev *real_device);
+ PCIBus *intel_pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid,
+ uint16_t did, const char *name, uint16_t revision);
+--- xen-4.3.1/tools/qemu-xen-traditional/hw/pci.h Thu Sep 6 11:05:30 2012
++++ xen-4.3.1-new/tools/qemu-xen-traditional/hw/pci.h Sat Nov 24 08:27:07 2012
+@@ -54,6 +54,8 @@ extern target_phys_addr_t pci_mem_base;
+
+ #define PCI_VENDOR_ID_CIRRUS 0x1013
+
++#define PCI_VENDOR_ID_ATI 0x1002
++
+ #define PCI_VENDOR_ID_IBM 0x1014
+ #define PCI_DEVICE_ID_IBM_OPENPIC2 0xffff
+
+--- xen-4.3.1/tools/qemu-xen-traditional/hw/pt-graphics.c Thu Sep 6 11:05:30 2012
++++ xen-4.3.1-new/tools/qemu-xen-traditional/hw/pt-graphics.c Sat Nov 24 08:28:10 2012
+@@ -13,6 +13,207 @@
+
+ extern int gfx_passthru;
+ extern int igd_passthru;
++/*********************************/
++/* Code for ATI GFX Passthru */
++/*********************************/
++/* ATI VBIOS Working Mechanism
++ *
++ * Generally there are three memory resources (two MMIO and one PIO)
++ * associated with modern ATI gfx. VBIOS uses special tricks to figure out
++ * BARs, instead of using regular PCI config space read.
++ *
++ * (1) VBIOS relies on I/O port 0x3C3 to retrieve PIO BAR
++ * (2) VBIOS maintains a shadow copy of PCI configure space. It retries the
++ * MMIO BARs from this shadow copy via sending I/O requests to first two
++ * registers of PIO (MMINDEX and MMDATA). The workflow is like this:
++ * MMINDEX (register 0) is written with an index value, specifying the
++ * register VBIOS wanting to access. Then the shadowed data can be
++ * read/written from MMDATA (register 1). For two MMIO BARs, the index
++ * values are 0x4010 and 0x4014 respectively.
++ *
++ */
++
++#define ATI_BAR1_INDEX 0 //MMIO BAR1
++#define ATI_BAR2_INDEX 1 //MMIO BAR2
++#define ATI_BAR5_INDEX 4 //PIO BAR == BAR5
++
++#define ATI_BAR1_MMINDEX 0x4010 //data written to MMINDEX for MMIO BAR1
++#define ATI_BAR2_MMINDEX 0x4014 //data written to MMINDEX FOR MMIO BAR2
++
++struct ati_gfx_info {
++ int initialized; /* initialized already? */
++
++ /* PIO */
++ uint32_t host_pio_base; /* host base addr of PIO */
++ uint32_t guest_pio_base; /* guest base addr of PIO */
++ uint32_t pio_size; /* PIO size */
++
++ /* MMIO */
++ uint32_t guest_mmio_base1; /* guest base addr of MMIO 1 */
++ uint32_t guest_mmio_base2; /* guest base addr of MMIO 2 */
++
++ /* PIO MMINDEX access recording */
++ uint32_t pre_mmindex_data; /* previous data written to MMINDEX */
++};
++
++static struct ati_gfx_info gfx_info;
++
++/* Convert guest PIO port to host PIO port */
++static uint16_t gport_to_hport(uint16_t gport)
++{
++ return (gport - gfx_info.guest_pio_base) + gfx_info.host_pio_base;
++}
++
++/* Read host PIO port */
++static uint32_t ati_hw_in(uint16_t hport)
++{
++ unsigned val;
++
++ //iopl(3);
++ asm volatile ("in %1,%0":"=a"(val):"Nd"(hport));
++ //iopl(0);
++
++ return val;
++}
++
++/* Write data to host PIO */
++static void ati_hw_out(uint16_t hport, uint32_t data)
++{
++ //iopl(3);
++ asm volatile ("out %1, %0"::"Nd"(hport),"a"(data));
++ //iopl(0);
++}
++
++static uint32_t ati_io_regs_read(void *opaque, uint32_t addr)
++{
++ uint32_t val;
++
++ val = ati_hw_in(gport_to_hport(addr));
++
++ /* tweak the value if VBIOS is reading MMIO BAR1 and BAR2 */
++ if ( addr == (gfx_info.guest_pio_base + 4) )
++ {
++ switch ( gfx_info.pre_mmindex_data )
++ {
++ case ATI_BAR1_MMINDEX:
++ val = gfx_info.guest_mmio_base1 | (val & 0x0000000f);
++ break;
++ case ATI_BAR2_MMINDEX:
++ val = gfx_info.guest_mmio_base2 | (val & 0x0000000f);
++ break;
++ default:
++ break;
++ }
++ }
++
++ return val;
++}
++
++static void ati_io_regs_write(void *opaque, uint32_t addr, uint32_t val)
++{
++ ati_hw_out(gport_to_hport(addr), val);
++
++ /* book keeping */
++ if ( addr == gfx_info.guest_pio_base )
++ gfx_info.pre_mmindex_data = val;
++}
++
++static void ati_gfx_init(struct pt_dev *assigned)
++{
++ PCIDevice *dev = (PCIDevice *)&assigned->dev;
++
++ register_ioport_read(dev->io_regions[ATI_BAR5_INDEX].addr,
++ dev->io_regions[ATI_BAR5_INDEX].size, 4, ati_io_regs_read, assigned);
++
++ register_ioport_write(dev->io_regions[ATI_BAR5_INDEX].addr,
++ dev->io_regions[ATI_BAR5_INDEX].size, 4, ati_io_regs_write, assigned);
++
++ /* initialize IO registers */
++ gfx_info.guest_pio_base = dev->io_regions[ATI_BAR5_INDEX].addr;
++ gfx_info.pio_size = dev->io_regions[ATI_BAR5_INDEX].size;
++ gfx_info.host_pio_base = assigned->bases[ATI_BAR5_INDEX].access.pio_base;
++
++ gfx_info.guest_mmio_base1 = dev->io_regions[ATI_BAR1_INDEX].addr;
++ gfx_info.guest_mmio_base2 = dev->io_regions[ATI_BAR2_INDEX].addr;
++ gfx_info.initialized = 1;
++
++ PT_LOG("guest_pio_bar = 0x%x, host_pio_bar = 0x%x, pio_size=0x%x "
++ "guest_mmio_bar1=0x%x, guest_mmio_bar2=0x%x\n",
++ gfx_info.guest_pio_base, gfx_info.host_pio_base, gfx_info.pio_size,
++ gfx_info.guest_mmio_base1, gfx_info.guest_mmio_base2);
++}
++
++static uint32_t ati_legacy_io_read(void *opaque, uint32_t addr)
++{
++ struct pt_dev *assigned_device = opaque;
++ PCIDevice *dev = (PCIDevice *)&assigned_device->dev;
++ uint32_t val = 0xFF;
++
++ switch( addr )
++ {
++ case 0x3c3:
++ val = dev->io_regions[ATI_BAR5_INDEX].addr >> 8;
++ /* Intercept GFX IO registers. This supposes to happen in
++ * ati_register_vga_regions(). But we cannot get guest phys IO BAR
++ * over there. */
++ if ( !gfx_info.initialized )
++ ati_gfx_init(assigned_device);
++ break;
++ default:
++ PT_LOG("ERROR: port 0x%x I/O read not handled\n", addr);
++ break;
++ }
++
++ return val;
++}
++
++static void ati_legacy_io_write(void *opaque, uint32_t addr, uint32_t val)
++{
++ PT_LOG("ERROR: port 0x%x I/O write not handled\n", addr);
++}
++
++int ati_register_vga_regions(struct pt_dev *real_device)
++{
++ PCIDevice *dev = (PCIDevice *)&real_device->dev;
++ int ret = 0;
++
++ /* We need to intercept VBIOS accesses to port 0x3C3, which returns
++ * device port I/O BAR. For the rest of legacy I/O ports, we allow direct
++ * accesses.
++ */
++ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
++ 0x3C0, 0x3, DPCI_ADD_MAPPING);
++
++ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C4,
++ 0x3C4, 0x1C, DPCI_ADD_MAPPING);
++
++ register_ioport_read(0x3c3, 1, 1, ati_legacy_io_read, real_device);
++ register_ioport_write(0x3c3, 1, 1, ati_legacy_io_write, real_device);
++
++ /* initialized on the first port 0x3C3 access in ati_gfx_init */
++ gfx_info.initialized = 0;
++
++ return ret;
++}
++
++int ati_unregister_vga_regions(struct pt_dev *real_device)
++{
++ int ret = 0;
++
++ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
++ 0x3C0, 0x3, DPCI_REMOVE_MAPPING);
++
++ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C4,
++ 0x3C4, 0x1C, DPCI_REMOVE_MAPPING);
++
++ gfx_info.initialized = 0;
++
++ return ret;
++}
++
++/*********************************/
++/* Code for Intel IGD Passthru */
++/*********************************/
+
+ static uint32_t igd_guest_opregion = 0;
+
+@@ -176,6 +377,77 @@ read_default:
+ return pci_default_read_config(pci_dev, config_addr, len);
+ }
+
++int igd_register_vga_regions(struct pt_dev *real_device)
++{
++ u32 vendor_id, igd_opregion;
++ int ret = 0;
++
++ /* legacy I/O ports 0x3C0 -- 0x3E0 */
++ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
++ 0x3C0, 0x20, DPCI_ADD_MAPPING);
++
++ /* 1:1 map ASL Storage register value */
++ vendor_id = pt_pci_host_read(real_device->pci_dev, PCI_VENDOR_ID, 2);
++ igd_opregion = pt_pci_host_read(real_device->pci_dev, PCI_INTEL_OPREGION, 4);
++ if ( (vendor_id == PCI_VENDOR_ID_INTEL) && igd_opregion )
++ {
++ ret |= xc_domain_memory_mapping(xc_handle, domid,
++ igd_opregion >> XC_PAGE_SHIFT,
++ igd_opregion >> XC_PAGE_SHIFT,
++ 2,
++ DPCI_ADD_MAPPING);
++ PT_LOG("register_vga: igd_opregion = %x\n", igd_opregion);
++ }
++
++ return ret;
++}
++
++int igd_unregister_vga_regions(struct pt_dev *real_device)
++{
++ u32 vendor_id, igd_opregion;
++ int ret = 0;
++
++ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
++ 0x3C0, 0x20, DPCI_REMOVE_MAPPING);
++
++ vendor_id = pt_pci_host_read(real_device->pci_dev, PCI_VENDOR_ID, 2);
++ igd_opregion = pt_pci_host_read(real_device->pci_dev, PCI_INTEL_OPREGION, 4);
++ if ( (vendor_id == PCI_VENDOR_ID_INTEL) && igd_opregion )
++ {
++ ret |= xc_domain_memory_mapping(xc_handle, domid,
++ igd_opregion >> XC_PAGE_SHIFT,
++ igd_opregion >> XC_PAGE_SHIFT,
++ 2,
++ DPCI_REMOVE_MAPPING);
++ }
++
++ return ret;
++}
++/*********************************/
++/* Generic Code for GFX Passthru */
++/*********************************/
++/* This function decides whether I/O port map should be skipped */
++int vga_skip_ioport_map(PCIDevice *d)
++{
++ struct pt_dev *dev = (struct pt_dev *)d;
++ int skip = 0;
++
++ if ( !gfx_passthru || dev->pci_dev->device_class != 0x0300 )
++ return 0;
++
++ switch( dev->pci_dev->vendor_id )
++ {
++ case PCI_VENDOR_ID_ATI:
++ case PCI_VENDOR_ID_AMD:
++ skip = 1;
++ break;
++ default:
++ skip = 0;
++ break;
++ }
++
++ return skip;
++}
+ /*
+ * register VGA resources for the domain with assigned gfx
+ */
+@@ -187,18 +459,33 @@ int register_vga_regions(struct pt_dev *
+ if ( !gfx_passthru || real_device->pci_dev->device_class != 0x0300 )
+ return ret;
+
++ /* legacy I/O ports 0x3B0 - 0x3BC */
+ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3B0,
+ 0x3B0, 0xC, DPCI_ADD_MAPPING);
+
+- ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
+- 0x3C0, 0x20, DPCI_ADD_MAPPING);
+-
++ /* legacy video MMIO range 0xA0000 - 0xBFFFF */
+ ret |= xc_domain_memory_mapping(xc_handle, domid,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0x20,
+ DPCI_ADD_MAPPING);
+
++ /* Other VGA regions are vendor specific */
++ switch( real_device->pci_dev->vendor_id )
++ {
++ case PCI_VENDOR_ID_INTEL:
++ ret = igd_register_vga_regions(real_device);
++ break;
++ case PCI_VENDOR_ID_ATI:
++ case PCI_VENDOR_ID_AMD:
++ ret = ati_register_vga_regions(real_device);
++ break;
++ default:
++ PT_LOG("gfx card wasn't supported by Xen passthru!\n");
++ ret = 1;
++ break;
++ }
++
+ if ( ret != 0 )
+ PT_LOG("VGA region mapping failed\n");
+
+@@ -216,26 +503,31 @@ int unregister_vga_regions(struct pt_dev
+ if ( !gfx_passthru || real_device->pci_dev->device_class != 0x0300 )
+ return ret;
+
++ /* legacy I/O ports 0x3B0 - 0x3BC */
+ ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3B0,
+ 0x3B0, 0xC, DPCI_REMOVE_MAPPING);
+
+- ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0,
+- 0x3C0, 0x20, DPCI_REMOVE_MAPPING);
+-
++ /* legacy video MMIO range 0xA0000 - 0xBFFFF */
+ ret |= xc_domain_memory_mapping(xc_handle, domid,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 0xa0000 >> XC_PAGE_SHIFT,
+ 20,
+ DPCI_REMOVE_MAPPING);
+
+- vendor_id = pt_pci_host_read(real_device->pci_dev, PCI_VENDOR_ID, 2);
+- if ( (vendor_id == PCI_VENDOR_ID_INTEL) && igd_guest_opregion )
++ /* Other VGA regions are vendor specific */
++ switch( real_device->pci_dev->vendor_id )
+ {
+- ret |= xc_domain_memory_mapping(xc_handle, domid,
+- igd_guest_opregion >> XC_PAGE_SHIFT,
+- igd_guest_opregion >> XC_PAGE_SHIFT,
+- 2,
+- DPCI_REMOVE_MAPPING);
++ case PCI_VENDOR_ID_INTEL:
++ ret = igd_unregister_vga_regions(real_device);
++ break;
++ case PCI_VENDOR_ID_ATI:
++ case PCI_VENDOR_ID_AMD:
++ ret = ati_unregister_vga_regions(real_device);
++ break;
++ default:
++ PT_LOG("gfx card wasn't supported by Xen passthru!\n");
++ ret = 1;
++ break;
+ }
+
+ if ( ret != 0 )
diff --git a/libre/xen/efi-xen.cfg b/libre/xen/efi-xen.cfg
new file mode 100644
index 000000000..3c8e4d04c
--- /dev/null
+++ b/libre/xen/efi-xen.cfg
@@ -0,0 +1,7 @@
+[global]
+default=xen
+
+[xen]
+options=console=vga dom0_mem=1024M,max:1024M dom0_max_vcpus=4 loglvl=all noreboot
+kernel=vmlinuz-linux-libre root=<Root Device> rw
+ramdisk=initramfs-linux-libre.img
diff --git a/libre/xen/grub.conf b/libre/xen/grub.conf
new file mode 100644
index 000000000..e456973db
--- /dev/null
+++ b/libre/xen/grub.conf
@@ -0,0 +1,3 @@
+#XEN_HYPERVISOR_CMDLINE="xsave=1"
+#XEN_LINUX_CMDLINE="console=tty0"
+#XEN_LINUX_CMDLINE_OVERRIDE=0
diff --git a/libre/xen/ovmf.patch b/libre/xen/ovmf.patch
new file mode 100644
index 000000000..19ad7d326
--- /dev/null
+++ b/libre/xen/ovmf.patch
@@ -0,0 +1,12 @@
+--- a/tools/firmware/Makefile
++++ b/tools/firmware/Makefile
+@@ -19,6 +19,9 @@
+
+ ovmf-dir:
+ GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf-dir
++ sed 's|python |python2 |g' -i "ovmf-dir/BaseTools/BinWrappers/PosixLike"/* || true
++ sed 's|python |python2 |g' -i "ovmf-dir/BaseTools/Tests/GNUmakefile"
++ patch -Np1 -i patch-gcc6-ovmf-build.sh.patch
+ cp ovmf-makefile ovmf-dir/Makefile;
+
+ seabios-dir:
diff --git a/libre/xen/patch-gcc6-etherboot-ath9k-9287-array.patch b/libre/xen/patch-gcc6-etherboot-ath9k-9287-array.patch
new file mode 100644
index 000000000..7b1f369b1
--- /dev/null
+++ b/libre/xen/patch-gcc6-etherboot-ath9k-9287-array.patch
@@ -0,0 +1,68 @@
+From 83d6f1f15f8cce844b0a131cbc63e444620e48b5 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Mon, 14 Mar 2016 15:18:36 +0100
+Subject: ath9k: fix buffer overrun for ar9287
+
+Code that was added back in 2.6.38 has an obvious overflow
+when accessing a static array, and at the time it was added
+only a code comment was put in front of it as a reminder
+to have it reviewed properly.
+
+This has not happened, but gcc-6 now points to the specific
+overflow:
+
+drivers/net/wireless/ath/ath9k/eeprom.c: In function 'ath9k_hw_get_gain_boundaries_pdadcs':
+drivers/net/wireless/ath/ath9k/eeprom.c:483:44: error: array subscript is above array bounds [-Werror=array-bounds]
+ maxPwrT4[i] = data_9287[idxL].pwrPdg[i][4];
+ ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
+
+It turns out that the correct array length exists in the local
+'intercepts' variable of this function, so we can just use that
+instead of hardcoding '4', so this patch changes all three
+instances to use that variable. The other two instances were
+already correct, but it's more consistent this way.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Fixes: 940cd2c12ebf ("ath9k_hw: merge the ar9287 version of ath9k_hw_get_gain_boundaries_pdadcs")
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/wireless/ath/ath9k/eeprom.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
+index 73fb423..a794157 100644
+--- a/src/drivers/net/ath/ath9k/ath9k_eeprom.c
++++ b/src/drivers/net/ath/ath9k/ath9k_eeprom.c
+@@ -477,10 +477,9 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
+
+ if (match) {
+ if (AR_SREV_9287(ah)) {
+- /* FIXME: array overrun? */
+ for (i = 0; i < numXpdGains; i++) {
+ minPwrT4[i] = data_9287[idxL].pwrPdg[i][0];
+- maxPwrT4[i] = data_9287[idxL].pwrPdg[i][4];
++ maxPwrT4[i] = data_9287[idxL].pwrPdg[i][intercepts - 1];
+ ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
+ data_9287[idxL].pwrPdg[i],
+ data_9287[idxL].vpdPdg[i],
+@@ -490,7 +489,7 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
+ } else if (eeprom_4k) {
+ for (i = 0; i < numXpdGains; i++) {
+ minPwrT4[i] = data_4k[idxL].pwrPdg[i][0];
+- maxPwrT4[i] = data_4k[idxL].pwrPdg[i][4];
++ maxPwrT4[i] = data_4k[idxL].pwrPdg[i][intercepts - 1];
+ ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
+ data_4k[idxL].pwrPdg[i],
+ data_4k[idxL].vpdPdg[i],
+@@ -500,7 +499,7 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
+ } else {
+ for (i = 0; i < numXpdGains; i++) {
+ minPwrT4[i] = data_def[idxL].pwrPdg[i][0];
+- maxPwrT4[i] = data_def[idxL].pwrPdg[i][4];
++ maxPwrT4[i] = data_def[idxL].pwrPdg[i][intercepts - 1];
+ ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
+ data_def[idxL].pwrPdg[i],
+ data_def[idxL].vpdPdg[i],
+--
+cgit v0.12
+
diff --git a/libre/xen/patch-gcc6-etherboot-e1000_phy.c.patch b/libre/xen/patch-gcc6-etherboot-e1000_phy.c.patch
new file mode 100644
index 000000000..4cd6c246c
--- /dev/null
+++ b/libre/xen/patch-gcc6-etherboot-e1000_phy.c.patch
@@ -0,0 +1,20 @@
+diff -aur a/src/drivers/net/e1000/e1000_phy.c b/src/drivers/net/e1000/e1000_phy.c
+--- a/src/drivers/net/e1000/e1000_phy.c 2016-05-12 19:40:13.950772568 +1000
++++ b/src/drivers/net/e1000/e1000_phy.c 2016-05-12 19:41:08.429089344 +1000
+@@ -164,7 +164,7 @@
+
+ DEBUGFUNC("e1000_get_phy_id");
+
+- if (!(phy->ops.read_reg))
++ if (!(phy->ops.read_reg)) {
+ goto out;
+
+ ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
+@@ -179,6 +179,7 @@
+
+ phy->id |= (u32)(phy_id & PHY_REVISION_MASK);
+ phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
++ }
+
+ out:
+ return ret_val;
diff --git a/libre/xen/patch-gcc6-etherboot-igb_phy.c.patch b/libre/xen/patch-gcc6-etherboot-igb_phy.c.patch
new file mode 100644
index 000000000..44beb4baa
--- /dev/null
+++ b/libre/xen/patch-gcc6-etherboot-igb_phy.c.patch
@@ -0,0 +1,20 @@
+diff -aur a/src/drivers/net/igb/igb_phy.c b/src/drivers/net/igb/igb_phy.c
+--- a/src/drivers/net/igb/igb_phy.c 2016-05-12 19:53:45.063246296 +1000
++++ b/src/drivers/net/igb/igb_phy.c 2016-05-12 19:54:09.992692278 +1000
+@@ -88,7 +88,7 @@
+
+ DEBUGFUNC("igb_get_phy_id");
+
+- if (!(phy->ops.read_reg))
++ if (!(phy->ops.read_reg)) {
+ goto out;
+
+ ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
+@@ -103,6 +103,7 @@
+
+ phy->id |= (u32)(phy_id & PHY_REVISION_MASK);
+ phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
++ }
+
+ out:
+ return ret_val;
diff --git a/libre/xen/patch-gcc6-etherboot-rm-unused-string-functions.patch b/libre/xen/patch-gcc6-etherboot-rm-unused-string-functions.patch
new file mode 100644
index 000000000..991d43330
--- /dev/null
+++ b/libre/xen/patch-gcc6-etherboot-rm-unused-string-functions.patch
@@ -0,0 +1,257 @@
+From b54167b8b6a35c7dab19bbe4b421d447036558d4 Mon Sep 17 00:00:00 2001
+From: Michael Brown <mcb30@ipxe.org>
+Date: Mon, 16 Feb 2015 15:33:32 +0000
+Subject: [PATCH] [libc] Remove unused string functions
+
+Signed-off-by: Michael Brown <mcb30@ipxe.org>
+---
+ src/core/stringextra.c | 188 ------------------------------------------------
+ src/include/string.h | 6 --
+ 2 files changed, 0 insertions(+), 194 deletions(-)
+
+diff --git a/src/core/stringextra.c b/src/core/stringextra.c
+index 0a50985..18ffc63 100644
+--- a/src/core/stringextra.c
++++ b/src/core/stringextra.c
+@@ -38,122 +38,6 @@ FILE_LICENCE ( GPL2_ONLY );
+
+ /* *** FROM string.c *** */
+
+-#ifndef __HAVE_ARCH_STRNICMP
+-/**
+- * strnicmp - Case insensitive, length-limited string comparison
+- * @s1: One string
+- * @s2: The other string
+- * @len: the maximum number of characters to compare
+- */
+-int strnicmp(const char *s1, const char *s2, size_t len)
+-{
+- /* Yes, Virginia, it had better be unsigned */
+- unsigned char c1, c2;
+-
+- c1 = 0; c2 = 0;
+- if (len) {
+- do {
+- c1 = *s1; c2 = *s2;
+- s1++; s2++;
+- if (!c1)
+- break;
+- if (!c2)
+- break;
+- if (c1 == c2)
+- continue;
+- c1 = tolower(c1);
+- c2 = tolower(c2);
+- if (c1 != c2)
+- break;
+- } while (--len);
+- }
+- return (int)c1 - (int)c2;
+-}
+-#endif
+-
+-char * ___strtok;
+-
+-#ifndef __HAVE_ARCH_STRNCAT
+-/**
+- * strncat - Append a length-limited, %NUL-terminated string to another
+- * @dest: The string to be appended to
+- * @src: The string to append to it
+- * @count: The maximum numbers of bytes to copy
+- *
+- * Note that in contrast to strncpy, strncat ensures the result is
+- * terminated.
+- */
+-char * strncat(char *dest, const char *src, size_t count)
+-{
+- char *tmp = dest;
+-
+- if (count) {
+- while (*dest)
+- dest++;
+- while ((*dest++ = *src++)) {
+- if (--count == 0) {
+- *dest = '\0';
+- break;
+- }
+- }
+- }
+-
+- return tmp;
+-}
+-#endif
+-
+-#ifndef __HAVE_ARCH_STRSPN
+-/**
+- * strspn - Calculate the length of the initial substring of @s which only
+- * contain letters in @accept
+- * @s: The string to be searched
+- * @accept: The string to search for
+- */
+-size_t strspn(const char *s, const char *accept)
+-{
+- const char *p;
+- const char *a;
+- size_t count = 0;
+-
+- for (p = s; *p != '\0'; ++p) {
+- for (a = accept; *a != '\0'; ++a) {
+- if (*p == *a)
+- break;
+- }
+- if (*a == '\0')
+- return count;
+- ++count;
+- }
+-
+- return count;
+-}
+-#endif
+-
+-#ifndef __HAVE_ARCH_STRCSPN
+-/**
+- * strcspn - Calculate the length of the initial substring of @s which only
+- * contain letters not in @reject
+- * @s: The string to be searched
+- * @accept: The string to search for
+- */
+-size_t strcspn(const char *s, const char *reject)
+-{
+- const char *p;
+- const char *r;
+- size_t count = 0;
+-
+- for (p = s; *p != '\0'; ++p) {
+- for (r = reject; *r != '\0'; ++r) {
+- if (*p == *r)
+- return count;
+- }
+- ++count;
+- }
+-
+- return count;
+-}
+-#endif
+-
+ #ifndef __HAVE_ARCH_STRPBRK
+ /**
+ * strpbrk - Find the first occurrence of a set of characters
+@@ -174,35 +58,6 @@ char * strpbrk(const char * cs,const char * ct)
+ }
+ #endif
+
+-#ifndef __HAVE_ARCH_STRTOK
+-/**
+- * strtok - Split a string into tokens
+- * @s: The string to be searched
+- * @ct: The characters to search for
+- *
+- * WARNING: strtok is deprecated, use strsep instead.
+- */
+-char * strtok(char * s,const char * ct)
+-{
+- char *sbegin, *send;
+-
+- sbegin = s ? s : ___strtok;
+- if (!sbegin) {
+- return NULL;
+- }
+- sbegin += strspn(sbegin,ct);
+- if (*sbegin == '\0') {
+- ___strtok = NULL;
+- return( NULL );
+- }
+- send = strpbrk( sbegin, ct);
+- if (send && *send != '\0')
+- *send++ = '\0';
+- ___strtok = send;
+- return (sbegin);
+-}
+-#endif
+-
+ #ifndef __HAVE_ARCH_STRSEP
+ /**
+ * strsep - Split a string into tokens
+@@ -230,46 +85,3 @@ char * strsep(char **s, const char *ct)
+ return sbegin;
+ }
+ #endif
+-
+-#ifndef __HAVE_ARCH_BCOPY
+-/**
+- * bcopy - Copy one area of memory to another
+- * @src: Where to copy from
+- * @dest: Where to copy to
+- * @count: The size of the area.
+- *
+- * Note that this is the same as memcpy(), with the arguments reversed.
+- * memcpy() is the standard, bcopy() is a legacy BSD function.
+- *
+- * You should not use this function to access IO space, use memcpy_toio()
+- * or memcpy_fromio() instead.
+- */
+-char * bcopy(const char * src, char * dest, int count)
+-{
+- return memmove(dest,src,count);
+-}
+-#endif
+-
+-#ifndef __HAVE_ARCH_MEMSCAN
+-/**
+- * memscan - Find a character in an area of memory.
+- * @addr: The memory area
+- * @c: The byte to search for
+- * @size: The size of the area.
+- *
+- * returns the address of the first occurrence of @c, or 1 byte past
+- * the area if @c is not found
+- */
+-void * memscan(const void * addr, int c, size_t size)
+-{
+- unsigned char * p = (unsigned char *) addr;
+-
+- while (size) {
+- if (*p == c)
+- return (void *) p;
+- p++;
+- size--;
+- }
+- return (void *) p;
+-}
+-#endif
+diff --git a/src/include/string.h b/src/include/string.h
+index 3482e1b..dfd78a6 100644
+--- a/src/include/string.h
++++ b/src/include/string.h
+@@ -19,11 +19,9 @@ FILE_LICENCE ( GPL2_ONLY );
+ #include <stddef.h>
+ #include <bits/string.h>
+
+-int __pure strnicmp(const char *s1, const char *s2, size_t len) __nonnull;
+ char * strcpy(char * dest,const char *src) __nonnull;
+ char * strncpy(char * dest,const char *src,size_t count) __nonnull;
+ char * strcat(char * dest, const char * src) __nonnull;
+-char * strncat(char *dest, const char *src, size_t count) __nonnull;
+ int __pure strcmp(const char * cs,const char * ct) __nonnull;
+ int __pure strncmp(const char * cs,const char * ct,
+ size_t count) __nonnull;
+@@ -31,16 +29,12 @@ char * __pure strchr(const char * s, int c) __nonnull;
+ char * __pure strrchr(const char * s, int c) __nonnull;
+ size_t __pure strlen(const char * s) __nonnull;
+ size_t __pure strnlen(const char * s, size_t count) __nonnull;
+-size_t __pure strspn(const char *s, const char *accept) __nonnull;
+-size_t __pure strcspn(const char *s, const char *reject) __nonnull;
+ char * __pure strpbrk(const char * cs,const char * ct) __nonnull;
+-char * strtok(char * s,const char * ct) __nonnull;
+ char * strsep(char **s, const char *ct) __nonnull;
+ void * memset(void * s,int c,size_t count) __nonnull;
+ void * memmove(void * dest,const void *src,size_t count) __nonnull;
+ int __pure memcmp(const void * cs,const void * ct,
+ size_t count) __nonnull;
+-void * __pure memscan(const void * addr, int c, size_t size) __nonnull;
+ char * __pure strstr(const char * s1,const char * s2) __nonnull;
+ void * __pure memchr(const void *s, int c, size_t n) __nonnull;
+ char * __malloc strdup(const char *s) __nonnull;
+--
+1.7.9
+
diff --git a/libre/xen/patch-gcc6-etherboot-via-rhine.c.patch b/libre/xen/patch-gcc6-etherboot-via-rhine.c.patch
new file mode 100644
index 000000000..697208ae3
--- /dev/null
+++ b/libre/xen/patch-gcc6-etherboot-via-rhine.c.patch
@@ -0,0 +1,21 @@
+diff -aru a/src/drivers/net/via-rhine.c b/src/drivers/net/via-rhine.c
+--- a/src/drivers/net/via-rhine.c 2016-05-12 19:24:14.047825550 +1000
++++ b/src/drivers/net/via-rhine.c 2016-05-12 19:33:18.061858418 +1000
+@@ -945,13 +945,15 @@
+ /* added comment by guard */
+ /* For supporting VT6107, please use revision id to recognize different chips in driver */
+ // if (tp->chip_id == 0x3065)
+- if( tp->chip_revision < 0x80 && tp->chip_revision >=0x40 )
++ if( tp->chip_revision < 0x80 && tp->chip_revision >=0x40 ) {
+ intr_status |= inb(nic->ioaddr + IntrStatus2) << 16;
+ intr_status = (intr_status & ~DEFAULT_INTR);
+- if ( action == ENABLE )
++ if ( action == ENABLE ) {
+ intr_status = intr_status | DEFAULT_INTR;
+ outw(intr_status, nic->ioaddr + IntrEnable);
++ }
+ break;
++ }
+ case FORCE :
+ outw(0x0010, nic->ioaddr + 0x84);
+ break;
diff --git a/libre/xen/patch-gcc6-etherboot-via-velocity.c.patch b/libre/xen/patch-gcc6-etherboot-via-velocity.c.patch
new file mode 100644
index 000000000..36a3d8115
--- /dev/null
+++ b/libre/xen/patch-gcc6-etherboot-via-velocity.c.patch
@@ -0,0 +1,12 @@
+diff -aur a/src/drivers/net/via-velocity.c b/src/drivers/net/via-velocity.c
+--- a/src/drivers/net/via-velocity.c 2016-05-12 19:14:33.231788641 +1000
++++ b/src/drivers/net/via-velocity.c 2016-05-12 19:17:08.235494746 +1000
+@@ -69,7 +69,7 @@
+
+ /* NIC specific static variables go here */
+ #define VELOCITY_PARAM(N,D) \
+- static const int N[MAX_UNITS]=OPTION_DEFAULT;
++ static __attribute__ ((unused)) const int N[MAX_UNITS]=OPTION_DEFAULT;
+ /* MODULE_PARM(N, "1-" __MODULE_STRING(MAX_UNITS) "i");\
+ MODULE_PARM_DESC(N, D); */
+
diff --git a/libre/xen/patch-gcc6-ovmf-build.sh.patch b/libre/xen/patch-gcc6-ovmf-build.sh.patch
new file mode 100644
index 000000000..3da5e1c32
--- /dev/null
+++ b/libre/xen/patch-gcc6-ovmf-build.sh.patch
@@ -0,0 +1,12 @@
+diff -aur a/ovmf-dir/OvmfPkg/build.sh b/ovmf-dir/OvmfPkg/build.sh
+--- a/ovmf-dir/OvmfPkg/build.sh 2016-05-12 12:32:47.417562962 +1000
++++ b/ovmf-dir/OvmfPkg/build.sh 2016-05-12 12:32:06.440897741 +1000
+@@ -95,7 +95,7 @@
+ 4.8.*)
+ TARGET_TOOLS=GCC48
+ ;;
+- 4.9.*|4.1[0-9].*|5.*.*)
++ 4.9.*|4.1[0-9].*|5.*.*|6.*.*)
+ TARGET_TOOLS=GCC49
+ ;;
+ *)
diff --git a/libre/xen/tmpfiles.d-xen.conf b/libre/xen/tmpfiles.d-xen.conf
new file mode 100644
index 000000000..a55258b0f
--- /dev/null
+++ b/libre/xen/tmpfiles.d-xen.conf
@@ -0,0 +1,2 @@
+d /run/xen 0755 root root -
+d /run/xenstored 0755 root root -
diff --git a/libre/xen/xen.conf b/libre/xen/xen.conf
new file mode 100644
index 000000000..37a5b59f7
--- /dev/null
+++ b/libre/xen/xen.conf
@@ -0,0 +1,19 @@
+xen-evtchn
+xen-gntdev
+xen-gntalloc
+xen-blkback
+xen-netback
+xen-pciback
+xen-acpi-processor
+## xen-acpi-processor: This module may not work on all machines; try removing this first if it causes issues.
+
+## The following were included in xencommons, but were not inserted by systemd:
+# evtchn
+# gntdev
+# netbk
+# blkbk
+# xen-scsibk
+# usbbk
+# pciback
+# blktap2
+# blktap
diff --git a/libre/xen/xen.install b/libre/xen/xen.install
new file mode 100644
index 000000000..f48de62f8
--- /dev/null
+++ b/libre/xen/xen.install
@@ -0,0 +1,75 @@
+install_msg() {
+ cat << __EOF__
+===> IMPORTANT NOTICES:
+
+In order to complete the installation, and enable Xen,
+at the very least you must:
+1. If using GRUB2, edit your GRUB2 config files as specified at
+ https://wiki.parabola.nu/index.php/Xen#Bootloader_Configuration
+
+ Support for the grub-mkconfig command was added, and will auto-discover
+ the deployed xen hypervisor and linux kernel
+2. If booting via efi, copy the example /etc/xen/efi-xen.cfg to /boot/xen.cfg
+ and edit the contents to match the settings you need.
+3. Issue the following commands to allow you to create and start VMs:
+
+ systemctl enable xen-qemu-dom0-disk-backend.service
+ systemctl enable xen-init-dom0.service
+ systemctl enable xenconsoled.service
+
+ Other optional services are:
+ systemctl enable xen-watchdog.service
+
+4. If you want some domains to automatically start up/shutdown, run the following:
+ systemctl enable xendomains.service
+
+For more information refer to the Wiki:
+ https://wiki.parabola.nu/index.php/Xen
+
+__EOF__
+
+}
+
+upgrade_msg() {
+ cat << __EOF__
+Xen 4.7
+Release notes
+http://wiki.xen.org/wiki/Xen_Project_4.7_Release_Notes
+Feature list
+http://wiki.xen.org/wiki/Xen_Project_4.7_Feature_List
+__EOF__
+
+}
+
+post_install() {
+ install_msg
+ upgrade_msg
+}
+
+post_upgrade() {
+ upgrade_msg
+}
+
+pre_remove() {
+ systemctl stop xendomains.service
+ systemctl stop xen-watchdog.service
+ systemctl stop xenconsoled.service
+ systemctl stop xen-init-dom0.service
+ systemctl stop xen-qemu-dom0-disk-backend.service
+
+ systemctl disable xendomains.service
+ systemctl disable xen-watchdog.service
+ systemctl disable xenconsoled.service
+ systemctl disable xen-init-dom0.service
+ systemctl disable xen-qemu-dom0-disk-backend.service
+}
+
+post_remove() {
+ cat << __EOF__
+===> IMPORTANT NOTICE:
+
+In order to finish removing Xen, you will need to modify
+your bootloader configuration files to load your Linux-libre
+kernel instead of Xen kernel.
+__EOF__
+}