[PATCH v2 1/2] misc: refine the allocate logic of offline tool


chenli.wei
 

On 9/30/2022 9:40 AM, Junjie Mao wrote:
-----Original Message-----
From: Chenli Wei <chenli.wei@...>
Sent: Friday, September 30, 2022 12:16 AM
To: Sun, Victor <victor.sun@...>; Mao, Junjie <junjie.mao@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [PATCH v2 1/2] misc: refine the allocate logic of offline tool

From: Chenli Wei <chenli.wei@...>

The current code use VM number to calculate HV_RAM_SIZE, this is not
match the HV logic.

This patch use the max number of trusty VMs to calculate the size of
sworld memory and assume 4M ram / VM to calculate the final ACRN ram
size.

v1-->v2:
1 enable acrn:view, user could config secure world support from ACRN
Configurator now.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@...>
---
misc/config_tools/library/common.py | 3 ++-
misc/config_tools/schema/config.xsd | 2 +-
misc/config_tools/static_allocators/hv_ram.py | 8 +++-----
misc/config_tools/xforms/vm_configurations.h.xsl | 1 +
4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/misc/config_tools/library/common.py b/misc/config_tools/library/common.py
index 9c9d9c62e..db414e56c 100644
--- a/misc/config_tools/library/common.py
+++ b/misc/config_tools/library/common.py
@@ -45,7 +45,8 @@ MAX_VM_NUM = 16
MAX_VUART_NUM = 8

HV_BASE_RAM_SIZE = 0x1400000
-VM_RAM_SIZE = 0x2800000
+VM_RAM_SIZE = 0x400000
+TRUSTY_RAM_SIZE = 0x1000000

class MultiItem():

diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 65226e7af..944294037 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -405,7 +405,7 @@ These settings can only be changed at build time.</xs:documentation>
</xs:simpleType>
</xs:element>
<xs:element name="secure_world_support" type="Boolean" default="n" minOccurs="0">
You can remove the "minOccurs='0'" here to reduce complexity.
OK

- <xs:annotation acrn:views="">
+ <xs:annotation acrn:title="Specify secure world support for trusty OS"
It is not a good idea to use the same title and tooltip.

For the title you can use "Enable secure world for running Trusty".
Done

acrn:views="advanced" acrn:applicable-vms="post-launched">
<xs:documentation>Specify secure world support for trusty OS.</xs:documentation>
The tooltip needs a refresh as well, e.g. "Enable secure world for this VM to provide an isolated execution environment which is suitable for running Trusted Execution Environment (TEE) such as Trusty. This is typically enabled when the VM is designed to run Android OS, and disabled otherwise.".
Done
---
Best Regards
Junjie Mao

</xs:annotation>
</xs:element>
diff --git a/misc/config_tools/static_allocators/hv_ram.py
b/misc/config_tools/static_allocators/hv_ram.py
index eed41e472..e35c07bc8 100644
--- a/misc/config_tools/static_allocators/hv_ram.py
+++ b/misc/config_tools/static_allocators/hv_ram.py
@@ -17,11 +17,9 @@ def fn(board_etree, scenario_etree, allocation_etree):
# this dictonary mapped with 'address start':'mem range'
ram_range = {}

- vm_num = 0
- vm_list = scenario_etree.xpath("//vm")
- if vm_list is not None:
- vm_num = len(vm_list)
- hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * vm_num
+ max_vm_num = int(common.get_node(f"//hv/CAPACITIES/MAX_VM_NUM/text()",
scenario_etree))
+ max_trusty_vm = len(scenario_etree.xpath(f"//vm[./secure_world_support/text() =
'y']"))
+ hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * max_vm_num +
max_trusty_vm * common.TRUSTY_RAM_SIZE
ivshmem_list = scenario_etree.xpath("//IVSHMEM_SIZE/text()")
total_shm_size = 0
for ram_size in ivshmem_list:
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl
b/misc/config_tools/xforms/vm_configurations.h.xsl
index 98973187a..43bc18ca9 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -57,6 +57,7 @@
<xsl:value-of select="acrn:define('PRE_VM_NUM', count(vm[acrn:is-pre-launched-
vm(load_order)]), 'U')" />
<xsl:value-of select="acrn:define('SERVICE_VM_NUM', count(vm[acrn:is-service-
vm(load_order)]), 'U')" />
<xsl:value-of select="acrn:define('MAX_POST_VM_NUM', hv/CAPACITIES/MAX_VM_NUM -
count(vm[acrn:is-pre-launched-vm(load_order)]) - count(vm[acrn:is-service-
vm(load_order)]) , 'U')" />
+ <xsl:value-of select="acrn:define('MAX_TRUSTY_VM_NUM',
count(vm[./secure_world_support/text() = 'y']) , 'U')" />
<xsl:value-of select="acrn:define('CONFIG_MAX_VM_NUM', hv/CAPACITIES/MAX_VM_NUM ,
'U')" />
</xsl:template>

