config_tools: refine memory setting for HPAn

1. Update the data structure of vm/memory in scenario and schema files.
The scenario will look like this.

<hpa_region>
  <start_hpa>xxx</start_hpa>
  <size_hpa>xxx</size_hpa>
</hpa_region>

2. Update xsl files to generate the related struct.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@intel.com>
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Chenli Wei 2022-04-12 19:42:34 +08:00 committed by acrnsi-robot
parent ed1c638c87
commit 52268f5cc2
5 changed files with 44 additions and 50 deletions

View File

@ -211,7 +211,7 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id
if lapic_ids: if lapic_ids:
script.add_dynamic_dm_parameter("add_cpus", f"{' '.join([str(x) for x in sorted(lapic_ids)])}") script.add_dynamic_dm_parameter("add_cpus", f"{' '.join([str(x) for x in sorted(lapic_ids)])}")
script.add_plain_dm_parameter(f"-m {eval_xpath(vm_scenario_etree, './/memory/whole/text()')}M") script.add_plain_dm_parameter(f"-m {eval_xpath(vm_scenario_etree, './/memory/size/text()')}M")
if eval_xpath(vm_scenario_etree, "//SSRAM_ENABLED") == "y" and \ if eval_xpath(vm_scenario_etree, "//SSRAM_ENABLED") == "y" and \
eval_xpath(vm_scenario_etree, ".//vm_type/text()") == "RTVM": eval_xpath(vm_scenario_etree, ".//vm_type/text()") == "RTVM":

View File

@ -100,31 +100,32 @@ CLOSID 0 and the second is mapped to virtual CLOSID 1, etc.</xs:documentation>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
<xs:complexType name="HPARegionType">
<xs:sequence>
<xs:element name="start_hpa" type="HexFormat">
<xs:annotation acrn:title="Start physical address">
<xs:documentation>Specify the starting address for non-contiguous allocation.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="size_hpa" type="xs:integer">
<xs:annotation acrn:title="Size (MB)">
<xs:documentation>Specify the physical memory size for non-contiguous allocation in megabytes.
The size is a subset of the VM's total memory size specified on the Basic tab.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MemoryInfo"> <xs:complexType name="MemoryInfo">
<xs:all> <xs:all>
<xs:element name="whole" type="xs:integer" default="256"> <xs:element name="size" type="xs:integer" minOccurs="0" default="256">
<xs:annotation acrn:title="Memory size (MB)" acrn:views="basic" acrn:applicable-vms="post-launched"> <xs:annotation acrn:title="Memory size (MB)" acrn:views="basic" acrn:applicable-vms="pre-launched, post-launched">
<xs:documentation>Specify the physical memory size allocated to this VM in megabytes.</xs:documentation> <xs:documentation>Specify the physical memory size allocated to this VM in megabytes.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element name="start_hpa" type="HexFormat" default="0x100000000"> <xs:element name="hpa_region" type="HPARegionType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation acrn:views="advanced" acrn:applicable-vms="pre-launched, service-vm"> <xs:annotation acrn:title="Physical memory segmentation" acrn:views="advanced" acrn:applicable-vms="pre-launched" >
<xs:documentation>The starting physical address in host for the VM.</xs:documentation> <xs:documentation>Specify Physical memory information for Prelaunched VM </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="size" type="MemorySizeType" default="0x20000000" minOccurs="0">
<xs:annotation acrn:views="advanced" acrn:applicable-vms="pre-launched, service-vm">
<xs:documentation>The memory size in bytes for the VM. Default value is ``0x200000000``.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="start_hpa2" type="HexFormat" default="0x0" minOccurs="0">
<xs:annotation acrn:views="advanced" acrn:applicable-vms="pre-launched, service-vm">
<xs:documentation>Start of second HPA for non-contiguous allocations in host for the VM.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="size_hpa2" type="MemorySizeType" default="0x0" minOccurs="0">
<xs:annotation acrn:views="advanced" acrn:applicable-vms="pre-launched, service-vm">
<xs:documentation>Memory size of second HPA for non-contiguous allocations in Bytes for the VM.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
</xs:all> </xs:all>

View File

@ -358,9 +358,9 @@ Refer SDM 17.19.2 for details, and use with caution.</xs:documentation>
<xs:documentation>Specify the Intel Software Guard Extensions (SGX) enclave page cache (EPC) section settings.</xs:documentation> <xs:documentation>Specify the Intel Software Guard Extensions (SGX) enclave page cache (EPC) section settings.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element name="memory" type="MemoryInfo"> <xs:element name="memory" type="MemoryInfo" minOccurs="0">
<xs:annotation acrn:views="basic, advanced"> <xs:annotation acrn:views="basic, advanced" acrn:applicable-vms="pre-launched, post-launched">
<xs:documentation>Specify memory information for Service and User VMs.</xs:documentation> <xs:documentation>Specify memory information for User VMs.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element name="priority" type="PriorityType" default="PRIO_LOW"> <xs:element name="priority" type="PriorityType" default="PRIO_LOW">

View File

