arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size
PATCH 1/4 arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size
From: Nathan Dunne <[email protected]>
Reduced the level at which messages relating to overriding the user provided value for XEN_DEVICETREE_DOM0_SIZE when it is too small are logged at from 'warn' to 'note'
Issue-Id: SCM-2037
--- .../recipes-extended/xen-devicetree/xen-devicetree.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb +2 -2
@@ -91,11 +91,11 @@ python calc_xen_dtb_dom0_size() { size_defined = int(d.getVar('XEN_DEVICETREE_DOM0_SIZE'), 16) if size_required > size_defined: - bb.warn ("Wrong kernel size setting inside xen dtb!\n"\ + bb.note ("Wrong kernel size setting inside xen dtb!\n"\ "Required:\t%(req)d (%(req)#010X)\n"\ "Requested:\t%(def)d (%(def)#010X)"\ % {"req": size_required, "def": size_defined}) - bb.warn ("Overriding XEN_DEVICETREE_DOM0_SIZE with "\ + bb.note ("Overriding XEN_DEVICETREE_DOM0_SIZE with "\ "%(req)d (%(req)#010X)" % {"req": size_required}) d.setVar('XEN_DEVICETREE_DOM0_SIZE', hex(size_required)) }
Signature · 1 line
2.17.1
PATCH 2/4 arm-autonomy/xen-devicetree: Allow hex or decimal Dom0 Size
From: Nathan Dunne <[email protected]>
Check whether XEN_DEVICETREE_DOM0_SIZE begins '0x' and cast from hex or decimal accordingly, rather than assuming hex.
Issue-Id: SCM-2037
--- .../recipes-extended/xen-devicetree/xen-devicetree.bb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb +5 -1
@@ -88,7 +88,11 @@ python calc_xen_dtb_dom0_size() { bb.note('size in bytes: %d' % size) # Ceil to MiB size_required = ceil(size / (2 ** 20)) * (2 ** 20) - size_defined = int(d.getVar('XEN_DEVICETREE_DOM0_SIZE'), 16) + xen_devicetree_dom0_size = d.getVar('XEN_DEVICETREE_DOM0_SIZE') + if xen_devicetree_dom0_size[:2] == "0x": + size_defined = int(xen_devicetree_dom0_size, 16) + else: + size_defined = int(xen_devicetree_dom0_size) if size_required > size_defined: bb.note ("Wrong kernel size setting inside xen dtb!\n"\
Signature · 1 line
2.17.1
PATCH 3/4 arm-autonomy/xen-devicetree: Check for empty/invalid variable values
In reply to Nathan DunneFrom: Nathan Dunne <[email protected]>
Added check to xen-devicetree to validate values of required variables:XEN_DEVICETREE_DOM0_ADDRXEN_DEVICETREE_DOM0_SIZEXEN_DEVICETREE_DOM0_MEM
Issue-Id: SCM-2037
--- .../documentation/xen-devicetree.md | 10 +++++--- .../xen-devicetree/xen-devicetree.bb | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-)
meta-arm-autonomy/documentation/xen-devicetree.md +7 -3
@@ -70,7 +70,9 @@ The following parameters are available: 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". + This variable is set by default to "1024M", and cannot be empty. + The value can also be of the form "1024M,max:1024M", as documented here: + https://wiki.xenproject.org/wiki/Do%EF%BB%BFm0_Memory_%E2%80%94_Where_It_Has_Not_Gone - XEN_DEVICETREE_DOM0_BOOTARGS: Boot arguments to pass to Dom0 Linux when booting it.
@@ -84,7 +86,8 @@ The following parameters are available: - 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". + This variable is set by default to "0x80080000", and cannot be empty. + Values for this variable can be in hex (prefixed with '0x') or in decimal. - 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
@@ -92,7 +95,8 @@ The following parameters are available: 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". + This variable is set by default to "0x01000000" and cannot be empty. + Values for this variable can be in hex (prefixed with '0x') or in decimal. - 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
meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb +24 -0
@@ -35,6 +35,30 @@ do_configure[noexec] = "1" do_compile[noexec] = "1" do_install[noexec] = "1" +# Validate xen devicetree variables +python __anonymous() { + + # Compare values of a list of variables to a regex pattern + def validate_type(pattern, var_list): + for varname in var_list: + if d.getVar(varname): + if not pattern.match(d.getVar(varname)): + raise bb.parse.SkipRecipe(d.getVar(varname) + "' is not a valid value for " + varname + "!") + else: + raise bb.parse.SkipRecipe('Required variable ' + varname + ' is empty!') + + import re + + num_vars_to_check = ['XEN_DEVICETREE_DOM0_ADDR', 'XEN_DEVICETREE_DOM0_SIZE'] + size_vars_to_check = ['XEN_DEVICETREE_DOM0_MEM'] + + num_pattern = re.compile(r'((0x[0-9a-fA-F]+)|[0-9]+)$') + size_pattern = re.compile(r'[0-9]+[MG](,max:[0-9]+[MG])?$') + + validate_type(num_pattern, num_vars_to_check) + validate_type(size_pattern, size_vars_to_check) +} + do_deploy() { if [ ! -f ${WORKDIR}/xen.dtsi.in ]; then die "xen.dtsi.in does not exist"
Signature · 1 line
2.17.1
PATCH 4/4 arm-autonomy/xen-devictree: Update dom0_mem default inline with best practices
In reply to Nathan DunneFrom: Nathan Dunne <[email protected]>
Updated default value for XEN_DEVICETREE_DOM0_MEM from "1024M" to "1024M,max:1024" to match best practice for dom0_mem command line argument. Documentation also updated to refer to new default value
Issue-Id: SCM-2037
--- meta-arm-autonomy/documentation/xen-devicetree.md | 7 ++++--- .../recipes-extended/xen-devicetree/xen-devicetree.bb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
meta-arm-autonomy/documentation/xen-devicetree.md +4 -3
@@ -70,9 +70,10 @@ The following parameters are available: 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", and cannot be empty. - The value can also be of the form "1024M,max:1024M", as documented here: - https://wiki.xenproject.org/wiki/Do%EF%BB%BFm0_Memory_%E2%80%94_Where_It_Has_Not_Gone + This variable is set by default to "1024M,max:1024", and cannot be empty. + The value can simply specify a size, e.g. "1024M", but best practice is to + also provide a max, documented here: + https://wiki.xenproject.org/wiki/Xen_Project_Best_Practices - XEN_DEVICETREE_DOM0_BOOTARGS: Boot arguments to pass to Dom0 Linux when booting it.
meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb +1 -1
@@ -19,7 +19,7 @@ DESCRIPTION = "Add entries in DTB for Xen and Dom0" XEN_DEVICETREE_DEPEND_append = " 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_MEM ?= "1024M,max:1024M" XEN_DEVICETREE_DOM0_BOOTARGS ?= "console=hvc0 earlycon=xen" XEN_DEVICETREE_DOM0_ADDR ?= "0x80080000" XEN_DEVICETREE_DOM0_SIZE ?= "0x01000000"
Signature · 1 line
2.17.1
Quoted 10 lines · Nathan Dunne
From: Nathan Dunne <[email protected]>
Reduced the level at which messages relating to overriding the user provided value for
XEN_DEVICETREE_DOM0_SIZEwhen it is too small are logged at from 'warn' to 'note'Issue-Id: SCM-2037
Signed-off-by Nathan Dunne <[email protected]>Change-Id I1436dac2c347d40c897291220fe30a95a57f2fa1---
Series applied to the master branch
Thanks,
Jon
Quoted 28 lines
.../recipes-extended/xen-devicetree/xen-devicetree.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb +2
-2@@ -91,11 +91,11 @@ python calc_xen_dtb_dom0_size() { size_defined = int(d.getVar('XEN_DEVICETREE_DOM0_SIZE'), 16) if size_required > size_defined: - bb.warn ("Wrong kernel size setting inside xen dtb!\n"\ + bb.note ("Wrong kernel size setting inside xen dtb!\n"\ "Required:\t%(req)d (%(req)#010X)\n"\ "Requested:\t%(def)d (%(def)#010X)"\ % {"req": size_required, "def": size_defined}) - bb.warn ("Overriding XEN_DEVICETREE_DOM0_SIZE with "\ + bb.note ("Overriding XEN_DEVICETREE_DOM0_SIZE with "\ "%(req)d (%(req)#010X)" % {"req": size_required}) d.setVar('XEN_DEVICETREE_DOM0_SIZE', hex(size_required)) }Signature · 1 line
2.17.1