[ImageBuilder][PATCH] Fix Xen boot-time cpupools handling

Michal Orzel posted 1 patch 3 months ago
Failed in applying to current master (apply log)
scripts/uboot-script-gen | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[ImageBuilder][PATCH] Fix Xen boot-time cpupools handling
Posted by Michal Orzel 3 months ago
When retrieving a phandle for a CPU node using "fdtget -t x", the
resulting hex number (in case the phandle exists) lacks the '0x' prefix.
This value is subsequently used to construct the cpupool-cpus property.
This results in an incorrect property generation that leads to Xen
failure (example: cpupool-cpus < a> instead of < 0xa>). Address the
issue by adding 0x prefix to the result from fdtget.

Additionally, avoid unnecessary regeneration of the phandle if it already
exists.

Fixes: b687773b5046 ("Add support for Xen boot-time cpupools")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
This only worked if phandle did not exist or if its value did not contain a-f
and was regenerated anyway.
---
 scripts/uboot-script-gen | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index 078a667c61ab..3cc6b47c7c62 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -262,12 +262,12 @@ function add_device_tree_cpupools()
             fi
 
             # set phandle for a cpu if there is none
-            if ! phandle=$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)
+            if ! phandle="0x$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)"
             then
                 get_next_phandle phandle
+                dt_set "$cpu" "phandle" "hex" "$phandle"
             fi
 
-            dt_set "$cpu" "phandle" "hex" "$phandle"
             cpu_phandles="$cpu_phandles $phandle"
             cpu_list="$cpu_list $cpu"
         done
-- 
2.25.1
Re: [ImageBuilder][PATCH] Fix Xen boot-time cpupools handling
Posted by Stefano Stabellini 3 months ago
On Fri, 25 Jan 2024, Michal Orzel wrote:
> When retrieving a phandle for a CPU node using "fdtget -t x", the
> resulting hex number (in case the phandle exists) lacks the '0x' prefix.
> This value is subsequently used to construct the cpupool-cpus property.
> This results in an incorrect property generation that leads to Xen
> failure (example: cpupool-cpus < a> instead of < 0xa>). Address the
> issue by adding 0x prefix to the result from fdtget.
> 
> Additionally, avoid unnecessary regeneration of the phandle if it already
> exists.
> 
> Fixes: b687773b5046 ("Add support for Xen boot-time cpupools")
> Signed-off-by: Michal Orzel <michal.orzel@amd.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> This only worked if phandle did not exist or if its value did not contain a-f
> and was regenerated anyway.
> ---
>  scripts/uboot-script-gen | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index 078a667c61ab..3cc6b47c7c62 100755
> --- a/scripts/uboot-script-gen
> +++ b/scripts/uboot-script-gen
> @@ -262,12 +262,12 @@ function add_device_tree_cpupools()
>              fi
>  
>              # set phandle for a cpu if there is none
> -            if ! phandle=$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)
> +            if ! phandle="0x$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)"
>              then
>                  get_next_phandle phandle
> +                dt_set "$cpu" "phandle" "hex" "$phandle"
>              fi
>  
> -            dt_set "$cpu" "phandle" "hex" "$phandle"
>              cpu_phandles="$cpu_phandles $phandle"
>              cpu_list="$cpu_list $cpu"
>          done
> -- 
> 2.25.1
>