svn commit: r475255 - in head: emulators/xen-kernel411 emulators/xen-kernel411/files sysutils/xen-tools411 sysutils/xen-tools411/files
Roger Pau Monné
royger at FreeBSD.org
Tue Jul 24 13:57:50 UTC 2018
Author: royger (src committer)
Date: Tue Jul 24 13:57:46 2018
New Revision: 475255
URL: https://svnweb.freebsd.org/changeset/ports/475255
Log:
xen: import version 4.11
Reviewed by: bapt
Sponsored by: Citrix Systems R&D
Differential Revision: https://reviews.freebsd.org/D16418
Added:
head/emulators/xen-kernel411/
head/emulators/xen-kernel411/Makefile (contents, props changed)
head/emulators/xen-kernel411/distinfo (contents, props changed)
head/emulators/xen-kernel411/files/
head/emulators/xen-kernel411/files/0001-pci-treat-class-0-devices-as-endpoints.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-vpci-msi-split-code-to-bind-pirq.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-x86-HVM-improve-MTRR-load-checks.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-x86-dom0-add-extra-RAM-regions-as-UNUSABLE-for-PVH-m.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-x86-efi-move-the-logic-to-detect-PE-build-support.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-x86-mtrr-introduce-mask-to-get-VCNT-from-MTRRcap-MSR.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-x86-pvh-change-the-order-of-the-iommu-initialization.patch (contents, props changed)
head/emulators/xen-kernel411/files/0001-x86-replace-usage-in-the-linker-script.patch (contents, props changed)
head/emulators/xen-kernel411/files/0002-vpci-msi-fix-update-of-bound-MSI-interrupts.patch (contents, props changed)
head/emulators/xen-kernel411/files/0002-x86-efi-split-compiler-vs-linker-support.patch (contents, props changed)
head/emulators/xen-kernel411/files/0002-x86-mtrr-split-enabled-field-into-two-boolean-flags.patch (contents, props changed)
head/emulators/xen-kernel411/files/0003-hvm-mtrr-add-emacs-local-variables-block-with-format.patch (contents, props changed)
head/emulators/xen-kernel411/files/0004-hvm-mtrr-use-the-hardware-number-of-variable-ranges-.patch (contents, props changed)
head/emulators/xen-kernel411/files/0005-hvm-mtrr-copy-hardware-state-for-Dom0.patch (contents, props changed)
head/emulators/xen-kernel411/files/0006-libxc-pvh-set-default-MTRR-type-to-write-back.patch (contents, props changed)
head/emulators/xen-kernel411/files/0007-docs-pvh-document-initial-MTRR-state.patch (contents, props changed)
head/emulators/xen-kernel411/files/xen.4th (contents, props changed)
head/emulators/xen-kernel411/pkg-descr (contents, props changed)
head/emulators/xen-kernel411/pkg-message (contents, props changed)
head/sysutils/xen-tools411/
head/sysutils/xen-tools411/Makefile (contents, props changed)
head/sysutils/xen-tools411/distinfo (contents, props changed)
head/sysutils/xen-tools411/files/
head/sysutils/xen-tools411/files/0001-build-fix-include-paths-in-FreeBSD.patch (contents, props changed)
head/sysutils/xen-tools411/files/0001-docs-use-the-make-wildcard-function-instead-of-find.patch (contents, props changed)
head/sysutils/xen-tools411/files/0001-x86-efi-move-the-logic-to-detect-PE-build-support.patch (contents, props changed)
head/sysutils/xen-tools411/files/0001-x86-replace-usage-in-the-linker-script.patch (contents, props changed)
head/sysutils/xen-tools411/files/0002-x86-efi-split-compiler-vs-linker-support.patch (contents, props changed)
head/sysutils/xen-tools411/pkg-descr (contents, props changed)
head/sysutils/xen-tools411/pkg-plist (contents, props changed)
Added: head/emulators/xen-kernel411/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/Makefile Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,73 @@
+# $FreeBSD$
+
+PORTNAME= xen
+PORTVERSION= 4.11.0
+PORTREVISION= 0
+CATEGORIES= emulators
+MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/
+PKGNAMESUFFIX= -kernel
+
+MAINTAINER= royger at FreeBSD.org
+COMMENT= Hypervisor using a microkernel design
+
+LICENSE= GPLv2
+
+ONLY_FOR_ARCHS= amd64
+
+USES= cpe gmake python:2.7,build
+# Ports build environment has ARCH=amd64 set which disables Xen automatic arch
+# detection, but amd64 is not a valid arch for Xen. Hardcode x86_64 on the
+# command line in order to overwrite the one from the environment.
+MAKE_ARGS= clang=y PYTHON=${PYTHON_CMD} ARCH=x86_64
+NO_MTREE= yes
+STRIP= #
+PLIST_FILES= /boot/xen \
+ /boot/xen.4th \
+ lib/debug/boot/xen.debug
+
+# IOMMU fixes
+EXTRA_PATCHES= ${FILESDIR}/0001-pci-treat-class-0-devices-as-endpoints.patch:-p1
+# vPCI MSI fixes
+EXTRA_PATCHES+= ${FILESDIR}/0001-vpci-msi-split-code-to-bind-pirq.patch:-p1 \
+ ${FILESDIR}/0002-vpci-msi-fix-update-of-bound-MSI-interrupts.patch:-p1
+# Add extra RAM regions to Dom0 memory map as UNUSABNLE
+EXTRA_PATCHES+= ${FILESDIR}/0001-x86-dom0-add-extra-RAM-regions-as-UNUSABLE-for-PVH-m.patch:-p1
+# MTRR guest setup for PVH
+EXTRA_PATCHES+= ${FILESDIR}/0001-x86-mtrr-introduce-mask-to-get-VCNT-from-MTRRcap-MSR.patch:-p1 \
+ ${FILESDIR}/0001-x86-HVM-improve-MTRR-load-checks.patch:-p1 \
+ ${FILESDIR}/0002-x86-mtrr-split-enabled-field-into-two-boolean-flags.patch:-p1 \
+ ${FILESDIR}/0003-hvm-mtrr-add-emacs-local-variables-block-with-format.patch:-p1 \
+ ${FILESDIR}/0004-hvm-mtrr-use-the-hardware-number-of-variable-ranges-.patch:-p1 \
+ ${FILESDIR}/0005-hvm-mtrr-copy-hardware-state-for-Dom0.patch:-p1 \
+ ${FILESDIR}/0006-libxc-pvh-set-default-MTRR-type-to-write-back.patch:-p1 \
+ ${FILESDIR}/0007-docs-pvh-document-initial-MTRR-state.patch:-p1
+# Build with lld (LLVM linker)
+EXTRA_PATCHES+= ${FILESDIR}/0001-x86-replace-usage-in-the-linker-script.patch:-p1 \
+ ${FILESDIR}/0001-x86-efi-move-the-logic-to-detect-PE-build-support.patch:-p1 \
+ ${FILESDIR}/0002-x86-efi-split-compiler-vs-linker-support.patch:-p1
+# Fix PVH Dom0 build with shadow paging
+EXTRA_PATCHES+= ${FILESDIR}/0001-x86-pvh-change-the-order-of-the-iommu-initialization.patch:-p1
+
+.include <bsd.port.options.mk>
+
+.if ${OPSYS} != FreeBSD
+IGNORE= only supported on FreeBSD
+.endif
+
+.if ${OSVERSION} < 1200074
+IGNORE= only supported on recent FreeBSD HEAD
+.endif
+
+# The ports native 'build' target cannot be used because it sets
+# CFLAGS, and that breaks the Xen build system.
+do-build:
+ ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -C ${WRKSRC} xen ${MAKE_ARGS}
+
+do-install:
+ ${MKDIR} ${STAGEDIR}/boot
+ ${MKDIR} ${STAGEDIR}${PREFIX}/lib/debug/boot/
+ ${INSTALL_PROGRAM} ${WRKSRC}/xen/xen ${STAGEDIR}/boot
+ ${INSTALL_DATA} ${FILESDIR}/xen.4th ${STAGEDIR}/boot
+ ${INSTALL_DATA} ${WRKSRC}/xen/xen-syms ${STAGEDIR}${PREFIX}/lib/debug/boot/xen.debug
+
+.include <bsd.port.mk>
Added: head/emulators/xen-kernel411/distinfo
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/distinfo Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1532345202
+SHA256 (xen-4.11.0.tar.gz) = 826e3a9f6d0eac94a825d272cc2c1294e22640ae75af906eb13920f9ad667643
+SIZE (xen-4.11.0.tar.gz) = 25131533
Added: head/emulators/xen-kernel411/files/0001-pci-treat-class-0-devices-as-endpoints.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-pci-treat-class-0-devices-as-endpoints.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,50 @@
+From 7495a5b6aa1c741964baf18a1cbdb8b8d71cce98 Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau at citrix.com>
+Date: Tue, 8 May 2018 11:33:00 +0200
+Subject: [PATCH] pci: treat class 0 devices as endpoints
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Class 0 devices are legacy pre PCI 2.0 devices that didn't have a
+class code. Treat them as endpoints, so that they can be handled by
+the IOMMU and properly passed-through to the hardware domain.
+
+Such device has been seen on a Super Micro server, lspci -vv reports:
+
+00:13.0 Non-VGA unclassified device: Intel Corporation Device a135 (rev 31)
+ Subsystem: Super Micro Computer Inc Device 0931
+ Flags: bus master, fast devsel, latency 0, IRQ 11
+ Memory at df222000 (64-bit, non-prefetchable) [size=4K]
+ Capabilities: [80] Power Management version 3
+
+Arguably this is not a legacy device (since this is a new server), but
+in any case Xen needs to deal with it.
+
+Suggested-by: Andrew Cooper <andrew.cooper3 at citrix.com>
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Acked-by: Jan Beulich <jbeulich at suse.com>
+---
+ xen/drivers/passthrough/pci.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
+index 1db69d5b99..c4890a4295 100644
+--- a/xen/drivers/passthrough/pci.c
++++ b/xen/drivers/passthrough/pci.c
+@@ -927,10 +927,11 @@ enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn)
+ case PCI_CLASS_BRIDGE_HOST:
+ return DEV_TYPE_PCI_HOST_BRIDGE;
+
+- case 0x0000: case 0xffff:
++ case 0xffff:
+ return DEV_TYPE_PCI_UNKNOWN;
+ }
+
++ /* NB: treat legacy pre PCI 2.0 devices (class_device == 0) as endpoints. */
+ return pos ? DEV_TYPE_PCIe_ENDPOINT : DEV_TYPE_PCI;
+ }
+
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-vpci-msi-split-code-to-bind-pirq.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-vpci-msi-split-code-to-bind-pirq.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,123 @@
+From 9109e5afb99012244e9fbe7f44e7010950051443 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau at citrix.com>
+Date: Mon, 2 Jul 2018 13:07:26 +0200
+Subject: [PATCH 1/2] vpci/msi: split code to bind pirq
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+And put it in a separate update function. This is required in order to
+improve binding of MSI PIRQs when using vPCI.
+
+No functional change.
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Reviewed-by: Jan Beulich <jbeulich at suse.com>
+---
+ xen/arch/x86/hvm/vmsi.c | 73 +++++++++++++++++++++++++----------------
+ 1 file changed, 45 insertions(+), 28 deletions(-)
+
+diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
+index 5ab7387d78..acadc23f8d 100644
+--- a/xen/arch/x86/hvm/vmsi.c
++++ b/xen/arch/x86/hvm/vmsi.c
+@@ -663,6 +663,42 @@ void vpci_msi_arch_mask(struct vpci_msi *msi, const struct pci_dev *pdev,
+ vpci_mask_pirq(pdev->domain, msi->arch.pirq + entry, mask);
+ }
+
++static int vpci_msi_update(const struct pci_dev *pdev, uint32_t data,
++ uint64_t address, unsigned int vectors,
++ unsigned int pirq, uint32_t mask)
++{
++ unsigned int i;
++
++ ASSERT(pcidevs_locked());
++
++ for ( i = 0; i < vectors; i++ )
++ {
++ uint8_t vector = MASK_EXTR(data, MSI_DATA_VECTOR_MASK);
++ uint8_t vector_mask = 0xff >> (8 - fls(vectors) + 1);
++ struct xen_domctl_bind_pt_irq bind = {
++ .machine_irq = pirq + i,
++ .irq_type = PT_IRQ_TYPE_MSI,
++ .u.msi.gvec = (vector & ~vector_mask) |
++ ((vector + i) & vector_mask),
++ .u.msi.gflags = msi_gflags(data, address, (mask >> i) & 1),
++ };
++ int rc = pt_irq_create_bind(pdev->domain, &bind);
++
++ if ( rc )
++ {
++ gdprintk(XENLOG_ERR,
++ "%04x:%02x:%02x.%u: failed to bind PIRQ %u: %d\n",
++ pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn),
++ PCI_FUNC(pdev->devfn), pirq + i, rc);
++ while ( bind.machine_irq-- > pirq )
++ pt_irq_destroy_bind(pdev->domain, &bind);
++ return rc;
++ }
++ }
++
++ return 0;
++}
++
+ static int vpci_msi_enable(const struct pci_dev *pdev, uint32_t data,
+ uint64_t address, unsigned int nr,
+ paddr_t table_base, uint32_t mask)
+@@ -674,7 +710,7 @@ static int vpci_msi_enable(const struct pci_dev *pdev, uint32_t data,
+ .table_base = table_base,
+ .entry_nr = nr,
+ };
+- unsigned int i, vectors = table_base ? 1 : nr;
++ unsigned vectors = table_base ? 1 : nr;
+ int rc, pirq = INVALID_PIRQ;
+
+ /* Get a PIRQ. */
+@@ -690,36 +726,17 @@ static int vpci_msi_enable(const struct pci_dev *pdev, uint32_t data,
+ return rc;
+ }
+
+- for ( i = 0; i < vectors; i++ )
++ pcidevs_lock();
++ rc = vpci_msi_update(pdev, data, address, vectors, pirq, mask);
++ if ( rc )
+ {
+- uint8_t vector = MASK_EXTR(data, MSI_DATA_VECTOR_MASK);
+- uint8_t vector_mask = 0xff >> (8 - fls(vectors) + 1);
+- struct xen_domctl_bind_pt_irq bind = {
+- .machine_irq = pirq + i,
+- .irq_type = PT_IRQ_TYPE_MSI,
+- .u.msi.gvec = (vector & ~vector_mask) |
+- ((vector + i) & vector_mask),
+- .u.msi.gflags = msi_gflags(data, address, (mask >> i) & 1),
+- };
+-
+- pcidevs_lock();
+- rc = pt_irq_create_bind(pdev->domain, &bind);
+- if ( rc )
+- {
+- gdprintk(XENLOG_ERR,
+- "%04x:%02x:%02x.%u: failed to bind PIRQ %u: %d\n",
+- pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn),
+- PCI_FUNC(pdev->devfn), pirq + i, rc);
+- while ( bind.machine_irq-- > pirq )
+- pt_irq_destroy_bind(pdev->domain, &bind);
+- spin_lock(&pdev->domain->event_lock);
+- unmap_domain_pirq(pdev->domain, pirq);
+- spin_unlock(&pdev->domain->event_lock);
+- pcidevs_unlock();
+- return rc;
+- }
++ spin_lock(&pdev->domain->event_lock);
++ unmap_domain_pirq(pdev->domain, pirq);
++ spin_unlock(&pdev->domain->event_lock);
+ pcidevs_unlock();
++ return rc;
+ }
++ pcidevs_unlock();
+
+ return pirq;
+ }
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-x86-HVM-improve-MTRR-load-checks.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-x86-HVM-improve-MTRR-load-checks.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,86 @@
+From 76159f10b174d8a5cd4c50213a9d21fcc0e9441d Mon Sep 17 00:00:00 2001
+From: Jan Beulich <jbeulich at suse.com>
+Date: Mon, 16 Jul 2018 15:08:02 +0200
+Subject: [PATCH 1/7] x86/HVM: improve MTRR load checks
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We should not assume that the incoming set of values contains exactly
+MTRR_VCNT variable range MSRs. Permit a smaller amount and reject a
+bigger one. As a result the save path then also needs to no longer use
+a fixed upper bound, in turn requiring unused space in the save record
+to be zeroed up front.
+
+Also slightly refine types where appropriate.
+
+Signed-off-by: Jan Beulich <jbeulich at suse.com>
+[switch to use MASK_EXTR to get VCNT]
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+---
+ xen/arch/x86/hvm/mtrr.c | 28 ++++++++++++++++++----------
+ 1 file changed, 18 insertions(+), 10 deletions(-)
+
+diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
+index c2927fb437..a636012388 100644
+--- a/xen/arch/x86/hvm/mtrr.c
++++ b/xen/arch/x86/hvm/mtrr.c
+@@ -673,22 +673,22 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
+
+ static int hvm_save_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
+ {
+- int i;
+ struct vcpu *v;
+- struct hvm_hw_mtrr hw_mtrr;
+- struct mtrr_state *mtrr_state;
++
+ /* save mtrr&pat */
+ for_each_vcpu(d, v)
+ {
+- mtrr_state = &v->arch.hvm_vcpu.mtrr;
++ const struct mtrr_state *mtrr_state = &v->arch.hvm_vcpu.mtrr;
++ struct hvm_hw_mtrr hw_mtrr = {
++ .msr_mtrr_def_type = mtrr_state->def_type |
++ (mtrr_state->enabled << 10),
++ .msr_mtrr_cap = mtrr_state->mtrr_cap,
++ };
++ unsigned int i;
+
+ hvm_get_guest_pat(v, &hw_mtrr.msr_pat_cr);
+
+- hw_mtrr.msr_mtrr_def_type = mtrr_state->def_type
+- | (mtrr_state->enabled << 10);
+- hw_mtrr.msr_mtrr_cap = mtrr_state->mtrr_cap;
+-
+- for ( i = 0; i < MTRR_VCNT; i++ )
++ for ( i = 0; i < MASK_EXTR(hw_mtrr.msr_mtrr_cap, MTRRcap_VCNT); i++ )
+ {
+ /* save physbase */
+ hw_mtrr.msr_mtrr_var[i*2] =
+@@ -726,6 +726,14 @@ static int hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
+ if ( hvm_load_entry(MTRR, h, &hw_mtrr) != 0 )
+ return -EINVAL;
+
++ if ( MASK_EXTR(hw_mtrr.msr_mtrr_cap, MTRRcap_VCNT) > MTRR_VCNT )
++ {
++ dprintk(XENLOG_G_ERR,
++ "HVM restore: %pv: too many (%lu) variable range MTRRs\n",
++ v, MASK_EXTR(hw_mtrr.msr_mtrr_cap, MTRRcap_VCNT));
++ return -EINVAL;
++ }
++
+ mtrr_state = &v->arch.hvm_vcpu.mtrr;
+
+ hvm_set_guest_pat(v, hw_mtrr.msr_pat_cr);
+@@ -735,7 +743,7 @@ static int hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
+ for ( i = 0; i < NUM_FIXED_MSR; i++ )
+ mtrr_fix_range_msr_set(d, mtrr_state, i, hw_mtrr.msr_mtrr_fixed[i]);
+
+- for ( i = 0; i < MTRR_VCNT; i++ )
++ for ( i = 0; i < MASK_EXTR(hw_mtrr.msr_mtrr_cap, MTRRcap_VCNT); i++ )
+ {
+ mtrr_var_range_msr_set(d, mtrr_state,
+ MSR_IA32_MTRR_PHYSBASE(i),
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-x86-dom0-add-extra-RAM-regions-as-UNUSABLE-for-PVH-m.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-x86-dom0-add-extra-RAM-regions-as-UNUSABLE-for-PVH-m.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,94 @@
+From e8e58be2b77708fd4d6ba6bca3f70bc507fde4be Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau at citrix.com>
+Date: Tue, 26 Jun 2018 08:48:14 +0200
+Subject: [PATCH] x86/dom0: add extra RAM regions as UNUSABLE for PVH memory
+ map
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When running as PVH Dom0 the native memory map is used in order to
+craft a tailored memory map for Dom0 taking into account it's memory
+limit.
+
+Dom0 memory is always going to be smaller than the total amount
+of memory present on the host, so in order to prevent Dom0 from
+relocating PCI BARs over RAM regions mark all the RAM regions not
+available to Dom0 as UNUSABLE in the memory map.
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Acked-by: Jan Beulich <jbeulich at suse.com>
+---
+ xen/arch/x86/hvm/dom0_build.c | 25 +++++++++++++++++--------
+ 1 file changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
+index b237508072..e2b5d48e03 100644
+--- a/xen/arch/x86/hvm/dom0_build.c
++++ b/xen/arch/x86/hvm/dom0_build.c
+@@ -314,8 +314,10 @@ static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages)
+
+ /*
+ * Craft the e820 memory map for Dom0 based on the hardware e820 map.
++ * Add an extra entry in case we have to split a RAM entry into a RAM and a
++ * UNUSABLE one in order to truncate it.
+ */
+- d->arch.e820 = xzalloc_array(struct e820entry, e820.nr_map);
++ d->arch.e820 = xzalloc_array(struct e820entry, e820.nr_map + 1);
+ if ( !d->arch.e820 )
+ panic("Unable to allocate memory for Dom0 e820 map");
+ entry_guest = d->arch.e820;
+@@ -323,19 +325,20 @@ static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages)
+ /* Clamp e820 memory map to match the memory assigned to Dom0 */
+ for ( i = 0, entry = e820.map; i < e820.nr_map; i++, entry++ )
+ {
++ *entry_guest = *entry;
++
+ if ( entry->type != E820_RAM )
+- {
+- *entry_guest = *entry;
+ goto next;
+- }
+
+ if ( nr_pages == cur_pages )
+ {
+ /*
+- * We already have all the assigned memory,
+- * skip this entry
++ * We already have all the requested memory, turn this RAM region
++ * into a UNUSABLE region in order to prevent Dom0 from placing
++ * BARs in this area.
+ */
+- continue;
++ entry_guest->type = E820_UNUSABLE;
++ goto next;
+ }
+
+ /*
+@@ -358,6 +361,12 @@ static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages)
+ {
+ /* Truncate region */
+ entry_guest->size = (nr_pages - cur_pages) << PAGE_SHIFT;
++ /* Add the remaining of the RAM region as UNUSABLE. */
++ entry_guest++;
++ d->arch.nr_e820++;
++ entry_guest->type = E820_UNUSABLE;
++ entry_guest->addr = start + ((nr_pages - cur_pages) << PAGE_SHIFT);
++ entry_guest->size = end - entry_guest->addr;
+ cur_pages = nr_pages;
+ }
+ else
+@@ -367,9 +376,9 @@ static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages)
+ next:
+ d->arch.nr_e820++;
+ entry_guest++;
++ ASSERT(d->arch.nr_e820 <= e820.nr_map + 1);
+ }
+ ASSERT(cur_pages == nr_pages);
+- ASSERT(d->arch.nr_e820 <= e820.nr_map);
+ }
+
+ static int __init pvh_setup_p2m(struct domain *d)
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-x86-efi-move-the-logic-to-detect-PE-build-support.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-x86-efi-move-the-logic-to-detect-PE-build-support.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,129 @@
+From 9bd8e5d5cf128f5f19d8b8e74bd693c2711ce4d4 Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau at citrix.com>
+Date: Fri, 20 Jul 2018 10:58:50 +0200
+Subject: [PATCH 1/2] x86/efi: move the logic to detect PE build support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So that it can be used by other components apart from the efi specific
+code. By moving the detection code creating a dummy efi/disabled file
+can be avoided.
+
+This is required so that the conditional used to define the efi symbol
+in the linker script can be removed and instead the definition of the
+efi symbol can be guarded using the preprocessor.
+
+The motivation behind this change is to be able to build Xen using lld
+(the LLVM linker), that at least on version 6.0.0 doesn't work
+properly with a DEFINED being used in a conditional expression:
+
+ld -melf_x86_64_fbsd -T xen.lds -N prelink.o --build-id=sha1 \
+ /root/src/xen/xen/common/symbols-dummy.o -o /root/src/xen/xen/.xen-syms.0
+ld: error: xen.lds:233: symbol not found: efi
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Reviewed-by: Jan Beulich <jbeulich at suse.com>
+---
+Cc: Jan Beulich <jbeulich at suse.com>
+Cc: Andrew Cooper <andrew.cooper3 at citrix.com>
+Cc: Daniel Kiper <daniel.kiper at oracle.com>
+---
+Changes since v2:
+ - Use CFLAGS-y to append the XEN_BUILD_PE define.
+ - Check that XEN_BUILD_PE is set to 'y' in order to build the PE
+ binary.
+
+Changes since v1:
+ - Rename variable.
+ - Remove usage of the efi/disabled file.
+---
+ .gitignore | 1 -
+ xen/arch/x86/Makefile | 9 +++++++--
+ xen/arch/x86/efi/Makefile | 11 +++--------
+ xen/arch/x86/xen.lds.S | 4 +++-
+ 4 files changed, 13 insertions(+), 12 deletions(-)
+
+diff --git a/.gitignore b/.gitignore
+index 55b78008c0..1625a8f0e7 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -302,7 +302,6 @@ xen/arch/x86/boot/*.bin
+ xen/arch/x86/boot/*.lnk
+ xen/arch/x86/efi.lds
+ xen/arch/x86/efi/check.efi
+-xen/arch/x86/efi/disabled
+ xen/arch/x86/efi/mkreloc
+ xen/arch/*/efi/boot.c
+ xen/arch/*/efi/compat.c
+diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
+index 5563c813dd..172685fb41 100644
+--- a/xen/arch/x86/Makefile
++++ b/xen/arch/x86/Makefile
+@@ -163,10 +163,15 @@ 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
+
++# Check if the build system supports PE.
++XEN_BUILD_PE := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
++export XEN_BUILD_PE := $(if $(XEN_BUILD_PE),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>/dev/null && echo y))
++CFLAGS-$(XEN_BUILD_PE) += -DXEN_BUILD_PE
++
+ $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A VIRT_START$$,,p')
+ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_START$$,,p')
+ # Don't use $(wildcard ...) here - at least make 3.80 expands this too early!
+-$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)
++$(TARGET).efi: guard = $(if $(filter y,$(XEN_BUILD_PE)),,:)
+
+ ifneq ($(build_id_linker),)
+ ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
+@@ -232,6 +237,6 @@ efi/mkreloc: efi/mkreloc.c
+ clean::
+ rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32
+ rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d
+- rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/disabled efi/mkreloc
++ rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/mkreloc
+ rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin
+ rm -f note.o
+diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile
+index 3be9661108..918383b325 100644
+--- a/xen/arch/x86/efi/Makefile
++++ b/xen/arch/x86/efi/Makefile
+@@ -1,16 +1,11 @@
+ CFLAGS += -fshort-wchar
+
+-efi := y$(shell rm -f disabled)
+-efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c check.c 2>disabled && echo y))
+-efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o check.efi check.o 2>disabled && echo y))
+-efi := $(if $(efi),$(shell rm disabled)y)
+-
+ %.o: %.ihex
+ $(OBJCOPY) -I ihex -O binary $< $@
+
+ boot.init.o: buildid.o
+
+ obj-y := stub.o
+-obj-$(efi) := boot.init.o compat.o relocs-dummy.o runtime.o
+-extra-$(efi) += buildid.o
+-nocov-$(efi) += stub.o
++obj-$(XEN_BUILD_PE) := boot.init.o compat.o relocs-dummy.o runtime.o
++extra-$(XEN_BUILD_PE) += buildid.o
++nocov-$(XEN_BUILD_PE) += stub.o
+diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
+index 326e885402..4a59467986 100644
+--- a/xen/arch/x86/xen.lds.S
++++ b/xen/arch/x86/xen.lds.S
+@@ -304,7 +304,9 @@ SECTIONS
+ } :text
+ #endif
+
+- efi = DEFINED(efi) ? efi : .;
++#ifndef XEN_BUILD_PE
++ efi = .;
++#endif
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-x86-mtrr-introduce-mask-to-get-VCNT-from-MTRRcap-MSR.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-x86-mtrr-introduce-mask-to-get-VCNT-from-MTRRcap-MSR.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,87 @@
+From f7c587fa1341b59f4ff654bd7e55e162f3513130 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau at citrix.com>
+Date: Thu, 5 Jul 2018 15:28:56 +0200
+Subject: [PATCH] x86/mtrr: introduce mask to get VCNT from MTRRcap MSR
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+No functional change.
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Reviewed-by: Jan Beulich <jbeulich at suse.com>
+---
+ xen/arch/x86/cpu/mtrr/main.c | 2 +-
+ xen/arch/x86/hvm/mtrr.c | 8 ++++----
+ xen/include/asm-x86/msr-index.h | 2 ++
+ 3 files changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/xen/arch/x86/cpu/mtrr/main.c b/xen/arch/x86/cpu/mtrr/main.c
+index 56f71a6e1f..e9df53f00d 100644
+--- a/xen/arch/x86/cpu/mtrr/main.c
++++ b/xen/arch/x86/cpu/mtrr/main.c
+@@ -95,7 +95,7 @@ static void __init set_num_var_ranges(void)
+ config = 2;
+ else if (is_cpu(CENTAUR))
+ config = 8;
+- num_var_ranges = config & 0xff;
++ num_var_ranges = MASK_EXTR(config, MTRRcap_VCNT);
+ }
+
+ static void __init init_table(void)
+diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
+index c78e5c17ad..c2927fb437 100644
+--- a/xen/arch/x86/hvm/mtrr.c
++++ b/xen/arch/x86/hvm/mtrr.c
+@@ -78,7 +78,7 @@ static uint8_t __read_mostly pat_entry_tbl[PAT_TYPE_NUMS] =
+ bool_t is_var_mtrr_overlapped(const struct mtrr_state *m)
+ {
+ unsigned int seg, i;
+- unsigned int num_var_ranges = (uint8_t)m->mtrr_cap;
++ unsigned int num_var_ranges = MASK_EXTR(m->mtrr_cap, MTRRcap_VCNT);
+
+ for ( i = 0; i < num_var_ranges; i++ )
+ {
+@@ -193,7 +193,7 @@ static int get_mtrr_type(const struct mtrr_state *m,
+ uint8_t overlap_mtrr = 0;
+ uint8_t overlap_mtrr_pos = 0;
+ uint64_t mask = -(uint64_t)PAGE_SIZE << order;
+- unsigned int seg, num_var_ranges = m->mtrr_cap & 0xff;
++ unsigned int seg, num_var_ranges = MASK_EXTR(m->mtrr_cap, MTRRcap_VCNT);
+
+ if ( unlikely(!(m->enabled & 0x2)) )
+ return MTRR_TYPE_UNCACHABLE;
+@@ -483,7 +483,7 @@ bool mtrr_pat_not_equal(const struct vcpu *vd, const struct vcpu *vs)
+
+ if ( md->enabled & 2 )
+ {
+- unsigned int num_var_ranges = (uint8_t)md->mtrr_cap;
++ unsigned int num_var_ranges = MASK_EXTR(md->mtrr_cap, MTRRcap_VCNT);
+
+ /* Test default type MSR. */
+ if ( md->def_type != ms->def_type )
+@@ -499,7 +499,7 @@ bool mtrr_pat_not_equal(const struct vcpu *vd, const struct vcpu *vs)
+ return true;
+
+ /* Test variable ranges. */
+- if ( num_var_ranges != (uint8_t)ms->mtrr_cap ||
++ if ( num_var_ranges != MASK_EXTR(ms->mtrr_cap, MTRRcap_VCNT) ||
+ memcmp(md->var_ranges, ms->var_ranges,
+ num_var_ranges * sizeof(*md->var_ranges)) )
+ return true;
+diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
+index 8fbccc88a7..95bb66916c 100644
+--- a/xen/include/asm-x86/msr-index.h
++++ b/xen/include/asm-x86/msr-index.h
+@@ -60,6 +60,8 @@
+ #define ATM_LNC_C6_AUTO_DEMOTE (1UL << 25)
+
+ #define MSR_MTRRcap 0x000000fe
++#define MTRRcap_VCNT 0x000000ff
++
+ #define MSR_IA32_BBL_CR_CTL 0x00000119
+
+ #define MSR_IA32_SYSENTER_CS 0x00000174
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-x86-pvh-change-the-order-of-the-iommu-initialization.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-x86-pvh-change-the-order-of-the-iommu-initialization.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,53 @@
+From ec3d58041829e0747d94efa11a44467c3e083b60 Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau at citrix.com>
+Date: Tue, 24 Jul 2018 13:12:18 +0200
+Subject: [PATCH] x86/pvh: change the order of the iommu initialization for
+ Dom0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The iommu initialization will also create MMIO mappings in the Dom0
+p2m, so the paging memory pool needs to be allocated or else iommu
+initialization will fail.
+
+Move the call to init the iommu after the Dom0 p2m has been setup in
+order to solve this.
+
+Note that issues caused by this wrong ordering have only been seen
+when using shadow paging.
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Acked-by: Jan Beulich <jbeulich at suse.com>
+---
+Cc: Jan Beulich <jbeulich at suse.com>
+Cc: Andrew Cooper <andrew.cooper3 at citrix.com>
+---
+ xen/arch/x86/hvm/dom0_build.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
+index 9a833fa4b9..f0cd63b1ec 100644
+--- a/xen/arch/x86/hvm/dom0_build.c
++++ b/xen/arch/x86/hvm/dom0_build.c
+@@ -1093,8 +1093,6 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
+
+ printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id);
+
+- iommu_hwdom_init(d);
+-
+ rc = pvh_setup_p2m(d);
+ if ( rc )
+ {
+@@ -1102,6 +1100,8 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
+ return rc;
+ }
+
++ iommu_hwdom_init(d);
++
+ rc = pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map(image),
+ cmdline, &entry, &start_info);
+ if ( rc )
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0001-x86-replace-usage-in-the-linker-script.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0001-x86-replace-usage-in-the-linker-script.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,39 @@
+From e21ba44f771226a5f6f0ce269aabcfb019eae539 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau at citrix.com>
+Date: Thu, 12 Jul 2018 10:48:18 +0200
+Subject: [PATCH] x86: replace '||' usage in the linker script
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+With '|'. The result is the same, and the later works with lld. Fixes
+the following error when building Xen with lld:
+
+ld -melf_x86_64_fbsd -T xen.lds -N prelink.o --build-id=sha1 \
+ /root/src/xen/xen/common/symbols-dummy.o -o /root/src/xen/xen/.xen-syms.0
+ld: error: xen.lds:260: malformed number: |
+>>> ASSERT(__image_base__ > (((((((((261 >> 8) * 0xffff000000000000) | (261 << 39))) + ((1 << 39) / 2)) + (64 << 30)) + (1 << 30)) + (1 << 30))) ||
+>>> ^
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Reviewed-by: Jan Beulich <jbeulich at suse.com>
+---
+ xen/arch/x86/xen.lds.S | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
+index 70afedd31d..326e885402 100644
+--- a/xen/arch/x86/xen.lds.S
++++ b/xen/arch/x86/xen.lds.S
+@@ -331,7 +331,7 @@ SECTIONS
+ .comment 0 : { *(.comment) }
+ }
+
+-ASSERT(__image_base__ > XEN_VIRT_START ||
++ASSERT(__image_base__ > XEN_VIRT_START |
+ __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ "Xen image overlaps stubs area")
+
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0002-vpci-msi-fix-update-of-bound-MSI-interrupts.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0002-vpci-msi-fix-update-of-bound-MSI-interrupts.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,94 @@
+From 1e34ed7174cce6ab37e420dda9452267301fb7d2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau at citrix.com>
+Date: Mon, 2 Jul 2018 13:07:55 +0200
+Subject: [PATCH 2/2] vpci/msi: fix update of bound MSI interrupts
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Current update process of already bound MSI interrupts is wrong
+because unmap_domain_pirq calls pci_disable_msi, which disables MSI
+interrupts on the device. On the other hand map_domain_pirq doesn't
+enable MSI, so the current update process of already enabled MSI
+entries is wrong because MSI control bit will be disabled by
+unmap_domain_pirq and not re-enabled by map_domain_pirq.
+
+In order to fix this avoid unmapping the PIRQs and just update the
+binding of the PIRQ. A new arch helper to do that is introduced.
+
+Note that MSI-X is not affected because unmap_domain_pirq only
+disables the MSI enable control bit for the MSI case, for MSI-X the
+bit is left untouched by unmap_domain_pirq.
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Acked-by: Jan Beulich <jbeulich at suse.com>
+---
+ xen/arch/x86/hvm/vmsi.c | 23 +++++++++++++++++++++++
+ xen/drivers/vpci/msi.c | 3 +--
+ xen/include/xen/vpci.h | 2 ++
+ 3 files changed, 26 insertions(+), 2 deletions(-)
+
+diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
+index acadc23f8d..3001d5c488 100644
+--- a/xen/arch/x86/hvm/vmsi.c
++++ b/xen/arch/x86/hvm/vmsi.c
+@@ -699,6 +699,29 @@ static int vpci_msi_update(const struct pci_dev *pdev, uint32_t data,
+ return 0;
+ }
+
++int vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev)
++{
++ int rc;
++
++ ASSERT(msi->arch.pirq != INVALID_PIRQ);
++
++ pcidevs_lock();
++ rc = vpci_msi_update(pdev, msi->data, msi->address, msi->vectors,
++ msi->arch.pirq, msi->mask);
++ if ( rc )
++ {
++ spin_lock(&pdev->domain->event_lock);
++ unmap_domain_pirq(pdev->domain, msi->arch.pirq);
++ spin_unlock(&pdev->domain->event_lock);
++ pcidevs_unlock();
++ msi->arch.pirq = INVALID_PIRQ;
++ return rc;
++ }
++ pcidevs_unlock();
++
++ return 0;
++}
++
+ static int vpci_msi_enable(const struct pci_dev *pdev, uint32_t data,
+ uint64_t address, unsigned int nr,
+ paddr_t table_base, uint32_t mask)
+diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c
+index ad26c38a92..8f15ad7bf2 100644
+--- a/xen/drivers/vpci/msi.c
++++ b/xen/drivers/vpci/msi.c
+@@ -87,8 +87,7 @@ static void update_msi(const struct pci_dev *pdev, struct vpci_msi *msi)
+ if ( !msi->enabled )
+ return;
+
+- vpci_msi_arch_disable(msi, pdev);
+- if ( vpci_msi_arch_enable(msi, pdev, msi->vectors) )
++ if ( vpci_msi_arch_update(msi, pdev) )
+ msi->enabled = false;
+ }
+
+diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
+index 72d2225a97..af2b8580ee 100644
+--- a/xen/include/xen/vpci.h
++++ b/xen/include/xen/vpci.h
+@@ -159,6 +159,8 @@ int __must_check vpci_msi_arch_enable(struct vpci_msi *msi,
+ const struct pci_dev *pdev,
+ unsigned int vectors);
+ void vpci_msi_arch_disable(struct vpci_msi *msi, const struct pci_dev *pdev);
++int __must_check vpci_msi_arch_update(struct vpci_msi *msi,
++ const struct pci_dev *pdev);
+ void vpci_msi_arch_init(struct vpci_msi *msi);
+ void vpci_msi_arch_print(const struct vpci_msi *msi);
+
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0002-x86-efi-split-compiler-vs-linker-support.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0002-x86-efi-split-compiler-vs-linker-support.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,77 @@
+From fe810e9bcbca982a2f6980d119695c7e933c39bd Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau at citrix.com>
+Date: Fri, 20 Jul 2018 10:58:50 +0200
+Subject: [PATCH 2/2] x86/efi: split compiler vs linker support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So that an ELF binary with support for EFI services will be built when
+the compiler supports the MS ABI, regardless of the linker support for
+PE.
+
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+Reviewed-by: Jan Beulich <jbeulich at suse.com>
+---
+Cc: Jan Beulich <jbeulich at suse.com>
+Cc: Andrew Cooper <andrew.cooper3 at citrix.com>
+Cc: Daniel Kiper <daniel.kiper at oracle.com>
+---
+Changes since v1:
+ - New in this version.
+---
+ xen/arch/x86/Makefile | 9 +++++----
+ xen/arch/x86/efi/Makefile | 6 +++---
+ xen/arch/x86/xen.lds.S | 2 +-
+ 3 files changed, 9 insertions(+), 8 deletions(-)
+
+diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
+index 172685fb41..17e7d3fa34 100644
+--- a/xen/arch/x86/Makefile
++++ b/xen/arch/x86/Makefile
+@@ -163,10 +163,11 @@ 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
+
+-# Check if the build system supports PE.
+-XEN_BUILD_PE := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
+-export XEN_BUILD_PE := $(if $(XEN_BUILD_PE),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>/dev/null && echo y))
+-CFLAGS-$(XEN_BUILD_PE) += -DXEN_BUILD_PE
++# Check if the compiler supports the MS ABI.
++export XEN_BUILD_EFI := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
++# Check if the linker supports PE.
++XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>/dev/null && echo y))
++CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
+
+ $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A VIRT_START$$,,p')
+ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_START$$,,p')
+diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile
+index 918383b325..3816de2738 100644
+--- a/xen/arch/x86/efi/Makefile
++++ b/xen/arch/x86/efi/Makefile
+@@ -6,6 +6,6 @@ CFLAGS += -fshort-wchar
+ boot.init.o: buildid.o
+
+ obj-y := stub.o
+-obj-$(XEN_BUILD_PE) := boot.init.o compat.o relocs-dummy.o runtime.o
+-extra-$(XEN_BUILD_PE) += buildid.o
+-nocov-$(XEN_BUILD_PE) += stub.o
++obj-$(XEN_BUILD_EFI) := boot.init.o compat.o relocs-dummy.o runtime.o
++extra-$(XEN_BUILD_EFI) += buildid.o
++nocov-$(XEN_BUILD_EFI) += stub.o
+diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
+index 4a59467986..6e9bda5109 100644
+--- a/xen/arch/x86/xen.lds.S
++++ b/xen/arch/x86/xen.lds.S
+@@ -304,7 +304,7 @@ SECTIONS
+ } :text
+ #endif
+
+-#ifndef XEN_BUILD_PE
++#ifndef XEN_BUILD_EFI
+ efi = .;
+ #endif
+
+--
+2.18.0
+
Added: head/emulators/xen-kernel411/files/0002-x86-mtrr-split-enabled-field-into-two-boolean-flags.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/emulators/xen-kernel411/files/0002-x86-mtrr-split-enabled-field-into-two-boolean-flags.patch Tue Jul 24 13:57:46 2018 (r475255)
@@ -0,0 +1,198 @@
+From 8ebc60e0274b770743e59256f665789d4308b188 Mon Sep 17 00:00:00 2001
+From: Jan Beulich <jbeulich at suse.com>
+Date: Mon, 16 Jul 2018 15:09:12 +0200
+Subject: [PATCH 2/7] x86/mtrr: split "enabled" field into two boolean flags
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The code hopefully is more readable this way.
+
+Also switch have_fixed to bool, seeing that it already is used as a
+boolean.
+
+Signed-off-by: Jan Beulich <jbeulich at suse.com>
+[switched to use MASK_*]
+Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
+---
+ xen/arch/x86/cpu/mtrr/generic.c | 14 +++++++++-----
+ xen/arch/x86/hvm/hvm.c | 6 ++++--
+ xen/arch/x86/hvm/mtrr.c | 23 ++++++++++++++---------
+ xen/include/asm-x86/msr-index.h | 2 ++
+ xen/include/asm-x86/mtrr.h | 5 +++--
+ 5 files changed, 32 insertions(+), 18 deletions(-)
+
+diff --git a/xen/arch/x86/cpu/mtrr/generic.c b/xen/arch/x86/cpu/mtrr/generic.c
+index 7ba0c3f0fe..09763654be 100644
+--- a/xen/arch/x86/cpu/mtrr/generic.c
++++ b/xen/arch/x86/cpu/mtrr/generic.c
+@@ -80,7 +80,8 @@ void __init get_mtrr_state(void)
+
+ rdmsrl(MSR_MTRRdefType, msr_content);
+ mtrr_state.def_type = (msr_content & 0xff);
+- mtrr_state.enabled = (msr_content & 0xc00) >> 10;
++ mtrr_state.enabled = MASK_EXTR(msr_content, MTRRdefType_E);
++ mtrr_state.fixed_enabled = MASK_EXTR(msr_content, MTRRdefType_FE);
+
+ /* Store mtrr_cap for HVM MTRR virtualisation. */
+ rdmsrl(MSR_MTRRcap, mtrr_state.mtrr_cap);
+@@ -159,7 +160,7 @@ static void __init print_mtrr_state(const char *level)
+ unsigned int base = 0, step = 0x10000;
+
+ printk("%sMTRR fixed ranges %sabled:\n", level,
+- mtrr_state.enabled & 1 ? "en" : "dis");
++ mtrr_state.fixed_enabled ? "en" : "dis");
+ for (; block->ranges; ++block, step >>= 2) {
+ for (i = 0; i < block->ranges; ++i, fr += 8) {
+ print_fixed(base, step, fr, level);
+@@ -169,7 +170,7 @@ static void __init print_mtrr_state(const char *level)
+ print_fixed_last(level);
+ }
+ printk("%sMTRR variable ranges %sabled:\n", level,
+- mtrr_state.enabled & 2 ? "en" : "dis");
++ mtrr_state.enabled ? "en" : "dis");
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-ports-head
mailing list