[PATCH v3] misc: add config for P2SB


chenli.wei
 

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

Currently we have to use additional patch to change config tool python
code to enable P2SB hidden device.

This patch have add an element, user could config the P2SB device in
the scenario XML.

v2-->v3:
1. modify the error message of assertion

v1-->v2:
1. add an assertion to check the "00:1f.1" when pre launched VMs have
enable "P2SB bridge passthrough"
2. Code refine

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@...>
---
misc/config_tools/board_config/board_c.py | 8 +++++++-
misc/config_tools/schema/VMtypes.xsd | 10 ++++++++++
misc/config_tools/schema/checks/vbdf_assignment.xsd | 7 +++++++
misc/config_tools/schema/config.xsd | 7 +++++++
misc/config_tools/xforms/lib.xsl | 3 +++
5 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/board_config/board_c.py b/misc/config_tools/board_config/board_c.py
index 655cfc6c4..c1ce14e29 100644
--- a/misc/config_tools/board_config/board_c.py
+++ b/misc/config_tools/board_config/board_c.py
@@ -408,8 +408,14 @@ def gen_px_cx(config):

def gen_pci_hide(config):
"""Generate hide pci information for this platform"""
+
+ scenario_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE)
+ hidden_pdev_list = [x.replace('.', ':') for x in scenario_etree.xpath(f"//HIDDEN_PDEV/text()")]
+
if board_cfg_lib.BOARD_NAME in list(board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB.keys()) and board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME] != 0:
- hidden_pdev_list = board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME]
+ hidden_pdev_list += board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME] + scenario_pdev_list
+
+ if len(hidden_pdev_list) > 0:
hidden_pdev_num = len(hidden_pdev_list)
print("const union pci_bdf plat_hidden_pdevs[MAX_HIDDEN_PDEVS_NUM] = {", file=config)
for hidden_pdev_i in range(hidden_pdev_num):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index ce4ef09be..4ced8e02d 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -272,6 +272,16 @@ The size is a subset of the VM's total memory size specified on the Basic tab.</
</xs:all>
</xs:complexType>

+<xs:complexType name="HiddenDevType">
+ <xs:all>
+ <xs:element name="HIDDEN_PDEV" type="VBDFType" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation acrn:views="">
+ <xs:documentation>Specify the hidden device vBDF</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:all>
+</xs:complexType>
+
<xs:complexType name="PCIDevsConfiguration">
<xs:sequence>
<xs:element name="pci_dev" type="xs:string" minOccurs="0" maxOccurs="unbounded">
diff --git a/misc/config_tools/schema/checks/vbdf_assignment.xsd b/misc/config_tools/schema/checks/vbdf_assignment.xsd
index c151c2fed..c17f93f63 100644
--- a/misc/config_tools/schema/checks/vbdf_assignment.xsd
+++ b/misc/config_tools/schema/checks/vbdf_assignment.xsd
@@ -24,4 +24,11 @@
</xs:annotation>
</xs:assert>

+ <xs:assert test="every $vm in /acrn-config//vm[./load_order/text() = 'PRE_LAUNCHED_VM' and ./mmio_resources/p2sb/text() = 'y'] satisfies
+ count(/acrn-config//HIDDEN_PDEV[./text() = '00:1f.1']) = 0">
+ <xs:annotation acrn:severity="error" acrn:report-on="/acrn-config//p2sb[./text() = 'y']">
+ <xs:documentation>Can't passthrough P2SB to VM {/acrn-config//vm[./load_order/text() = 'PRE_LAUNCHED_VM' and .//p2sb/text() = 'y']/name/text()} because '00:1f.1' is set as a hidden device".</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
</xs:schema>
diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 2bb5a4fb8..d75971524 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -304,6 +304,13 @@ Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
<xs:documentation>Miscellaneous options for workarounds.</xs:documentation>
</xs:annotation>
</xs:element>
+
+ <xs:element name="HIDDEN_PDEV_REGION" type="HiddenDevType" minOccurs="0">
+ <xs:annotation acrn:views="">
+ <xs:documentation>Specify the hidden devices.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
<xs:element name="CACHE_REGION" type="CacheRegionType" minOccurs="0">
<xs:annotation acrn:views="advanced">
<xs:documentation>Specify the cache setting.</xs:documentation>
diff --git a/misc/config_tools/xforms/lib.xsl b/misc/config_tools/xforms/lib.xsl
index 2fdad6b37..8974cc16a 100644
--- a/misc/config_tools/xforms/lib.xsl
+++ b/misc/config_tools/xforms/lib.xsl
@@ -375,6 +375,9 @@
<xsl:when test="//@board = 'apl-up2'">
<func:result select="1" />
</xsl:when>
+ <xsl:when test="count(//HIDDEN_PDEV/text()) > 0">
+ <func:result select="count(//HIDDEN_PDEV/text())" />
+ </xsl:when>
<xsl:otherwise>
<func:result select="0" />
</xsl:otherwise>
--
2.25.1


Junjie Mao
 

-----Original Message-----
From: Chenli Wei <chenli.wei@...>
Sent: Wednesday, August 31, 2022 2:52 AM
To: Mao, Junjie <junjie.mao@...>; acrn-dev@...
Cc: Wei, Chenli <chenli.wei@...>; Chenli Wei <chenli.wei@...>
Subject: [PATCH v3] misc: add config for P2SB

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

Currently we have to use additional patch to change config tool python
code to enable P2SB hidden device.

This patch have add an element, user could config the P2SB device in
the scenario XML.

v2-->v3:
1. modify the error message of assertion

v1-->v2:
1. add an assertion to check the "00:1f.1" when pre launched VMs have
enable "P2SB bridge passthrough"
2. Code refine

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

One minor comment below.

---
misc/config_tools/board_config/board_c.py | 8 +++++++-
misc/config_tools/schema/VMtypes.xsd | 10 ++++++++++
misc/config_tools/schema/checks/vbdf_assignment.xsd | 7 +++++++
misc/config_tools/schema/config.xsd | 7 +++++++
misc/config_tools/xforms/lib.xsl | 3 +++
5 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/board_config/board_c.py
b/misc/config_tools/board_config/board_c.py
index 655cfc6c4..c1ce14e29 100644
--- a/misc/config_tools/board_config/board_c.py
+++ b/misc/config_tools/board_config/board_c.py
@@ -408,8 +408,14 @@ def gen_px_cx(config):

def gen_pci_hide(config):
"""Generate hide pci information for this platform"""
+
+ scenario_etree = lxml.etree.parse(common.SCENARIO_INFO_FILE)
+ hidden_pdev_list = [x.replace('.', ':') for x in
scenario_etree.xpath(f"//HIDDEN_PDEV/text()")]
+
if board_cfg_lib.BOARD_NAME in list(board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB.keys())
and board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME] != 0:
- hidden_pdev_list =
board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME]
+ hidden_pdev_list +=
board_cfg_lib.KNOWN_HIDDEN_PDEVS_BOARD_DB[board_cfg_lib.BOARD_NAME] + scenario_pdev_list
+
+ if len(hidden_pdev_list) > 0:
hidden_pdev_num = len(hidden_pdev_list)
print("const union pci_bdf plat_hidden_pdevs[MAX_HIDDEN_PDEVS_NUM] = {",
file=config)
for hidden_pdev_i in range(hidden_pdev_num):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index ce4ef09be..4ced8e02d 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -272,6 +272,16 @@ The size is a subset of the VM's total memory size specified on the
Basic tab.</
</xs:all>
</xs:complexType>