@ -28,6 +28,7 @@
<xsl:template match="config-data/acrn-config"> <xsl:template match="config-data/acrn-config">
<!-- Declaration of pci_devs --> <!-- Declaration of pci_devs -->
<xsl:for-each select="vm"> <xsl:for-each select="vm">
<xsl:variable name="vm_id" select="@id" />
<xsl:choose> <xsl:choose>
<xsl:when test="acrn:is-service-vm(load_order)"> <xsl:when test="acrn:is-service-vm(load_order)">
<xsl:value-of select="acrn:extern('struct acrn_vm_pci_dev_config', 'sos_pci_devs', 'CONFIG_MAX_PCI_DEV_NUM')" /> <xsl:value-of select="acrn:extern('struct acrn_vm_pci_dev_config', 'sos_pci_devs', 'CONFIG_MAX_PCI_DEV_NUM')" />
@ -39,7 +40,6 @@
<!-- Declaration of pt_intx --> <!-- Declaration of pt_intx -->
<xsl:if test="acrn:is-pre-launched-vm(load_order)"> <xsl:if test="acrn:is-pre-launched-vm(load_order)">
<xsl:variable name="vm_id" select="@id" />
<xsl:variable name="length" select="count(acrn:get-intx-mapping(//vm[@id=$vm_id]//pt_intx))" /> <xsl:variable name="length" select="count(acrn:get-intx-mapping(//vm[@id=$vm_id]//pt_intx))" />
<xsl:choose> <xsl:choose>
<xsl:when test="$length"> <xsl:when test="$length">
@ -49,6 +49,17 @@
<xsl:value-of select="acrn:extern('struct pt_intx_config', concat('vm', @id, '_pt_intx'), '1U')" /> <xsl:value-of select="acrn:extern('struct pt_intx_config', concat('vm', @id, '_pt_intx'), '1U')" />
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<!-- Initializer of memory -->
<xsl:value-of select="concat('static struct vm_hpa_regions ', concat('vm', @id, '_hpa'), '[] = {')" />
<xsl:for-each select="//allocation-data/acrn-config/vm[@id=$vm_id]/memory/hpa_region" >
<xsl:variable name="pos" select="position()" />
<xsl:variable name="start_hpa" select="acrn:initializer('start_hpa', ./start_hpa, 'UL')" />
<xsl:variable name="size_hpa" select="acrn:initializer('size_hpa', ./size_hpa, 'UL')" />
<xsl:value-of select="concat('{', $start_hpa, ', ', $size_hpa, '}', ',')" />
</xsl:for-each>
<xsl:text>};</xsl:text>
<xsl:value-of select="$newline" />
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
@ -99,7 +110,9 @@
<xsl:call-template name="cpu_affinity" /> <xsl:call-template name="cpu_affinity" />
<xsl:apply-templates select="epc_section" /> <xsl:apply-templates select="epc_section" />
<xsl:if test="acrn:is-pre-launched-vm(load_order)">
<xsl:apply-templates select="memory" /> <xsl:apply-templates select="memory" />
</xsl:if>
<xsl:apply-templates select="os_config" /> <xsl:apply-templates select="os_config" />
<xsl:call-template name="acpi_config" /> <xsl:call-template name="acpi_config" />
<xsl:apply-templates select="console_vuart" /> <xsl:apply-templates select="console_vuart" />
@ -185,18 +198,10 @@
</xsl:template> </xsl:template>
<xsl:template match="memory"> <xsl:template match="memory">
<xsl:variable name="vm_id" select="../@id" />
<xsl:value-of select="acrn:initializer('memory', '{', true())" /> <xsl:value-of select="acrn:initializer('memory', '{', true())" />
<xsl:choose> <xsl:value-of select="acrn:initializer('region_num', count(//allocation-data/acrn-config/vm[@id=$vm_id]/memory/hpa_region))" />
<xsl:when test="acrn:is-pre-launched-vm(../load_order)"> <xsl:value-of select="acrn:initializer('host_regions', concat('vm', ../@id, '_hpa'))" />
<xsl:value-of select="acrn:initializer('start_hpa', concat('VM', ../@id, '_CONFIG_MEM_START_HPA'))" />
<xsl:value-of select="acrn:initializer('size', concat('VM', ../@id, '_CONFIG_MEM_SIZE'))" />
<xsl:value-of select="acrn:initializer('start_hpa2', concat('VM', ../@id, '_CONFIG_MEM_START_HPA2'))" />
<xsl:value-of select="acrn:initializer('size_hpa2', concat('VM', ../@id, '_CONFIG_MEM_SIZE_HPA2'))" />
</xsl:when>
<xsl:when test="acrn:is-service-vm(../load_order)">
<xsl:value-of select="acrn:initializer('start_hpa', concat(start_hpa, 'UL'))" />
</xsl:when>
</xsl:choose>
<xsl:text>},</xsl:text> <xsl:text>},</xsl:text>
<xsl:value-of select="$newline" /> <xsl:value-of select="$newline" />
</xsl:template> </xsl:template>

View File

@ -31,7 +31,6 @@
<xsl:template match="config-data/acrn-config"> <xsl:template match="config-data/acrn-config">
<xsl:call-template name="vm_count" /> <xsl:call-template name="vm_count" />
<xsl:call-template name="pre_launched_vm_hpa" />
<xsl:call-template name="sos_vm_bootarges" /> <xsl:call-template name="sos_vm_bootarges" />
</xsl:template> </xsl:template>
@ -52,15 +51,4 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name ="pre_launched_vm_hpa">
<xsl:for-each select="vm">
<xsl:if test="acrn:is-pre-launched-vm(load_order)">
<xsl:value-of select="acrn:define(concat('VM', @id, '_CONFIG_MEM_START_HPA'), memory/start_hpa, 'UL')" />
<xsl:value-of select="acrn:define(concat('VM', @id, '_CONFIG_MEM_SIZE'), memory/size, 'UL')" />
<xsl:value-of select="acrn:define(concat('VM', @id, '_CONFIG_MEM_START_HPA2'), memory/start_hpa2, 'UL')" />
<xsl:value-of select="acrn:define(concat('VM', @id, '_CONFIG_MEM_SIZE_HPA2'), memory/size_hpa2, 'UL')" />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>