diff --git a/misc/config_tools/library/common.py b/misc/config_tools/library/common.py index 2f17201ab..fc00d71b0 100644 --- a/misc/config_tools/library/common.py +++ b/misc/config_tools/library/common.py @@ -17,6 +17,7 @@ ACRN_CONFIG_TARGET = '' SOURCE_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../') HV_LICENSE_FILE = SOURCE_ROOT_DIR + 'misc/config_tools/library/hypervisor_license' SCENARIO_SCHEMA_FILE = SOURCE_ROOT_DIR + 'misc/config_tools/schema/config.xsd' +DATACHECK_SCHEMA_FILE = SOURCE_ROOT_DIR + 'misc/config_tools/schema/datachecks.xsd' PY_CACHES = ["__pycache__", "../board_config/__pycache__", "../scenario_config/__pycache__"] diff --git a/misc/config_tools/scenario_config/scenario_cfg_gen.py b/misc/config_tools/scenario_config/scenario_cfg_gen.py index 937cbc7ac..875d34979 100755 --- a/misc/config_tools/scenario_config/scenario_cfg_gen.py +++ b/misc/config_tools/scenario_config/scenario_cfg_gen.py @@ -24,6 +24,11 @@ import board_defconfig from hv_item import HvInfo import asl_gen +try: + import xmlschema +except ImportError: + pass + ACRN_PATH = common.SOURCE_ROOT_DIR ACRN_CONFIG_DEF = ACRN_PATH + 'misc/config_tools/data/' GEN_FILE = ["vm_configurations.h", "vm_configurations.c", "pci_dev.c", ".config", "ivshmem_cfg.h", "pt_intx.c"] @@ -97,10 +102,6 @@ def validate_scenario_schema(scenario_info): :param xsd_doc: scenario schema :param scenario_info: scenario file """ - try: - import xmlschema - except ImportError: - return """ XMLSchema does not process XInclude. @@ -129,13 +130,36 @@ def validate_scenario_schema(scenario_info): reason = validation_error.reason + ": last call: " + str(validation_error.obj) scenario_cfg_lib.ERR_LIST[key] = element + reason +def apply_data_checks(board_info, scenario_info): + xsd_doc = etree.parse(common.DATACHECK_SCHEMA_FILE) + xsd_doc.xinclude() + datachecks_schema = xmlschema.XMLSchema11(etree.tostring(xsd_doc, encoding="unicode")) + main_etree = etree.parse(board_info) + scenario_etree = etree.parse(scenario_info) + main_etree.getroot().extend(scenario_etree.getroot()[:]) + # FIXME: Figure out proper error keys for data check failures + error_key = "" + + it = datachecks_schema.iter_errors(main_etree) + for idx, error in enumerate(it, start=1): + anno = error.validator.annotation + description = anno.documentation[0].text + severity = anno.elem.get("{https://projectacrn.org}severity") + + if severity == "error": + if error_key in scenario_cfg_lib.ERR_LIST.keys(): + scenario_cfg_lib.ERR_LIST[error_key].append("\n" + description) + else: + scenario_cfg_lib.ERR_LIST[error_key] = description def validate_scenario_setting(board_info, scenario_info): hv_cfg_lib.ERR_LIST = {} scenario_cfg_lib.ERR_LIST = {} - validate_scenario_schema(scenario_info) + if "xmlschema" in sys.modules.keys(): + validate_scenario_schema(scenario_info) + apply_data_checks(board_info, scenario_info) """ Validate settings in scenario xml diff --git a/misc/config_tools/schema/checks/pre_launched_vm_support.xsd b/misc/config_tools/schema/checks/pre_launched_vm_support.xsd new file mode 100644 index 000000000..c7c7b7bdb --- /dev/null +++ b/misc/config_tools/schema/checks/pre_launched_vm_support.xsd @@ -0,0 +1,39 @@ + + + + + + The physical CPUs allocated to VMs shall exist on the target board. + +This assertion checks that the physical CPUs that are explicitly allocated to VMs do exist on the target board. Failures +in meeting this assertion may cause the following. + +- The hypervisor may access wrong per CPU regions, leading to random memory corruption. +- A VM may failed wake (by sending INIT-SIPI-SIPI IPIs) all the vCPUs allocated to it. + +To fix this error, you can + +- In the board XML, check whether all physical CPUs are encoded under the processors/ node. When generating the board + XML on the target board, make sure the native OS has not make any CPU offline. +- In the scenario XML, check whether the allocated CPUs are specified using consecutive integers starting from 0, not + their APIC IDs or x2APIC IDs. + + + + + + The physical CPUs allocated to the same VM shall have the same core types. + +On platforms having both big and little cores, the current design of ACRN only allows allocating the same type of cores +to a pre-launched VM. + +To fix this error, double check the allocation of physical CPUs to each pre-launched VM and ensure that only big cores +or little cores are assigned, but not both. + + + + diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd new file mode 100644 index 000000000..cf093191d --- /dev/null +++ b/misc/config_tools/schema/datachecks.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +