hv/config_tools: amend the struct acrn_vm_config to make it compatible with vCAT

For vCAT, it may need to store more than MAX_VCPUS_PER_VM of closids,
change clos in vm_config.h to a pointer to accommodate this situation

Rename clos to pclosids

pclosids now is a pointer to an array of physical CLOSIDs that is defined
in vm_configurations.c by vmconfig. The number of elements in the array
must be equal to the value given by num_pclosids

Add max_type_pcbm (type: l2 or l3) to struct acrn_vm_config, which stores a bitmask
that selects/covers all the physical cache ways assigned to the VM

Change vmsr.c to accommodate this amended data structure

Change the config-tools to generate vm_configurations.c, and fill in the num_closids
and clos pointers based on the information from the scenario file.

Now vm_configurations.c.xsl generates all the clos related code so remove the same
code from misc_cfg.h.xsl.

Examples:

  Scenario file:

  <RDT>
    <RDT_ENABLED>y</RDT_ENABLED>
    <CDP_ENABLED>n</CDP_ENABLED>
    <VCAT_ENABLED>y</VCAT_ENABLED>
    <CLOS_MASK>0x7ff</CLOS_MASK>
    <CLOS_MASK>0x7ff</CLOS_MASK>
    <CLOS_MASK>0x7ff</CLOS_MASK>
    <CLOS_MASK>0xff800</CLOS_MASK>
    <CLOS_MASK>0xff800</CLOS_MASK>
    <CLOS_MASK>0xff800</CLOS_MASK>
    <CLOS_MASK>0xff800</CLOS_MASK>
    <CLOS_MASK>0xff800</CLOS_MASK>
  /RDT>

  <vm id="0">
   <guest_flags>
     <guest_flag>GUEST_FLAG_VCAT_ENABLED</guest_flag>
   </guest_flags>
   <clos>
     <vcpu_clos>3</vcpu_clos>
     <vcpu_clos>4</vcpu_clos>
     <vcpu_clos>5</vcpu_clos>
     <vcpu_clos>6</vcpu_clos>
     <vcpu_clos>7</vcpu_clos>
   </clos>
  </vm>

  <vm id="1">
   <clos>
     <vcpu_clos>1</vcpu_clos>
     <vcpu_clos>2</vcpu_clos>
   </clos>
  </vm>

 vm_configurations.c (generated by config-tools) with the above vCAT config:

  static uint16_t vm0_vcpu_clos[5U] = {3U, 4U, 5U, 6U, 7U};
  static uint16_t vm1_vcpu_clos[2U] = {1U, 2U};

  struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
  {
  .guest_flags = (GUEST_FLAG_VCAT_ENABLED),
  .pclosids = vm0_vcpu_clos,
  .num_pclosids = 5U,
  .max_l3_pcbm = 0xff800U,
  },
  {
  .pclosids = vm1_vcpu_clos,
  .num_pclosids = 2U,
  },
  };

Tracked-On: #5917
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2021-09-14 19:31:57 -07:00
committed by wenlingz
parent 3ddcbd424f
commit cb2bb78b6f
6 changed files with 95 additions and 34 deletions

View File

@@ -376,6 +376,17 @@
</xsl:choose>
</func:function>
<func:function name="acrn:is-vcat-enabled">
<xsl:choose>
<xsl:when test="acrn:is-rdt-enabled() and //VCAT_ENABLED = 'y'">
<func:result select="true()" />
</xsl:when>
<xsl:otherwise>
<func:result select="false()" />
</xsl:otherwise>
</xsl:choose>
</func:function>
<func:function name="acrn:is-rdt-supported">
<xsl:variable name="rdt_resource" select="acrn:get-normalized-closinfo-rdt-res-str()" />
<xsl:variable name="rdt_res_clos_max" select="acrn:get-normalized-closinfo-rdt-clos-max-str()" />

View File

