[IMAGEBUILDER PATCH] Add domain capabilities

Jason Andryuk posted 23 patches 3 days ago
[IMAGEBUILDER PATCH] Add domain capabilities
Posted by Jason Andryuk 3 days ago
Add domain capabilities to creating disaggregated systems.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 README.md                | 16 ++++++++++++++
 scripts/uboot-script-gen | 47 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/README.md b/README.md
index ae2fdfd..25c9b6e 100644
--- a/README.md
+++ b/README.md
@@ -250,6 +250,22 @@ Where:
   Set driver_domain in xl config file. This option is only available for
   the disk_image script.
 
+- DOMU_CAPS[number] = "string" or "hex" (optional)
+  A "|"-concatentated string of capabilities:
+    - control
+    - hardware
+    - xenstore
+    - dom0 (All of the above)
+    - none
+
+  e.g. "control|hardware"
+
+  Or a numeric bitwise flags to specify domain capabilities:
+  0: None
+  1: Control
+  2: Hardware
+  4: Xenstore
+
 - LINUX is optional but specifies the Linux kernel for when Xen is NOT
   used.  To enable this set any LINUX\_\* variables and do NOT set the
   XEN variable.
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index db2c011..397d73b 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -309,6 +309,43 @@ function add_device_tree_cpupools()
     done
 }
 
+function parse_domain_caps()
+{
+    local caps_str="$1"
+    local caps=0
+
+    for x in $( echo $caps_str | sed 's/|/ /g' | tr '[:upper:]' '[:lower:]' )
+    do
+        case "$x" in
+        none)
+            caps=$(( caps | 0 ))
+            ;;
+        control)
+            caps=$(( caps | 0x1 ))
+            ;;
+        hardware)
+            caps=$(( caps | 0x2 ))
+            ;;
+        xenstore)
+            caps=$(( caps | 0x4 ))
+            ;;
+        dom0|domain0)
+            caps=$(( caps | 0x7 ))
+            ;;
+        [0-9]*|0x[0-9a-fA-f]*)
+            caps=$(( caps | $x ))
+            ;;
+        *)
+            return 1
+            ;;
+        esac
+    done
+
+    echo "$caps"
+
+    return 0
+}
+
 function xen_device_tree_editing()
 {
     dt_set "/chosen" "#address-cells" "hex" "0x2"
@@ -386,6 +423,16 @@ function xen_device_tree_editing()
         then
             dt_set "/chosen/domU$i" "max_maptrack_frames" "int" "${DOMU_MAPTRACK_FRAMES[i]}"
         fi
+        if test -n "${DOMU_CAPS[i]}"
+        then
+            local caps
+
+            if ! caps=$( parse_domain_caps ${DOMU_CAPS[i]} ) ; then
+                echo "Invalid DOMU_CAPS[$i] \"${DOMU_CAPS[i]}\""
+                cleanup_and_return_err
+            fi
+            dt_set "/chosen/domU$i" "capabilities" "int" "$caps"
+        fi
 
         if test -n "${DOMU_SHARED_MEM[i]}"
         then
-- 
2.48.1
Re: [IMAGEBUILDER PATCH] Add domain capabilities
Posted by Stefano Stabellini 2 days, 22 hours ago
On Thu, 6 Mar 2025, Jason Andryuk wrote:
> Add domain capabilities to creating disaggregated systems.
> 
> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>

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


> ---
>  README.md                | 16 ++++++++++++++
>  scripts/uboot-script-gen | 47 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 63 insertions(+)
> 
> diff --git a/README.md b/README.md
> index ae2fdfd..25c9b6e 100644
> --- a/README.md
> +++ b/README.md
> @@ -250,6 +250,22 @@ Where:
>    Set driver_domain in xl config file. This option is only available for
>    the disk_image script.
>  
> +- DOMU_CAPS[number] = "string" or "hex" (optional)
> +  A "|"-concatentated string of capabilities:
> +    - control
> +    - hardware
> +    - xenstore
> +    - dom0 (All of the above)
> +    - none
> +
> +  e.g. "control|hardware"
> +
> +  Or a numeric bitwise flags to specify domain capabilities:
> +  0: None
> +  1: Control
> +  2: Hardware
> +  4: Xenstore
> +
>  - LINUX is optional but specifies the Linux kernel for when Xen is NOT
>    used.  To enable this set any LINUX\_\* variables and do NOT set the
>    XEN variable.
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index db2c011..397d73b 100755
> --- a/scripts/uboot-script-gen
> +++ b/scripts/uboot-script-gen
> @@ -309,6 +309,43 @@ function add_device_tree_cpupools()
>      done
>  }
>  
> +function parse_domain_caps()
> +{
> +    local caps_str="$1"
> +    local caps=0
> +
> +    for x in $( echo $caps_str | sed 's/|/ /g' | tr '[:upper:]' '[:lower:]' )
> +    do
> +        case "$x" in
> +        none)
> +            caps=$(( caps | 0 ))
> +            ;;
> +        control)
> +            caps=$(( caps | 0x1 ))
> +            ;;
> +        hardware)
> +            caps=$(( caps | 0x2 ))
> +            ;;
> +        xenstore)
> +            caps=$(( caps | 0x4 ))
> +            ;;
> +        dom0|domain0)
> +            caps=$(( caps | 0x7 ))
> +            ;;
> +        [0-9]*|0x[0-9a-fA-f]*)
> +            caps=$(( caps | $x ))
> +            ;;
> +        *)
> +            return 1
> +            ;;
> +        esac
> +    done
> +
> +    echo "$caps"
> +
> +    return 0
> +}
> +
>  function xen_device_tree_editing()
>  {
>      dt_set "/chosen" "#address-cells" "hex" "0x2"
> @@ -386,6 +423,16 @@ function xen_device_tree_editing()
>          then
>              dt_set "/chosen/domU$i" "max_maptrack_frames" "int" "${DOMU_MAPTRACK_FRAMES[i]}"
>          fi
> +        if test -n "${DOMU_CAPS[i]}"
> +        then
> +            local caps
> +
> +            if ! caps=$( parse_domain_caps ${DOMU_CAPS[i]} ) ; then
> +                echo "Invalid DOMU_CAPS[$i] \"${DOMU_CAPS[i]}\""
> +                cleanup_and_return_err
> +            fi
> +            dt_set "/chosen/domU$i" "capabilities" "int" "$caps"
> +        fi
>  
>          if test -n "${DOMU_SHARED_MEM[i]}"
>          then
> -- 
> 2.48.1
>