On Mon, 24 Jun 2024, Michal Orzel wrote:
> Reflect the latest Xen support to be able to omit the host physical
> address for static shared memory regions, in which case the address will
> come from the Xen heap.
>
> Signed-off-by: Michal Orzel
Reviewed-by: Stefano Stabellini
> ---
> README.md| 7 ---
> scripts/uboot-script-gen | 19 +--
> 2 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/README.md b/README.md
> index 7683492a6f7f..4fcd908c2c2f 100644
> --- a/README.md
> +++ b/README.md
> @@ -199,9 +199,10 @@ Where:
>
> - DOMU_SHARED_MEM[number]="SHM-ID HPA GPA size"
>if specified, indicate SHM-ID represents the unique identifier of the
> shared
> - memory region, the host physical address HPA will get mapped at guest
> - address GPA in domU and the memory of size will be reserved to be shared
> - memory. The shared memory is used between two dom0less domUs.
> + memory region. The host physical address HPA is optional, if specified,
> will
> + get mapped at guest address GPA in domU (otherwise it will come from Xen
> heap)
> + and the memory of size will be reserved to be shared memory. The shared
> memory
> + is used between two dom0less domUs.
>
>Below is an example:
>NUM_DOMUS=2
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index 20cc6ef7f892..8b664e711b10 100755
> --- a/scripts/uboot-script-gen
> +++ b/scripts/uboot-script-gen
> @@ -211,18 +211,25 @@ function add_device_tree_static_shared_mem()
> local shared_mem_id=${shared_mem%% *}
> local regions="${shared_mem#* }"
> local cells=()
> -local shared_mem_host=${regions%% *}
> -
> -dt_mknode "${path}" "shared-mem@${shared_mem_host}"
> +local node_name=
>
> for val in ${regions[@]}
> do
> cells+=("$(split_value $val)")
> done
>
> -dt_set "${path}/shared-mem@${shared_mem_host}" "compatible" "str"
> "xen,domain-shared-memory-v1"
> -dt_set "${path}/shared-mem@${shared_mem_host}" "xen,shm-id" "str"
> "${shared_mem_id}"
> -dt_set "${path}/shared-mem@${shared_mem_host}" "xen,shared-mem" "hex"
> "${cells[*]}"
> +# Less than 3 cells means host address not provided
> +if [ ${#cells[@]} -lt 3 ]; then
> +node_name="shared-mem-${shared_mem_id}"
> +else
> +node_name="shared-mem@${regions%% *}"
> +fi
> +
> +dt_mknode "${path}" "${node_name}"
> +
> +dt_set "${path}/${node_name}" "compatible" "str"
> "xen,domain-shared-memory-v1"
> +dt_set "${path}/${node_name}" "xen,shm-id" "str" "${shared_mem_id}"
> +dt_set "${path}/${node_name}" "xen,shared-mem" "hex" "${cells[*]}"
> }
>
> function add_device_tree_cpupools()
> --
> 2.25.1
>