1
0
mirror of https://git.yoctoproject.org/meta-arm synced 2026-05-07 04:58:57 +00:00

arm-autonomy: Create xen-devicetree recipe

Create a xen-devicetree recipe to add entries required to boot Xen and a
Dom0 inside a DTB.
The recipe is introducing XEN_DEVICETREE_* parameters to define the xen
command line, the dom0 command line, the dom0 memory size, the dom0
kernel load address and size.
The recipe can also be extended using bbappend to adapt the device tree
and the parameters.
Adaptation are provided to support Juno, fvp-base and foundation-armv8
boards from meta-arm-bsp.
Add xen-devicetree as EXTRA_IMAGEDEPENDS to
arm-autonomy-host-image-minimal

Change-Id: Ibcfbd02c2377a9abcbd20caa47ea833b5308fbac
Issue-Id: SCM-767
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Reviewed-by: Diego Sueiro <diego.sueiro@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
Bertrand Marquis
2020-03-27 10:50:10 +00:00
committed by Jon Mason
parent 12c70f287f
commit bca1918461
7 changed files with 225 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ Each recipe introducing such variables has a chapter "Bitbake parameters" in
its documentation.
Those documentation files should be checked for variables:
- [xen-devicetree](documentation/xen-devicetree.md)
BSPs
----
@@ -63,6 +64,9 @@ Recipes and classes
-------------------
This layer is adding the following recipes and classes:
* [xen-devicetree](documentation/xen-devicetree.md): this is a recipe to modify
a device tree blob to add information required to boot xen and a Dom0 linux.
Contributing
------------
This project has not put in place a process for contributions currently. If you

View File

@@ -0,0 +1,104 @@
Xen device tree
===============
Introduction
------------
xen-devicetree recipe can be used to modify an existing Device Tree Blob,
produced by Linux kernel or another recipe, to include in it entries required
to start Xen and a Dom0 Linux on top of it.
The recipe will do the following processing:
- generate a xen.dtsi file with entries required for xen based on parameters
- turn DTBs in ${XEN_DEVICETREE_DTBS} back to dts
- include in xen.dtsi and all other dtsi from
${XEN_DEVICETREE_DTSI_MERGE} (check Bitbake parameters for more information
on this).
- use dtc to create a new DTB file
The recipe will generate new files in deploy/images and name them with the
extension "-xen.dtb".
For example **machine.dtb** will generate **machine-xen.dtb**.
Entries added to the DTBs
-------------------------
When a DTB is processed by the recipe, the following block is added:
```
chosen {
xen,dom0-bootargs = "VAL";
xen,xen-bootargs = "VAL";
modules {
#size-cells = <0x00000001>;
#address-cells = <0x00000001>;
module@0 {
reg = <VAL VAL>;
compatible = "multiboot,module";
};
};
};
```
Each occurence of **VAL** is replaced by the content of the variables listed in
this documentation.
Bitbake parameters
------------------
Several parameters are available to configure the xen-devicetree during Yocto
project compilation (those can be set in your project local.conf, for exmple).
The following parameters are available:
- XEN_DEVICETREE_DEPEND: This variable can be used to indicate which recipe
task is generating the DTBs that xen-devicetree will modify. This makes sure
the xen devicetrees are properly regenerated if the source DTBs are changed.
This variable is set by default to "virtual/kernel:do_deploy" to use DTBs
generated during the compilation of the Linux kernel. This must be changed
if the machine your are using is not using a DTB listed in KERNEL_DEVICETREE.
- XEN_DEVICETREE_DTBS: This should be set to the list of DTBs you want to be
modified by xen-devicetree. Those must be files that xen-devicetree can find
in the ${DEPLOY_DIR_IMAGE} directory using only the basename of the entries.
For example "mydir/board.dtb" will make the recipe look for
${DEPLOY_DIR_IMAGE}/board.dtb.
This variable is set by default to "${KERNEL_DEVICETREE}" to process the DTBs
generated by the Linux kernel.
- XEN_DEVICETREE_DOM0_MEM: Memory size to allocate to Dom0.
This variable is only used if XEN_DEVICETREE_XEN_BOOTARGS has a value
containing "dom0_mem=${XEN_DEVICETREE_DOM0_MEM}" as the memory assigned to
dom0 is defined using Xen boot arguments.
This variable is set by default to "1024M".
- XEN_DEVICETREE_DOM0_BOOTARGS: Boot arguments to pass to Dom0 Linux when
booting it.
This variable is set by default to "console=hvc0 earlycon=xen".
- XEN_DEVICETREE_XEN_BOOTARGS: this variable should be set with the boot
arguments to be passed to Xen on boot.
This variable is set by default to
"noreboot dom0_mem=${XEN_DEVICETREE_DOM0_MEM}".
- XEN_DEVICETREE_DOM0_ADDR: This is the address from which the Linux kernel to
be used for Dom0 will be copied. When using u-boot, this is the address at
which you will load the kernel Image before starting Xen.
This variable is set by default to "0x80080000".
- XEN_DEVICETREE_DOM0_SIZE: This is the size of the kernel loaded at
${XEN_DEVICETREE_DOM0_ADDR}. Xen will copy this amount of data inside the
guest before starting it so the size must be at least equal to the kernel
size but can be bigger. You must be careful not to have a value too big as it
could slow down boot or copy other parts with it (like the DTB).
You might need to increase this if you use a kernel with a bundled initramfs.
This variable is set by default to "0x01000000".
- XEN_DEVICETREE_DTSI_MERGE: This variable contains the list of dtsi files that
must be included inside the generated DTB file. By default the only one
include is the "xen.dtsi" generated by the recipe.
If your board or project needs to include more fixes or entries in the DTB,
this variable can be appended from a bbappend file to include other dtsi. The
files must be inside the recipe workspace during Yocto compilation.
You can check xen-devicetree.bbappend for an example.

