From 67c2cebeab0e5b1b36d8ddff98379ddd3fe1db76 Mon Sep 17 00:00:00 2001 From: Jose Quaresma Date: Mon, 23 Sep 2024 16:45:04 +0100 Subject: [PATCH] base/bsp: drop jailhouse This allows us to reduce maintenance and testing effort. If necessary, it can be added at the customer's factory. Signed-off-by: Jose Quaresma --- meta-lmp-base/conf/distro/include/lmp.inc | 3 +- .../conf/distro/include/non-clangable.inc | 5 - .../jailhouse/jailhouse-arch.inc | 22 - .../recipes-kernel/jailhouse/jailhouse_git.bb | 125 -- .../recipes-kernel/linux/linux-lmp.inc | 2 - .../images/lmp-base-console-image.bb | 1 - .../images/lmp-feature-jailhouse.inc | 6 - .../machine/include/lmp-machine-custom.inc | 4 +- .../recipes-bsp/u-boot/u-boot-ti-staging.inc | 1 - ...ow-re-reserving-post-relocation-U-Bo.patch | 92 -- .../0001-uio-Enable-read-only-mappings.patch | 61 - .../0002-ivshmem-Add-header-file.patch | 56 - ...er-for-inter-VM-shared-memory-device.patch | 315 ----- ...mple-debug-console-via-the-hyperviso.patch | 181 --- ...e-the-ability-to-set-HYP-vectors-out.patch | 117 -- ...t_cpu_mode-for-use-in-Jailhouse-driv.patch | 47 - ...0007-mm-Re-export-ioremap_page_range.patch | 32 - ...-t-allow-executable-ioremap-mappings.patch | 34 - ...-vmalloc-Export-__get_vm_area_caller.patch | 33 - ...-arm-arm64-export-__hyp_stub_vectors.patch | 61 - .../0011-x86-Export-lapic_timer_period.patch | 32 - ...virtual-network-device-for-Jailhouse.patch | 1158 ----------------- ...served_memory-label-for-CMA-regions-.patch | 32 - ...base-board-Reserve-memory-for-jailho.patch | 57 - ...ile-Update-makefile-to-build-overlay.patch | 32 - .../linux/linux-lmp-ti-staging_git.bb | 20 - .../u-boot-ostree-scr-fit/am62xx-evm/boot.cmd | 3 - .../u-boot-ostree-scr-fit/beagleplay/boot.cmd | 3 - ...k3-am625-sk-Add-crypto-memory-region.patch | 53 - ...001-configs-k3-use-intx-for-bar_mask.patch | 67 - ...-am625-sk-Switch-inmate-boot-console.patch | 63 - ...rm64-k3-am625-sk-add-vtm-memory-node.patch | 52 - ...4-k3-am625-sk-Add-GPMC-memory-region.patch | 52 - .../jailhouse/jailhouse_git.bbappend | 11 - 34 files changed, 2 insertions(+), 2831 deletions(-) delete mode 100644 meta-lmp-base/recipes-kernel/jailhouse/jailhouse-arch.inc delete mode 100644 meta-lmp-base/recipes-kernel/jailhouse/jailhouse_git.bb delete mode 100644 meta-lmp-base/recipes-samples/images/lmp-feature-jailhouse.inc delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging/0003-HACK-lib-lmb-Allow-re-reserving-post-relocation-U-Bo.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0001-uio-Enable-read-only-mappings.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0002-ivshmem-Add-header-file.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0003-uio-Add-driver-for-inter-VM-shared-memory-device.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0004-jailhouse-Add-simple-debug-console-via-the-hyperviso.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0005-Revert-arm-Remove-the-ability-to-set-HYP-vectors-out.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0006-arm-Export-__boot_cpu_mode-for-use-in-Jailhouse-driv.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0007-mm-Re-export-ioremap_page_range.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0008-Revert-mm-don-t-allow-executable-ioremap-mappings.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0009-mm-vmalloc-Export-__get_vm_area_caller.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0010-arm-arm64-export-__hyp_stub_vectors.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0011-x86-Export-lapic_timer_period.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0012-ivshmem-net-virtual-network-device-for-Jailhouse.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0013-arm64-dts-add-reserved_memory-label-for-CMA-regions-.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0014-arm64-dts-am625-base-board-Reserve-memory-for-jailho.patch delete mode 100644 meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0015-arm64-dts-Makefile-Update-makefile-to-build-overlay.patch delete mode 100644 meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-arm64-k3-am625-sk-Add-crypto-memory-region.patch delete mode 100644 meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-k3-use-intx-for-bar_mask.patch delete mode 100644 meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0002-configs-arm64-k3-am625-sk-Switch-inmate-boot-console.patch delete mode 100644 meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0003-configs-arm64-k3-am625-sk-add-vtm-memory-node.patch delete mode 100644 meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0004-configs-arm64-k3-am625-sk-Add-GPMC-memory-region.patch delete mode 100644 meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse_git.bbappend diff --git a/meta-lmp-base/conf/distro/include/lmp.inc b/meta-lmp-base/conf/distro/include/lmp.inc index 6bae44b7f1..d8d03a4c88 100644 --- a/meta-lmp-base/conf/distro/include/lmp.inc +++ b/meta-lmp-base/conf/distro/include/lmp.inc @@ -135,10 +135,9 @@ BBMASK += " \ /meta-st-stm32mp/recipes-graphics/drm/libdrm_2.4.115.bbappend \ /meta-st-stm32mp/recipes-bsp/trusted-firmware-a/tf-a-stm32mp_2.6.bb \ " -# meta-ti-bsp: mask optee and jailhouse related recipes as they are provided by lmp +# meta-ti-bsp: mask optee related recipes as they are provided by lmp BBMASK += " \ /meta-ti/meta-ti-bsp/recipes-security/optee \ - /meta-ti/meta-ti-extras/recipes-ti/jailhouse \ " # disable xsct tarball by default (xilinx) diff --git a/meta-lmp-base/conf/distro/include/non-clangable.inc b/meta-lmp-base/conf/distro/include/non-clangable.inc index a20c3b37c2..d2667a700f 100644 --- a/meta-lmp-base/conf/distro/include/non-clangable.inc +++ b/meta-lmp-base/conf/distro/include/non-clangable.inc @@ -119,11 +119,6 @@ STRIP:pn-linux-tegra:toolchain-clang = "${HOST_PREFIX}strip" OBJCOPY:pn-linux-tegra-rt:toolchain-clang = "${HOST_PREFIX}objcopy" STRIP:pn-linux-tegra-rt:toolchain-clang = "${HOST_PREFIX}strip" -# jailhouse (includes kernel module) -# | warning: the compiler differs from the one used to build the kernel -TOOLCHAIN:pn-jailhouse = "gcc" -TOOLCHAIN:pn-jailhouse-imx = "gcc" - # use gcc for now as it fail with clang with some compile errors: # error: passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] # error: fields must have a constant size: 'variable length array in structure' extension will never be supported diff --git a/meta-lmp-base/recipes-kernel/jailhouse/jailhouse-arch.inc b/meta-lmp-base/recipes-kernel/jailhouse/jailhouse-arch.inc deleted file mode 100644 index 498b25ed32..0000000000 --- a/meta-lmp-base/recipes-kernel/jailhouse/jailhouse-arch.inc +++ /dev/null @@ -1,22 +0,0 @@ -# Set jailhouse architecture JH_ARCH variable -# -# return value must match one of architectures supported by jailhouse -# -valid_jh_archs = "x86 arm" - -def map_jh_arch(a, d): - import re - - valid_jh_archs = d.getVar('valid_jh_archs', True).split() - - if re.match('(i.86|athlon|x86.64)$', a): return 'x86' - elif re.match('armeb$', a): return 'arm' - elif re.match('aarch64$', a): return 'arm64' - elif re.match('aarch64_be$', a): return 'arm64' - elif a in valid_jh_archs: return a - else: - bb.error("cannot map '%s' to a jailhouse supported architecture" % a) - -export JH_ARCH = "${@map_jh_arch(d.getVar('TARGET_ARCH', True), d)}" - -COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux" diff --git a/meta-lmp-base/recipes-kernel/jailhouse/jailhouse_git.bb b/meta-lmp-base/recipes-kernel/jailhouse/jailhouse_git.bb deleted file mode 100644 index 6f5b90fa72..0000000000 --- a/meta-lmp-base/recipes-kernel/jailhouse/jailhouse_git.bb +++ /dev/null @@ -1,125 +0,0 @@ -SUMMARY = "Linux-based partitioning hypervisor" -DESCRIPTION = "Jailhouse is a partitioning Hypervisor based on Linux. It is able to run bare-metal applications or (adapted) \ -operating systems besides Linux. For this purpose, it configures CPU and device virtualization features of the hardware \ -platform in a way that none of these domains, called 'cells' here, can interfere with each other in an unacceptable way." -HOMEPAGE = "https://github.com/siemens/jailhouse" -SECTION = "jailhouse" -LICENSE = "GPL-2.0-only" - -LIC_FILES_CHKSUM = "file://COPYING;md5=9fa7f895f96bde2d47fd5b7d95b6ba4d \ - file://tools/root-cell-config.c.tmpl;beginline=6;endline=33;md5=2825581c1666c44a17955dc574cfbfb3 \ - file://include/jailhouse/hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ - file://include/jailhouse/cell-config.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ - file://include/arch/arm/asm/jailhouse_hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ - file://include/arch/arm64/asm/jailhouse_hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ - file://include/arch/x86/asm/jailhouse_hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ - file://driver/jailhouse.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ -" - -PV = "0.12+git${SRCPV}" -SRCREV = "e57d1eff6d55aeed5f977fe4e2acfb6ccbdd7560" -BRANCH = "master" - -SRC_URI = " \ - git://github.com/siemens/jailhouse.git;protocol=https;branch=${BRANCH} \ -" - -DEPENDS = " \ - make-native \ - python3-mako-native \ - python3-mako \ - dtc-native \ -" - -inherit module python3native bash-completion deploy setuptools3 - -S = "${WORKDIR}/git" -B = "${S}" - -require jailhouse-arch.inc - -JH_DATADIR ?= "${datadir}/jailhouse" -CELL_DIR ?= "${JH_DATADIR}/cells" -CELLCONF_DIR ?= "${JH_DATADIR}/configs" -INMATES_DIR ?= "${JH_DATADIR}/inmates" -INMATES_DTB_DIR ?= "${JH_DATADIR}/inmates/dtb" - -# Inmate dtbs are manually installed (empty == all) -JH_INMATE_DTB ?= "" - -do_configure() { - if [ -d ${STAGING_DIR_HOST}/${CELLCONF_DIR} ]; - then - cp "${STAGING_DIR_HOST}/${CELLCONF_DIR}/"*.c ${S}/configs/${ARCH}/ - fi -} - -do_compile:prepend() { - unset LDFLAGS - oe_runmake V=1 CC="${CC}" \ - ARCH=${JH_ARCH} CROSS_COMPILE=${TARGET_PREFIX} \ - KDIR=${STAGING_KERNEL_BUILDDIR} -} - -do_install:prepend() { - oe_runmake \ - PYTHON=python3 \ - V=1 \ - LDFLAGS="" \ - CC="${CC}" \ - ARCH=${JH_ARCH} \ - CROSS_COMPILE=${TARGET_PREFIX} \ - KDIR=${STAGING_KERNEL_BUILDDIR} \ - INSTALL_MOD_PATH=${D}${root_prefix} \ - firmwaredir=${nonarch_base_libdir}/firmware \ - DESTDIR=${D} install - - install -d ${D}${CELL_DIR} - install ${B}/configs/${JH_ARCH}/*.cell ${D}${CELL_DIR}/ - - install -d ${D}${INMATES_DIR}/tools/${JH_ARCH} - install ${B}/inmates/demos/${JH_ARCH}/*.bin ${D}${INMATES_DIR} - - install -d ${D}${JH_DATADIR}/tools - install ${B}/tools/jailhouse-cell-linux ${D}${JH_DATADIR}/tools - install ${B}/tools/jailhouse-cell-stats ${D}${JH_DATADIR}/tools - install ${B}/tools/jailhouse-config-collect ${D}${JH_DATADIR}/tools - install ${B}/tools/jailhouse-config-create ${D}${JH_DATADIR}/tools - install ${B}/tools/jailhouse-gcov-extract ${D}${JH_DATADIR}/tools - install ${B}/tools/jailhouse-hardware-check ${D}${JH_DATADIR}/tools - install ${B}/inmates/tools/${JH_ARCH}/linux-loader.bin ${D}${INMATES_DIR}/tools/${JH_ARCH} - - # inmate dtbs - if [ -d ${B}/configs/${JH_ARCH}/dts ]; then - install -d ${D}${INMATES_DTB_DIR} - if [ -z "${JH_INMATE_DTB}" ]; then - install ${B}/configs/${JH_ARCH}/dts/*.dtb ${D}${INMATES_DTB_DIR} - else - install ${B}/configs/${JH_ARCH}/dts/${JH_INMATE_DTB} ${D}${INMATES_DTB_DIR} - fi - fi -} - -PACKAGE_BEFORE_PN = "pyjailhouse" - -FILES:${PN} += "${nonarch_base_libdir}/firmware ${libexecdir} ${sbindir} ${JH_DATADIR}" -# Remove libdir/* appended by setuptools3-base.bbclass for module split to work correctly -FILES:${PN}:remove = "${libdir}/*" -FILES:pyjailhouse = "${PYTHON_SITEPACKAGES_DIR}" - -RDEPENDS:${PN} += " \ - python3-curses \ - python3-datetime \ - python3-mmap \ -" - -RDEPENDS:pyjailhouse = " \ - python3-core \ - python3-ctypes \ - python3-fcntl \ - python3-shell \ -" - -INSANE_SKIP:${PN} = "ldflags" - -COMPATIBLE_MACHINE ?= "^$" diff --git a/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc b/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc index 080bcc5de2..cd80723782 100644 --- a/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc +++ b/meta-lmp-base/recipes-kernel/linux/linux-lmp.inc @@ -2,8 +2,6 @@ DESCRIPTION = "Common Foundries.io Linux microPlatform Kernel" PV = "${LINUX_VERSION}+git${SRCPV}" -KERNEL_FEATURES += "${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', ' features/jailhouse/jailhouse.scc', '', d)}" - DEPENDS += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-native', '', d)}" DEPENDS += "openssl-native util-linux-native" diff --git a/meta-lmp-base/recipes-samples/images/lmp-base-console-image.bb b/meta-lmp-base/recipes-samples/images/lmp-base-console-image.bb index c238a6c59b..372b99ada5 100644 --- a/meta-lmp-base/recipes-samples/images/lmp-base-console-image.bb +++ b/meta-lmp-base/recipes-samples/images/lmp-base-console-image.bb @@ -17,7 +17,6 @@ require ${@bb.utils.contains('MACHINE_FEATURES', 'optee', 'lmp-feature-optee.inc require ${@bb.utils.contains('MACHINE_FEATURES', 'se05x', 'lmp-feature-se05x.inc', '', d)} require ${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'lmp-feature-tpm2.inc', '', d)} require ${@bb.utils.contains('MACHINE_FEATURES', 'efi', 'lmp-feature-efi.inc', '', d)} -require ${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', 'lmp-feature-jailhouse.inc', '', d)} require ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'lmp-feature-ima.inc', '', d)} require ${@bb.utils.contains('DISTRO_FEATURES', 'lmpdebug', 'lmp-feature-debug.inc', '', d)} diff --git a/meta-lmp-base/recipes-samples/images/lmp-feature-jailhouse.inc b/meta-lmp-base/recipes-samples/images/lmp-feature-jailhouse.inc deleted file mode 100644 index b70e0f0128..0000000000 --- a/meta-lmp-base/recipes-samples/images/lmp-feature-jailhouse.inc +++ /dev/null @@ -1,6 +0,0 @@ -# Jailhouse packages -CORE_IMAGE_BASE_INSTALL += " \ - kernel-module-uio-ivshmem \ - kernel-module-jailhouse \ - jailhouse \ -" diff --git a/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc b/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc index 88858eca42..e467bf4c57 100644 --- a/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc +++ b/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc @@ -702,7 +702,7 @@ UBOOT_SIGN_KEYDIR:k3 ?= "${TOPDIR}/conf/keys" FIT_HASH_ALG:sota:k3 ?= "sha256" FIT_SIGN_ALG:sota:k3 ?= "rsa2048" KERNEL_IMAGETYPE:sota:k3 = "fitImage" -KERNEL_IMAGETYPES:sota:k3 = "${KERNEL_IMAGETYPE} ${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', 'Image', '', d)}" +KERNEL_IMAGETYPES:sota:k3 = "${KERNEL_IMAGETYPE}" PREFERRED_PROVIDER_virtual/kernel:k3 ?= "linux-lmp-ti-staging" WKS_FILE_DEPENDS:append:k3 = " virtual/bootloader" OSTREE_DEPLOY_USR_OSTREE_BOOT:k3 = "${@bb.utils.contains('DISTRO_FEATURES', 'luks', '1', '0', d)}" @@ -726,8 +726,6 @@ LMP_BOOT_FIRMWARE_FILES:am62xx = "tispl.bin u-boot.img tiboot3-am62x-gp-evm.bin LMP_BOOT_FIRMWARE_FILES:append:sota:am62xx = " boot.itb" ## am62xx-evm SOTA_CLIENT_FEATURES:append:am62xx-evm = " ubootenv" -KERNEL_DEVICETREE:append:am62xx-evm = " ${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', 'ti/k3-am625-base-board-jailhouse.dtbo', '', d)}" -KERNEL_MODULE_AUTOLOAD:append:am62xx-evm = " ${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', 'jailhouse uio_ivshmem', '', d)}" ## beagleplay SOTA_CLIENT_FEATURES:append:beagleplay = " ubootenv" KERNEL_DEVICETREE:beagleplay = "ti/k3-am625-beagleplay.dtb ti/k3-am625-beagleplay-csi2-ov5640.dtbo ti/k3-am625-beagleplay-csi2-tevi-ov5640.dtbo" diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging.inc b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging.inc index 8e8c2cc93f..29bda07332 100644 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging.inc +++ b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging.inc @@ -1,7 +1,6 @@ include recipes-bsp/u-boot/u-boot-lmp-common.inc SRC_URI:append = " \ - ${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', 'file://0003-HACK-lib-lmb-Allow-re-reserving-post-relocation-U-Bo.patch', '', d)} \ file://lib-zlib-Fix-a-bug-when-getting-a-gzip-header-extra-field.patch \ file://k3-accept-filesystem-path-to-the-RoT-key.patch \ file://k3-set-env-variable-device_type.patch \ diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging/0003-HACK-lib-lmb-Allow-re-reserving-post-relocation-U-Bo.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging/0003-HACK-lib-lmb-Allow-re-reserving-post-relocation-U-Bo.patch deleted file mode 100644 index 82ebd52e6b..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti-staging/0003-HACK-lib-lmb-Allow-re-reserving-post-relocation-U-Bo.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 84d73d8433704c58d86e70330493c41da394d945 Mon Sep 17 00:00:00 2001 -From: Andreas Dannenberg -Date: Fri, 16 Sep 2022 16:23:39 -0500 -Subject: [PATCH] HACK: lib: lmb: Allow re-reserving post-relocation U-Boot - memory - -Doing this allows that memory to be reserved for example for later HLOS -use via DTS entry without conflicting with temporary U-Boot usage, which -would normally result in an error like "ERROR: reserving fdt memory region -failed" shown during Linux Kernel boot preparations. - -WARNING: The user must ensure with their U-Boot usage and DTS setup to -not use the newly-extended reserved memory region during U-Boot runtime, -otherwise U-Boot corruption could occur. This includes but is not limited -to attempting to load binary files that would overlap U-Boot's after- -relocation's memory region, for which now no error would be shown. - -Upstream-Status: Pending - -Signed-off-by: Andreas Dannenberg ---- - lib/lmb.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 54 insertions(+) - -diff --git a/lib/lmb.c b/lib/lmb.c -index 2444b2a6212..106ca5e320a 100644 ---- a/lib/lmb.c -+++ b/lib/lmb.c -@@ -258,6 +258,60 @@ static long lmb_add_region_flags(struct lmb_region *rgn, phys_addr_t base, - return -1; /* regions with new flags */ - } - -+ /* -+ * See if the memory region being checked against is U-Boot's -+ * own after-relocation region. If it is and the newly added -+ * region overlaps U-Boot's own region adjust it in size and/ -+ * or location to make it adjacent to U-Boot's own region, -+ * essentially allowing for U-Boot's own region to be extended -+ * in the next step to also cover the newly added region. -+ * -+ * Doing this allows that memory to be reserved for example for -+ * later HLOS use via DTS entry without conflicting with -+ * temporary U-Boot usage, which would normally result in an -+ * error like "ERROR: reserving fdt memory region failed" shown -+ * during Linux Kernel boot preparations. -+ * -+ * WARNING: The user must ensure with their U-Boot usage and -+ * DTS setup to not use the newly-extended reserved memory -+ * region during U-Boot runtime, otherwise U-Boot corruption -+ * could occur. This includes but is not limited to attempting -+ * to load binary files that would overlap U-Boot's after- -+ * relocation's memory region, for which now no error would be -+ * shown. -+ */ -+ if ((rgnbase <= gd->relocaddr) && -+ (gd->relocaddr < rgnbase + rgnsize)) { -+ if ((base > rgnbase) && -+ (base + size < rgnbase + rgnsize)) { -+ /* -+ * New region is within U-Boot's region, -+ * so we're done. -+ */ -+ return 0; -+ } -+ else if ((base < rgnbase) && (base + size > rgnbase) && -+ (base + size <= rgnbase + rgnsize)) { -+ /* -+ * New region starts below U-Boot's region and -+ * reaches into it. Shorten it to make it -+ * adjacent. -+ */ -+ size -= base + size - rgnbase; -+ } -+ else if ((base >= rgnbase) && (base < rgnbase + rgnsize)) { -+ /* -+ * New region starts within U-Boot's region and -+ * reaches beyond it. Move its start address and -+ * shorten it to make it adjacent. -+ */ -+ size -= rgnbase + rgnsize - base; -+ base = rgnbase + rgnsize; -+ -+ } -+ } -+ -+ - adjacent = lmb_addrs_adjacent(base, size, rgnbase, rgnsize); - if (adjacent > 0) { - if (flags != rgnflags) --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0001-uio-Enable-read-only-mappings.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0001-uio-Enable-read-only-mappings.patch deleted file mode 100644 index 7f1b0852ae..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0001-uio-Enable-read-only-mappings.patch +++ /dev/null @@ -1,61 +0,0 @@ -From cc3005a720bebf1ab8ac5060bce54eaf96ca5936 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Tue, 4 Jun 2019 14:40:09 +0200 -Subject: [PATCH 01/15] uio: Enable read-only mappings - -This allows to tag memory regions read-only, denying userspace to map -them writable. Default remains read/write. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit fdbff561f1499c218946877f4a3cb46fb69f010f) -Signed-off-by: Ricardo Salveti ---- - drivers/uio/uio.c | 9 +++++++++ - include/linux/uio_driver.h | 2 ++ - 2 files changed, 11 insertions(+) - -diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c -index 43afbb7c5ab916..75bdffd0fe979a 100644 ---- a/drivers/uio/uio.c -+++ b/drivers/uio/uio.c -@@ -792,6 +792,15 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma) - goto out; - } - -+ if (idev->info->mem[mi].readonly) { -+ if (vma->vm_flags & VM_WRITE) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ vma->vm_flags &= ~VM_MAYWRITE; -+ } -+ - if (idev->info->mmap) { - ret = idev->info->mmap(idev->info, vma); - goto out; -diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h -index 47c5962b876b02..e7a101e47457bd 100644 ---- a/include/linux/uio_driver.h -+++ b/include/linux/uio_driver.h -@@ -31,6 +31,7 @@ struct uio_map; - * @offs: offset of device memory within the page - * @size: size of IO (multiple of page size) - * @memtype: type of memory addr points to -+ * @readonly: true of region is read-only - * @internal_addr: ioremap-ped version of addr, for driver internal use - * @map: for use by the UIO core only. - */ -@@ -40,6 +41,7 @@ struct uio_mem { - unsigned long offs; - resource_size_t size; - int memtype; -+ bool readonly; - void __iomem *internal_addr; - struct uio_map *map; - }; --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0002-ivshmem-Add-header-file.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0002-ivshmem-Add-header-file.patch deleted file mode 100644 index 77e0b50576..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0002-ivshmem-Add-header-file.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 75925116c12d66a9d59aa2c278e4fcc59e0c8e71 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Tue, 1 Oct 2019 12:33:25 +0200 -Subject: [PATCH 02/15] ivshmem: Add header file - -Common defines and structures for the ivshmem device. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit 6cd86d72f4b64422ee86bd8823758f2c604a20a1) -Signed-off-by: Ricardo Salveti ---- - include/linux/ivshmem.h | 30 ++++++++++++++++++++++++++++++ - 1 file changed, 30 insertions(+) - create mode 100644 include/linux/ivshmem.h - -diff --git a/include/linux/ivshmem.h b/include/linux/ivshmem.h -new file mode 100644 -index 00000000000000..bad8547f071b69 ---- /dev/null -+++ b/include/linux/ivshmem.h -@@ -0,0 +1,30 @@ -+/* SPDX-License-Identifier: GPL-2.0-only */ -+#ifndef _LINUX_IVSHMEM_H -+#define _LINUX_IVSHMEM_H -+ -+#include -+ -+#define IVSHM_PROTO_UNDEFINED 0x0000 -+#define IVSHM_PROTO_NET 0x0001 -+#define IVSHM_PROTO_VIRTIO_FRONT 0x8000 -+#define IVSHM_PROTO_VIRTIO_BACK 0xc000 -+#define IVSHM_PROTO_VIRTIO_DEVID_MASK 0x7fff -+ -+#define IVSHM_CFG_PRIV_CNTL 0x03 -+# define IVSHM_PRIV_CNTL_ONESHOT_INT BIT(0) -+#define IVSHM_CFG_STATE_TAB_SZ 0x04 -+#define IVSHM_CFG_RW_SECTION_SZ 0x08 -+#define IVSHM_CFG_OUTPUT_SECTION_SZ 0x10 -+#define IVSHM_CFG_ADDRESS 0x18 -+ -+struct ivshm_regs { -+ u32 id; -+ u32 max_peers; -+ u32 int_control; -+ u32 doorbell; -+ u32 state; -+}; -+ -+#define IVSHM_INT_ENABLE BIT(0) -+ -+#endif /* _LINUX_IVSHMEM_H */ --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0003-uio-Add-driver-for-inter-VM-shared-memory-device.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0003-uio-Add-driver-for-inter-VM-shared-memory-device.patch deleted file mode 100644 index 112e3394c8..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0003-uio-Add-driver-for-inter-VM-shared-memory-device.patch +++ /dev/null @@ -1,315 +0,0 @@ -From 15e0ed8d4c336373f0a483b712375b7146dd2332 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Tue, 4 Jun 2019 18:40:25 +0200 -Subject: [PATCH 03/15] uio: Add driver for inter-VM shared memory device - -This adds a UIO driver the ivshmem device, found in QEMU and the -Jailhouse hypervisor. It exposes the MMIO register region and all shared -memory section to userspace. Interrupts are configured in one-shot mode -so that userspace needs to re-enable them after each event via the -Interrupt Control register. The driver registers all possible MSI-X -vectors, coalescing them into the single notifier UIO provides. - -Note: Specification work for the interface is ongoing, so details may -still change. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit e8095ac1ea00c67b1d334232c74924c238c15878) -Signed-off-by: Ricardo Salveti ---- - drivers/uio/Kconfig | 7 ++ - drivers/uio/Makefile | 1 + - drivers/uio/uio_ivshmem.c | 241 ++++++++++++++++++++++++++++++++++++++ - include/linux/pci_ids.h | 1 + - 4 files changed, 250 insertions(+) - create mode 100644 drivers/uio/uio_ivshmem.c - -diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig -index 2e16c5338e5b14..d2cc0d03d8e783 100644 ---- a/drivers/uio/Kconfig -+++ b/drivers/uio/Kconfig -@@ -182,4 +182,11 @@ config UIO_DFL - opae-sdk/tools/libopaeuio/ - - If you compile this as a module, it will be called uio_dfl. -+ -+config UIO_IVSHMEM -+ tristate "Inter-VM Shared Memory driver" -+ depends on PCI -+ help -+ Userspace I/O driver for the inter-VM shared memory PCI device -+ as provided by QEMU and the Jailhouse hypervisor. - endif -diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile -index f2f416a142286b..893c9d0a399b21 100644 ---- a/drivers/uio/Makefile -+++ b/drivers/uio/Makefile -@@ -12,3 +12,4 @@ obj-$(CONFIG_UIO_MF624) += uio_mf624.o - obj-$(CONFIG_UIO_FSL_ELBC_GPCM) += uio_fsl_elbc_gpcm.o - obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o - obj-$(CONFIG_UIO_DFL) += uio_dfl.o -+obj-$(CONFIG_UIO_IVSHMEM) += uio_ivshmem.o -diff --git a/drivers/uio/uio_ivshmem.c b/drivers/uio/uio_ivshmem.c -new file mode 100644 -index 00000000000000..0c16d428c6edf8 ---- /dev/null -+++ b/drivers/uio/uio_ivshmem.c -@@ -0,0 +1,241 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * UIO driver for Inter-VM shared memory PCI device -+ * -+ * Copyright (c) Siemens AG, 2019 -+ * -+ * Authors: -+ * Jan Kiszka -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#define DRV_NAME "uio_ivshmem" -+ -+struct ivshm_dev { -+ struct uio_info info; -+ struct pci_dev *pdev; -+ struct ivshm_regs __iomem *regs; -+ int vectors; -+}; -+ -+static irqreturn_t ivshm_irq_handler(int irq, void *dev_id) -+{ -+ struct ivshm_dev *ivshm_dev = (struct ivshm_dev *)dev_id; -+ -+ /* nothing else to do, we configured one-shot interrupt mode */ -+ uio_event_notify(&ivshm_dev->info); -+ -+ return IRQ_HANDLED; -+} -+ -+static u64 get_config_qword(struct pci_dev *pdev, unsigned int pos) -+{ -+ u32 lo, hi; -+ -+ pci_read_config_dword(pdev, pos, &lo); -+ pci_read_config_dword(pdev, pos + 4, &hi); -+ return lo | ((u64)hi << 32); -+} -+ -+static int ivshm_release(struct uio_info *info, struct inode *inode) -+{ -+ struct ivshm_dev *ivshm_dev = -+ container_of(info, struct ivshm_dev, info); -+ -+ writel(0, &ivshm_dev->regs->state); -+ return 0; -+} -+ -+static int ivshm_probe(struct pci_dev *pdev, const struct pci_device_id *id) -+{ -+ resource_size_t rw_section_sz, output_section_sz; -+ struct ivshm_dev *ivshm_dev; -+ phys_addr_t section_addr; -+ int err, vendor_cap, i; -+ unsigned int cap_pos; -+ struct uio_mem *mem; -+ char *device_name; -+ u32 dword; -+ -+ ivshm_dev = devm_kzalloc(&pdev->dev, sizeof(struct ivshm_dev), -+ GFP_KERNEL); -+ if (!ivshm_dev) -+ return -ENOMEM; -+ -+ err = pcim_enable_device(pdev); -+ if (err) -+ return err; -+ -+ device_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s[%s]", DRV_NAME, -+ dev_name(&pdev->dev)); -+ if (!device_name) -+ return -ENOMEM; -+ -+ ivshm_dev->info.name = device_name; -+ ivshm_dev->info.version = "1"; -+ ivshm_dev->info.release = ivshm_release; -+ -+ err = pcim_iomap_regions(pdev, BIT(0), device_name); -+ if (err) -+ return err; -+ ivshm_dev->regs = pcim_iomap_table(pdev)[0]; -+ -+ mem = &ivshm_dev->info.mem[0]; -+ -+ mem->name = "registers"; -+ mem->addr = pci_resource_start(pdev, 0); -+ if (!mem->addr) -+ return -ENODEV; -+ mem->size = pci_resource_len(pdev, 0); -+ mem->memtype = UIO_MEM_PHYS; -+ -+ vendor_cap = pci_find_capability(pdev, PCI_CAP_ID_VNDR); -+ if (vendor_cap < 0) -+ return -ENODEV; -+ -+ if (pci_resource_len(pdev, 2) > 0) { -+ section_addr = pci_resource_start(pdev, 2); -+ } else { -+ cap_pos = vendor_cap + IVSHM_CFG_ADDRESS; -+ section_addr = get_config_qword(pdev, cap_pos); -+ } -+ -+ mem++; -+ mem->name = "state_table"; -+ mem->addr = section_addr; -+ cap_pos = vendor_cap + IVSHM_CFG_STATE_TAB_SZ; -+ pci_read_config_dword(pdev, cap_pos, &dword); -+ mem->size = dword; -+ mem->memtype = UIO_MEM_IOVA; -+ mem->readonly = true; -+ if (!devm_request_mem_region(&pdev->dev, mem->addr, mem->size, -+ device_name)) -+ return -EBUSY; -+ dev_info(&pdev->dev, "%s at %pa, size %pa\n", mem->name, &mem->addr, -+ &mem->size); -+ -+ cap_pos = vendor_cap + IVSHM_CFG_RW_SECTION_SZ; -+ rw_section_sz = get_config_qword(pdev, cap_pos); -+ if (rw_section_sz > 0) { -+ section_addr += mem->size; -+ -+ mem++; -+ mem->name = "rw_section"; -+ mem->addr = section_addr; -+ mem->size = rw_section_sz; -+ mem->memtype = UIO_MEM_IOVA; -+ if (!devm_request_mem_region(&pdev->dev, mem->addr, mem->size, -+ device_name)) -+ return -EBUSY; -+ dev_info(&pdev->dev, "%s at %pa, size %pa\n", mem->name, -+ &mem->addr, &mem->size); -+ } -+ -+ cap_pos = vendor_cap + IVSHM_CFG_OUTPUT_SECTION_SZ; -+ output_section_sz = get_config_qword(pdev, cap_pos); -+ if (output_section_sz > 0) { -+ section_addr += mem->size; -+ -+ mem++; -+ mem->name = "input_sections"; -+ mem->addr = section_addr; -+ mem->size = -+ readl(&ivshm_dev->regs->max_peers) * output_section_sz; -+ mem->memtype = UIO_MEM_IOVA; -+ mem->readonly = true; -+ if (!devm_request_mem_region(&pdev->dev, mem->addr, mem->size, -+ device_name)) -+ return -EBUSY; -+ dev_info(&pdev->dev, "%s at %pa, size %pa\n", mem->name, -+ &mem->addr, &mem->size); -+ -+ mem++; -+ mem->name = "output_section"; -+ mem->addr = section_addr + -+ readl(&ivshm_dev->regs->id) * output_section_sz; -+ mem->size = output_section_sz; -+ mem->memtype = UIO_MEM_IOVA; -+ dev_info(&pdev->dev, "%s at %pa, size %pa\n", mem->name, -+ &mem->addr, &mem->size); -+ } -+ -+ pci_write_config_byte(pdev, vendor_cap + IVSHM_CFG_PRIV_CNTL, -+ IVSHM_PRIV_CNTL_ONESHOT_INT); -+ -+ /* -+ * Grab all vectors although we can only coalesce them into a single -+ * notifier. This avoids missing any event. -+ */ -+ ivshm_dev->vectors = pci_msix_vec_count(pdev); -+ if (ivshm_dev->vectors < 0) -+ ivshm_dev->vectors = 1; -+ -+ err = pci_alloc_irq_vectors(pdev, ivshm_dev->vectors, -+ ivshm_dev->vectors, -+ PCI_IRQ_LEGACY | PCI_IRQ_MSIX); -+ if (err < 0) -+ return err; -+ -+ for (i = 0; i < ivshm_dev->vectors; i++) { -+ err = request_irq(pci_irq_vector(pdev, i), ivshm_irq_handler, -+ IRQF_SHARED, ivshm_dev->info.name, ivshm_dev); -+ if (err) -+ goto error; -+ } -+ -+ ivshm_dev->info.irq = UIO_IRQ_CUSTOM; -+ -+ err = uio_register_device(&pdev->dev, &ivshm_dev->info); -+ if (err) -+ goto error; -+ -+ pci_set_master(pdev); -+ -+ pci_set_drvdata(pdev, ivshm_dev); -+ -+ return 0; -+ -+error: -+ while (--i > 0) -+ free_irq(pci_irq_vector(pdev, i), ivshm_dev); -+ pci_free_irq_vectors(pdev); -+ return err; -+} -+ -+static void ivshm_remove(struct pci_dev *pdev) -+{ -+ struct ivshm_dev *ivshm_dev = pci_get_drvdata(pdev); -+ int i; -+ -+ writel(0, &ivshm_dev->regs->int_control); -+ pci_clear_master(pdev); -+ -+ uio_unregister_device(&ivshm_dev->info); -+ -+ for (i = 0; i < ivshm_dev->vectors; i++) -+ free_irq(pci_irq_vector(pdev, i), ivshm_dev); -+ -+ pci_free_irq_vectors(pdev); -+} -+ -+static const struct pci_device_id ivshm_device_id_table[] = { -+ { PCI_DEVICE(PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_IVSHMEM), -+ (PCI_CLASS_OTHERS << 16) | IVSHM_PROTO_UNDEFINED, 0xffffff }, -+ { 0 } -+}; -+MODULE_DEVICE_TABLE(pci, ivshm_device_id_table); -+ -+static struct pci_driver uio_ivshm_driver = { -+ .name = DRV_NAME, -+ .id_table = ivshm_device_id_table, -+ .probe = ivshm_probe, -+ .remove = ivshm_remove, -+}; -+module_pci_driver(uio_ivshm_driver); -+ -+MODULE_AUTHOR("Jan Kiszka "); -+MODULE_LICENSE("GPL v2"); -diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h -index 45c3d62e616d85..680ebb3e9927e9 100644 ---- a/include/linux/pci_ids.h -+++ b/include/linux/pci_ids.h -@@ -1499,6 +1499,7 @@ - - #define PCI_VENDOR_ID_SIEMENS 0x110A - #define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102 -+#define PCI_DEVICE_ID_IVSHMEM 0x4106 - - #define PCI_VENDOR_ID_VORTEX 0x1119 - #define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000 --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0004-jailhouse-Add-simple-debug-console-via-the-hyperviso.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0004-jailhouse-Add-simple-debug-console-via-the-hyperviso.patch deleted file mode 100644 index 08684cc9e6..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0004-jailhouse-Add-simple-debug-console-via-the-hyperviso.patch +++ /dev/null @@ -1,181 +0,0 @@ -From 26a23e3b68b349878f6f973a4359ed92a751cb96 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Sun, 11 Sep 2016 23:30:04 +0200 -Subject: [PATCH 04/15] jailhouse: Add simple debug console via the hypervisor - -Jailhouse allows explicitly enabled cells to write character-wise -messages to the hypervisor debug console. Make use of this for a -platform-agnostic boot diagnosis channel, specifically for non-root -cells. This also comes with earlycon support. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit ed980bafb5a5fe00ff05809b8dc1797ff50955a6) -Signed-off-by: Ricardo Salveti ---- - MAINTAINERS | 1 + - drivers/virt/Kconfig | 11 ++++ - drivers/virt/Makefile | 1 + - drivers/virt/jailhouse_dbgcon.c | 103 ++++++++++++++++++++++++++++++++ - 4 files changed, 116 insertions(+) - create mode 100644 drivers/virt/jailhouse_dbgcon.c - -diff --git a/MAINTAINERS b/MAINTAINERS -index 170e7640f01092..14b5f29a3ae0c4 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -10966,6 +10966,7 @@ L: jailhouse-dev@googlegroups.com - S: Maintained - F: arch/x86/include/asm/jailhouse_para.h - F: arch/x86/kernel/jailhouse.c -+F: drivers/virt/jailhouse_dbgcon.c - - JC42.4 TEMPERATURE SENSOR DRIVER - M: Guenter Roeck -diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig -index 87ef258cec6483..880aeff04293ab 100644 ---- a/drivers/virt/Kconfig -+++ b/drivers/virt/Kconfig -@@ -42,6 +42,17 @@ config FSL_HV_MANAGER - 4) A kernel interface for receiving callbacks when a managed - partition shuts down. - -+config JAILHOUSE_DBGCON -+ tristate "Jailhouse console driver" -+ depends on X86 || ARM || ARM64 -+ help -+ The Jailhouse hypervisor provides a simple write-only console for -+ debugging the bootstrap process of its cells. This driver registers -+ a console with the kernel to make use of it. -+ -+ Note that Jailhouse has to be configured to permit a cell the usage -+ of the console interface. -+ - source "drivers/virt/vboxguest/Kconfig" - - source "drivers/virt/nitro_enclaves/Kconfig" -diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile -index 093674e05c40f2..ff4f2ce093b3f5 100644 ---- a/drivers/virt/Makefile -+++ b/drivers/virt/Makefile -@@ -4,6 +4,7 @@ - # - - obj-$(CONFIG_FSL_HV_MANAGER) += fsl_hypervisor.o -+obj-$(CONFIG_JAILHOUSE_DBGCON) += jailhouse_dbgcon.o - obj-$(CONFIG_VMGENID) += vmgenid.o - obj-y += vboxguest/ - -diff --git a/drivers/virt/jailhouse_dbgcon.c b/drivers/virt/jailhouse_dbgcon.c -new file mode 100644 -index 00000000000000..1fd201ea146066 ---- /dev/null -+++ b/drivers/virt/jailhouse_dbgcon.c -@@ -0,0 +1,103 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+/* -+ * Console driver for running over the Jailhouse partitioning hypervisor -+ * -+ * Copyright (c) Siemens AG, 2016-2018 -+ * -+ * Authors: -+ * Jan Kiszka -+ */ -+ -+#include -+#include -+#include -+#include -+#ifdef CONFIG_X86 -+#include -+#endif -+#ifdef CONFIG_ARM -+#include -+#endif -+ -+#define JAILHOUSE_HC_DEBUG_CONSOLE_PUTC 8 -+ -+static void hypervisor_putc(char c) -+{ -+#if defined(CONFIG_X86) -+ int result; -+ -+ asm volatile( -+ ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", -+ X86_FEATURE_VMMCALL) -+ : "=a" (result) -+ : "a" (JAILHOUSE_HC_DEBUG_CONSOLE_PUTC), "D" (c) -+ : "memory"); -+#elif defined(CONFIG_ARM) -+ register u32 num_res asm("r0") = JAILHOUSE_HC_DEBUG_CONSOLE_PUTC; -+ register u32 arg1 asm("r1") = c; -+ -+ asm volatile( -+ __HVC(0x4a48) -+ : "=r" (num_res) -+ : "r" (num_res), "r" (arg1) -+ : "memory"); -+#elif defined(CONFIG_ARM64) -+ register u64 num_res asm("x0") = JAILHOUSE_HC_DEBUG_CONSOLE_PUTC; -+ register u64 arg1 asm("x1") = c; -+ -+ asm volatile( -+ "hvc #0x4a48\n\t" -+ : "=r" (num_res) -+ : "r" (num_res), "r" (arg1) -+ : "memory"); -+#else -+#error Unsupported architecture. -+#endif -+} -+ -+static void jailhouse_dbgcon_write(struct console *con, const char *s, -+ unsigned count) -+{ -+ while (count > 0) { -+ hypervisor_putc(*s); -+ count--; -+ s++; -+ } -+} -+ -+static int __init early_jailhouse_dbgcon_setup(struct earlycon_device *device, -+ const char *options) -+{ -+ device->con->write = jailhouse_dbgcon_write; -+ return 0; -+} -+ -+EARLYCON_DECLARE(jailhouse, early_jailhouse_dbgcon_setup); -+ -+static struct console jailhouse_dbgcon = { -+ .name = "jailhouse", -+ .write = jailhouse_dbgcon_write, -+ .flags = CON_PRINTBUFFER | CON_ANYTIME, -+ .index = -1, -+}; -+ -+static int __init jailhouse_dbgcon_init(void) -+{ -+ if (!jailhouse_paravirt()) -+ return -ENODEV; -+ -+ register_console(&jailhouse_dbgcon); -+ return 0; -+} -+ -+static void __exit jailhouse_dbgcon_exit(void) -+{ -+ unregister_console(&jailhouse_dbgcon); -+} -+ -+module_init(jailhouse_dbgcon_init); -+module_exit(jailhouse_dbgcon_exit); -+ -+MODULE_LICENSE("GPL v2"); -+MODULE_DESCRIPTION("Jailhouse debug console driver"); -+MODULE_AUTHOR("Jan Kiszka "); --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0005-Revert-arm-Remove-the-ability-to-set-HYP-vectors-out.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0005-Revert-arm-Remove-the-ability-to-set-HYP-vectors-out.patch deleted file mode 100644 index f0a37a172c..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0005-Revert-arm-Remove-the-ability-to-set-HYP-vectors-out.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 56b8e25e2338c63d262ec385e101766293e03d0c Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Sun, 27 Dec 2020 15:04:31 +0100 -Subject: [PATCH 05/15] Revert "arm: Remove the ability to set HYP vectors - outside of the decompressor" - -This reverts commit 15ff9a39cd5ebabdf704634ea58806f2d12bbc39. It's -needed for Jailhouse. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit 6360d1a4f982ef43ee49d9754c4df56061299026) -Signed-off-by: Ricardo Salveti ---- - arch/arm/include/asm/virt.h | 5 +++++ - arch/arm/kernel/hyp-stub.S | 39 +++++++++++++++++++++++++++++-------- - 2 files changed, 36 insertions(+), 8 deletions(-) - -diff --git a/arch/arm/include/asm/virt.h b/arch/arm/include/asm/virt.h -index dd9697b2bde809..47600a5894b179 100644 ---- a/arch/arm/include/asm/virt.h -+++ b/arch/arm/include/asm/virt.h -@@ -39,6 +39,8 @@ static inline void sync_boot_mode(void) - sync_cache_r(&__boot_cpu_mode); - } - -+void __hyp_set_vectors(unsigned long phys_vector_base); -+void __hyp_reset_vectors(void); - #else - #define __boot_cpu_mode (SVC_MODE) - #define sync_boot_mode() -@@ -73,6 +75,9 @@ static inline bool is_kernel_in_hyp_mode(void) - - #define HVC_SET_VECTORS 0 - #define HVC_SOFT_RESTART 1 -+#define HVC_RESET_VECTORS 2 -+ -+#define HVC_STUB_HCALL_NR 3 - - #endif /* __ASSEMBLY__ */ - -diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S -index b699b22a4db1fa..b19ae4459f14b4 100644 ---- a/arch/arm/kernel/hyp-stub.S -+++ b/arch/arm/kernel/hyp-stub.S -@@ -186,19 +186,19 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE - ENDPROC(__hyp_stub_install_secondary) - - __hyp_stub_do_trap: --#ifdef ZIMAGE - teq r0, #HVC_SET_VECTORS - bne 1f -- /* Only the ZIMAGE stubs can change the HYP vectors */ - mcr p15, 4, r1, c12, c0, 0 @ set HVBAR - b __hyp_stub_exit --#endif - - 1: teq r0, #HVC_SOFT_RESTART -- bne 2f -+ bne 1f - bx r1 - --2: ldr r0, =HVC_STUB_ERR -+1: teq r0, #HVC_RESET_VECTORS -+ beq __hyp_stub_exit -+ -+ ldr r0, =HVC_STUB_ERR - __ERET - - __hyp_stub_exit: -@@ -207,9 +207,26 @@ __hyp_stub_exit: - ENDPROC(__hyp_stub_do_trap) - - /* -- * __hyp_set_vectors is only used when ZIMAGE must bounce between HYP -- * and SVC. For the kernel itself, the vectors are set once and for -- * all by the stubs. -+ * __hyp_set_vectors: Call this after boot to set the initial hypervisor -+ * vectors as part of hypervisor installation. On an SMP system, this should -+ * be called on each CPU. -+ * -+ * r0 must be the physical address of the new vector table (which must lie in -+ * the bottom 4GB of physical address space. -+ * -+ * r0 must be 32-byte aligned. -+ * -+ * Before calling this, you must check that the stub hypervisor is installed -+ * everywhere, by waiting for any secondary CPUs to be brought up and then -+ * checking that BOOT_CPU_MODE_HAVE_HYP(__boot_cpu_mode) is true. -+ * -+ * If not, there is a pre-existing hypervisor, some CPUs failed to boot, or -+ * something else went wrong... in such cases, trying to install a new -+ * hypervisor is unlikely to work as desired. -+ * -+ * When you call into your shiny new hypervisor, sp_hyp will contain junk, -+ * so you will need to set that to something sensible at the new hypervisor's -+ * initialisation entry point. - */ - ENTRY(__hyp_set_vectors) - mov r1, r0 -@@ -225,6 +242,12 @@ ENTRY(__hyp_soft_restart) - ret lr - ENDPROC(__hyp_soft_restart) - -+ENTRY(__hyp_reset_vectors) -+ mov r0, #HVC_RESET_VECTORS -+ __HVC(0) -+ ret lr -+ENDPROC(__hyp_reset_vectors) -+ - .align 5 - ENTRY(__hyp_stub_vectors) - __hyp_stub_reset: W(b) . --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0006-arm-Export-__boot_cpu_mode-for-use-in-Jailhouse-driv.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0006-arm-Export-__boot_cpu_mode-for-use-in-Jailhouse-driv.patch deleted file mode 100644 index de127586cf..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0006-arm-Export-__boot_cpu_mode-for-use-in-Jailhouse-driv.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 9e2a59546b6635c2901a7487d600fe9730b31971 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Sun, 3 Jul 2016 10:02:40 +0200 -Subject: [PATCH 06/15] arm: Export __boot_cpu_mode for use in Jailhouse driver - module - -Onlining a CPU while Jailhouse was running sets BOOT_CPU_MODE_MISMATCH -because the kernel detect that the CPU will now only come up in SVC -mode. Therefore, we need to fix up the flag after disabling Jailhouse -again. - -Moreover, exporting the symbol allows to use is_hyp_mode_available() in -the driver, thus prevents us from crashing during Jailhouse activation -when there is no hyp stub installed. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit 7c6832aec86a040c10188efe89fb2aaaa6093164) -Signed-off-by: Ricardo Salveti ---- - arch/arm/kernel/armksyms.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c -index 82e96ac836849c..354ab3e4e41fef 100644 ---- a/arch/arm/kernel/armksyms.c -+++ b/arch/arm/kernel/armksyms.c -@@ -16,6 +16,7 @@ - - #include - #include -+#include - - /* - * libgcc functions - functions that are used internally by the -@@ -175,3 +176,7 @@ EXPORT_SYMBOL(__pv_offset); - EXPORT_SYMBOL(__arm_smccc_smc); - EXPORT_SYMBOL(__arm_smccc_hvc); - #endif -+ -+#ifdef CONFIG_ARM_VIRT_EXT -+EXPORT_SYMBOL_GPL(__boot_cpu_mode); -+#endif --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0007-mm-Re-export-ioremap_page_range.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0007-mm-Re-export-ioremap_page_range.patch deleted file mode 100644 index a072c051cd..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0007-mm-Re-export-ioremap_page_range.patch +++ /dev/null @@ -1,32 +0,0 @@ -From dd0d663d8b00984916627640583b419ee157c685 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Tue, 7 Feb 2017 17:52:00 +0100 -Subject: [PATCH 07/15] mm: Re-export ioremap_page_range - -We need this in Jailhouse to map at specific virtual addresses, at -least for the moment. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit 7f2e91a804ac75eec3516062ec0d015005c6c5ef) -Signed-off-by: Ricardo Salveti ---- - mm/vmalloc.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/mm/vmalloc.c b/mm/vmalloc.c -index d5dc361dc104d7..96c105bfdda087 100644 ---- a/mm/vmalloc.c -+++ b/mm/vmalloc.c -@@ -325,6 +325,7 @@ int ioremap_page_range(unsigned long addr, unsigned long end, - ioremap_max_page_shift); - return err; - } -+EXPORT_SYMBOL_GPL(ioremap_page_range); - - static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, - pgtbl_mod_mask *mask) --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0008-Revert-mm-don-t-allow-executable-ioremap-mappings.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0008-Revert-mm-don-t-allow-executable-ioremap-mappings.patch deleted file mode 100644 index e4306d721a..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0008-Revert-mm-don-t-allow-executable-ioremap-mappings.patch +++ /dev/null @@ -1,34 +0,0 @@ -From f06d4ea2c488181698f709e7d8c1367a5648c8b6 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Sat, 2 Oct 2021 11:24:16 +0200 -Subject: [PATCH 08/15] Revert "mm: don't allow executable ioremap mappings" - -This reverts commit 8491502f787c4a902bd4f223b578ef47d3490264. - -Jailhouse needs executable ioremapped RAM to start the hypervisor. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit b808e2e02ec18c02084aaf5984e40558ac3f41ee) -Signed-off-by: Ricardo Salveti ---- - mm/vmalloc.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/mm/vmalloc.c b/mm/vmalloc.c -index 96c105bfdda087..dc4913366d2f85 100644 ---- a/mm/vmalloc.c -+++ b/mm/vmalloc.c -@@ -317,7 +317,7 @@ int ioremap_page_range(unsigned long addr, unsigned long end, - { - int err; - -- err = vmap_range_noflush(addr, end, phys_addr, pgprot_nx(prot), -+ err = vmap_range_noflush(addr, end, phys_addr, prot, - ioremap_max_page_shift); - flush_cache_vmap(addr, end); - if (!err) --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0009-mm-vmalloc-Export-__get_vm_area_caller.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0009-mm-vmalloc-Export-__get_vm_area_caller.patch deleted file mode 100644 index 53badb9aa0..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0009-mm-vmalloc-Export-__get_vm_area_caller.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 5ee886fd3cb8530e33b4d06b1061c15c5d1af3b1 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Sun, 6 Sep 2020 17:30:55 +0200 -Subject: [PATCH 09/15] mm: vmalloc: Export __get_vm_area_caller - -Needed by Jailhouse so far, as replacement of __get_vm_area. Should be -solved there eventually (via removal of JAILHOUSE_BORROW_ROOT_PT), then -this can be dropped again. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit b5ca803f2e5dcb1905a95915d6ffa34bf53a2db7) -Signed-off-by: Ricardo Salveti ---- - mm/vmalloc.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/mm/vmalloc.c b/mm/vmalloc.c -index dc4913366d2f85..5121265e412a9a 100644 ---- a/mm/vmalloc.c -+++ b/mm/vmalloc.c -@@ -2533,6 +2533,7 @@ struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags, - return __get_vm_area_node(size, 1, PAGE_SHIFT, flags, start, end, - NUMA_NO_NODE, GFP_KERNEL, caller); - } -+EXPORT_SYMBOL_GPL(__get_vm_area_caller); - - /** - * get_vm_area - reserve a contiguous kernel virtual area --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0010-arm-arm64-export-__hyp_stub_vectors.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0010-arm-arm64-export-__hyp_stub_vectors.patch deleted file mode 100644 index 60ea5b62b6..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0010-arm-arm64-export-__hyp_stub_vectors.patch +++ /dev/null @@ -1,61 +0,0 @@ -From cdb382de380c5edab8a18bc5eb4da5110ee015db Mon Sep 17 00:00:00 2001 -From: Ralf Ramsauer -Date: Wed, 7 Jun 2017 15:48:43 +0200 -Subject: [PATCH 10/15] arm, arm64: export __hyp_stub_vectors - -HVC_GET_VECTORS got removed. External hypervisors, like Jailhouse, need -this address when they are deactivated, in order to restore original -state. - -Upstream-Status: Pending - -Signed-off-by: Ralf Ramsauer -Signed-off-by: Jan Kiszka -(cherry picked from commit 04ea1cb888eece6aa4b7a0705e65f63be1f25b1a) -Signed-off-by: Ricardo Salveti ---- - arch/arm/kernel/hyp-stub.S | 2 ++ - arch/arm64/kernel/hyp-stub.S | 2 ++ - 2 files changed, 4 insertions(+) - -diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S -index b19ae4459f14b4..b9ba0585a4ce27 100644 ---- a/arch/arm/kernel/hyp-stub.S -+++ b/arch/arm/kernel/hyp-stub.S -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -259,4 +260,5 @@ __hyp_stub_trap: W(b) __hyp_stub_do_trap - __hyp_stub_irq: W(b) . - __hyp_stub_fiq: W(b) . - ENDPROC(__hyp_stub_vectors) -+EXPORT_SYMBOL_GPL(__hyp_stub_vectors) - -diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S -index 2ee18c860f2ab6..47d117fd1fbca8 100644 ---- a/arch/arm64/kernel/hyp-stub.S -+++ b/arch/arm64/kernel/hyp-stub.S -@@ -9,6 +9,7 @@ - #include - #include - -+#include - #include - #include - #include -@@ -66,6 +67,7 @@ SYM_CODE_START(__hyp_stub_vectors) - ventry el1_fiq_invalid // FIQ 32-bit EL1 - ventry el1_error_invalid // Error 32-bit EL1 - SYM_CODE_END(__hyp_stub_vectors) -+EXPORT_SYMBOL_GPL(__hyp_stub_vectors) - - .align 11 - --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0011-x86-Export-lapic_timer_period.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0011-x86-Export-lapic_timer_period.patch deleted file mode 100644 index e46bf96e63..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0011-x86-Export-lapic_timer_period.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 150f03dd86c8c0ec300b50b76389a7dd338ef634 Mon Sep 17 00:00:00 2001 -From: Jan Kiszka -Date: Thu, 23 Nov 2017 07:12:57 +0100 -Subject: [PATCH 11/15] x86: Export lapic_timer_period - -Required for the Jailhouse driver in order to forward the calibration -value to other cells. - -Upstream-Status: Pending - -Signed-off-by: Jan Kiszka -(cherry picked from commit 3ee22d568a3cda9d66b5d448c4a036336c558454) -Signed-off-by: Ricardo Salveti ---- - arch/x86/kernel/apic/apic.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c -index 20d9a604da7c4b..d94c1a7e4f7fe2 100644 ---- a/arch/x86/kernel/apic/apic.c -+++ b/arch/x86/kernel/apic/apic.c -@@ -200,6 +200,7 @@ static struct resource lapic_resource = { - }; - - unsigned int lapic_timer_period = 0; -+EXPORT_SYMBOL_GPL(lapic_timer_period); - - static void apic_pm_activate(void); - --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0012-ivshmem-net-virtual-network-device-for-Jailhouse.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0012-ivshmem-net-virtual-network-device-for-Jailhouse.patch deleted file mode 100644 index ba0356a5bb..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0012-ivshmem-net-virtual-network-device-for-Jailhouse.patch +++ /dev/null @@ -1,1158 +0,0 @@ -From ecf3d476ec199333454c2f55276ea1cc3bb40cd6 Mon Sep 17 00:00:00 2001 -From: Mans Rullgard -Date: Thu, 26 May 2016 16:04:02 +0100 -Subject: [PATCH 12/15] ivshmem-net: virtual network device for Jailhouse - -Combines the work from Mans' baseline, over various fixes and -improvements to the conversion to "ivshmem 2.0". - -Upstream-Status: Pending - -Signed-off-by: Mans Rullgard -[Jan: combined fixes and enhancements] -Signed-off-by: Jan Kiszka -(cherry picked from commit ed88f61398ea848685dfceec6c12977986b7f57a) -Signed-off-by: Ricardo Salveti ---- - drivers/net/Kconfig | 4 + - drivers/net/Makefile | 2 + - drivers/net/ivshmem-net.c | 1104 +++++++++++++++++++++++++++++++++++++ - 3 files changed, 1110 insertions(+) - create mode 100644 drivers/net/ivshmem-net.c - -diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig -index 9e63b8c43f3e2e..6da3ab912089e4 100644 ---- a/drivers/net/Kconfig -+++ b/drivers/net/Kconfig -@@ -631,4 +631,8 @@ config NETDEV_LEGACY_INIT - Drivers that call netdev_boot_setup_check() should select this - symbol, everything else no longer needs it. - -+config IVSHMEM_NET -+ tristate "IVSHMEM virtual network device" -+ depends on PCI -+ - endif # NETDEVICES -diff --git a/drivers/net/Makefile b/drivers/net/Makefile -index 6ce076462dbfd2..eb12689da752c1 100644 ---- a/drivers/net/Makefile -+++ b/drivers/net/Makefile -@@ -89,3 +89,5 @@ thunderbolt-net-y += thunderbolt.o - obj-$(CONFIG_USB4_NET) += thunderbolt-net.o - obj-$(CONFIG_NETDEVSIM) += netdevsim/ - obj-$(CONFIG_NET_FAILOVER) += net_failover.o -+ -+obj-$(CONFIG_IVSHMEM_NET) += ivshmem-net.o -diff --git a/drivers/net/ivshmem-net.c b/drivers/net/ivshmem-net.c -new file mode 100644 -index 00000000000000..a7128ecf2b9067 ---- /dev/null -+++ b/drivers/net/ivshmem-net.c -@@ -0,0 +1,1104 @@ -+/* -+ * Copyright 2016 Mans Rullgard -+ * Copyright (c) Siemens AG, 2016-2020 -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define DRV_NAME "ivshmem-net" -+ -+#define IVSHM_NET_STATE_UNKNOWN (~0) -+#define IVSHM_NET_STATE_RESET 0 -+#define IVSHM_NET_STATE_INIT 1 -+#define IVSHM_NET_STATE_READY 2 -+#define IVSHM_NET_STATE_RUN 3 -+ -+#define IVSHM_NET_FLAG_RUN 0 -+ -+#define IVSHM_NET_MTU_DEF 16384 -+ -+#define IVSHM_NET_FRAME_SIZE(s) ALIGN(18 + (s), SMP_CACHE_BYTES) -+ -+#define IVSHM_NET_VQ_ALIGN 64 -+ -+#define IVSHM_NET_SECTION_TX 0 -+#define IVSHM_NET_SECTION_RX 1 -+ -+#define IVSHM_NET_MSIX_STATE 0 -+#define IVSHM_NET_MSIX_TX_RX 1 -+ -+#define IVSHM_NET_NUM_VECTORS 2 -+ -+struct ivshm_net_queue { -+ struct vring vr; -+ u32 free_head; -+ u32 num_free; -+ u32 num_added; -+ u16 last_avail_idx; -+ u16 last_used_idx; -+ -+ void *data; -+ void *end; -+ u32 size; -+ u32 head; -+ u32 tail; -+}; -+ -+struct ivshm_net_stats { -+ u32 tx_rx_interrupts; -+ u32 tx_packets; -+ u32 tx_notify; -+ u32 tx_pause; -+ u32 rx_packets; -+ u32 rx_notify; -+ u32 napi_poll; -+ u32 napi_complete; -+ u32 napi_poll_n[10]; -+}; -+ -+struct ivshm_net { -+ struct ivshm_net_queue rx; -+ struct ivshm_net_queue tx; -+ -+ u32 vrsize; -+ u32 qlen; -+ u32 qsize; -+ -+ struct napi_struct napi; -+ -+ struct mutex state_lock; -+ u32 state; -+ u32 last_peer_state; -+ u32 *state_table; -+ -+ unsigned long flags; -+ -+ struct workqueue_struct *state_wq; -+ struct work_struct state_work; -+ -+ struct ivshm_net_stats stats; -+ -+ struct ivshm_regs __iomem *ivshm_regs; -+ void *shm[2]; -+ resource_size_t shmlen; -+ u32 peer_id; -+ -+ u32 tx_rx_vector; -+ -+ struct pci_dev *pdev; -+}; -+ -+static void *ivshm_net_desc_data(struct ivshm_net *in, -+ struct ivshm_net_queue *q, -+ unsigned int region, -+ struct vring_desc *desc, -+ u32 *len) -+{ -+ u64 offs = READ_ONCE(desc->addr); -+ u32 dlen = READ_ONCE(desc->len); -+ u16 flags = READ_ONCE(desc->flags); -+ void *data; -+ -+ if (flags) -+ return NULL; -+ -+ if (offs >= in->shmlen) -+ return NULL; -+ -+ data = in->shm[region] + offs; -+ -+ if (data < q->data || data >= q->end) -+ return NULL; -+ -+ if (dlen > q->end - data) -+ return NULL; -+ -+ *len = dlen; -+ -+ return data; -+} -+ -+static void ivshm_net_init_queue(struct ivshm_net *in, -+ struct ivshm_net_queue *q, -+ void *mem, unsigned int len) -+{ -+ memset(q, 0, sizeof(*q)); -+ -+ vring_init(&q->vr, len, mem, IVSHM_NET_VQ_ALIGN); -+ q->data = mem + in->vrsize; -+ q->end = q->data + in->qsize; -+ q->size = in->qsize; -+} -+ -+static void ivshm_net_init_queues(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ void *tx; -+ void *rx; -+ int i; -+ -+ tx = in->shm[IVSHM_NET_SECTION_TX]; -+ rx = in->shm[IVSHM_NET_SECTION_RX]; -+ -+ memset(tx, 0, in->shmlen); -+ -+ ivshm_net_init_queue(in, &in->tx, tx, in->qlen); -+ ivshm_net_init_queue(in, &in->rx, rx, in->qlen); -+ -+ swap(in->rx.vr.used, in->tx.vr.used); -+ -+ in->tx.num_free = in->tx.vr.num; -+ -+ for (i = 0; i < in->tx.vr.num - 1; i++) -+ in->tx.vr.desc[i].next = i + 1; -+} -+ -+static int ivshm_net_calc_qsize(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ unsigned int vrsize; -+ unsigned int qsize; -+ unsigned int qlen; -+ -+ for (qlen = 4096; qlen > 32; qlen >>= 1) { -+ vrsize = vring_size(qlen, IVSHM_NET_VQ_ALIGN); -+ vrsize = ALIGN(vrsize, IVSHM_NET_VQ_ALIGN); -+ if (vrsize < in->shmlen / 8) -+ break; -+ } -+ -+ if (vrsize > in->shmlen) -+ return -EINVAL; -+ -+ qsize = in->shmlen - vrsize; -+ -+ if (qsize < 4 * ETH_MIN_MTU) -+ return -EINVAL; -+ -+ in->vrsize = vrsize; -+ in->qlen = qlen; -+ in->qsize = qsize; -+ -+ return 0; -+} -+ -+static void ivshm_net_notify_tx(struct ivshm_net *in, unsigned int num) -+{ -+ u16 evt, old, new; -+ -+ virt_mb(); -+ -+ evt = READ_ONCE(vring_avail_event(&in->tx.vr)); -+ old = in->tx.last_avail_idx - num; -+ new = in->tx.last_avail_idx; -+ -+ if (vring_need_event(evt, new, old)) { -+ writel(in->tx_rx_vector | (in->peer_id << 16), -+ &in->ivshm_regs->doorbell); -+ in->stats.tx_notify++; -+ } -+} -+ -+static void ivshm_net_enable_rx_irq(struct ivshm_net *in) -+{ -+ vring_avail_event(&in->rx.vr) = in->rx.last_avail_idx; -+ virt_wmb(); -+} -+ -+static void ivshm_net_notify_rx(struct ivshm_net *in, unsigned int num) -+{ -+ u16 evt, old, new; -+ -+ virt_mb(); -+ -+ evt = READ_ONCE(vring_used_event(&in->rx.vr)); -+ old = in->rx.last_used_idx - num; -+ new = in->rx.last_used_idx; -+ -+ if (vring_need_event(evt, new, old)) { -+ writel(in->tx_rx_vector | (in->peer_id << 16), -+ &in->ivshm_regs->doorbell); -+ in->stats.rx_notify++; -+ } -+} -+ -+static void ivshm_net_enable_tx_irq(struct ivshm_net *in) -+{ -+ vring_used_event(&in->tx.vr) = in->tx.last_used_idx; -+ virt_wmb(); -+} -+ -+static bool ivshm_net_rx_avail(struct ivshm_net *in) -+{ -+ virt_mb(); -+ return READ_ONCE(in->rx.vr.avail->idx) != in->rx.last_avail_idx; -+} -+ -+static size_t ivshm_net_tx_space(struct ivshm_net *in) -+{ -+ struct ivshm_net_queue *tx = &in->tx; -+ u32 tail = tx->tail; -+ u32 head = tx->head; -+ u32 space; -+ -+ if (head < tail) -+ space = tail - head; -+ else -+ space = max(tx->size - head, tail); -+ -+ return space; -+} -+ -+static bool ivshm_net_tx_ok(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ return in->tx.num_free >= 2 && -+ ivshm_net_tx_space(in) >= 2 * IVSHM_NET_FRAME_SIZE(ndev->mtu); -+} -+ -+static u32 ivshm_net_tx_advance(struct ivshm_net_queue *q, u32 *pos, u32 len) -+{ -+ u32 p = *pos; -+ -+ len = IVSHM_NET_FRAME_SIZE(len); -+ -+ if (q->size - p < len) -+ p = 0; -+ *pos = p + len; -+ -+ return p; -+} -+ -+static bool ivshm_net_tx_clean(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ struct ivshm_net_queue *tx = &in->tx; -+ struct vring_used_elem *used; -+ struct vring *vr = &tx->vr; -+ struct vring_desc *desc; -+ struct vring_desc *fdesc; -+ u16 last = tx->last_used_idx; -+ unsigned int num; -+ bool tx_ok; -+ u32 fhead; -+ -+ fdesc = NULL; -+ fhead = 0; -+ num = 0; -+ -+ while (last != virt_load_acquire(&vr->used->idx)) { -+ void *data; -+ u32 len; -+ u32 tail; -+ -+ used = vr->used->ring + (last % vr->num); -+ if (used->id >= vr->num || used->len != 1) { -+ netdev_err(ndev, "invalid tx used->id %d ->len %d\n", -+ used->id, used->len); -+ break; -+ } -+ -+ desc = &vr->desc[used->id]; -+ -+ data = ivshm_net_desc_data(in, &in->tx, IVSHM_NET_SECTION_TX, -+ desc, &len); -+ if (!data) { -+ netdev_err(ndev, "bad tx descriptor, data == NULL\n"); -+ break; -+ } -+ -+ tail = ivshm_net_tx_advance(tx, &tx->tail, len); -+ if (data != tx->data + tail) { -+ netdev_err(ndev, "bad tx descriptor\n"); -+ break; -+ } -+ -+ if (!num) -+ fdesc = desc; -+ else -+ desc->next = fhead; -+ -+ fhead = used->id; -+ -+ tx->last_used_idx = ++last; -+ num++; -+ tx->num_free++; -+ BUG_ON(tx->num_free > vr->num); -+ -+ tx_ok = ivshm_net_tx_ok(ndev); -+ if (!tx_ok) -+ ivshm_net_enable_tx_irq(in); -+ } -+ -+ if (num) { -+ fdesc->next = tx->free_head; -+ tx->free_head = fhead; -+ } else { -+ tx_ok = ivshm_net_tx_ok(ndev); -+ } -+ -+ return tx_ok; -+} -+ -+static void ivshm_net_tx_poll(struct net_device *ndev) -+{ -+ struct netdev_queue *txq = netdev_get_tx_queue(ndev, 0); -+ -+ if (!__netif_tx_trylock(txq)) -+ return; -+ -+ if (ivshm_net_tx_clean(ndev) && netif_queue_stopped(ndev)) -+ netif_wake_queue(ndev); -+ -+ __netif_tx_unlock(txq); -+} -+ -+static struct vring_desc *ivshm_net_rx_desc(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ struct ivshm_net_queue *rx = &in->rx; -+ struct vring *vr = &rx->vr; -+ unsigned int avail; -+ u16 avail_idx; -+ -+ avail_idx = virt_load_acquire(&vr->avail->idx); -+ -+ if (avail_idx == rx->last_avail_idx) -+ return NULL; -+ -+ avail = vr->avail->ring[rx->last_avail_idx++ & (vr->num - 1)]; -+ if (avail >= vr->num) { -+ netdev_err(ndev, "invalid rx avail %d\n", avail); -+ return NULL; -+ } -+ -+ return &vr->desc[avail]; -+} -+ -+static void ivshm_net_rx_finish(struct ivshm_net *in, struct vring_desc *desc) -+{ -+ struct ivshm_net_queue *rx = &in->rx; -+ struct vring *vr = &rx->vr; -+ unsigned int desc_id = desc - vr->desc; -+ unsigned int used; -+ -+ used = rx->last_used_idx++ & (vr->num - 1); -+ vr->used->ring[used].id = desc_id; -+ vr->used->ring[used].len = 1; -+ -+ virt_store_release(&vr->used->idx, rx->last_used_idx); -+} -+ -+static int ivshm_net_poll(struct napi_struct *napi, int budget) -+{ -+ struct net_device *ndev = napi->dev; -+ struct ivshm_net *in = container_of(napi, struct ivshm_net, napi); -+ int received = 0; -+ -+ in->stats.napi_poll++; -+ -+ ivshm_net_tx_poll(ndev); -+ -+ while (received < budget) { -+ struct vring_desc *desc; -+ struct sk_buff *skb; -+ void *data; -+ u32 len; -+ -+ desc = ivshm_net_rx_desc(ndev); -+ if (!desc) -+ break; -+ -+ data = ivshm_net_desc_data(in, &in->rx, IVSHM_NET_SECTION_RX, -+ desc, &len); -+ if (!data) { -+ netdev_err(ndev, "bad rx descriptor\n"); -+ break; -+ } -+ -+ skb = napi_alloc_skb(napi, len); -+ -+ if (skb) { -+ memcpy(skb_put(skb, len), data, len); -+ skb->protocol = eth_type_trans(skb, ndev); -+ napi_gro_receive(napi, skb); -+ } -+ -+ ndev->stats.rx_packets++; -+ ndev->stats.rx_bytes += len; -+ -+ ivshm_net_rx_finish(in, desc); -+ received++; -+ } -+ -+ if (received < budget) { -+ in->stats.napi_complete++; -+ napi_complete_done(napi, received); -+ ivshm_net_enable_rx_irq(in); -+ if (ivshm_net_rx_avail(in)) -+ napi_schedule(napi); -+ } -+ -+ if (received) -+ ivshm_net_notify_rx(in, received); -+ -+ in->stats.rx_packets += received; -+ in->stats.napi_poll_n[received ? 1 + min(ilog2(received), 8) : 0]++; -+ -+ return received; -+} -+ -+static netdev_tx_t ivshm_net_xmit(struct sk_buff *skb, struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ struct ivshm_net_queue *tx = &in->tx; -+ bool xmit_more = netdev_xmit_more(); -+ struct vring *vr = &tx->vr; -+ struct vring_desc *desc; -+ unsigned int desc_idx; -+ unsigned int avail; -+ u32 head; -+ void *buf; -+ -+ if (!ivshm_net_tx_clean(ndev)) { -+ netif_stop_queue(ndev); -+ -+ netdev_err(ndev, "BUG: tx ring full when queue awake!\n"); -+ return NETDEV_TX_BUSY; -+ } -+ -+ desc_idx = tx->free_head; -+ desc = &vr->desc[desc_idx]; -+ tx->free_head = desc->next; -+ tx->num_free--; -+ -+ head = ivshm_net_tx_advance(tx, &tx->head, skb->len); -+ -+ if (!ivshm_net_tx_ok(ndev)) { -+ ivshm_net_enable_tx_irq(in); -+ netif_stop_queue(ndev); -+ xmit_more = false; -+ in->stats.tx_pause++; -+ } -+ -+ buf = tx->data + head; -+ skb_copy_and_csum_dev(skb, buf); -+ -+ desc->addr = buf - in->shm[IVSHM_NET_SECTION_TX]; -+ desc->len = skb->len; -+ desc->flags = 0; -+ -+ avail = tx->last_avail_idx++ & (vr->num - 1); -+ vr->avail->ring[avail] = desc_idx; -+ tx->num_added++; -+ -+ virt_store_release(&vr->avail->idx, tx->last_avail_idx); -+ -+ if (!xmit_more) { -+ ivshm_net_notify_tx(in, tx->num_added); -+ tx->num_added = 0; -+ } -+ -+ in->stats.tx_packets++; -+ ndev->stats.tx_packets++; -+ ndev->stats.tx_bytes += skb->len; -+ -+ dev_consume_skb_any(skb); -+ -+ return NETDEV_TX_OK; -+} -+ -+static void ivshm_net_set_state(struct ivshm_net *in, u32 state) -+{ -+ virt_wmb(); -+ WRITE_ONCE(in->state, state); -+ writel(state, &in->ivshm_regs->state); -+} -+ -+static void ivshm_net_run(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ if (in->state < IVSHM_NET_STATE_READY) -+ return; -+ -+ if (!netif_running(ndev)) -+ return; -+ -+ if (in->last_peer_state == IVSHM_NET_STATE_RUN) -+ netif_carrier_on(ndev); -+ -+ if (test_and_set_bit(IVSHM_NET_FLAG_RUN, &in->flags)) -+ return; -+ -+ netif_start_queue(ndev); -+ napi_enable(&in->napi); -+ napi_schedule(&in->napi); -+ ivshm_net_set_state(in, IVSHM_NET_STATE_RUN); -+} -+ -+static void ivshm_net_do_stop(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ ivshm_net_set_state(in, IVSHM_NET_STATE_RESET); -+ -+ if (!test_and_clear_bit(IVSHM_NET_FLAG_RUN, &in->flags)) -+ return; -+ -+ netif_carrier_off(ndev); -+ netif_stop_queue(ndev); -+ napi_disable(&in->napi); -+} -+ -+static void ivshm_net_state_change(struct work_struct *work) -+{ -+ struct ivshm_net *in = container_of(work, struct ivshm_net, state_work); -+ struct net_device *ndev = in->napi.dev; -+ u32 peer_state = READ_ONCE(in->state_table[in->peer_id]); -+ -+ mutex_lock(&in->state_lock); -+ -+ if (peer_state == in->last_peer_state) { -+ mutex_unlock(&in->state_lock); -+ return; -+ } -+ -+ in->last_peer_state = peer_state; -+ -+ switch (in->state) { -+ case IVSHM_NET_STATE_RESET: -+ /* -+ * Wait for the remote to leave READY/RUN before transitioning -+ * to INIT. -+ */ -+ if (peer_state < IVSHM_NET_STATE_READY) -+ ivshm_net_set_state(in, IVSHM_NET_STATE_INIT); -+ break; -+ -+ case IVSHM_NET_STATE_INIT: -+ /* -+ * Wait for the remote to leave RESET before performing the -+ * initialization and moving to READY. -+ */ -+ if (peer_state > IVSHM_NET_STATE_RESET) { -+ ivshm_net_init_queues(ndev); -+ ivshm_net_set_state(in, IVSHM_NET_STATE_READY); -+ -+ mutex_unlock(&in->state_lock); -+ -+ rtnl_lock(); -+ call_netdevice_notifiers(NETDEV_CHANGEADDR, ndev); -+ rtnl_unlock(); -+ -+ return; -+ } -+ break; -+ -+ case IVSHM_NET_STATE_READY: -+ case IVSHM_NET_STATE_RUN: -+ if (peer_state >= IVSHM_NET_STATE_READY) { -+ /* -+ * Link is up and we are running once the remote is in -+ * READY or RUN. -+ */ -+ ivshm_net_run(ndev); -+ } else if (peer_state == IVSHM_NET_STATE_RESET) { -+ /* -+ * If the remote goes to RESET, we need to follow -+ * immediately. -+ */ -+ ivshm_net_do_stop(ndev); -+ } -+ break; -+ } -+ -+ mutex_unlock(&in->state_lock); -+} -+ -+static void ivshm_net_check_state(struct ivshm_net *in) -+{ -+ queue_work(in->state_wq, &in->state_work); -+} -+ -+static irqreturn_t ivshm_net_int_state(int irq, void *data) -+{ -+ struct ivshm_net *in = data; -+ -+ ivshm_net_check_state(in); -+ -+ return IRQ_HANDLED; -+} -+ -+static irqreturn_t ivshm_net_int_tx_rx(int irq, void *data) -+{ -+ struct ivshm_net *in = data; -+ -+ in->stats.tx_rx_interrupts++; -+ -+ napi_schedule_irqoff(&in->napi); -+ -+ return IRQ_HANDLED; -+} -+ -+static irqreturn_t ivshm_net_intx(int irq, void *data) -+{ -+ ivshm_net_int_state(irq, data); -+ ivshm_net_int_tx_rx(irq, data); -+ -+ return IRQ_HANDLED; -+} -+ -+static int ivshm_net_open(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ netdev_reset_queue(ndev); -+ ndev->operstate = IF_OPER_UP; -+ -+ mutex_lock(&in->state_lock); -+ ivshm_net_run(ndev); -+ mutex_unlock(&in->state_lock); -+ -+ return 0; -+} -+ -+static int ivshm_net_stop(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ ndev->operstate = IF_OPER_DOWN; -+ -+ mutex_lock(&in->state_lock); -+ ivshm_net_do_stop(ndev); -+ mutex_unlock(&in->state_lock); -+ -+ return 0; -+} -+ -+static int ivshm_net_change_mtu(struct net_device *ndev, int mtu) -+{ -+ if (netif_running(ndev)) { -+ netdev_err(ndev, "must be stopped to change its MTU\n"); -+ return -EBUSY; -+ } -+ -+ ndev->mtu = mtu; -+ -+ return 0; -+} -+ -+#ifdef CONFIG_NET_POLL_CONTROLLER -+static void ivshm_net_poll_controller(struct net_device *ndev) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ napi_schedule(&in->napi); -+} -+#endif -+ -+static const struct net_device_ops ivshm_net_ops = { -+ .ndo_open = ivshm_net_open, -+ .ndo_stop = ivshm_net_stop, -+ .ndo_start_xmit = ivshm_net_xmit, -+ .ndo_change_mtu = ivshm_net_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+#ifdef CONFIG_NET_POLL_CONTROLLER -+ .ndo_poll_controller = ivshm_net_poll_controller, -+#endif -+}; -+ -+static const char ivshm_net_stats[][ETH_GSTRING_LEN] = { -+ "tx_rx_interrupts", -+ "tx_packets", -+ "tx_notify", -+ "tx_pause", -+ "rx_packets", -+ "rx_notify", -+ "napi_poll", -+ "napi_complete", -+ "napi_poll_0", -+ "napi_poll_1", -+ "napi_poll_2", -+ "napi_poll_4", -+ "napi_poll_8", -+ "napi_poll_16", -+ "napi_poll_32", -+ "napi_poll_64", -+ "napi_poll_128", -+ "napi_poll_256", -+}; -+ -+#define NUM_STATS ARRAY_SIZE(ivshm_net_stats) -+ -+static int ivshm_net_get_sset_count(struct net_device *ndev, int sset) -+{ -+ if (sset == ETH_SS_STATS) -+ return NUM_STATS; -+ -+ return -EOPNOTSUPP; -+} -+ -+static void ivshm_net_get_strings(struct net_device *ndev, u32 sset, u8 *buf) -+{ -+ if (sset == ETH_SS_STATS) -+ memcpy(buf, &ivshm_net_stats, sizeof(ivshm_net_stats)); -+} -+ -+static void ivshm_net_get_ethtool_stats(struct net_device *ndev, -+ struct ethtool_stats *estats, u64 *st) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ unsigned int n = 0; -+ unsigned int i; -+ -+ st[n++] = in->stats.tx_rx_interrupts; -+ st[n++] = in->stats.tx_packets; -+ st[n++] = in->stats.tx_notify; -+ st[n++] = in->stats.tx_pause; -+ st[n++] = in->stats.rx_packets; -+ st[n++] = in->stats.rx_notify; -+ st[n++] = in->stats.napi_poll; -+ st[n++] = in->stats.napi_complete; -+ -+ for (i = 0; i < ARRAY_SIZE(in->stats.napi_poll_n); i++) -+ st[n++] = in->stats.napi_poll_n[i]; -+ -+ memset(&in->stats, 0, sizeof(in->stats)); -+} -+ -+#define IVSHM_NET_REGS_LEN (3 * sizeof(u32) + 6 * sizeof(u16)) -+ -+static int ivshm_net_get_regs_len(struct net_device *ndev) -+{ -+ return IVSHM_NET_REGS_LEN; -+} -+ -+static void ivshm_net_get_regs(struct net_device *ndev, -+ struct ethtool_regs *regs, void *p) -+{ -+ struct ivshm_net *in = netdev_priv(ndev); -+ u32 *reg32 = p; -+ u16 *reg16; -+ -+ *reg32++ = in->state; -+ *reg32++ = in->last_peer_state; -+ *reg32++ = in->qlen; -+ -+ reg16 = (u16 *)reg32; -+ -+ *reg16++ = in->tx.vr.avail ? in->tx.vr.avail->idx : 0; -+ *reg16++ = in->tx.vr.used ? in->tx.vr.used->idx : 0; -+ *reg16++ = in->tx.vr.avail ? vring_avail_event(&in->tx.vr) : 0; -+ -+ *reg16++ = in->rx.vr.avail ? in->rx.vr.avail->idx : 0; -+ *reg16++ = in->rx.vr.used ? in->rx.vr.used->idx : 0; -+ *reg16++ = in->rx.vr.avail ? vring_avail_event(&in->rx.vr) : 0; -+} -+ -+static const struct ethtool_ops ivshm_net_ethtool_ops = { -+ .get_sset_count = ivshm_net_get_sset_count, -+ .get_strings = ivshm_net_get_strings, -+ .get_ethtool_stats = ivshm_net_get_ethtool_stats, -+ .get_regs_len = ivshm_net_get_regs_len, -+ .get_regs = ivshm_net_get_regs, -+}; -+ -+static u64 get_config_qword(struct pci_dev *pdev, unsigned int pos) -+{ -+ u32 lo, hi; -+ -+ pci_read_config_dword(pdev, pos, &lo); -+ pci_read_config_dword(pdev, pos + 4, &hi); -+ return lo | ((u64)hi << 32); -+} -+ -+static int ivshm_net_probe(struct pci_dev *pdev, -+ const struct pci_device_id *pci_id) -+{ -+ phys_addr_t output_sections_addr, section_addr; -+ resource_size_t section_sz, output_section_sz; -+ void *state_table, *output_sections; -+ struct ivshm_regs __iomem *regs; -+ struct net_device *ndev; -+ struct ivshm_net *in; -+ unsigned int cap_pos; -+ char *device_name; -+ int vendor_cap; -+ u32 id, dword; -+ int ret; -+ -+ ret = pcim_enable_device(pdev); -+ if (ret) { -+ dev_err(&pdev->dev, "pci_enable_device: %d\n", ret); -+ return ret; -+ } -+ -+ ret = pcim_iomap_regions(pdev, BIT(0), DRV_NAME); -+ if (ret) { -+ dev_err(&pdev->dev, "pcim_iomap_regions: %d\n", ret); -+ return ret; -+ } -+ -+ regs = pcim_iomap_table(pdev)[0]; -+ -+ id = readl(®s->id); -+ if (id > 1) { -+ dev_err(&pdev->dev, "invalid ID %d\n", id); -+ return -EINVAL; -+ } -+ if (readl(®s->max_peers) > 2) { -+ dev_err(&pdev->dev, "only 2 peers supported\n"); -+ return -EINVAL; -+ } -+ -+ vendor_cap = pci_find_capability(pdev, PCI_CAP_ID_VNDR); -+ if (vendor_cap < 0) { -+ dev_err(&pdev->dev, "missing vendor capability\n"); -+ return -EINVAL; -+ } -+ -+ if (pci_resource_len(pdev, 2) > 0) { -+ section_addr = pci_resource_start(pdev, 2); -+ } else { -+ cap_pos = vendor_cap + IVSHM_CFG_ADDRESS; -+ section_addr = get_config_qword(pdev, cap_pos); -+ } -+ -+ cap_pos = vendor_cap + IVSHM_CFG_STATE_TAB_SZ; -+ pci_read_config_dword(pdev, cap_pos, &dword); -+ section_sz = dword; -+ -+ if (!devm_request_mem_region(&pdev->dev, section_addr, section_sz, -+ DRV_NAME)) -+ return -EBUSY; -+ -+ state_table = devm_memremap(&pdev->dev, section_addr, section_sz, -+ MEMREMAP_WB); -+ if (!state_table) -+ return -ENOMEM; -+ -+ output_sections_addr = section_addr + section_sz; -+ -+ cap_pos = vendor_cap + IVSHM_CFG_RW_SECTION_SZ; -+ section_sz = get_config_qword(pdev, cap_pos); -+ if (section_sz > 0) { -+ dev_info(&pdev->dev, "R/W section detected - " -+ "unused by this driver version\n"); -+ output_sections_addr += section_sz; -+ } -+ -+ cap_pos = vendor_cap + IVSHM_CFG_OUTPUT_SECTION_SZ; -+ output_section_sz = get_config_qword(pdev, cap_pos); -+ if (output_section_sz == 0) { -+ dev_err(&pdev->dev, "Missing input/output sections\n"); -+ return -EINVAL; -+ } -+ -+ if (!devm_request_mem_region(&pdev->dev, output_sections_addr, -+ output_section_sz * 2, DRV_NAME)) -+ return -EBUSY; -+ -+ output_sections = devm_memremap(&pdev->dev, output_sections_addr, -+ output_section_sz * 2, MEMREMAP_WB); -+ if (!output_sections) -+ return -ENOMEM; -+ -+ section_addr = output_sections_addr + output_section_sz * id; -+ dev_info(&pdev->dev, "TX memory at %pa, size %pa\n", -+ §ion_addr, &output_section_sz); -+ section_addr = output_sections_addr + output_section_sz * !id; -+ dev_info(&pdev->dev, "RX memory at %pa, size %pa\n", -+ §ion_addr, &output_section_sz); -+ -+ device_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s[%s]", DRV_NAME, -+ dev_name(&pdev->dev)); -+ if (!device_name) -+ return -ENOMEM; -+ -+ ndev = alloc_etherdev(sizeof(*in)); -+ if (!ndev) -+ return -ENOMEM; -+ -+ pci_set_drvdata(pdev, ndev); -+ SET_NETDEV_DEV(ndev, &pdev->dev); -+ -+ in = netdev_priv(ndev); -+ in->ivshm_regs = regs; -+ in->state_table = state_table; -+ -+ in->shm[IVSHM_NET_SECTION_TX] = -+ output_sections + output_section_sz * id; -+ in->shm[IVSHM_NET_SECTION_RX] = -+ output_sections + output_section_sz * !id; -+ -+ in->shmlen = output_section_sz; -+ -+ in->peer_id = !id; -+ in->pdev = pdev; -+ in->last_peer_state = IVSHM_NET_STATE_UNKNOWN; -+ -+ mutex_init(&in->state_lock); -+ -+ ret = ivshm_net_calc_qsize(ndev); -+ if (ret) -+ goto err_free; -+ -+ in->state_wq = alloc_ordered_workqueue(device_name, 0); -+ if (!in->state_wq) -+ goto err_free; -+ -+ INIT_WORK(&in->state_work, ivshm_net_state_change); -+ -+ eth_random_addr(ndev->perm_addr); -+ dev_addr_set(ndev, ndev->perm_addr); -+ ndev->netdev_ops = &ivshm_net_ops; -+ ndev->ethtool_ops = &ivshm_net_ethtool_ops; -+ ndev->mtu = min_t(u32, IVSHM_NET_MTU_DEF, in->qsize / 16); -+ ndev->min_mtu = ETH_MIN_MTU; -+ ndev->max_mtu = min_t(u32, ETH_MAX_MTU, in->qsize / 4); -+ ndev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG; -+ ndev->features = ndev->hw_features; -+ -+ netif_carrier_off(ndev); -+ netif_napi_add(ndev, &in->napi, ivshm_net_poll); -+ -+ ret = register_netdev(ndev); -+ if (ret) -+ goto err_wq; -+ -+ ret = pci_alloc_irq_vectors(pdev, 1, 2, PCI_IRQ_LEGACY | PCI_IRQ_MSIX); -+ if (ret < 0) -+ goto err_alloc_irq; -+ -+ if (pdev->msix_enabled) { -+ if (ret != 2) { -+ ret = -EBUSY; -+ goto err_request_irq; -+ } -+ -+ device_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, -+ "%s-state[%s]", DRV_NAME, -+ dev_name(&pdev->dev)); -+ if (!device_name) { -+ ret = -ENOMEM; -+ goto err_request_irq; -+ } -+ -+ ret = request_irq(pci_irq_vector(pdev, IVSHM_NET_MSIX_STATE), -+ ivshm_net_int_state, 0, device_name, in); -+ if (ret) -+ goto err_request_irq; -+ -+ device_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, -+ "%s-tx-rx[%s]", DRV_NAME, -+ dev_name(&pdev->dev)); -+ if (!device_name) { -+ ret = -ENOMEM; -+ goto err_request_irq2; -+ } -+ -+ ret = request_irq(pci_irq_vector(pdev, IVSHM_NET_MSIX_TX_RX), -+ ivshm_net_int_tx_rx, 0, device_name, in); -+ if (ret) -+ goto err_request_irq2; -+ -+ in->tx_rx_vector = IVSHM_NET_MSIX_TX_RX; -+ } else { -+ ret = request_irq(pci_irq_vector(pdev, 0), ivshm_net_intx, 0, -+ device_name, in); -+ if (ret) -+ goto err_request_irq; -+ -+ in->tx_rx_vector = 0; -+ } -+ -+ pci_set_master(pdev); -+ -+ pci_write_config_byte(pdev, vendor_cap + IVSHM_CFG_PRIV_CNTL, 0); -+ writel(IVSHM_INT_ENABLE, &in->ivshm_regs->int_control); -+ -+ writel(IVSHM_NET_STATE_RESET, &in->ivshm_regs->state); -+ ivshm_net_check_state(in); -+ -+ return 0; -+ -+err_request_irq2: -+ free_irq(pci_irq_vector(pdev, IVSHM_NET_MSIX_STATE), in); -+err_request_irq: -+ pci_free_irq_vectors(pdev); -+err_alloc_irq: -+ unregister_netdev(ndev); -+err_wq: -+ destroy_workqueue(in->state_wq); -+err_free: -+ free_netdev(ndev); -+ -+ return ret; -+} -+ -+static void ivshm_net_remove(struct pci_dev *pdev) -+{ -+ struct net_device *ndev = pci_get_drvdata(pdev); -+ struct ivshm_net *in = netdev_priv(ndev); -+ -+ writel(IVSHM_NET_STATE_RESET, &in->ivshm_regs->state); -+ writel(0, &in->ivshm_regs->int_control); -+ -+ if (pdev->msix_enabled) { -+ free_irq(pci_irq_vector(pdev, IVSHM_NET_MSIX_STATE), in); -+ free_irq(pci_irq_vector(pdev, IVSHM_NET_MSIX_TX_RX), in); -+ } else { -+ free_irq(pci_irq_vector(pdev, 0), in); -+ } -+ pci_free_irq_vectors(pdev); -+ -+ unregister_netdev(ndev); -+ cancel_work_sync(&in->state_work); -+ destroy_workqueue(in->state_wq); -+ free_netdev(ndev); -+} -+ -+static const struct pci_device_id ivshm_net_id_table[] = { -+ { PCI_DEVICE(PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_IVSHMEM), -+ (PCI_CLASS_OTHERS << 16) | IVSHM_PROTO_NET, 0xffffff }, -+ { 0 } -+}; -+MODULE_DEVICE_TABLE(pci, ivshm_net_id_table); -+ -+static struct pci_driver ivshm_net_driver = { -+ .name = DRV_NAME, -+ .id_table = ivshm_net_id_table, -+ .probe = ivshm_net_probe, -+ .remove = ivshm_net_remove, -+}; -+module_pci_driver(ivshm_net_driver); -+ -+MODULE_AUTHOR("Mans Rullgard "); -+MODULE_LICENSE("GPL"); --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0013-arm64-dts-add-reserved_memory-label-for-CMA-regions-.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0013-arm64-dts-add-reserved_memory-label-for-CMA-regions-.patch deleted file mode 100644 index 4d34c3d110..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0013-arm64-dts-add-reserved_memory-label-for-CMA-regions-.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 53b89219201613e4e59218a3efbca88b48f806a5 Mon Sep 17 00:00:00 2001 -From: Paresh Bhagat -Date: Thu, 27 Apr 2023 11:10:29 +0530 -Subject: [PATCH 13/15] arm64: dts: add reserved_memory label for CMA regions - for k3-am625-sk - -Add lable fore reserved memory needed to build and apply overlay - -Upstream-Status: Pending - -Signed-off-by: Matt Ranostay -Signed-off-by: Paresh Bhagat ---- - arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi -index 07763091ab5953..60bf8cd6ca4586 100644 ---- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi -+++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi -@@ -35,7 +35,7 @@ memory@80000000 { - - }; - -- reserved-memory { -+ reserved_memory: reserved-memory { - #address-cells = <2>; - #size-cells = <2>; - ranges; --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0014-arm64-dts-am625-base-board-Reserve-memory-for-jailho.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0014-arm64-dts-am625-base-board-Reserve-memory-for-jailho.patch deleted file mode 100644 index eb24ce63a3..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0014-arm64-dts-am625-base-board-Reserve-memory-for-jailho.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 1bedddc22e54bd753287da7e7ea026583f4fc637 Mon Sep 17 00:00:00 2001 -From: Matt Ranostay -Date: Thu, 27 Apr 2023 11:27:04 +0530 -Subject: [PATCH 14/15] arm64: dts: am625-base-board: Reserve memory for - jailhouse - -This has to be in sync with jailhouse cell configurations. - -Upstream-Status: Pending - -Signed-off-by: Matt Ranostay -Signed-off-by: Paresh Bhagat -Signed-off-by: Ricardo Salveti ---- - .../dts/ti/k3-am625-base-board-jailhouse.dtso | 30 +++++++++++++++++++ - 1 file changed, 30 insertions(+) - create mode 100644 arch/arm64/boot/dts/ti/k3-am625-base-board-jailhouse.dtso - -diff --git a/arch/arm64/boot/dts/ti/k3-am625-base-board-jailhouse.dtso b/arch/arm64/boot/dts/ti/k3-am625-base-board-jailhouse.dtso -new file mode 100644 -index 00000000000000..8ebfd0e90c54ee ---- /dev/null -+++ b/arch/arm64/boot/dts/ti/k3-am625-base-board-jailhouse.dtso -@@ -0,0 +1,30 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/ -+ */ -+ -+/dts-v1/; -+/plugin/; -+ -+&reserved_memory { -+ #address-cells = <2>; -+ #size-cells = <2>; -+ -+ /* -+ * Reserve for Jailhouse hypervisor firmware and inmates. -+ * Must be in sync with jailhouse cell configurations. -+ */ -+ hyp_mem: jailhouse@dfa00000 { -+ reg = <0x0 0xdfa00000 0x0 0x20600000>; -+ alignment = <0x1000>; -+ no-map; -+ }; -+}; -+ -+&main_uart1 { -+ status = "disabled"; -+}; -+ -+&sdhci0 { -+ status = "disabled"; -+}; --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0015-arm64-dts-Makefile-Update-makefile-to-build-overlay.patch b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0015-arm64-dts-Makefile-Update-makefile-to-build-overlay.patch deleted file mode 100644 index 1e35d6756e..0000000000 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging/0015-arm64-dts-Makefile-Update-makefile-to-build-overlay.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 36f0ef4a69dc4a048e9aa7a7d6836df8870c3fbb Mon Sep 17 00:00:00 2001 -From: Paresh Bhagat -Date: Sun, 28 May 2023 11:21:24 +0530 -Subject: [PATCH 15/15] arm64: dts: Makefile: Update makefile to build overlay - -Update makefile to build overlay for jailhouse. - -Upstream-Status: Pending - -Signed-off-by: Matt Ranostay -Signed-off-by: Paresh Bhagat ---- - arch/arm64/boot/dts/ti/Makefile | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/arch/arm64/boot/dts/ti/Makefile b/arch/arm64/boot/dts/ti/Makefile -index d4c71593494c35..22abe3ad2eaa8f 100644 ---- a/arch/arm64/boot/dts/ti/Makefile -+++ b/arch/arm64/boot/dts/ti/Makefile -@@ -85,6 +85,9 @@ dtb-$(CONFIG_ARCH_K3) += k3-j784s4-evm-quad-port-eth-exp1.dtbo - dtb-$(CONFIG_ARCH_K3) += k3-j784s4-evm-usxgmii-exp1-exp2.dtbo - dtb-$(CONFIG_ARCH_K3) += k3-j784s4-evm-virt-mac-client.dtbo - -+#jailhouse overlay -+dtb-$(CONFIG_ARCH_K3) += k3-am625-base-board-jailhouse.dtbo -+ - # FPDLink Sensors - dtb-$(CONFIG_ARCH_K3) += k3-fpdlink-imx390-rcm-0-0.dtbo \ - k3-fpdlink-imx390-rcm-0-1.dtbo \ --- -2.40.1 - diff --git a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging_git.bb b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging_git.bb index fa7b59bbac..e9798f5a0e 100644 --- a/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging_git.bb +++ b/meta-lmp-bsp/dynamic-layers/meta-ti-bsp/recipes-kernel/linux/linux-lmp-ti-staging_git.bb @@ -20,26 +20,6 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" SRC_URI = "${KERNEL_REPO};protocol=${KERNEL_REPO_PROTOCOL};branch=${KERNEL_BRANCH};name=machine; \ ${KERNEL_META_REPO};protocol=${KERNEL_META_REPO_PROTOCOL};type=kmeta;name=meta;branch=${KERNEL_META_BRANCH};destsuffix=${KMETA} \ - ${@bb.utils.contains('MACHINE_FEATURES', 'jailhouse', '${SRC_URI_JAILHOUSE}', '', d)} \ -" - -# Jailhouse patches and config -SRC_URI_JAILHOUSE = " \ - file://0001-uio-Enable-read-only-mappings.patch \ - file://0002-ivshmem-Add-header-file.patch \ - file://0003-uio-Add-driver-for-inter-VM-shared-memory-device.patch \ - file://0004-jailhouse-Add-simple-debug-console-via-the-hyperviso.patch \ - file://0005-Revert-arm-Remove-the-ability-to-set-HYP-vectors-out.patch \ - file://0006-arm-Export-__boot_cpu_mode-for-use-in-Jailhouse-driv.patch \ - file://0007-mm-Re-export-ioremap_page_range.patch \ - file://0008-Revert-mm-don-t-allow-executable-ioremap-mappings.patch \ - file://0009-mm-vmalloc-Export-__get_vm_area_caller.patch \ - file://0010-arm-arm64-export-__hyp_stub_vectors.patch \ - file://0011-x86-Export-lapic_timer_period.patch \ - file://0012-ivshmem-net-virtual-network-device-for-Jailhouse.patch \ - file://0013-arm64-dts-add-reserved_memory-label-for-CMA-regions-.patch \ - file://0014-arm64-dts-am625-base-board-Reserve-memory-for-jailho.patch \ - file://0015-arm64-dts-Makefile-Update-makefile-to-build-overlay.patch \ " KMETA = "kernel-meta" diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/am62xx-evm/boot.cmd b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/am62xx-evm/boot.cmd index d2c7829907..37977129a0 100644 --- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/am62xx-evm/boot.cmd +++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/am62xx-evm/boot.cmd @@ -5,9 +5,6 @@ setenv devnum 0 setenv bootpart 1 setenv rootpart 2 -# Use "#conf-ti_overlayname.dtbo" -# setenv dtoverlay "#conf-ti_k3-am625-base-board-jailhouse.dtbo" - setenv loadaddr 0x90000000 setenv fit_addr "${loadaddr}" diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/beagleplay/boot.cmd b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/beagleplay/boot.cmd index b0d60e19e7..754f5c7de3 100644 --- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/beagleplay/boot.cmd +++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/beagleplay/boot.cmd @@ -3,9 +3,6 @@ setenv bootlimit 3 setenv devtype mmc setenv devnum ${mmcdev} -# Use "#conf-ti_overlayname.dtbo" -# setenv dtoverlay "#conf-ti_k3-am625-base-board-jailhouse.dtbo" - setenv loadaddr 0x90000000 setenv bootcmd_resetvars 'setenv kernel_image; setenv bootargs; setenv kernel_image2; setenv bootargs2' diff --git a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-arm64-k3-am625-sk-Add-crypto-memory-region.patch b/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-arm64-k3-am625-sk-Add-crypto-memory-region.patch deleted file mode 100644 index 7c078d416f..0000000000 --- a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-arm64-k3-am625-sk-Add-crypto-memory-region.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 81cdbe3a3910a992ecaffb1464eb874f6661c1ff Mon Sep 17 00:00:00 2001 -From: Andreas Dannenberg -Date: Mon, 12 Sep 2022 13:22:04 -0500 -Subject: [PATCH 1/4] configs: arm64: k3-am625-sk: Add crypto memory region - -Add the memory region for the AM62x crypto accelerator to the device- -specific config file. This fixes a runtime exception when the kernel -accesses that memory region: - - -Unhandled data read at 0x40910010(4) - -FATAL: unhandled trap (exception class 0x24) - - -Upstream-Status: Submitted - -Signed-off-by: Andreas Dannenberg -Signed-off-by: Ricardo Salveti ---- - configs/arm64/k3-am625-sk.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/configs/arm64/k3-am625-sk.c b/configs/arm64/k3-am625-sk.c -index 4c77e7fe..cfc8dc8d 100644 ---- a/configs/arm64/k3-am625-sk.c -+++ b/configs/arm64/k3-am625-sk.c -@@ -18,7 +18,7 @@ - struct { - struct jailhouse_system header; - __u64 cpus[1]; -- struct jailhouse_memory mem_regions[31]; -+ struct jailhouse_memory mem_regions[32]; - struct jailhouse_irqchip irqchips[5]; - struct jailhouse_pci_device pci_devices[2]; - } __attribute__((packed)) config = { -@@ -232,6 +232,13 @@ struct { - .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | - JAILHOUSE_MEM_IO, - }, -+ /* CRYPTO */ { -+ .phys_start = 0x40900000, -+ .virt_start = 0x40900000, -+ .size = 0x0030000, -+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | -+ JAILHOUSE_MEM_IO, -+ }, - /* First Wake Up Domain */ { - .phys_start = 0x2b000000, - .virt_start = 0x2b000000, --- -2.34.1 - diff --git a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-k3-use-intx-for-bar_mask.patch b/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-k3-use-intx-for-bar_mask.patch deleted file mode 100644 index 04082b400b..0000000000 --- a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0001-configs-k3-use-intx-for-bar_mask.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 84ea5e9f65fc8082d520267258784cae32c8b499 Mon Sep 17 00:00:00 2001 -From: Ricardo Salveti -Date: Wed, 1 Mar 2023 22:14:35 -0300 -Subject: [PATCH] configs/k3: use intx for bar_mask - -Fixes pci probe failure: - -[ 46.795840] pci 0001:00:00.0: BAR 0: no space for [mem size 0x00010000] -[ 46.802516] pci 0001:00:00.0: BAR 0: failed to assign [mem size 0x00010000] -[ 46.809512] pci 0001:00:01.0: BAR 0: no space for [mem size 0x00010000] -[ 46.816158] pci 0001:00:01.0: BAR 0: failed to assign [mem size 0x00010000] - -Upstream-Status: Pending - -Signed-off-by: Ricardo Salveti ---- - configs/arm64/k3-am625-sk-linux-demo.c | 4 ++-- - configs/arm64/k3-am625-sk.c | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/configs/arm64/k3-am625-sk-linux-demo.c b/configs/arm64/k3-am625-sk-linux-demo.c -index 6dac8859..dcc5f026 100644 ---- a/configs/arm64/k3-am625-sk-linux-demo.c -+++ b/configs/arm64/k3-am625-sk-linux-demo.c -@@ -197,7 +197,7 @@ struct { - /* 00:00.0 */ { - .type = JAILHOUSE_PCI_TYPE_IVSHMEM, - .bdf = 0 << 3, -- .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX_64K, -+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX, - .shmem_regions_start = 0, - .shmem_dev_id = 2, - .shmem_peers = 3, -@@ -206,7 +206,7 @@ struct { - /* 00:01.0 */ { - .type = JAILHOUSE_PCI_TYPE_IVSHMEM, - .bdf = 1 << 3, -- .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX_64K, -+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX, - .shmem_regions_start = 5, - .shmem_dev_id = 1, - .shmem_peers = 2, -diff --git a/configs/arm64/k3-am625-sk.c b/configs/arm64/k3-am625-sk.c -index 69ab12a4..dcea42e0 100644 ---- a/configs/arm64/k3-am625-sk.c -+++ b/configs/arm64/k3-am625-sk.c -@@ -325,7 +325,7 @@ struct { - .type = JAILHOUSE_PCI_TYPE_IVSHMEM, - .domain = 1, - .bdf = 0 << 3, -- .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX_64K, -+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX, - .shmem_regions_start = 0, - .shmem_dev_id = 0, - .shmem_peers = 3, -@@ -335,7 +335,7 @@ struct { - .type = JAILHOUSE_PCI_TYPE_IVSHMEM, - .domain = 1, - .bdf = 1 << 3, -- .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX_64K, -+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX, - .shmem_regions_start = 5, - .shmem_dev_id = 0, - .shmem_peers = 2, --- -2.34.1 - diff --git a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0002-configs-arm64-k3-am625-sk-Switch-inmate-boot-console.patch b/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0002-configs-arm64-k3-am625-sk-Switch-inmate-boot-console.patch deleted file mode 100644 index ded06d812d..0000000000 --- a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0002-configs-arm64-k3-am625-sk-Switch-inmate-boot-console.patch +++ /dev/null @@ -1,63 +0,0 @@ -From e89b2dfc08254cf62d0beffeed258ed362897635 Mon Sep 17 00:00:00 2001 -From: Andreas Dannenberg -Date: Mon, 12 Sep 2022 16:08:12 -0500 -Subject: [PATCH 2/4] configs: arm64: k3-am625-sk: Switch inmate boot console - alias to serial3 - -Traditionally the serial3 DTS alias is used for the 2nd main-domain UART -on K3 devices so go ahead and update the alias and its usage accordingly -for better consistency. - -While at it also do a minor cleanup of the UART's DTS node to use the -TISCI standard definitions as used in the corresponding Kernel DTS files. - -Upstream-Status: Submitted - -Signed-off-by: Andreas Dannenberg -Signed-off-by: Ricardo Salveti ---- - configs/arm64/dts/inmate-k3-am625-sk.dts | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -diff --git a/configs/arm64/dts/inmate-k3-am625-sk.dts b/configs/arm64/dts/inmate-k3-am625-sk.dts -index c1455073..8e1bebb8 100644 ---- a/configs/arm64/dts/inmate-k3-am625-sk.dts -+++ b/configs/arm64/dts/inmate-k3-am625-sk.dts -@@ -1,6 +1,7 @@ - /dts-v1/; - - #include -+#include - - / { - model = "Texas Instruments AM625 Inmate Model"; -@@ -10,11 +11,11 @@ - #size-cells = <2>; - - aliases { -- serial1 = &main_uart1; -+ serial3 = &main_uart1; - }; - - chosen { -- stdout-path = "serial1:115200n8"; -+ stdout-path = "serial3:115200n8"; - }; - - memory@e0000000 { -@@ -91,9 +92,9 @@ - compatible = "ti,am64-uart", "ti,am654-uart"; - reg = <0x00 0x02810000 0x00 0x100>; - interrupts = ; -- power-domains = <&k3_pds 152 1>; -- current-speed = <115200>; -- clock-frequency = <48000000>; -+ power-domains = <&k3_pds 152 TI_SCI_PD_EXCLUSIVE>; -+ clocks = <&k3_clks 152 0>; -+ clock-names = "fclk"; - }; - - pci@76000000 { --- -2.34.1 - diff --git a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0003-configs-arm64-k3-am625-sk-add-vtm-memory-node.patch b/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0003-configs-arm64-k3-am625-sk-add-vtm-memory-node.patch deleted file mode 100644 index a848addb90..0000000000 --- a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0003-configs-arm64-k3-am625-sk-add-vtm-memory-node.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 4e3ec2473b760f79f41558517f06300e3503ba0d Mon Sep 17 00:00:00 2001 -From: Ricardo Salveti -Date: Mon, 30 Jan 2023 23:10:49 -0300 -Subject: [PATCH 3/4] configs: arm64: k3-am625-sk: add vtm memory node - -Add the memory region for VTM to the device-specific config -file. This fixes a runtime exception when the kernel accesses -that memory region: - - -Unhandled data read at 0xb00308(4) - -FATAL: unhandled trap (exception class 0x24) - - -Upstream-Status: Submitted - -Signed-off-by: Ricardo Salveti ---- - configs/arm64/k3-am625-sk.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/configs/arm64/k3-am625-sk.c b/configs/arm64/k3-am625-sk.c -index cfc8dc8d..d6096e8f 100644 ---- a/configs/arm64/k3-am625-sk.c -+++ b/configs/arm64/k3-am625-sk.c -@@ -18,7 +18,7 @@ - struct { - struct jailhouse_system header; - __u64 cpus[1]; -- struct jailhouse_memory mem_regions[32]; -+ struct jailhouse_memory mem_regions[33]; - struct jailhouse_irqchip irqchips[5]; - struct jailhouse_pci_device pci_devices[2]; - } __attribute__((packed)) config = { -@@ -232,6 +232,13 @@ struct { - .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | - JAILHOUSE_MEM_IO, - }, -+ /* VTM */ { -+ .phys_start = 0x00b00000, -+ .virt_start = 0x00b00000, -+ .size = 0x00002400, -+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | -+ JAILHOUSE_MEM_IO_32 | JAILHOUSE_MEM_IO_UNALIGNED, -+ }, - /* CRYPTO */ { - .phys_start = 0x40900000, - .virt_start = 0x40900000, --- -2.34.1 - diff --git a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0004-configs-arm64-k3-am625-sk-Add-GPMC-memory-region.patch b/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0004-configs-arm64-k3-am625-sk-Add-GPMC-memory-region.patch deleted file mode 100644 index feff8a93c2..0000000000 --- a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse/0004-configs-arm64-k3-am625-sk-Add-GPMC-memory-region.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 6b5282f0a9f4cd576ab9743c21181a2decdb4aca Mon Sep 17 00:00:00 2001 -From: Andreas Dannenberg -Date: Thu, 19 Jan 2023 09:43:55 -0600 -Subject: [PATCH 4/4] configs: arm64: k3-am625-sk: Add GPMC memory region - -Add the memory region for GPMC, used by the AM62Q NAND card. - -Upstream-Status: Submitted - -Signed-off-by: Andreas Dannenberg -Signed-off-by: Ricardo Salveti ---- - configs/arm64/k3-am625-sk.c | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -diff --git a/configs/arm64/k3-am625-sk.c b/configs/arm64/k3-am625-sk.c -index d6096e8f..230d6a4a 100644 ---- a/configs/arm64/k3-am625-sk.c -+++ b/configs/arm64/k3-am625-sk.c -@@ -18,7 +18,7 @@ - struct { - struct jailhouse_system header; - __u64 cpus[1]; -- struct jailhouse_memory mem_regions[33]; -+ struct jailhouse_memory mem_regions[35]; - struct jailhouse_irqchip irqchips[5]; - struct jailhouse_pci_device pci_devices[2]; - } __attribute__((packed)) config = { -@@ -225,6 +225,20 @@ struct { - .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | - JAILHOUSE_MEM_IO, - }, -+ /* GPMC */ { -+ .phys_start = 0x3b000000, -+ .virt_start = 0x3b000000, -+ .size = 0x00000400, -+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | -+ JAILHOUSE_MEM_IO, -+ }, -+ /* GPMC */ { -+ .phys_start = 0x50000000, -+ .virt_start = 0x50000000, -+ .size = 0x08000000, -+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | -+ JAILHOUSE_MEM_IO, -+ }, - /* CPSW */ { - .phys_start = 0x08000000, - .virt_start = 0x08000000, --- -2.34.1 - diff --git a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse_git.bbappend b/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse_git.bbappend deleted file mode 100644 index 9f57764ced..0000000000 --- a/meta-lmp-bsp/recipes-kernel/jailhouse/jailhouse_git.bbappend +++ /dev/null @@ -1,11 +0,0 @@ -FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" - -SRC_URI:append:k3 = " \ - file://0001-configs-arm64-k3-am625-sk-Add-crypto-memory-region.patch \ - file://0002-configs-arm64-k3-am625-sk-Switch-inmate-boot-console.patch \ - file://0003-configs-arm64-k3-am625-sk-add-vtm-memory-node.patch \ - file://0004-configs-arm64-k3-am625-sk-Add-GPMC-memory-region.patch \ - file://0001-configs-k3-use-intx-for-bar_mask.patch \ -" - -COMPATIBLE_MACHINE = "(ti-soc)"