diff --git a/sysutils/xen-tools/Makefile b/sysutils/xen-tools/Makefile index 64dcddc10a7d..1d2d3ec85c42 100644 --- a/sysutils/xen-tools/Makefile +++ b/sysutils/xen-tools/Makefile @@ -1,99 +1,102 @@ PORTNAME= xen PKGNAMESUFFIX= -tools PORTVERSION= 4.15.0 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= sysutils emulators MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/ MAINTAINER= royger@FreeBSD.org COMMENT= Xen management tools LICENSE= GPLv2 LGPL3 LICENSE_COMB= multi LIB_DEPENDS= libyajl.so:devel/yajl \ liblzo2.so:archivers/lzo2 \ libpixman-1.so:x11/pixman \ libargp.so:devel/argp-standalone \ libxml2.so:textproc/libxml2 BUILD_DEPENDS= seabios>0:misc/seabios \ ${LOCALBASE}/share/edk2-xen/XEN_X64_EFI.fd:sysutils/edk2@xen_x64 RUN_DEPENDS= seabios>0:misc/seabios \ ${LOCALBASE}/share/edk2-xen/XEN_X64_EFI.fd:sysutils/edk2@xen_x64 OPTIONS_DEFINE= DOCS SPICE OPTIONS_DEFAULT= DOCS OPTIONS_SUB= yes SPICE_DESC= Enable SPICE protocol for QEMU SPICE_CONFIGURE_WITH= extra-qemuu-configure-args="--enable-spice" SPICE_BUILD_DEPENDS= spice-protocol>=0.12.10:devel/spice-protocol SPICE_LIB_DEPENDS= libspice-server.so:devel/libspice-server ONLY_FOR_ARCHS= amd64 ONLY_FOR_ARCHS_REASON= not yet ported to anything other than amd64 USES= cpe gettext gmake gnome libtool localbase:ldflags perl5 \ pkgconfig python:3.6+ shebangfix iconv bison USE_GNOME= glib20 USE_LDCONFIG= yes USE_PYTHON= py3kplist HAS_CONFIGURE= yes # Set ARCH=x86_64 in order to overwrite the environment ARCH=amd64 MAKE_ARGS= clang=y ARCH=x86_64 BINARY_ALIAS= python3=${PYTHON_CMD} CONFIGURE_ARGS+= --with-system-seabios=${LOCALBASE}/share/seabios/bios.bin \ --with-system-ovmf=${LOCALBASE}/share/edk2-xen/XEN_X64_EFI.fd \ --mandir=${MANPREFIX}/man \ --disable-golang SHEBANG_FILES= tools/misc/xencov_split \ tools/python/scripts/convert-legacy-stream \ tools/python/scripts/verify-stream-v2 \ tools/xenmon/xenmon.py ALL_TARGET= tools DOCS_ALL_TARGET= docs INSTALL_TARGET= install-tools DOCS_INSTALL_TARGET= install-docs +# Fix pv shim build with clang 13.0.0 +EXTRA_PATCHES+= ${PATCHDIR}/0001-efi-fix-alignment-of-function-parameters-in-compat-m.patch:-p1 + .include .if ${OPSYS} != FreeBSD IGNORE= only supported on FreeBSD .endif .if ${PORT_OPTIONS:MSPICE} && ${OSVERSION} < 1300008 BROKEN= SPICE support requires FreeBSD version 13.0 or higher .endif # ivshmem requires eventfd .if ${OSVERSION} >= 1300000 PLIST_SUB+= IVSHMEM="" .else PLIST_SUB+= IVSHMEM="@comment " .endif post-patch: @for p in `ls ${FILESDIR}/*qemuu*.patch 2>/dev/null`; do \ ${ECHO_CMD} "====> Applying $${p##*/}" ; \ ${PATCH} -s -p1 -i $${p} -d ${WRKSRC}/tools/qemu-xen ; \ done # The ports native 'build' target cannot be used because it sets CFLAGS, and # that breaks the Xen kernel build system that's used by the tools in order to # build the pv-shim. do-build: ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -C ${WRKSRC} ${MAKE_ARGS} ${ALL_TARGET} do-install: ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -C ${WRKSRC} ${MAKE_ARGS} ${INSTALL_TARGET} post-install: ${MKDIR} ${STAGEDIR}/var/run/xen # Empty dir, purge it. ${RMDIR} ${STAGEDIR}/${PREFIX}/lib/xen/include .include diff --git a/sysutils/xen-tools/files/0001-efi-fix-alignment-of-function-parameters-in-compat-m.patch b/sysutils/xen-tools/files/0001-efi-fix-alignment-of-function-parameters-in-compat-m.patch new file mode 100644 index 000000000000..1612c5a113a1 --- /dev/null +++ b/sysutils/xen-tools/files/0001-efi-fix-alignment-of-function-parameters-in-compat-m.patch @@ -0,0 +1,105 @@ +From be12fcca8b784e456df3adedbffe657d753c5ff9 Mon Sep 17 00:00:00 2001 +From: Roger Pau Monne +Date: Thu, 18 Nov 2021 09:28:06 +0100 +Subject: [PATCH] efi: fix alignment of function parameters in compat mode +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Currently the max_store_size, remain_store_size and max_size in +compat_pf_efi_runtime_call are 4 byte aligned, which makes clang +13.0.0 complain with: + +In file included from compat.c:30: +./runtime.c:646:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 2 of 'QueryVariableInfo' may result in an unaligned pointer access [-Werror,-Walign-mismatch] + &op->u.query_variable_info.max_store_size, + ^ +./runtime.c:647:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 3 of 'QueryVariableInfo' may result in an unaligned pointer access [-Werror,-Walign-mismatch] + &op->u.query_variable_info.remain_store_size, + ^ +./runtime.c:648:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 4 of 'QueryVariableInfo' may result in an unaligned pointer access [-Werror,-Walign-mismatch] + &op->u.query_variable_info.max_size); + ^ +Fix this by bouncing the variables on the stack in order for them to +be 8 byte aligned. + +Note this could be done in a more selective manner to only apply to +compat code calls, but given the overhead of making an EFI call doing +an extra copy of 3 variables doesn't seem to warrant the special +casing. + +Signed-off-by: Roger Pau Monné +Release-Acked-by: Ian Jackson +Reviewed-by: Ian Jackson +Signed-off-by: Ian Jackson +Reviewed-by: Jan Beulich + +--- +Changes since v3: + - Remove hard tabs. Apply Jan's r-b as authorised in email. +Changes since v2: + - Adjust the commentary as per discussion. +Changes since v1: + - Copy back the results. +--- + xen/common/efi/runtime.c | 31 +++++++++++++++++++++++++++---- + 1 file changed, 27 insertions(+), 4 deletions(-) + +diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c +index 375b94229e..d2fdc28df3 100644 +--- a/xen/common/efi/runtime.c ++++ b/xen/common/efi/runtime.c +@@ -607,6 +607,9 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op) + break; + + case XEN_EFI_query_variable_info: ++ { ++ uint64_t max_store_size, remain_store_size, max_size; ++ + if ( op->misc & ~XEN_EFI_VARINFO_BOOT_SNAPSHOT ) + return -EINVAL; + +@@ -638,16 +641,36 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op) + + if ( !efi_enabled(EFI_RS) || (efi_rs->Hdr.Revision >> 16) < 2 ) + return -EOPNOTSUPP; ++ ++ /* ++ * Bounce the variables onto the stack to make them 8 byte aligned when ++ * called from the compat handler, as their placement in ++ * compat_pf_efi_runtime_call will make them 4 byte aligned instead and ++ * and compilers may validly complain. ++ * ++ * Note that while the function parameters are OUT only, copy the ++ * values here anyway just in case. This is done regardless of whether ++ * called from the compat handler or not, as it's not worth the extra ++ * logic to differentiate. ++ */ ++ max_store_size = op->u.query_variable_info.max_store_size; ++ remain_store_size = op->u.query_variable_info.remain_store_size; ++ max_size = op->u.query_variable_info.max_size; ++ + state = efi_rs_enter(); + if ( !state.cr3 ) + return -EOPNOTSUPP; + status = efi_rs->QueryVariableInfo( +- op->u.query_variable_info.attr, +- &op->u.query_variable_info.max_store_size, +- &op->u.query_variable_info.remain_store_size, +- &op->u.query_variable_info.max_size); ++ op->u.query_variable_info.attr, &max_store_size, &remain_store_size, ++ &max_size); + efi_rs_leave(&state); ++ ++ op->u.query_variable_info.max_store_size = max_store_size; ++ op->u.query_variable_info.remain_store_size = remain_store_size; ++ op->u.query_variable_info.max_size = max_size; ++ + break; ++ } + + case XEN_EFI_query_capsule_capabilities: + case XEN_EFI_update_capsule: +-- +2.33.0 +