1<?xml version="1.0" encoding="utf-8"?> 2 3<!-- Copyright (C) 2021-2022 Intel Corporation. --> 4<!-- SPDX-License-Identifier: BSD-3-Clause --> 5 6<xsl:stylesheet 7 version="1.0" 8 xmlns:xi="http://www.w3.org/2003/XInclude" 9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 10 xmlns:dyn="http://exslt.org/dynamic" 11 xmlns:math="http://exslt.org/math" 12 xmlns:str="http://exslt.org/strings" 13 xmlns:acrn="http://projectacrn.org"> 14 <xsl:include href="lib.xsl" /> 15 <xsl:output method="text" /> 16 17 <xsl:template match="/acrn-offline-data"> 18 <!-- Declaration of license --> 19 <xsl:value-of select="$license" /> 20 21 <!-- Header include guard --> 22 <xsl:value-of select="acrn:include-guard('MISC_CFG_H')" /> 23 24 <xsl:apply-templates select="board-data/acrn-config" /> 25 <xsl:apply-templates select="config-data/acrn-config" /> 26 27 <xsl:apply-templates select="allocation-data/acrn-config" /> 28 29 <xsl:value-of select="acrn:include-guard-end('MISC_CFG_H')" /> 30 </xsl:template> 31 32 <xsl:template match="board-data/acrn-config"> 33 <xsl:apply-templates select="BLOCK_DEVICE_INFO" /> 34 </xsl:template> 35 36 <xsl:template match="config-data/acrn-config"> 37 <xsl:if test="count(vm[acrn:is-service-vm(load_order)])"> 38 <xsl:call-template name="sos_bootargs_diff" /> 39 </xsl:if> 40 <xsl:call-template name="cpu_affinity" /> 41 <xsl:call-template name="rdt" /> 42 <xsl:call-template name="vm0_passthrough_tpm" /> 43 <xsl:call-template name="service_vm_super_role" /> 44 <xsl:call-template name="vm_config_pci_dev_num" /> 45 <xsl:call-template name="vm_boot_args" /> 46 </xsl:template> 47 48 <xsl:template match="allocation-data/acrn-config"> 49 <xsl:choose> 50 <xsl:when test="//ssram"> 51 <xsl:value-of select="acrn:define('PRE_RTVM_SW_SRAM_MAX_SIZE', //ssram/max_size, 'UL')" /> 52 </xsl:when> 53 <xsl:otherwise> 54 <xsl:value-of select="acrn:define('PRE_RTVM_SW_SRAM_MAX_SIZE', 0, 'UL')" /> 55 </xsl:otherwise> 56 </xsl:choose> 57 </xsl:template> 58 59 <xsl:template match="BLOCK_DEVICE_INFO"> 60 <xsl:variable name="block_devices_list_1" select="translate(current(), $newline, ',')" /> 61 <xsl:variable name="block_devices_list_2" select="translate($block_devices_list_1, $whitespaces, '')" /> 62 <xsl:variable name="block_devices_list" select="str:split($block_devices_list_2, ',')" /> 63 <xsl:for-each select="$block_devices_list"> 64 <xsl:variable name="pos" select="position()" /> 65 <xsl:variable name="block_device" select="$block_devices_list[$pos]" /> 66 <xsl:if test="not(contains($block_device, 'ext4'))"> 67 <xsl:value-of select="acrn:define(concat('ROOTFS_', $pos), concat($quot, 'root=', substring-before($block_device, ':'), ' ', $quot))" /> 68 </xsl:if> 69 </xsl:for-each> 70 </xsl:template> 71 72<xsl:template name="sos_bootargs_diff"> 73 <xsl:variable name="sos_rootfs"> 74 <xsl:variable name="bootargs" select="str:split(//vm[acrn:is-service-vm(load_order)]/os_config/bootargs[text()], ' ')" /> 75 <xsl:for-each select="$bootargs"> 76 <xsl:variable name="pos" select="position()" /> 77 <xsl:variable name="bootarg" select="$bootargs[$pos]" /> 78 <xsl:if test="contains($bootarg, 'root=')"> 79 <xsl:value-of select="$bootarg" /> 80 </xsl:if> 81 </xsl:for-each> 82 </xsl:variable> 83 <xsl:variable name="sos_bootargs" select="normalize-space(str:replace(//vm[acrn:is-service-vm(load_order)]/os_config/bootargs[text()], $sos_rootfs, ''))" /> 84 <xsl:variable name="maxcpunum" select="count(//vm[acrn:is-service-vm(load_order)]/cpu_affinity//pcpu_id)" /> 85 <xsl:variable name="maxcpus"> 86 <xsl:choose> 87 <xsl:when test="$maxcpunum != 0"> 88 <xsl:value-of select="concat('maxcpus=', $maxcpunum)" /> 89 </xsl:when> 90 <xsl:otherwise> 91 <xsl:value-of select="''" /> 92 </xsl:otherwise> 93 </xsl:choose> 94 </xsl:variable> 95 <xsl:variable name="hugepage_kernelstring"> 96 <xsl:if test="//board-data//processors//capability[@id='gbyte_pages']"> 97 <xsl:value-of select="concat('hugepagesz=1G hugepages=', //allocation-data//vm[acrn:is-service-vm(load_order)]/hugepages/gb)" /> 98 </xsl:if> 99 </xsl:variable> 100 <xsl:value-of select="acrn:define('SERVICE_VM_ROOTFS', concat($quot, $sos_rootfs, ' ', $quot), '')" /> 101 <xsl:value-of select="acrn:define('SERVICE_VM_BOOTARGS_DIFF', concat($quot, $sos_bootargs, ' ', $maxcpus, ' ', $hugepage_kernelstring, ' ', $quot), '')" /> 102 <xsl:value-of select="acrn:define('SERVICE_VM_BOOTARGS_MISC', concat($quot, 'udmabuf.list_limit=8192 ', $quot), '')" /> 103</xsl:template> 104 105<xsl:template name="cpu_affinity"> 106 <xsl:for-each select="vm"> 107 <xsl:choose> 108 <xsl:when test="acrn:is-service-vm(load_order)"> 109 <xsl:value-of select="acrn:define('SERVICE_VM_CONFIG_CPU_AFFINITY', concat('(', acrn:string-join(//vm[acrn:is-service-vm(load_order)]/cpu_affinity//pcpu_id, '|', 'AFFINITY_CPU(', 'U)'),')'), '')" /> 110 </xsl:when> 111 <xsl:otherwise> 112 <xsl:value-of select="acrn:define(concat('VM', @id, '_CONFIG_CPU_AFFINITY'), concat('(', acrn:string-join(cpu_affinity//pcpu_id, '|', 'AFFINITY_CPU(', 'U)'),')'), '')" /> 113 </xsl:otherwise> 114 </xsl:choose> 115 </xsl:for-each> 116</xsl:template> 117 118<!-- HV_SUPPORTED_MAX_CLOS: 119 The maximum CLOS that is allowed by ACRN hypervisor. 120 Its value is set to be least common Max CLOS (CPUID.(EAX=0x10,ECX=ResID):EDX[15:0]) 121 among all supported RDT resources in the platform. In other words, it is 122 min(maximum CLOS of L2, L3 and MBA). This is done in order to have consistent 123 CLOS allocations between all the RDT resources. --> 124<!-- MAX_MBA_CLOS_NUM_ENTRIES: 125 Max number of Cache Mask entries corresponding to each CLOS. 126 This can vary if CDP is enabled vs disabled, as each CLOS entry will have corresponding 127 cache mask values for Data and Code when CDP is enabled. --> 128<!-- MAX_CACHE_CLOS_NUM_ENTRIES: 129 Max number of MBA delay entries corresponding to each CLOS. --> 130<xsl:template name="rdt"> 131 <xsl:variable name="rdt_res_clos_max" select="acrn:get-normalized-closinfo-rdt-clos-max-str()" /> 132 <xsl:variable name="common_clos_max" select="acrn:get-common-clos-count()"/> 133 <xsl:choose> 134 <xsl:when test="acrn:is-cdp-enabled()"> 135 <xsl:value-of select="acrn:ifdef('CONFIG_RDT_ENABLED')" /> 136 <xsl:value-of select="acrn:ifdef('CONFIG_CDP_ENABLED')" /> 137 <xsl:value-of select="acrn:define('HV_SUPPORTED_MAX_CLOS', $common_clos_max, 'U')" /> 138 <xsl:value-of select="acrn:define('MAX_CACHE_CLOS_NUM_ENTRIES', 2 * $common_clos_max, 'U')" /> 139 <xsl:value-of select="$else" /> 140 <xsl:value-of select="acrn:define('HV_SUPPORTED_MAX_CLOS', acrn:find-list-min($rdt_res_clos_max, ','), 'U')" /> 141 <xsl:value-of select="acrn:define('MAX_CACHE_CLOS_NUM_ENTRIES', $common_clos_max, 'U')" /> 142 <xsl:value-of select="$endif" /> 143 <xsl:value-of select="acrn:define('MAX_MBA_CLOS_NUM_ENTRIES', $common_clos_max, 'U')" /> 144 </xsl:when> 145 <xsl:otherwise> 146 <xsl:value-of select="acrn:ifdef('CONFIG_RDT_ENABLED')" /> 147 <xsl:value-of select="acrn:define('HV_SUPPORTED_MAX_CLOS', $common_clos_max, 'U')" /> 148 <xsl:value-of select="acrn:define('MAX_MBA_CLOS_NUM_ENTRIES', $common_clos_max, 'U')" /> 149 <xsl:value-of select="acrn:define('MAX_CACHE_CLOS_NUM_ENTRIES', $common_clos_max, 'U')" /> 150 <xsl:if test="not(acrn:is-rdt-supported())"> 151 <xsl:value-of select="$endif" /> 152 </xsl:if> 153 </xsl:otherwise> 154 </xsl:choose> 155 <xsl:if test="acrn:is-rdt-supported()"> 156 <xsl:value-of select="$endif" /> 157 </xsl:if> 158</xsl:template> 159 160<xsl:template name="vm0_passthrough_tpm"> 161 <xsl:if test="acrn:is-pre-launched-vm(vm[@id = 0]/load_order)"> 162 <xsl:if test="//vm/mmio_resources/TPM2/text() = 'y' and //device[@id = 'MSFT0101' or compatible_id = 'MSFT0101']"> 163 <xsl:value-of select="acrn:define('VM0_PASSTHROUGH_TPM', '', '')" /> 164 <xsl:value-of select="acrn:define('VM0_TPM_BUFFER_BASE_ADDR', '0xFED40000', 'UL')" /> 165 <xsl:value-of select="acrn:define('VM0_TPM_BUFFER_BASE_ADDR_GPA', '0xFED40000', 'UL')" /> 166 <xsl:value-of select="acrn:define('VM0_TPM_BUFFER_SIZE', '0x5000', 'UL')" /> 167 <xsl:if test="//capability[@id='log_area']"> 168 <xsl:value-of select="acrn:define('VM0_TPM_EVENTLOG_BASE_ADDR', //allocation-data/acrn-config/vm[@id = '0']/log_area_start_address, 'UL')" /> 169 <xsl:value-of select="acrn:define('VM0_TPM_EVENTLOG_BASE_ADDR_HPA', //capability[@id='log_area']/log_area_start_address, 'UL')" /> 170 <xsl:value-of select="acrn:define('VM0_TPM_EVENTLOG_SIZE', //allocation-data/acrn-config/vm[@id = '0']/log_area_minimum_length, 'UL')" /> 171 </xsl:if> 172 </xsl:if> 173 </xsl:if> 174</xsl:template> 175 176<xsl:template name="service_vm_super_role"> 177 <xsl:choose> 178 <xsl:when test="//SERVICE_VM_SUPERVISOR_ENABLED = 'y'"> 179 <xsl:value-of select="acrn:define('RTVM_SEVERITY_LEVEL', '0x10', 'U')" /> 180 </xsl:when> 181 <xsl:otherwise> 182 <xsl:value-of select="acrn:define('RTVM_SEVERITY_LEVEL', '0x30', 'U')" /> 183 </xsl:otherwise> 184 </xsl:choose> 185</xsl:template> 186 187<xsl:template name="vm_config_pci_dev_num"> 188 <xsl:for-each select="vm"> 189 <xsl:if test="acrn:pci-dev-num(@id)"> 190 <xsl:value-of select="acrn:define(concat('VM', @id, '_CONFIG_PCI_DEV_NUM'), acrn:pci-dev-num(@id), 'U')" /> 191 </xsl:if> 192 </xsl:for-each> 193 <xsl:value-of select="$newline" /> 194</xsl:template> 195 196<xsl:template name="vm_boot_args"> 197 <xsl:for-each select="vm"> 198 <xsl:if test="acrn:is-pre-launched-vm(load_order)"> 199 <xsl:variable name="bootargs" select="normalize-space(os_config/bootargs)" /> 200 <xsl:if test="$bootargs"> 201 <xsl:value-of select="acrn:define(concat('VM', @id, '_BOOT_ARGS'), concat($quot, $bootargs, ' ', $quot), '')" /> 202 </xsl:if> 203 </xsl:if> 204 </xsl:for-each> 205</xsl:template> 206 207</xsl:stylesheet> 208