Index: head/emulators/xen-kernel/Makefile =================================================================== --- head/emulators/xen-kernel/Makefile (revision 507570) +++ head/emulators/xen-kernel/Makefile (revision 507571) @@ -1,73 +1,76 @@ # $FreeBSD$ PORTNAME= xen PORTVERSION= 4.12.0 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= emulators MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/ PKGNAMESUFFIX= -kernel MAINTAINER= royger@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 \ lib/debug/boot/xen.debug # Pre-patches for XSA-297 to apply cleanly EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-tsx-Implement-controls-for-RTM-force-abort-mode.patch:-p1 \ ${PATCHDIR}/0001-x86-msr-Shorten-ARCH_CAPABILITIES_-constants.patch:-p1 \ ${PATCHDIR}/0002-x86-spec-ctrl-Extend-repoline-safey-calcuations-for-.patch:-p1 # Fixes for XSA-297 (MDS) EXTRA_PATCHES+= ${PATCHDIR}/xsa297-4.12-1.patch:-p1 \ ${PATCHDIR}/xsa297-4.12-2.patch:-p1 \ ${PATCHDIR}/xsa297-4.12-3.patch:-p1 \ ${PATCHDIR}/xsa297-4.12-4.patch:-p1 \ ${PATCHDIR}/xsa297-4.12-5.patch:-p1 \ ${PATCHDIR}/xsa297-4.12-6.patch:-p1 \ ${PATCHDIR}/xsa297-4.12-7.patch:-p1 # LLD 8 changed the behaviour re the placement of orphaned sections, which # produces a non-bootable Xen kernel: # # https://bugs.llvm.org/show_bug.cgi?id=42327 # # Backport the fixes from upstream EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-linker-add-a-reloc-section-to-ELF-linker-script.patch:-p1 \ ${PATCHDIR}/0003-xen-link-handle-.init.rodata.cst-sections-in-the-lin.patch:-p1 \ ${PATCHDIR}/0004-x86-check-for-multiboot-1-2-header-presence.patch:-p1 + +# Fix for Intel foreign mapping issues. +EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-ept-pass-correct-level-to-p2m_entry_modify.patch:-p1 .include .if ${OPSYS} != FreeBSD IGNORE= only supported on FreeBSD .endif .if ${OSVERSION} < 1200074 IGNORE= only supported on FreeBSD 12.0 or newer .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} build-xen ${MAKE_ARGS} do-install: ${MKDIR} ${STAGEDIR}/boot ${MKDIR} ${STAGEDIR}${PREFIX}/lib/debug/boot/ ${INSTALL_PROGRAM} ${WRKSRC}/xen/xen ${STAGEDIR}/boot ${INSTALL_DATA} ${WRKSRC}/xen/xen-syms ${STAGEDIR}${PREFIX}/lib/debug/boot/xen.debug .include Index: head/emulators/xen-kernel/files/0001-x86-ept-pass-correct-level-to-p2m_entry_modify.patch =================================================================== --- head/emulators/xen-kernel/files/0001-x86-ept-pass-correct-level-to-p2m_entry_modify.patch (nonexistent) +++ head/emulators/xen-kernel/files/0001-x86-ept-pass-correct-level-to-p2m_entry_modify.patch (revision 507571) @@ -0,0 +1,57 @@ +From ec2ab491b52815c1daedfdf3d95d13cfe25fb38e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= +Date: Tue, 16 Jul 2019 09:05:28 +0200 +Subject: [PATCH] x86/ept: pass correct level to p2m_entry_modify +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +EPT differs from NPT and shadow when translating page orders to levels +in the physmap page tables. EPT page tables level for order 0 pages is +0, while NPT and shadow instead use 1, ie: EPT page tables levels +starts at 0 while NPT and shadow starts at 1. + +Fix the p2m_entry_modify call in atomic_write_ept_entry to always add +one to the level, in order to match NPT and shadow usage. + +While there also add a check to ensure p2m_entry_modify is never +called with level == 0. That should allow to catch future errors +related to the level parameter. + +Fixes: c7a4c088ad1c ('x86/mm: split p2m ioreq server pages special handling into helper') +Signed-off-by: Roger Pau Monné +Reviewed-by: Jan Beulich +Reviewed-by: Kevin Tian +--- + xen/arch/x86/mm/p2m-ept.c | 2 +- + xen/include/asm-x86/p2m.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c +index e3044bee2e..6b8468c793 100644 +--- a/xen/arch/x86/mm/p2m-ept.c ++++ b/xen/arch/x86/mm/p2m-ept.c +@@ -51,7 +51,7 @@ static int atomic_write_ept_entry(struct p2m_domain *p2m, + int level) + { + int rc = p2m_entry_modify(p2m, new.sa_p2mt, entryptr->sa_p2mt, +- _mfn(new.mfn), _mfn(entryptr->mfn), level); ++ _mfn(new.mfn), _mfn(entryptr->mfn), level + 1); + + if ( rc ) + return rc; +diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h +index 09ef7e02fd..aff34e3adf 100644 +--- a/xen/include/asm-x86/p2m.h ++++ b/xen/include/asm-x86/p2m.h +@@ -946,6 +946,7 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt, + p2m_type_t ot, mfn_t nfn, mfn_t ofn, + unsigned int level) + { ++ BUG_ON(!level); + BUG_ON(level > 1 && (nt == p2m_ioreq_server || nt == p2m_map_foreign)); + + if ( level != 1 || (nt == ot && mfn_eq(nfn, ofn)) ) +-- +2.20.1 (Apple Git-117) + Property changes on: head/emulators/xen-kernel/files/0001-x86-ept-pass-correct-level-to-p2m_entry_modify.patch ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property