--
2.25.1



Junjie Mao
 

-----Original Message-----
From: Chenli Wei <chenli.wei@...>
Sent: Friday, September 30, 2022 12:16 AM
To: Sun, Victor <victor.sun@...>; Mao, Junjie <junjie.mao@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [PATCH v2 1/2] misc: refine the allocate logic of offline tool

From: Chenli Wei <chenli.wei@...>

The current code use VM number to calculate HV_RAM_SIZE, this is not
match the HV logic.

This patch use the max number of trusty VMs to calculate the size of
sworld memory and assume 4M ram / VM to calculate the final ACRN ram
size.

v1-->v2:
1 enable acrn:view, user could config secure world support from ACRN
Configurator now.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@...>
---
misc/config_tools/library/common.py | 3 ++-
misc/config_tools/schema/config.xsd | 2 +-
misc/config_tools/static_allocators/hv_ram.py | 8 +++-----
misc/config_tools/xforms/vm_configurations.h.xsl | 1 +
4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/misc/config_tools/library/common.py b/misc/config_tools/library/common.py
index 9c9d9c62e..db414e56c 100644
--- a/misc/config_tools/library/common.py
+++ b/misc/config_tools/library/common.py
@@ -45,7 +45,8 @@ MAX_VM_NUM = 16
MAX_VUART_NUM = 8

HV_BASE_RAM_SIZE = 0x1400000
-VM_RAM_SIZE = 0x2800000
+VM_RAM_SIZE = 0x400000
+TRUSTY_RAM_SIZE = 0x1000000

class MultiItem():

diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 65226e7af..944294037 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -405,7 +405,7 @@ These settings can only be changed at build time.</xs:documentation>
</xs:simpleType>
</xs:element>
<xs:element name="secure_world_support" type="Boolean" default="n" minOccurs="0">
You can remove the "minOccurs='0'" here to reduce complexity.

- <xs:annotation acrn:views="">
+ <xs:annotation acrn:title="Specify secure world support for trusty OS"
It is not a good idea to use the same title and tooltip.

For the title you can use "Enable secure world for running Trusty".

acrn:views="advanced" acrn:applicable-vms="post-launched">
<xs:documentation>Specify secure world support for trusty OS.</xs:documentation>
The tooltip needs a refresh as well, e.g. "Enable secure world for this VM to provide an isolated execution environment which is suitable for running Trusted Execution Environment (TEE) such as Trusty. This is typically enabled when the VM is designed to run Android OS, and disabled otherwise.".

---
Best Regards
Junjie Mao

</xs:annotation>
</xs:element>
diff --git a/misc/config_tools/static_allocators/hv_ram.py
b/misc/config_tools/static_allocators/hv_ram.py
index eed41e472..e35c07bc8 100644
--- a/misc/config_tools/static_allocators/hv_ram.py
+++ b/misc/config_tools/static_allocators/hv_ram.py
@@ -17,11 +17,9 @@ def fn(board_etree, scenario_etree, allocation_etree):
# this dictonary mapped with 'address start':'mem range'
ram_range = {}

- vm_num = 0
- vm_list = scenario_etree.xpath("//vm")
- if vm_list is not None:
- vm_num = len(vm_list)
- hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * vm_num
+ max_vm_num = int(common.get_node(f"//hv/CAPACITIES/MAX_VM_NUM/text()",
scenario_etree))
+ max_trusty_vm = len(scenario_etree.xpath(f"//vm[./secure_world_support/text() =
'y']"))
+ hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * max_vm_num +
max_trusty_vm * common.TRUSTY_RAM_SIZE
ivshmem_list = scenario_etree.xpath("//IVSHMEM_SIZE/text()")
total_shm_size = 0
for ram_size in ivshmem_list:
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl
b/misc/config_tools/xforms/vm_configurations.h.xsl
index 98973187a..43bc18ca9 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -57,6 +57,7 @@
<xsl:value-of select="acrn:define('PRE_VM_NUM', count(vm[acrn:is-pre-launched-
vm(load_order)]), 'U')" />
<xsl:value-of select="acrn:define('SERVICE_VM_NUM', count(vm[acrn:is-service-
vm(load_order)]), 'U')" />
<xsl:value-of select="acrn:define('MAX_POST_VM_NUM', hv/CAPACITIES/MAX_VM_NUM -
count(vm[acrn:is-pre-launched-vm(load_order)]) - count(vm[acrn:is-service-
vm(load_order)]) , 'U')" />
+ <xsl:value-of select="acrn:define('MAX_TRUSTY_VM_NUM',
count(vm[./secure_world_support/text() = 'y']) , 'U')" />
<xsl:value-of select="acrn:define('CONFIG_MAX_VM_NUM', hv/CAPACITIES/MAX_VM_NUM ,
'U')" />
</xsl:template>

