[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ImageBuilder][PATCH V2] uboot-script-gen: Add ability to configure static event channels


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Tue, 30 Sep 2025 17:44:24 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=detDOakbFZyYY+f8Axm7fNQyZuXhP3koC2LbQJDRUq8=; b=dNs+K+yWFp7wLxtcnFj15IZj38R/QO/vQ5w6fycZN6OEUolfLmWU8mm0AP8GX/PO9aNfzkvf7j891kL+79/k5jQcen+23juNAD7r1/dRX18CBf7dNki7c4+Xl9UmBYV4gKqjLMTPL0JqiT0//Mr7hf4EwyQXKGJjitzs8MXamS5Z+JZzLolm6aB7EMvg/FST0SeXr/9mGjJg3m7VDCUFJZ5Ni8vO7L4oYEQlTDadoOTV9hDTOyqC5tVJz6/JREgGP9jxkDv9PLlyaY/OXw87nUtzIZSI+I4VjGimEGL5kp3iqeKQcSVivHbnSZoeTmMyiYfsjysBBw9Bg93VheeOxg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EaeKvMcYk+RttFjx6vdlsKRn9ng2n949mWuLDIwYOGh1R300L6DLtl8oOLvCkAKu/AVfpMidiy9RP+putACDt+AQVNBWPfIVtoiwaSSHtnVpkafGuDZTwTyevG2S5Gd+eK9EAcY/ATLBpawYj+9b4SHHlWAlM/8gtPS/ry39eCHPa5c/ErDEFwg0HWgC20gchPzucTqm+YqOK1VYwtmvretdOhnJexXsNkFQ1ajItut6spH5LfyyskeXRCQcXfHyw4ULdvZqAWTl/Pm1+fl+p/XxkutCTX4AJGN5e7Ror3xbU4Jc5crsPCge0hBxdZTfXl/l3FnQ33wxDaYkzklhDQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Ayan Kumar Halder <ayankuma@xxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Delivery-date: Tue, 30 Sep 2025 17:44:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcMjHccr4/QgJ2+kWZ37s9cExJRg==
  • Thread-topic: [ImageBuilder][PATCH V2] uboot-script-gen: Add ability to configure static event channels

Add DOMU_STATIC_EVTCHNS[number]="local_port remote_dom_idx remote_port; ..."
configuration file string option specifying the static event channel
definitions for domain.

For the following example:
DOMU_STATIC_EVTCHNS[0]="10 1 11; 12 1 13"
DOMU_STATIC_EVTCHNS[1]="11 0 10; 13 0 12"

it generates:
fdt mknod /chosen/domU0 evtchn@10
fdt set /chosen/domU0/evtchn@10 phandle <0xfffffffe>
fdt set /chosen/domU0/evtchn@10 compatible "xen,evtchn-v1"
fdt set /chosen/domU0/evtchn@10 xen,evtchn <10 0xfffffffd>
fdt mknod /chosen/domU0 evtchn@12
fdt set /chosen/domU0/evtchn@12 phandle <0xfffffffc>
fdt set /chosen/domU0/evtchn@12 compatible "xen,evtchn-v1"
fdt set /chosen/domU0/evtchn@12 xen,evtchn <12 0xfffffffb>
...
fdt mknod /chosen/domU1 evtchn@11
fdt set /chosen/domU1/evtchn@11 phandle <0xfffffffd>
fdt set /chosen/domU1/evtchn@11 compatible "xen,evtchn-v1"
fdt set /chosen/domU1/evtchn@11 xen,evtchn <11 0xfffffffe>
fdt mknod /chosen/domU1 evtchn@13
fdt set /chosen/domU1/evtchn@13 phandle <0xfffffffb>
fdt set /chosen/domU1/evtchn@13 compatible "xen,evtchn-v1"
fdt set /chosen/domU1/evtchn@13 xen,evtchn <13 0xfffffffc>

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
---
  V2:
   - completely rework based on Stefano-s suggestion at:
     
https://patchew.org/Xen/20250929180746.1881872-1-oleksandr._5Ftyshchenko@xxxxxxxx/
---
---
 README.md                |  21 ++++++++
 scripts/uboot-script-gen |   7 +++
 scripts/xen_dt_domu      | 103 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 131 insertions(+)

