mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-01 20:05:30 +00:00
acrn-config: add support for P2SB bridge passthrough
This patch is to support direct assignment of P2SB bridge to one pre-launched VM for EHL. User can configure this per-VM attribute in scenario xml: <mmio_resources desc="MMIO resources."> <p2sb>y</p2sb> </mmio_resources> Set p2sb to y to passthru P2SB bridge to VM, and n otherwise. Tracked-On: #5221 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
This commit is contained in:
parent
10d4773f1d
commit
01c66eb4b3
@ -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)
|
||||
|
@ -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, "<IOMEM_INFO>", "</IOMEM_INFO>")
|
||||
|
||||
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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -77,6 +77,9 @@
|
||||
<cpu_affinity desc="List of pCPU that this VM's vCPUs are pinned to.">
|
||||
<pcpu_id>3</pcpu_id>
|
||||
</cpu_affinity>
|
||||
<mmio_resources desc="MMIO resources.">
|
||||
<p2sb>n</p2sb>
|
||||
</mmio_resources>
|
||||
<clos desc="Class of Service for Cache Allocation Technology. Please refer SDM 17.19.2 for details and use with caution.">
|
||||
<vcpu_clos>0</vcpu_clos>
|
||||
</clos>
|
||||
|
Loading…
Reference in New Issue
Block a user