+<xs:complexType name="HiddenDevType">
+ <xs:all>
+ <xs:element name="HIDDEN_PDEV" type="VBDFType" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation acrn:views="">
+ <xs:documentation>Specify the hidden device vBDF</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:all>
+</xs:complexType>
+
<xs:complexType name="PCIDevsConfiguration">
<xs:sequence>
<xs:element name="pci_dev" type="xs:string" minOccurs="0" maxOccurs="unbounded">
diff --git a/misc/config_tools/schema/checks/vbdf_assignment.xsd
b/misc/config_tools/schema/checks/vbdf_assignment.xsd
index c151c2fed..c17f93f63 100644
--- a/misc/config_tools/schema/checks/vbdf_assignment.xsd
+++ b/misc/config_tools/schema/checks/vbdf_assignment.xsd
@@ -24,4 +24,11 @@
</xs:annotation>
</xs:assert>

+ <xs:assert test="every $vm in /acrn-config//vm[./load_order/text() = 'PRE_LAUNCHED_VM'
and ./mmio_resources/p2sb/text() = 'y'] satisfies
+ count(/acrn-config//HIDDEN_PDEV[./text() = '00:1f.1']) = 0">
+ <xs:annotation acrn:severity="error" acrn:report-on="/acrn-config//p2sb[./text() =
'y']">
+ <xs:documentation>Can't passthrough P2SB to VM {/acrn-config//vm[./load_order/text()
= 'PRE_LAUNCHED_VM' and .//p2sb/text() = 'y']/name/text()} because '00:1f.1' is set as a
hidden device".</xs:documentation>
You can use `$vm` to refer to the VM you found in the assertion that is pre-launched and has P2SB passthrough enabled.

---
Best Regards
Junjie Mao

+ </xs:annotation>
+ </xs:assert>
+
</xs:schema>
diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 2bb5a4fb8..d75971524 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -304,6 +304,13 @@ Refer to :ref:`vuart_config` for detailed vUART
settings.</xs:documentation>
<xs:documentation>Miscellaneous options for workarounds.</xs:documentation>
</xs:annotation>
</xs:element>
+
+ <xs:element name="HIDDEN_PDEV_REGION" type="HiddenDevType" minOccurs="0">
+ <xs:annotation acrn:views="">
+ <xs:documentation>Specify the hidden devices.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
<xs:element name="CACHE_REGION" type="CacheRegionType" minOccurs="0">
<xs:annotation acrn:views="advanced">
<xs:documentation>Specify the cache setting.</xs:documentation>
diff --git a/misc/config_tools/xforms/lib.xsl b/misc/config_tools/xforms/lib.xsl
index 2fdad6b37..8974cc16a 100644
--- a/misc/config_tools/xforms/lib.xsl
+++ b/misc/config_tools/xforms/lib.xsl
@@ -375,6 +375,9 @@
<xsl:when test="//@board = 'apl-up2'">
<func:result select="1" />
</xsl:when>
+ <xsl:when test="count(//HIDDEN_PDEV/text()) > 0">
+ <func:result select="count(//HIDDEN_PDEV/text())" />
+ </xsl:when>
<xsl:otherwise>
<func:result select="0" />
</xsl:otherwise>
--
2.25.1