All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size
@ 2021-01-28 10:06 Nathan Dunne
  2021-01-28 10:06 ` [PATCH 2/4] arm-autonomy/xen-devicetree: Allow hex or decimal Dom0 Size Nathan Dunne
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nathan Dunne @ 2021-01-28 10:06 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Nathan Dunne

From: Nathan Dunne <Nathan.Dunne@arm.com>

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
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
Change-Id: I1436dac2c347d40c897291220fe30a95a57f2fa1
---
 .../recipes-extended/xen-devicetree/xen-devicetree.bb         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
index 0369b96..13afb7a 100644
--- a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
+++ b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
@@ -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))
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] arm-autonomy/xen-devicetree: Allow hex or decimal Dom0 Size
  2021-01-28 10:06 [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Nathan Dunne
@ 2021-01-28 10:06 ` Nathan Dunne
  2021-01-28 10:06 ` [PATCH 3/4] arm-autonomy/xen-devicetree: Check for empty/invalid variable values Nathan Dunne
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nathan Dunne @ 2021-01-28 10:06 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Nathan Dunne

From: Nathan Dunne <Nathan.Dunne@arm.com>

Check whether XEN_DEVICETREE_DOM0_SIZE begins '0x' and cast from hex
or decimal accordingly, rather than assuming hex.

Issue-Id: SCM-2037
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
Change-Id: I3a1c7c7ae6711b3d645cdb66bcd9c2c27196b054
---
 .../recipes-extended/xen-devicetree/xen-devicetree.bb       | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
index 13afb7a..398385a 100644
--- a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
+++ b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
@@ -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"\
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] arm-autonomy/xen-devicetree: Check for empty/invalid variable values
  2021-01-28 10:06 [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Nathan Dunne
  2021-01-28 10:06 ` [PATCH 2/4] arm-autonomy/xen-devicetree: Allow hex or decimal Dom0 Size Nathan Dunne
@ 2021-01-28 10:06 ` Nathan Dunne
  2021-01-28 10:06 ` [PATCH 4/4] arm-autonomy/xen-devictree: Update dom0_mem default inline with best practices Nathan Dunne
  2021-02-03 14:02 ` [meta-arm] [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Jon Mason
  3 siblings, 0 replies; 5+ messages in thread
From: Nathan Dunne @ 2021-01-28 10:06 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Nathan Dunne

From: Nathan Dunne <Nathan.Dunne@arm.com>

Added check to xen-devicetree to validate values of required variables:
XEN_DEVICETREE_DOM0_ADDR
XEN_DEVICETREE_DOM0_SIZE
XEN_DEVICETREE_DOM0_MEM

Issue-Id: SCM-2037
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
Change-Id: I31bfcdb9d064f6e91beb1500d0a18f2a30a42028
---
 .../documentation/xen-devicetree.md           | 10 +++++---
 .../xen-devicetree/xen-devicetree.bb          | 24 +++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/meta-arm-autonomy/documentation/xen-devicetree.md b/meta-arm-autonomy/documentation/xen-devicetree.md
index a44dca7..0d4466a 100644
--- a/meta-arm-autonomy/documentation/xen-devicetree.md
+++ b/meta-arm-autonomy/documentation/xen-devicetree.md
@@ -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
diff --git a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
index 398385a..c6a785f 100644
--- a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
+++ b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
@@ -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"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] arm-autonomy/xen-devictree: Update dom0_mem default inline with best practices
  2021-01-28 10:06 [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Nathan Dunne
  2021-01-28 10:06 ` [PATCH 2/4] arm-autonomy/xen-devicetree: Allow hex or decimal Dom0 Size Nathan Dunne
  2021-01-28 10:06 ` [PATCH 3/4] arm-autonomy/xen-devicetree: Check for empty/invalid variable values Nathan Dunne
@ 2021-01-28 10:06 ` Nathan Dunne
  2021-02-03 14:02 ` [meta-arm] [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Jon Mason
  3 siblings, 0 replies; 5+ messages in thread
From: Nathan Dunne @ 2021-01-28 10:06 UTC (permalink / raw)
  To: meta-arm; +Cc: nd, Nathan Dunne

From: Nathan Dunne <Nathan.Dunne@arm.com>

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
Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
Change-Id: Ifa7e78bf22b024cb7fe4b782f628860ff44860ad
---
 meta-arm-autonomy/documentation/xen-devicetree.md          | 7 ++++---
 .../recipes-extended/xen-devicetree/xen-devicetree.bb      | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/meta-arm-autonomy/documentation/xen-devicetree.md b/meta-arm-autonomy/documentation/xen-devicetree.md
index 0d4466a..0b3f41b 100644
--- a/meta-arm-autonomy/documentation/xen-devicetree.md
+++ b/meta-arm-autonomy/documentation/xen-devicetree.md
@@ -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.
diff --git a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
index c6a785f..29b8023 100644
--- a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
+++ b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
@@ -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"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [meta-arm] [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size
  2021-01-28 10:06 [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Nathan Dunne
                   ` (2 preceding siblings ...)
  2021-01-28 10:06 ` [PATCH 4/4] arm-autonomy/xen-devictree: Update dom0_mem default inline with best practices Nathan Dunne
@ 2021-02-03 14:02 ` Jon Mason
  3 siblings, 0 replies; 5+ messages in thread
From: Jon Mason @ 2021-02-03 14:02 UTC (permalink / raw)
  To: Nathan Dunne; +Cc: meta-arm, nd

On Thu, Jan 28, 2021 at 10:06:37AM +0000, Nathan Dunne wrote:
> From: Nathan Dunne <Nathan.Dunne@arm.com>
> 
> 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
> Signed-off-by: Nathan Dunne <Nathan.Dunne@arm.com>
> Change-Id: I1436dac2c347d40c897291220fe30a95a57f2fa1
> ---

Series applied to the master branch

Thanks,
Jon

>  .../recipes-extended/xen-devicetree/xen-devicetree.bb         | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
> index 0369b96..13afb7a 100644
> --- a/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
> +++ b/meta-arm-autonomy/recipes-extended/xen-devicetree/xen-devicetree.bb
> @@ -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))
>  }
> -- 
> 2.17.1
> 

> 
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-03 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 10:06 [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Nathan Dunne
2021-01-28 10:06 ` [PATCH 2/4] arm-autonomy/xen-devicetree: Allow hex or decimal Dom0 Size Nathan Dunne
2021-01-28 10:06 ` [PATCH 3/4] arm-autonomy/xen-devicetree: Check for empty/invalid variable values Nathan Dunne
2021-01-28 10:06 ` [PATCH 4/4] arm-autonomy/xen-devictree: Update dom0_mem default inline with best practices Nathan Dunne
2021-02-03 14:02 ` [meta-arm] [PATCH 1/4] arm-autonomy/xen-devicetree: Lower log level for incorrect kernel size Jon Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.