|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [ImageBuilder][PATCH v3 2/2] uboot-script-gen: add support for static shared memory
On Mon, 20 Mar 2023, jiamei.xie wrote:
> Introduce support for creating shared-mem node for dom0less domUs in
> the device tree. Add the following option:
> - DOMU_SHARED_MEM[number]="SHM-ID HPA GPA size"
> if specified, indicate the unique identifier of the shared memory
> region is SHM-ID, 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 static shared memory is used between two dom0less domUs.
>
> Below is an example:
> NUM_DOMUS=2
> DOMU_SHARED_MEM[0]="my-shared-mem-0 0x50000000 0x6000000 0x10000000"
> DOMU_SHARED_MEM[1]="my-shared-mem-0 0x50000000 0x6000000 0x10000000"
>
> This static shared memory region is identified as "my-shared-mem-0",
> host physical address starting at 0x50000000 of 256MB will be reserved
> to be shared between two domUs. It will get mapped at 0x6000000 in both
> guest physical address space. Both DomUs are the borrower domain, the
> owner domain is the default owner domain DOMID_IO.
>
> Signed-off-by: jiamei.xie <jiamei.xie@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> ---
> Changes from v2:
> - Remove "domid" parameter
> - Use lower capital letters for local variables
> Changes from v1:
> - Rather than two separate properties and just use one like follows:
> Change
> DOMU_SHARED_MEM[0]="0x50000000 0x6000000 0x10000000"
> DOMU_SHARED_MEM_ID[0]="my-shared-mem-0"
> to
> DOMU_SHARED_MEM[0]="my-shared-mem-0 0x50000000 0x6000000 0x10000000"
> - Use split_value function instead of opencoding it.
> ---
> README.md | 17 +++++++++++++++++
> scripts/uboot-script-gen | 26 ++++++++++++++++++++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/README.md b/README.md
> index 78b83f1..fe5d205 100644
> --- a/README.md
> +++ b/README.md
> @@ -196,6 +196,23 @@ Where:
> if specified, indicates the host physical address regions
> [baseaddr, baseaddr + size) to be reserved to the VM for static allocation.
>
> +- 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.
> +
> + Below is an example:
> + NUM_DOMUS=2
> + DOMU_SHARED_MEM[0]="my-shared-mem-0 0x50000000 0x6000000 0x10000000"
> + DOMU_SHARED_MEM[1]="my-shared-mem-0 0x50000000 0x6000000 0x10000000"
> +
> + This static shared memory region is identified as "my-shared-mem-0", host
> + physical address starting at 0x50000000 of 256MB will be reserved to be
> + shared between two domUs. It will get mapped at 0x6000000 in both guest
> + physical address space. Both DomUs are the borrower domain, the owner
> + domain is the default owner domain DOMID_IO.
> +
> - DOMU_DIRECT_MAP[number] can be set to 1 or 0.
> If set to 1, the VM is direct mapped. The default is 1.
> This is only applicable when DOMU_STATIC_MEM is specified.
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index cca3e59..9656a45 100755
> --- a/scripts/uboot-script-gen
> +++ b/scripts/uboot-script-gen
> @@ -204,6 +204,27 @@ function add_device_tree_xen_static_heap()
> dt_set "$path" "xen,static-heap" "hex" "${cells[*]}"
> }
>
> +function add_device_tree_static_shared_mem()
> +{
> + local path=$1
> + local shared_mem=$2
> + 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}"
> +
> + 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[*]}"
> +}
> +
> function add_device_tree_cpupools()
> {
> local cpu
> @@ -329,6 +350,11 @@ function xen_device_tree_editing()
> dt_set "/chosen/domU$i" "xen,enhanced" "str" "enabled"
> fi
>
> + if test -n "${DOMU_SHARED_MEM[i]}"
> + then
> + add_device_tree_static_shared_mem "/chosen/domU${i}"
> "${DOMU_SHARED_MEM[i]}"
> + fi
> +
> if test "${DOMU_COLORS[$i]}"
> then
> local startcolor=$(echo "${DOMU_COLORS[$i]}" | cut -d "-" -f 1)
> --
> 2.25.1
>
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |