diff --git a/misc/acrn-config/board_config/board_info_h.py b/misc/acrn-config/board_config/board_info_h.py
index 028be65d3..525a62ae6 100644
--- a/misc/acrn-config/board_config/board_info_h.py
+++ b/misc/acrn-config/board_config/board_info_h.py
@@ -5,6 +5,7 @@
import common
import board_cfg_lib
+import scenario_cfg_lib
BOARD_INFO_DEFINE="""#ifndef BOARD_INFO_H
#define BOARD_INFO_H
@@ -90,4 +91,10 @@ def generate_file(config):
# generate HI_MMIO_START/HI_MMIO_END
find_hi_mmio_window(config)
+ if (common.VM_TYPES.get(0) is not None and
+ scenario_cfg_lib.VM_DB[common.VM_TYPES[0]]['load_type'] == "PRE_LAUNCHED_VM"
+ and board_cfg_lib.is_p2sb_passthru_possible()):
+ print("", file=config)
+ print("#define P2SB_BAR_ADDR\t\t\t0x{:X}UL".format(board_cfg_lib.find_p2sb_bar_addr()), file=config)
+
print(BOARD_INFO_ENDIF, file=config)
diff --git a/misc/acrn-config/library/board_cfg_lib.py b/misc/acrn-config/library/board_cfg_lib.py
index 921a0fe0b..506528267 100644
--- a/misc/acrn-config/library/board_cfg_lib.py
+++ b/misc/acrn-config/library/board_cfg_lib.py
@@ -39,6 +39,8 @@ KNOWN_CAPS_PCI_DEVS_DB = {
"TSN":TSN_DEVS,
}
+P2SB_PASSTHRU_BOARD = ('ehl-crb-b')
+
def get_info(board_info, msg_s, msg_e):
"""
Get information which specify by argument
@@ -680,3 +682,36 @@ def get_ram_range():
continue
return ram_range
+
+
+def is_p2sb_passthru_possible():
+
+ p2sb_passthru = False
+ (_, board) = common.get_board_name()
+ if board in P2SB_PASSTHRU_BOARD:
+ p2sb_passthru = True
+
+ return p2sb_passthru
+
+
+def is_matched_board(boardlist):
+
+ (_, board) = common.get_board_name()
+
+ return board in boardlist
+
+
+def find_p2sb_bar_addr():
+ if not is_matched_board(('ehl-crb-b')):
+ common.print_red('find_p2sb_bar_addr() can only be called for board ehl-crb-b', err=True)
+ sys.exit(1)
+
+ iomem_lines = get_info(common.BOARD_INFO_FILE, "", "")
+
+ for line in iomem_lines:
+ if 'INTC1020:' in line:
+ start_addr = int(line.split('-')[0], 16) & 0xFF000000
+ return start_addr
+
+ common.print_red('p2sb device is not found in board file %s!\n' % common.BOARD_INFO_FILE, err=True)
+ sys.exit(1)
diff --git a/misc/acrn-config/library/common.py b/misc/acrn-config/library/common.py
index 70f4d526f..b770e6265 100644
--- a/misc/acrn-config/library/common.py
+++ b/misc/acrn-config/library/common.py
@@ -526,3 +526,25 @@ def get_avl_dev_info(bdf_desc_map, pci_sub_class):
tmp_pci_desc.append(pci_desc_value.strip())
return tmp_pci_desc
+
+
+def str2bool(v):
+ return v.lower() in ("yes", "true", "t", "y", "1") if v else False
+
+
+def get_leaf_tag_map_bool(config_file, branch_tag, tag_str=''):
+ """
+ This convert and return map's value from string to bool
+ """
+
+ result = {}
+
+ tag_map = get_leaf_tag_map(config_file, branch_tag, tag_str)
+ for vm_i, s in tag_map.items():
+ result[vm_i] = str2bool(s)
+
+ return result
+
+
+def hpa2gpa(vm_id, hpa, size):
+ return hpa
diff --git a/misc/acrn-config/library/scenario_cfg_lib.py b/misc/acrn-config/library/scenario_cfg_lib.py
index ba2df8449..4ec646ac9 100644
--- a/misc/acrn-config/library/scenario_cfg_lib.py
+++ b/misc/acrn-config/library/scenario_cfg_lib.py
@@ -798,3 +798,24 @@ def share_mem_check(shmem_regions, raw_shmem_regions, vm_type_info, prime_item,
or (2 in bar_attr_dic.keys() and int(bar_attr_dic[2].addr, 16) < 0x100000000):
ERR_LIST[key] = "Failed to get the start address of the shared memory, please check the size of it."
return
+
+
+def check_p2sb(enable_p2sb):
+
+ for vm_i,p2sb in enable_p2sb.items():
+ if vm_i != 0:
+ key = "vm:id={},p2sb".format(vm_i)
+ ERR_LIST[key] = "Can only specify p2sb passthru for VM0"
+ return
+
+ if p2sb and not VM_DB[common.VM_TYPES[0]]['load_type'] == "PRE_LAUNCHED_VM":
+ ERR_LIST["vm:id=0,p2sb"] = "p2sb passthru can only be enabled for Pre-launched VM"
+ return
+
+ if p2sb and not board_cfg_lib.is_p2sb_passthru_possible():
+ ERR_LIST["vm:id=0,p2sb"] = "p2sb passthru is not allowed for this board"
+ return
+
+ if p2sb and board_cfg_lib.is_tpm_passthru():
+ ERR_LIST["vm:id=0,p2sb"] = "Cannot enable p2sb and tpm passthru at the same time"
+ return
diff --git a/misc/acrn-config/scenario_config/scenario_cfg_gen.py b/misc/acrn-config/scenario_config/scenario_cfg_gen.py
index f3adba141..b01d4d585 100755
--- a/misc/acrn-config/scenario_config/scenario_cfg_gen.py
+++ b/misc/acrn-config/scenario_config/scenario_cfg_gen.py
@@ -52,6 +52,7 @@ def get_scenario_item_values(board_info, scenario_info):
scenario_item_values["vm,clos,vcpu_clos"] = hw_info.get_clos_val()
scenario_item_values["vm,pci_devs"] = scenario_cfg_lib.avl_pci_devs()
scenario_item_values["vm,os_config,kern_type"] = scenario_cfg_lib.KERN_TYPE_LIST
+ scenario_item_values["vm,mmio_resources,p2sb"] = hv_cfg_lib.N_Y
scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
# board
diff --git a/misc/acrn-config/scenario_config/scenario_item.py b/misc/acrn-config/scenario_config/scenario_item.py
index 174989ad1..737a11b2e 100644
--- a/misc/acrn-config/scenario_config/scenario_item.py
+++ b/misc/acrn-config/scenario_config/scenario_item.py
@@ -272,6 +272,29 @@ class LoadOrderNum:
self.sos_vm = scenario_cfg_lib.get_load_vm_cnt(load_vm, "SOS_VM")
self.post_vm = scenario_cfg_lib.get_load_vm_cnt(load_vm, "POST_LAUNCHED_VM")
+
+class MmioResourcesInfo:
+ """ This is Abstract of class of mmio resource setting information """
+ p2sb = False
+
+ def __init__(self, scenario_file):
+ self.scenario_info = scenario_file
+
+ def get_info(self):
+ """
+ Get all items which belong to this class
+ :return: None
+ """
+ self.p2sb = common.get_leaf_tag_map_bool(self.scenario_info, "mmio_resources", "p2sb")
+
+ def check_item(self):
+ """
+ Check all items in this class
+ :return: None
+ """
+ scenario_cfg_lib.check_p2sb(self.p2sb)
+
+
class VmInfo:
""" This is Abstract of class of VM setting """
name = {}
@@ -292,6 +315,8 @@ class VmInfo:
self.cfg_pci = CfgPci(self.scenario_info)
self.load_order_cnt = LoadOrderNum()
self.shmem = ShareMem(self.scenario_info)
+ self.mmio_resource_info = MmioResourcesInfo(self.scenario_info)
+
def get_info(self):
"""
@@ -313,6 +338,7 @@ class VmInfo:
self.vuart.get_info()
self.cfg_pci.get_info()
self.load_order_cnt.get_info(self.load_vm)
+ self.mmio_resource_info.get_info()
def set_ivshmem(self, ivshmem_regions):
"""
@@ -352,4 +378,5 @@ class VmInfo:
self.cfg_pci.check_item()
self.vuart.check_item()
self.shmem.check_items()
+ self.mmio_resource_info.check_item()
scenario_cfg_lib.ERR_LIST.update(err_dic)
diff --git a/misc/acrn-config/scenario_config/vm_configurations_c.py b/misc/acrn-config/scenario_config/vm_configurations_c.py
index 94cfd9f3e..3f17b34e9 100644
--- a/misc/acrn-config/scenario_config/vm_configurations_c.py
+++ b/misc/acrn-config/scenario_config/vm_configurations_c.py
@@ -357,6 +357,19 @@ def gen_pre_launch_vm(vm_type, vm_i, scenario_items, config):
print("\t\t\t.size = VM0_TPM_BUFFER_SIZE,", file=config)
print("\t\t},", file=config)
print("#endif", file=config)
+
+ if (vm_i == 0 and vm_info.mmio_resource_info.p2sb.get(vm_i) is not None
+ and vm_info.mmio_resource_info.p2sb[vm_i]):
+ print("#ifdef P2SB_BAR_ADDR", file=config)
+ print("\t\t.pt_p2sb_bar = true,", file=config)
+ print("\t\t.mmiodevs[0] = {", file=config)
+ gpa = common.hpa2gpa(0, board_cfg_lib.find_p2sb_bar_addr(), 0x1000000)
+ print("\t\t\t.base_gpa = 0x{:X}UL,".format(gpa), file=config)
+ print("\t\t\t.base_hpa = P2SB_BAR_ADDR,", file=config)
+ print("\t\t\t.size = 0x1000000UL,", file=config)
+ print("\t\t},", file=config)
+ print("#endif", file=config)
+
print("\t},", file=config)
diff --git a/misc/vm_configs/scenarios/hybrid/vm_configurations.c b/misc/vm_configs/scenarios/hybrid/vm_configurations.c
index 4d2dfff86..8bdc77757 100644
--- a/misc/vm_configs/scenarios/hybrid/vm_configurations.c
+++ b/misc/vm_configs/scenarios/hybrid/vm_configurations.c
@@ -38,6 +38,14 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
.t_vuart.vm_id = 1U,
.t_vuart.vuart_id = 1U,
},
+#ifdef P2SB_BAR_ADDR
+ .pt_p2sb_bar = true,
+ .mmiodevs[0] = {
+ .base_gpa = 0xFD000000UL,
+ .base_hpa = P2SB_BAR_ADDR,
+ .size = 0x1000000UL,
+ },
+#endif
},
{ /* VM1 */
CONFIG_SOS_VM,
diff --git a/misc/vm_configs/xmls/config-xmls/ehl-crb-b/hybrid.xml b/misc/vm_configs/xmls/config-xmls/ehl-crb-b/hybrid.xml
index 9fbd8560c..61b92e63e 100644
--- a/misc/vm_configs/xmls/config-xmls/ehl-crb-b/hybrid.xml
+++ b/misc/vm_configs/xmls/config-xmls/ehl-crb-b/hybrid.xml
@@ -77,6 +77,9 @@
3
+
+ n
+
0