diff --git a/README.md b/README.md
index 7b68cf5..2efac97 100644
--- a/README.md
+++ b/README.md
@@ -218,6 +218,27 @@ Where:
       DOMU_VCPU_HARD_AFFINITY[number,1]="3"
 ```
 
+- DOMU_STATIC_EVTCHNS[number]="local_port remote_dom_idx remote_port; ..."
+  if specified, this parameter allows the configuration of static event 
channels
+  for inter-domain communication. Each entry in DOMU_STATIC_EVTCHNS[number]
+  specifies one or more event channels for a particular domain.
+  The configuration format for each event channel definition is a set of
+  three values:
+    - local_port: The numeric port number for the local domain's endpoint.
+      This value must be unique within current domain.
+    - remote_dom_idx: The array index of the remote domain (e.g., if
+      connecting to DomU1, this would be `1`).
+    - remote_port: The numeric port number for the remote domain's endpoint.
+
+  Multiple event channel definitions for a single domain can be provided by
+  separating them with a semicolon (;).
+
+  Below is an example that creates two pairs of bidirectional channels between
+  two domains:
+  NUM_DOMUS=2
+  DOMU_STATIC_EVTCHNS[0]="10 1 11; 12 1 13"
+  DOMU_STATIC_EVTCHNS[1]="11 0 10; 13 0 12"
+
 - DOMU_COLORS[number] specifies the colors (cache coloring) to be used
   for the domain and is in the format startcolor-endcolor
 
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index 4f92610..e319de8 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -428,6 +428,8 @@ function xen_device_tree_editing()
         fi
     fi
 
+    xen_dt_build_evtchns_map
+
     i=0
     while test $i -lt $NUM_DOMUS
     do
@@ -512,6 +514,11 @@ function xen_device_tree_editing()
 
         xen_dt_domu_add_vcpu_nodes "/chosen/domU$i" $i ${DOMU_VCPUS[$i]}
 
+        if test "${DOMU_STATIC_EVTCHNS[$i]}"
+        then
+            xen_dt_domu_add_evtchns "/chosen/domU$i" "$i" 
"${DOMU_STATIC_EVTCHNS[$i]}"
+        fi
+
         add_device_tree_kernel "/chosen/domU$i" "domU${i}_kernel" 
${domU_kernel_addr[$i]} ${domU_kernel_size[$i]} "${DOMU_CMD[$i]}"
         if test "${domU_ramdisk_addr[$i]}"
         then
diff --git a/scripts/xen_dt_domu b/scripts/xen_dt_domu
index 8134896..45891b3 100644
--- a/scripts/xen_dt_domu
+++ b/scripts/xen_dt_domu
@@ -37,3 +37,106 @@ function xen_dt_domu_add_vcpu_nodes()
         fi
     done
 }
+
+declare -A EVTCHN_ENDPOINT_TO_PHANDLE_MAP
+
+function xen_dt_build_evtchns_map()
+{
+    local def
+    local local_dom_idx
+    local local_port remote_dom_idx remote_port
+    local new_phandle
+    local local_key remote_key
+
+    for (( local_dom_idx=0; local_dom_idx<$NUM_DOMUS; local_dom_idx++ ))
+    do
+        local evtchn_str=${DOMU_STATIC_EVTCHNS[$local_dom_idx]}
+        if test -z "$evtchn_str"
+        then
+            continue
+        fi
+
+        IFS=';' read -ra evtchn_defs <<< "$evtchn_str"
+
+        # Loop over each definition and process both endpoints of the 
connection
+        for def in "${evtchn_defs[@]}"
+        do
+            read -r local_port remote_dom_idx remote_port <<< "$def"
+            if test -z "$local_port" || test -z "$remote_dom_idx" || test -z 
"$remote_port"
+            then
+                echo "Malformed evtchn definition: '$def' in 
DOMU_STATIC_EVTCHNS[$local_dom_idx]"
+                cleanup_and_return_err
+            fi
+
+            # Define keys for both endpoints of the connection
+            local_key="$local_dom_idx,$local_port"
+            remote_key="$remote_dom_idx,$remote_port"
+
+            if [[ "$local_key" == "$remote_key" ]]; then
+                echo "Invalid evtchn definition: '$def' in 
DOMU_STATIC_EVTCHNS[$local_dom_idx]"
+                cleanup_and_return_err
+            fi
+
+            # For each key, if it is not already in our map, assign it a new 
phandle
+            if [[ ! -v EVTCHN_ENDPOINT_TO_PHANDLE_MAP[$local_key] ]]
+            then
+                get_next_phandle new_phandle
+                EVTCHN_ENDPOINT_TO_PHANDLE_MAP[$local_key]=$new_phandle
+                echo "Local endpoint '$local_key' is assigned phandle 
'$new_phandle'"
+            fi
+
+            if [[ ! -v EVTCHN_ENDPOINT_TO_PHANDLE_MAP[$remote_key] ]]
+            then
+                get_next_phandle new_phandle
+                EVTCHN_ENDPOINT_TO_PHANDLE_MAP[$remote_key]=$new_phandle
+                echo "Remote endpoint '$remote_key' is assigned phandle 
'$new_phandle'"
+            fi
+        done
+    done
+}
+
+function xen_dt_domu_add_evtchns()
+{
+    # $1 - dt path
+    local path=$1
+    # $2 - index of the current domain
+    local local_dom_idx=$2
+    # $3 - full event channel definition string
+    local evtchn_str=$3
+
+    local def
+    local local_port remote_dom_idx remote_port
+    local local_phandle remote_phandle
+    local local_key remote_key
+
+    IFS=';' read -ra evtchn_defs <<< "$evtchn_str"
+
+    # Loop over each definition and create a node for it
+    for def in "${evtchn_defs[@]}"
+    do
+        read -r local_port remote_dom_idx remote_port <<< "$def"
+        if test -z "$local_port" || test -z "$remote_dom_idx" || test -z 
"$remote_port"
+        then
+            echo "Malformed evtchn definition: '$def' in 
DOMU_STATIC_EVTCHNS[$local_dom_idx]"
+            cleanup_and_return_err
+        fi
+
+        # Re-create the keys for both endpoints of the connection to look up 
the phandles
+        local_key="$local_dom_idx,$local_port"
+        remote_key="$remote_dom_idx,$remote_port"
+
+        local_phandle=${EVTCHN_ENDPOINT_TO_PHANDLE_MAP[$local_key]}
+        remote_phandle=${EVTCHN_ENDPOINT_TO_PHANDLE_MAP[$remote_key]}
+
+        if test -z "$local_phandle" || test -z "$remote_phandle"
+        then
+            echo "Could not find phandle for endpoint '$local_key' or 
'$remote_key'"
+            cleanup_and_return_err
+        fi
+
+        dt_mknode "${path}" "evtchn@$local_port"
+        dt_set "${path}/evtchn@$local_port" "phandle" "hex" "$local_phandle"
+        dt_set "${path}/evtchn@$local_port" "compatible" "str" "xen,evtchn-v1"
+        dt_set "${path}/evtchn@$local_port" "xen,evtchn" "hex" "$local_port 
$remote_phandle"
+    done
+}
-- 
2.34.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.