View File

@@ -18,6 +18,9 @@ IMAGE_INSTALL += " \
qemu \
"
# Build xen-devicetree to produce a xen ready devicetree
EXTRA_IMAGEDEPENDS += "xen-devicetree"
python __anonymous() {
if bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', False, True, d):
raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'arm-autonomy-host'")

View File

@@ -0,0 +1,11 @@
/*
* Disable IOMMU on juno board when Xen is used
*/
/ {
/* turn off iommu */
iommu@2b600000 {
status = "disabled";
};
};

View File

@@ -0,0 +1,17 @@
/ {
chosen {
xen,dom0-bootargs = "###XEN_DOM0_BOOTARGS###";
xen,xen-bootargs = "###XEN_XEN_BOOTARGS###";
modules {
#size-cells = <0x00000001>;
#address-cells = <0x00000001>;
module@0 {
reg = <###XEN_DOM0_ADDR### ###XEN_DOM0_SIZE###>;
compatible = "multiboot,module";
};
};
};
};

View File

@@ -0,0 +1,68 @@
# This recipe can be used to modify one or several DTBS to add
# entries required to declare and boot Linux as Dom0 from Xen
SRC_URI = "file://xen.dtsi.in"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "\
file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \
"
S = "${WORKDIR}"
DESCRIPTION = "Add entries in DTB for Xen and Dom0"
# Please refer to documentation/xen-devicetree.md for documentation on those
# parameters
XEN_DEVICETREE_DEPEND ?= "virtual/kernel:do_deploy"
XEN_DEVICETREE_DTBS ?= "${KERNEL_DEVICETREE}"
XEN_DEVICETREE_XEN_BOOTARGS ?= "noreboot dom0_mem=${XEN_DEVICETREE_DOM0_MEM}"
XEN_DEVICETREE_DOM0_MEM ?= "1024M"
XEN_DEVICETREE_DOM0_BOOTARGS ?= "console=hvc0 earlycon=xen"
XEN_DEVICETREE_DOM0_ADDR ?= "0x80080000"
XEN_DEVICETREE_DOM0_SIZE ?= "0x01000000"
XEN_DEVICETREE_DTSI_MERGE ?= "xen.dtsi"
# Our package does not generate any package for the rootfs but contributes to
# deploy
inherit nopackages deploy
DEPENDS += "dtc-native"
do_compile() {
cat ${WORKDIR}/xen.dtsi.in \
| sed -e "s,###XEN_DOM0_BOOTARGS###,${XEN_DEVICETREE_DOM0_BOOTARGS}," \
| sed -e "s,###XEN_XEN_BOOTARGS###,${XEN_DEVICETREE_XEN_BOOTARGS}," \
| sed -e "s,###XEN_DOM0_ADDR###,${XEN_DEVICETREE_DOM0_ADDR}," \
| sed -e "s,###XEN_DOM0_SIZE###,${XEN_DEVICETREE_DOM0_SIZE}," \
> ${WORKDIR}/xen.dtsi
# Generate final dtbs
for dtbf in ${XEN_DEVICETREE_DTBS}; do
rdtb=`basename $dtbf`
if [ ! -f ${DEPLOY_DIR_IMAGE}/$rdtb ]; then
die "Wrong file in XEN_DEVICETREE_DTBS: ${DEPLOY_DIR_IMAGE}/$rdtb does not exist"
fi
dtc -I dtb -O dts -o ${WORKDIR}/dom0-linux.dts ${DEPLOY_DIR_IMAGE}/$rdtb
# Add external includes
for inc in ${XEN_DEVICETREE_DTSI_MERGE}; do
echo "/include/ \"$inc\"" >> ${WORKDIR}/dom0-linux.dts
done
rdtbnoextn=`basename $dtbf ".dtb"`
dtc -I dts -O dtb \
-o ${WORKDIR}/${rdtbnoextn}-xen.dtb ${WORKDIR}/dom0-linux.dts
done
}
do_compile[depends] += "${XEN_DEVICETREE_DEPEND}"
do_deploy() {
# install generated dtbs
for dtbf in ${XEN_DEVICETREE_DTBS}; do
rdtbnoextn=`basename $dtbf ".dtb"`
install -m 644 ${rdtbnoextn}-xen.dtb ${DEPLOYDIR}/.
done
}
addtask deploy before do_build after do_compile

View File

@@ -0,0 +1,18 @@
# Platform dependent parameters
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
# Add a dtb snippet to turn off iommu in dom0 on Juno board
SRC_URI_append_juno = " file://xen-juno.dtsi"
XEN_DEVICETREE_DTSI_MERGE_append_juno = " xen-juno.dtsi"
# Board specific configs
XEN_DEVICETREE_DOM0_BOOTARGS_append_juno = " root=/dev/sda1 rootwait"
XEN_DEVICETREE_XEN_BOOTARGS_append_juno = " console=dtuart dtuart=serial0 bootscrub=0 iommu=no"
XEN_DEVICETREE_DOM0_BOOTARGS_append_fvp-base = " root=/dev/vda2"
XEN_DEVICETREE_XEN_BOOTARGS_append_fvp-base = " console=dtuart dtuart=serial0 bootscrub=0"
XEN_DEVICETREE_DOM0_BOOTARGS_append_foundation-armv8 = " root=/dev/vda2"
XEN_DEVICETREE_XEN_BOOTARGS_append_foundation-armv8 = " console=dtuart dtuart=serial0 bootscrub=0"