--
2.25.1


chenli.wei
 

From: Chenli Wei <chenli.wei@...>

The current code use VM number to calculate HV_RAM_SIZE, this is not
match the HV logic.

This patch use the max number of trusty VMs to calculate the size of
sworld memory and assume 4M ram / VM to calculate the final ACRN ram
size.

v1-->v2:
1 enable acrn:view, user could config secure world support from ACRN
Configurator now.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@...>
---
misc/config_tools/library/common.py | 3 ++-
misc/config_tools/schema/config.xsd | 2 +-
misc/config_tools/static_allocators/hv_ram.py | 8 +++-----
misc/config_tools/xforms/vm_configurations.h.xsl | 1 +
4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/misc/config_tools/library/common.py b/misc/config_tools/library/common.py
index 9c9d9c62e..db414e56c 100644
--- a/misc/config_tools/library/common.py
+++ b/misc/config_tools/library/common.py
@@ -45,7 +45,8 @@ MAX_VM_NUM = 16
MAX_VUART_NUM = 8

HV_BASE_RAM_SIZE = 0x1400000
-VM_RAM_SIZE = 0x2800000
+VM_RAM_SIZE = 0x400000
+TRUSTY_RAM_SIZE = 0x1000000

class MultiItem():

diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 65226e7af..944294037 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -405,7 +405,7 @@ These settings can only be changed at build time.</xs:documentation>
</xs:simpleType>
</xs:element>
<xs:element name="secure_world_support" type="Boolean" default="n" minOccurs="0">
- <xs:annotation acrn:views="">
+ <xs:annotation acrn:title="Specify secure world support for trusty OS" acrn:views="advanced" acrn:applicable-vms="post-launched">
<xs:documentation>Specify secure world support for trusty OS.</xs:documentation>
</xs:annotation>
</xs:element>
diff --git a/misc/config_tools/static_allocators/hv_ram.py b/misc/config_tools/static_allocators/hv_ram.py
index eed41e472..e35c07bc8 100644
--- a/misc/config_tools/static_allocators/hv_ram.py
+++ b/misc/config_tools/static_allocators/hv_ram.py
@@ -17,11 +17,9 @@ def fn(board_etree, scenario_etree, allocation_etree):
# this dictonary mapped with 'address start':'mem range'
ram_range = {}

- vm_num = 0
- vm_list = scenario_etree.xpath("//vm")
- if vm_list is not None:
- vm_num = len(vm_list)
- hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * vm_num
+ max_vm_num = int(common.get_node(f"//hv/CAPACITIES/MAX_VM_NUM/text()", scenario_etree))
+ max_trusty_vm = len(scenario_etree.xpath(f"//vm[./secure_world_support/text() = 'y']"))
+ hv_ram_size = common.HV_BASE_RAM_SIZE + common.VM_RAM_SIZE * max_vm_num + max_trusty_vm * common.TRUSTY_RAM_SIZE
ivshmem_list = scenario_etree.xpath("//IVSHMEM_SIZE/text()")
total_shm_size = 0
for ram_size in ivshmem_list:
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index 98973187a..43bc18ca9 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -57,6 +57,7 @@
<xsl:value-of select="acrn:define('PRE_VM_NUM', count(vm[acrn:is-pre-launched-vm(load_order)]), 'U')" />
<xsl:value-of select="acrn:define('SERVICE_VM_NUM', count(vm[acrn:is-service-vm(load_order)]), 'U')" />
<xsl:value-of select="acrn:define('MAX_POST_VM_NUM', hv/CAPACITIES/MAX_VM_NUM - count(vm[acrn:is-pre-launched-vm(load_order)]) - count(vm[acrn:is-service-vm(load_order)]) , 'U')" />
+ <xsl:value-of select="acrn:define('MAX_TRUSTY_VM_NUM', count(vm[./secure_world_support/text() = 'y']) , 'U')" />
<xsl:value-of select="acrn:define('CONFIG_MAX_VM_NUM', hv/CAPACITIES/MAX_VM_NUM , 'U')" />
</xsl:template>

--
2.25.1