diff options
| author | Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com> | 2024-01-03 19:51:28 -0700 |
|---|---|---|
| committer | Mark Hatle <mark.hatle@amd.com> | 2024-01-06 11:36:39 -0600 |
| commit | 0ddfa30d488a725341da80ea7bafb0da23e28659 (patch) | |
| tree | 970440300cb8eea525dfb1240334ed4835dafd85 /meta-xilinx-virtualization/recipes-extended/xen/xen.inc | |
| parent | bfe41ae084d13c13c595830c0ec5d6dde2252b57 (diff) | |
| download | meta-xilinx-0ddfa30d488a725341da80ea7bafb0da23e28659.tar.gz | |
xen: Move xen recipes and files from petalinux layer
Move xen recipes and files from meta-petalinux to xilinx-virtualization
layer exlcuding example configuration and passthrough device tree.
Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-virtualization/recipes-extended/xen/xen.inc')
| -rw-r--r-- | meta-xilinx-virtualization/recipes-extended/xen/xen.inc | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/meta-xilinx-virtualization/recipes-extended/xen/xen.inc b/meta-xilinx-virtualization/recipes-extended/xen/xen.inc new file mode 100644 index 00000000..5937763a --- /dev/null +++ b/meta-xilinx-virtualization/recipes-extended/xen/xen.inc | |||
| @@ -0,0 +1,233 @@ | |||
| 1 | HOMEPAGE = "http://xen.org" | ||
| 2 | LICENSE = "GPL-2.0-only" | ||
| 3 | SECTION = "console/tools" | ||
| 4 | |||
| 5 | inherit autotools-brokensep pkgconfig | ||
| 6 | |||
| 7 | require xen-arch.inc | ||
| 8 | |||
| 9 | PACKAGECONFIG ??= " \ | ||
| 10 | ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \ | ||
| 11 | " | ||
| 12 | |||
| 13 | PACKAGECONFIG[lzo] = ",,lzo" | ||
| 14 | PACKAGECONFIG[xsm] = "--enable-xsmpolicy,--disable-xsmpolicy,checkpolicy-native," | ||
| 15 | PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd,systemd," | ||
| 16 | PACKAGECONFIG[externalblktap] = ",,," | ||
| 17 | |||
| 18 | DEPENDS = " \ | ||
| 19 | ${@bb.utils.contains('XEN_TARGET_ARCH', 'x86_64', 'dev86-native', '', d)} \ | ||
| 20 | bison-native \ | ||
| 21 | flex-native \ | ||
| 22 | file-native \ | ||
| 23 | gettext-native \ | ||
| 24 | acpica-native \ | ||
| 25 | ncurses-native \ | ||
| 26 | util-linux-native \ | ||
| 27 | xz-native \ | ||
| 28 | bridge-utils \ | ||
| 29 | curl \ | ||
| 30 | dtc \ | ||
| 31 | gettext \ | ||
| 32 | glib-2.0 \ | ||
| 33 | gnutls \ | ||
| 34 | iproute2 \ | ||
| 35 | libnl \ | ||
| 36 | ncurses \ | ||
| 37 | openssl \ | ||
| 38 | pciutils \ | ||
| 39 | pixman \ | ||
| 40 | procps \ | ||
| 41 | python3 \ | ||
| 42 | libaio \ | ||
| 43 | util-linux \ | ||
| 44 | xz \ | ||
| 45 | yajl \ | ||
| 46 | zlib \ | ||
| 47 | gnu-efi \ | ||
| 48 | " | ||
| 49 | |||
| 50 | #### REQUIRED ENVIRONMENT VARIABLES #### | ||
| 51 | export BUILD_SYS | ||
| 52 | export HOST_SYS | ||
| 53 | export STAGING_INCDIR | ||
| 54 | export STAGING_LIBDIR | ||
| 55 | |||
| 56 | # specify xen hypervisor to build/target | ||
| 57 | export XEN_TARGET_ARCH = "${@map_xen_arch(d.getVar('TARGET_ARCH'), d)}" | ||
| 58 | export XEN_COMPILE_ARCH = "${@map_xen_arch(d.getVar('BUILD_ARCH'), d)}" | ||
| 59 | |||
| 60 | python () { | ||
| 61 | if d.getVar('XEN_TARGET_ARCH') == 'INVALID': | ||
| 62 | raise bb.parse.SkipPackage('Cannot map `%s` to a xen architecture' % d.getVar('TARGET_ARCH')) | ||
| 63 | } | ||
| 64 | |||
| 65 | # Yocto appends ${PN} to libexecdir by default and Xen appends 'xen' as well | ||
| 66 | # the result is a nested xen/xen/ so let's avoid that by shunning Yocto's | ||
| 67 | # extra ${PN} appended. | ||
| 68 | libexecdir = "${libdir}" | ||
| 69 | |||
| 70 | # hardcoded as Linux, as the only compatible hosts are Linux. | ||
| 71 | export XEN_OS = "Linux" | ||
| 72 | |||
| 73 | # this is used for the header (#!${bindir}/python) of the install python scripts | ||
| 74 | export PYTHONPATH="${bindir}/env python3" | ||
| 75 | export ac_cv_path_PYTHONPATH="${bindir}/env python3" | ||
| 76 | export DISTUTILS_BUILD_ARGS | ||
| 77 | export DISTUTILS_INSTALL_ARGS | ||
| 78 | |||
| 79 | # xen and seabios require HOSTCC and HOSTCXX set to cross-compile | ||
| 80 | export HOSTCC="${BUILD_CC}" | ||
| 81 | export HOSTCXX="${BUILD_CXX}" | ||
| 82 | |||
| 83 | # make xen requires CROSS_COMPILE set by hand as it does not abide by ./configure | ||
| 84 | export CROSS_COMPILE="${TARGET_PREFIX}" | ||
| 85 | |||
| 86 | # overide LDFLAGS to allow xen to build without: "x86_64-oe-linux-ld: unrecognized option '-Wl,-O1'" | ||
| 87 | export LDFLAGS="" | ||
| 88 | |||
| 89 | # No additional C flags for the main hypervisor build | ||
| 90 | EXTRA_CFLAGS_XEN_CORE ?= "" | ||
| 91 | # Add prefix maps to support buildpaths QA test and reproducibility | ||
| 92 | DEBUG_PREFIX_MAP:append = " \ | ||
| 93 | -ffile-prefix-map=${S}=${PN}-source \ | ||
| 94 | -fdebug-prefix-map=${WORKDIR}=${PN} \ | ||
| 95 | " | ||
| 96 | |||
| 97 | # - The Xen tools build for x86 systems with HVM-mode enabled includes hvmloader | ||
| 98 | # which fails to build when "-m64" is included in flags set via the | ||
| 99 | # EXTRA_CFLAGS_XEN_TOOLS: so clear TUNE_CCARGS on x86 to prevent that. | ||
| 100 | TUNE_CCARGS:x86-64="" | ||
| 101 | |||
| 102 | # - Yocto supplies the _FORTIFY_SOURCE flag via CC/CPP/CXX but then passes the | ||
| 103 | # optimization -O via C*FLAGS which is problematic when the CFLAGS are cleared | ||
| 104 | # within the build because compilation fails with the compiler stating | ||
| 105 | # "_FORTIFY_SOURCE requires compiling with optimization (-O)". | ||
| 106 | # - Move HOST_CC_ARCH into the Xen-provided CFLAGS variables and keep | ||
| 107 | # TOOLCHAIN_OPTIONS set via CC: this enables hvmloader to be built correctly. | ||
| 108 | # It must not be compiled with SSE compiler options enabled and the Xen build | ||
| 109 | # explicitly clears CFLAGS to ensure that, so such options must not be passed | ||
| 110 | # in via the tool variable. hvmloader is required to run HVM-mode guest VMs. | ||
| 111 | CC="${CCACHE}${HOST_PREFIX}gcc ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP} ${CC_REPRODUCIBLE_OPTIONS}" | ||
| 112 | EXTRA_CFLAGS_XEN_TOOLS="${HOST_CC_ARCH} ${CFLAGS}" | ||
| 113 | # 32-bit ARM needs the TUNE_CCARGS component of HOST_CC_ARCH to be passed | ||
| 114 | # in CC to ensure that configure can compile binaries for the right arch. | ||
| 115 | CC:arm="${CCACHE}${HOST_PREFIX}gcc ${TUNE_CCARGS} ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP} ${CC_REPRODUCIBLE_OPTIONS}" | ||
| 116 | |||
| 117 | # There are no Xen-provided variables for C++, so append to the tool variables: | ||
| 118 | CPP:append = " ${CPPFLAGS}" | ||
| 119 | CXX:append = " ${CXXFLAGS}" | ||
| 120 | |||
| 121 | EXTRA_OECONF += " \ | ||
| 122 | --exec-prefix=${prefix} \ | ||
| 123 | --prefix=${prefix} \ | ||
| 124 | --host=${HOST_SYS} \ | ||
| 125 | --disable-stubdom \ | ||
| 126 | --disable-ioemu-stubdom \ | ||
| 127 | --disable-pv-grub \ | ||
| 128 | --disable-xenstore-stubdom \ | ||
| 129 | --disable-rombios \ | ||
| 130 | --disable-ocamltools \ | ||
| 131 | --disable-qemu-traditional \ | ||
| 132 | ${@bb.utils.contains('XEN_TARGET_ARCH', 'x86_64', \ | ||
| 133 | '--enable-pvshim --with-system-seabios="/usr/share/firmware/bios.bin"', \ | ||
| 134 | '--disable-pvshim --disable-seabios', d)} \ | ||
| 135 | " | ||
| 136 | |||
| 137 | EXTRA_OEMAKE += "STDVGA_ROM=${STAGING_DIR_HOST}/usr/share/firmware/vgabios-0.8a.bin" | ||
| 138 | EXTRA_OEMAKE += "CIRRUSVGA_ROM=${STAGING_DIR_HOST}/usr/share/firmware/vgabios-0.8a.cirrus.bin" | ||
| 139 | EXTRA_OEMAKE += "SEABIOS_ROM=${STAGING_DIR_HOST}/usr/share/firmware/bios.bin" | ||
| 140 | EXTRA_OEMAKE += "ETHERBOOT_ROMS=${STAGING_DIR_HOST}/usr/share/firmware/rtl8139.rom" | ||
| 141 | |||
| 142 | # prevent the Xen build scripts from fetching things during the build | ||
| 143 | # all dependencies should be reflected in the Yocto recipe | ||
| 144 | EXTRA_OEMAKE += "WGET=/bin/false" | ||
| 145 | EXTRA_OEMAKE += "GIT=/bin/false" | ||
| 146 | |||
| 147 | # Improve build reproducibility: provide values for build variables. | ||
| 148 | def get_build_time_vars(d): | ||
| 149 | source_date_epoch = d.getVar('SOURCE_DATE_EPOCH') | ||
| 150 | if source_date_epoch is not None: | ||
| 151 | import datetime | ||
| 152 | utc_datetime = datetime.datetime.utcfromtimestamp(float(source_date_epoch)) | ||
| 153 | return " XEN_BUILD_DATE=" + utc_datetime.strftime("%Y-%m-%d") + \ | ||
| 154 | " XEN_BUILD_TIME=" + utc_datetime.strftime("%H:%M:%S") | ||
| 155 | return "" | ||
| 156 | EXTRA_OEMAKE += "${@['', 'XEN_WHOAMI=${PF} XEN_DOMAIN=${DISTRO} XEN_BUILD_HOST=${PN}-buildhost'] \ | ||
| 157 | [d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}${@get_build_time_vars(d)}" | ||
| 158 | |||
| 159 | # Improve build reproducibility: compiler flags to remove filesystem differences. | ||
| 160 | CC_REPRODUCIBLE_OPTIONS = "${@['', '-gno-record-gcc-switches'] \ | ||
| 161 | [d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1']}" | ||
| 162 | |||
| 163 | # check for XSM in package config to allow XSM_ENABLE to be set | ||
| 164 | python () { | ||
| 165 | pkgconfig = d.getVar('PACKAGECONFIG') | ||
| 166 | if ('xsm') in pkgconfig.split(): | ||
| 167 | d.setVar('XSM_ENABLED', '1') | ||
| 168 | else: | ||
| 169 | d.setVar('XSM_ENABLED', '0') | ||
| 170 | } | ||
| 171 | |||
| 172 | do_post_patch() { | ||
| 173 | # fixup AS/CC/CCP/etc variable within StdGNU.mk | ||
| 174 | for i in LD CC CPP CXX; do | ||
| 175 | sed -i "s/^\($i\s\s*\).*=/\1?=/" ${S}/config/StdGNU.mk | ||
| 176 | done | ||
| 177 | # fixup environment passing in some makefiles | ||
| 178 | sed -i 's#\(\w*\)=\(\$.\w*.\)#\1="\2"#' ${S}/tools/firmware/Makefile | ||
| 179 | |||
| 180 | # libsystemd-daemon -> libsystemd for newer systemd versions | ||
| 181 | sed -i 's#libsystemd-daemon#libsystemd#' ${S}/tools/configure | ||
| 182 | |||
| 183 | # Improve build reproducibility: disable insertion of the build timestamp | ||
| 184 | # into the x86 EFI hypervisor binary. | ||
| 185 | # binutils should allow a user-supplied timestamp or use SOURCE_DATE_EPOCH | ||
| 186 | # for PE but currently does not. | ||
| 187 | if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ] ; then | ||
| 188 | sed '/^EFI_LDFLAGS = /{a EFI_LDFLAGS += --no-insert-timestamp | ||
| 189 | }' -i "${S}/xen/arch/x86/Makefile" | ||
| 190 | fi | ||
| 191 | } | ||
| 192 | |||
| 193 | addtask post_patch after do_patch before do_configure | ||
| 194 | |||
| 195 | # Allow all hypervisor settings in a defconfig | ||
| 196 | EXTRA_OEMAKE += "XEN_CONFIG_EXPERT=y" | ||
| 197 | # Build release versions always. Technically since we track release | ||
| 198 | # tarballs this always happens but occasionally people pull in patches | ||
| 199 | # from staging that reverts this | ||
| 200 | EXTRA_OEMAKE += "debug=n" | ||
| 201 | |||
| 202 | do_configure_common() { | ||
| 203 | cd ${S} | ||
| 204 | |||
| 205 | #./configure --enable-xsmpolicy does not set XSM_ENABLE must be done manually | ||
| 206 | if [ "${XSM_ENABLED}" = "1" ]; then | ||
| 207 | echo "XSM_ENABLE := y" > ${S}/.config | ||
| 208 | fi | ||
| 209 | |||
| 210 | if [ -f "${WORKDIR}/defconfig" ]; then | ||
| 211 | cp "${WORKDIR}/defconfig" "${S}/xen/.config" || \ | ||
| 212 | bbfatal "Unable to copy defconfig to .config" | ||
| 213 | fi | ||
| 214 | |||
| 215 | unset CFLAGS | ||
| 216 | |||
| 217 | # do configure | ||
| 218 | oe_runconf EXTRA_CFLAGS_XEN_CORE="${EXTRA_CFLAGS_XEN_CORE}" \ | ||
| 219 | EXTRA_CFLAGS_XEN_TOOLS="${EXTRA_CFLAGS_XEN_TOOLS}" \ | ||
| 220 | PYTHON="${PYTHON}" | ||
| 221 | } | ||
| 222 | |||
| 223 | do_compile:prepend() { | ||
| 224 | # workaround for build bug when CFLAGS is exported | ||
| 225 | # https://www.mail-archive.com/xen-devel@lists.xen.org/msg67822.html | ||
| 226 | unset CFLAGS | ||
| 227 | } | ||
| 228 | |||
| 229 | do_install:prepend() { | ||
| 230 | # CFLAGS is used to set PY_CFLAGS which affects the pygrub install | ||
| 231 | # so also need to unset CFLAGS here: | ||
| 232 | unset CFLAGS | ||
| 233 | } | ||
