diff --git a/misc/config_tools/launch_config/launch_cfg_gen.py b/misc/config_tools/launch_config/launch_cfg_gen.py
index e0ccca1c0..910b2e6df 100755
--- a/misc/config_tools/launch_config/launch_cfg_gen.py
+++ b/misc/config_tools/launch_config/launch_cfg_gen.py
@@ -55,6 +55,10 @@ class LaunchScript:
next_vbdf = self._free_slots.pop(0)
return next_vbdf
+ def remove_virtual_bdf(self, slot):
+ if slot in self._free_slots:
+ self._free_slots.remove(slot)
+
class PassThruDeviceOptions:
passthru_device_options = {
"0x0200": [".//PTM[text()='y']", "enable_ptm"], # Ethernet controller, added if PTM is enabled for the VM
@@ -165,6 +169,8 @@ class LaunchScript:
if vbdf is None:
vbdf = self._vbdf_allocator.get_virtual_bdf()
+ else:
+ self._vbdf_allocator.remove_virtual_bdf(vbdf)
self.add_dynamic_dm_parameter("add_virtual_device", f"{vbdf} {kind} {options}")
def add_passthru_device(self, bus, dev, fun, options=""):
@@ -253,6 +259,9 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id
# Emulated PCI devices
script.add_virtual_device("hostbridge", vbdf="0:0")
+ #ivshmem and vuart must be the first virtual devices generated before the others except hostbridge and LPC
+ #ivshmem and vuart own reserved slots which setting by user
+
for ivshmem in eval_xpath_all(vm_scenario_etree, f"//IVSHMEM_REGION[PROVIDED_BY = 'Device Model' and .//VM_NAME = '{vm_name}']"):
script.add_virtual_device("ivshmem", options=f"dm:/{ivshmem.find('NAME').text},{ivshmem.find('IVSHMEM_SIZE').text}")
@@ -262,9 +271,14 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id
if eval_xpath(vm_scenario_etree, ".//console_vuart/text()") == "PCI":
script.add_virtual_device("uart", options="vuart_idx:0")
- for idx, conn in enumerate(eval_xpath_all(hv_scenario_etree, f".//vuart_connection[endpoint/vm_name = '{vm_name}']"), start=1):
- if eval_xpath(conn, "./type/text()") == "pci":
- script.add_virtual_device("uart", options=f"vuart_idx:{idx}")
+ for idx, conn in enumerate(eval_xpath_all(hv_scenario_etree, f"//vuart_connection[endpoint/vm_name/text() = '{vm_name}']"), start=1):
+ if eval_xpath(conn, f"./type/text()") == "pci":
+ vbdf = eval_xpath(conn, f"./endpoint[vm_name/text() = '{vm_name}']/vbdf/text()")
+ if vbdf is not None:
+ slot = int((vbdf.split(":")[1].split(".")[0]), 16)
+ else:
+ slot = None
+ script.add_virtual_device("uart", slot, options=f"vuart_idx:{idx}")
# Mediated PCI devices, including virtio
for usb_xhci in eval_xpath_all(vm_scenario_etree, ".//usb_xhci/usb_dev[text() != '']/text()"):
diff --git a/misc/config_tools/static_allocators/gpa.py b/misc/config_tools/static_allocators/gpa.py
index d0ac4a515..726457a36 100644
--- a/misc/config_tools/static_allocators/gpa.py
+++ b/misc/config_tools/static_allocators/gpa.py
@@ -109,15 +109,20 @@ class AddrWindow(namedtuple(
return False
return True
-def insert_vuart_to_dev_dict(scenario_etree, devdict_32bits):
+def insert_vuart_to_dev_dict(scenario_etree, vm_id, devdict_32bits):
+
console_vuart = scenario_etree.xpath(f"./console_vuart[base != 'INVALID_PCI_BASE']/@id")
- communication_vuarts = scenario_etree.xpath(f".//communication_vuart[base != 'INVALID_PCI_BASE']/@id")
for vuart_id in console_vuart:
devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE
devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE
- for vuart_id in communication_vuarts:
- devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE
- devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE
+
+ vm_name = common.get_node(f"//vm[@id = '{vm_id}']/name/text()", scenario_etree)
+ communication_vuarts = scenario_etree.xpath(f"//vuart_connection[endpoint/vm_name/text() = '{vm_name}']")
+ for vuart_id, vuart in enumerate(communication_vuarts, start=1):
+ connection_type = common.get_node(f"./type/text()", vuart)
+ if connection_type == "pci":
+ devdict_32bits[(f"{VUART}_{vuart_id}", "bar0")] = PCI_VUART_VBAR0_SIZE
+ devdict_32bits[(f"{VUART}_{vuart_id}", "bar1")] = PCI_VUART_VBAR1_SIZE
def insert_legacy_vuart_to_dev_dict(vm_node, devdict_io_port):
legacy_vuart = vm_node.xpath(f".//legacy_vuart[base = 'CONFIG_COM_BASE']/@id")
@@ -409,7 +414,7 @@ def allocate_pci_bar(board_etree, scenario_etree, allocation_etree):
devdict_32bits = {}
devdict_64bits = {}
- insert_vuart_to_dev_dict(vm_node, devdict_32bits)
+ insert_vuart_to_dev_dict(scenario_etree, vm_id, devdict_32bits)
insert_ivsheme_to_dev_dict(scenario_etree, devdict_32bits, devdict_64bits, vm_id)
insert_pt_devs_to_dev_dict(board_etree, vm_node, devdict_32bits, devdict_64bits)
diff --git a/misc/config_tools/xforms/lib.xsl b/misc/config_tools/xforms/lib.xsl
index 0e28f89f1..615961a16 100644
--- a/misc/config_tools/xforms/lib.xsl
+++ b/misc/config_tools/xforms/lib.xsl
@@ -331,8 +331,13 @@
+
-
+
+
+
+
+
diff --git a/misc/config_tools/xforms/pci_dev.c.xsl b/misc/config_tools/xforms/pci_dev.c.xsl
index de654b5e1..fdc274b97 100644
--- a/misc/config_tools/xforms/pci_dev.c.xsl
+++ b/misc/config_tools/xforms/pci_dev.c.xsl
@@ -46,7 +46,7 @@
-
+
@@ -95,32 +95,55 @@
-
-
-
-
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
},
-
+
+
diff --git a/misc/config_tools/xforms/vm_configurations.c.xsl b/misc/config_tools/xforms/vm_configurations.c.xsl
index 2a6ea08d0..bb2c3e29d 100644
--- a/misc/config_tools/xforms/vm_configurations.c.xsl
+++ b/misc/config_tools/xforms/vm_configurations.c.xsl
@@ -296,42 +296,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
},