From nobody Wed May 15 06:28:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677732422153498.36225976859043; Wed, 1 Mar 2023 20:47:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.504323.776967 (Exim 4.92) (envelope-from ) id 1pXapz-00064U-FM; Thu, 02 Mar 2023 04:46:39 +0000 Received: by outflank-mailman (output) from mailman id 504323.776967; Thu, 02 Mar 2023 04:46:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXapz-00064N-CU; Thu, 02 Mar 2023 04:46:39 +0000 Received: by outflank-mailman (input) for mailman id 504323; Thu, 02 Mar 2023 04:46:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXapx-0004UF-VL for xen-devel@lists.xenproject.org; Thu, 02 Mar 2023 04:46:37 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 372bf543-b8b5-11ed-96a9-2f268f93b82a; Thu, 02 Mar 2023 05:46:37 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 17E131FB; Wed, 1 Mar 2023 20:47:20 -0800 (PST) Received: from comhpcalt.shanghai.arm.com (comhpcalt.shanghai.arm.com [10.169.190.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3BC4C3F99C; Wed, 1 Mar 2023 20:46:34 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 372bf543-b8b5-11ed-96a9-2f268f93b82a From: "jiamei.xie" To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, jiamei.xie@arm.com, sstabellini@kernel.org Subject: [ImageBuilder][PATCH 1/2] uboot-script-gen: Add support for static heap Date: Thu, 2 Mar 2023 04:46:05 +0000 Message-Id: <20230302044606.136130-2-jiamei.xie@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302044606.136130-1-jiamei.xie@arm.com> References: <20230302044606.136130-1-jiamei.xie@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1677732424007100001 Content-Type: text/plain; charset="utf-8" From: jiamei Xie Add a new config parameter to configure static heap. STATIC_HEAP=3D"baseaddr1 size1 ... baseaddrN sizeN" if specified, indicates the host physical address regions [baseaddr, baseaddr + size) to be reserved as static heap. For instance, STATIC_HEAP=3D"0x50000000 0x30000000", if specified, indicates the host memory region starting from paddr 0x50000000 with a size of 0x30000000 to be reserved as static heap. Signed-off-by: jiamei Xie --- README.md | 4 ++++ scripts/uboot-script-gen | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index 814a004..787f413 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,10 @@ Where: =20 - NUM_CPUPOOLS specifies the number of boot-time cpupools to create. =20 +- STATIC_HEAP=3D"baseaddr1 size1 ... baseaddrN sizeN" + if specified, indicates the host physical address regions + [baseaddr, baseaddr + size) to be reserved as static heap. + Then you can invoke uboot-script-gen as follows: =20 ``` diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index f07e334..4775293 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -189,6 +189,21 @@ function add_device_tree_static_mem() dt_set "$path" "xen,static-mem" "hex" "${cells[*]}" } =20 +function add_device_tree_static_heap() +{ + local path=3D$1 + local regions=3D$2 + local cells=3D() + local val + + for val in ${regions[@]} + do + cells+=3D("$(printf "0x%x 0x%x" $(($val >> 32)) $(($val & ((1 << 3= 2) - 1))))") + done + + dt_set "$path" "xen,static-heap" "hex" "${cells[*]}" +} + function add_device_tree_cpupools() { local cpu @@ -344,6 +359,11 @@ function xen_device_tree_editing() then add_device_tree_cpupools fi + + if test "${STATIC_HEAP}" + then + add_device_tree_static_heap "/chosen" "${STATIC_HEAP}" + fi } =20 function linux_device_tree_editing() --=20 2.25.1 From nobody Wed May 15 06:28:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677732444067815.1542591403042; Wed, 1 Mar 2023 20:47:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.504331.776977 (Exim 4.92) (envelope-from ) id 1pXaqO-0006n0-V6; Thu, 02 Mar 2023 04:47:04 +0000 Received: by outflank-mailman (output) from mailman id 504331.776977; Thu, 02 Mar 2023 04:47:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXaqO-0006mt-Qh; Thu, 02 Mar 2023 04:47:04 +0000 Received: by outflank-mailman (input) for mailman id 504331; Thu, 02 Mar 2023 04:47:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXaqN-0006L7-TG for xen-devel@lists.xenproject.org; Thu, 02 Mar 2023 04:47:04 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 45ab1e52-b8b5-11ed-a550-8520e6686977; Thu, 02 Mar 2023 05:47:01 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7A4E31FB; Wed, 1 Mar 2023 20:47:44 -0800 (PST) Received: from comhpcalt.shanghai.arm.com (comhpcalt.shanghai.arm.com [10.169.190.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9D2303F99C; Wed, 1 Mar 2023 20:46:59 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 45ab1e52-b8b5-11ed-a550-8520e6686977 From: "jiamei.xie" To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, jiamei.xie@arm.com, sstabellini@kernel.org Subject: [ImageBuilder][PATCH 2/2] uboot-script-gen: Add support for static shared memory Date: Thu, 2 Mar 2023 04:46:06 +0000 Message-Id: <20230302044606.136130-3-jiamei.xie@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302044606.136130-1-jiamei.xie@arm.com> References: <20230302044606.136130-1-jiamei.xie@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1677732446222100001 Content-Type: text/plain; charset="utf-8" Introduce support for creating shared-mem node for dom0less domUs in the device tree. Add the following options: - DOMU_SHARED_MEM[number]=3D"HPA GPA size" if specified, indicates 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. - DOMU_SHARED_MEM_ID[number] An arbitrary string that represents the unique identifier of the shared memory region, with a strict limit on the number of characters(\0 included) The static shared memory is used between two dom0less domUs. Below is an example: NUM_DOMUS=3D2 DOMU_SHARED_MEM[0]=3D"0x50000000 0x6000000 0x10000000" DOMU_SHARED_MEM_ID[0]=3D"my-shared-mem-0" DOMU_SHARED_MEM[1]=3D"0x50000000 0x6000000 0x10000000" DOMU_SHARED_MEM_ID[1]=3D"my-shared-mem-0" 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 --- README.md | 18 ++++++++++++++++++ scripts/uboot-script-gen | 26 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/README.md b/README.md index 787f413..48044ee 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,24 @@ Where: if specified, indicates the host physical address regions [baseaddr, baseaddr + size) to be reserved to the VM for static allocati= on. =20 +- DOMU_SHARED_MEM[number]=3D"HPA GPA size" and DOMU_SHARED_MEM_ID[number] + if specified, indicate 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=3D2 + DOMU_SHARED_MEM[0]=3D"0x50000000 0x6000000 0x10000000" + DOMU_SHARED_MEM_ID[0]=3D"my-shared-mem-0" + DOMU_SHARED_MEM[1]=3D"0x50000000 0x6000000 0x10000000" + DOMU_SHARED_MEM_ID[1]=3D"my-shared-mem-0" + + 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 4775293..46215c8 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -204,6 +204,27 @@ function add_device_tree_static_heap() dt_set "$path" "xen,static-heap" "hex" "${cells[*]}" } =20 +function add_device_tree_static_shared_mem() +{ + local path=3D$1 + local domid=3D$2 + local regions=3D$3 + local SHARED_MEM_ID=3D$4 + local cells=3D() + local SHARED_MEM_HOST=3D${regions%% *} + + dt_mknode "${path}" "domU${domid}-shared-mem@${SHARED_MEM_HOST}" + + for val in ${regions[@]} + do + cells+=3D("$(printf "0x%x 0x%x" $(($val >> 32)) $(($val & ((1 << 3= 2) - 1))))") + done + + dt_set "${path}/domU${domid}-shared-mem@${SHARED_MEM_HOST}" "compatibl= e" "str" "xen,domain-shared-memory-v1" + dt_set "${path}/domU${domid}-shared-mem@${SHARED_MEM_HOST}" "xen,shm-i= d" "str" "${SHARED_MEM_ID}" + dt_set "${path}/domU${domid}-shared-mem@${SHARED_MEM_HOST}" "xen,share= d-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 =20 + if test -n "${DOMU_SHARED_MEM[i]}" -a -n "${DOMU_SHARED_MEM_ID[i]}" + then + add_device_tree_static_shared_mem "/chosen/domU${i}" "${i}= " "${DOMU_SHARED_MEM[i]}" "${DOMU_SHARED_MEM_ID[i]}" + fi + if test "${DOMU_COLORS[$i]}" then local startcolor=3D$(echo "${DOMU_COLORS[$i]}" | cut -d "-" -= f 1) --=20 2.25.1