@@ -122,12 +122,6 @@
</xsl:for-each>
</xsl:template>
<xsl:template name="vcpu_clos">
<xsl:for-each select="vm">
<xsl:value-of select="acrn:define(concat('VM', @id, '_VCPU_CLOS'), concat('{', acrn:string-join(clos/vcpu_clos, ',', '', 'U'),'}'), '')" />
</xsl:for-each>
</xsl:template>
<!-- HV_SUPPORTED_MAX_CLOS:
The maximum CLOS that is allowed by ACRN hypervisor.
Its value is set to be least common Max CLOS (CPUID.(EAX=0x10,ECX=ResID):EDX[15:0])
@@ -172,7 +166,6 @@
<xsl:for-each select="hv/FEATURES/RDT/CLOS_MASK">
<xsl:value-of select="acrn:define(concat('CLOS_MASK_', position() - 1), current(), 'U')" />
</xsl:for-each>
<xsl:call-template name="vcpu_clos" />
<xsl:value-of select="$endif" />
</xsl:if>
</xsl:template>

View File

@@ -50,6 +50,21 @@
</xsl:if>
</xsl:for-each>
<xsl:if test="acrn:is-rdt-enabled()">
<xsl:value-of select="$newline" />
<xsl:value-of select="acrn:ifdef('CONFIG_RDT_ENABLED')" />
<xsl:for-each select="vm">
<xsl:value-of select="concat('static uint16_t ', concat('vm', @id, '_vcpu_clos'), '[', count(clos/vcpu_clos), 'U] = {')" />
<xsl:value-of select="acrn:string-join(clos/vcpu_clos, ', ', '', 'U')" />
<xsl:text>};</xsl:text>
<xsl:value-of select="$newline" />
</xsl:for-each>
<xsl:value-of select="$endif" />
<xsl:value-of select="$newline" />
</xsl:if>
<!-- Definition of vm_configs -->
<xsl:value-of select="acrn:array-initializer('struct acrn_vm_config', 'vm_configs', 'CONFIG_MAX_VM_NUM')" />
<xsl:apply-templates select="vm"/>
@@ -70,7 +85,11 @@
</xsl:if>
<xsl:value-of select="acrn:initializer('vm_prio', priority)" />
<xsl:apply-templates select="guest_flags" />
<xsl:apply-templates select="clos" />
<xsl:if test="acrn:is-rdt-enabled()">
<xsl:apply-templates select="clos" />
</xsl:if>
<xsl:call-template name="cpu_affinity" />
<xsl:apply-templates select="epc_section" />
<xsl:apply-templates select="memory" />
@@ -133,7 +152,23 @@
<xsl:template match="clos">
<xsl:value-of select="acrn:ifdef('CONFIG_RDT_ENABLED')" />
<xsl:value-of select="acrn:initializer('clos', concat('VM', ../@id, '_VCPU_CLOS'))" />
<xsl:value-of select="acrn:initializer('pclosids', concat('vm', ../@id, '_vcpu_clos'))" />
<xsl:value-of select="acrn:initializer('num_pclosids', concat(count(vcpu_clos), 'U'))" />
<xsl:if test="acrn:is-vcat-enabled() and ../guest_flags[guest_flag = 'GUEST_FLAG_VCAT_ENABLED']">
<xsl:variable name="rdt_res_str" select="acrn:get-normalized-closinfo-rdt-res-str()" />
<xsl:variable name="closid" select="vcpu_clos[1]" />
<xsl:if test="contains($rdt_res_str, 'L2')">
<xsl:value-of select="acrn:initializer('max_l2_pcbm', concat(../../hv/FEATURES/RDT/CLOS_MASK[$closid + 1], 'U'))" />
</xsl:if>
<xsl:if test="contains($rdt_res_str, 'L3')">
<xsl:value-of select="acrn:initializer('max_l3_pcbm', concat(../../hv/FEATURES/RDT/CLOS_MASK[$closid + 1], 'U'))" />
</xsl:if>
</xsl:if>
<xsl:value-of select="$endif" />
</xsl:template>
@@ -148,13 +183,13 @@
<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:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:text>},</xsl:text>
<xsl:value-of select="$newline" />
</xsl:template>
<xsl:template match="epc_section">
<xsl:template match="epc_section">
<xsl:if test="base != '0' and size != '0'">
<xsl:value-of select="acrn:initializer('epc', '{', true())" />
<xsl:value-of select="acrn:initializer('base', base)" />