From 3eb1237db34e2f72b9516f8f0eb76dcfc2d1d735 Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Mon, 4 Jul 2022 15:07:28 +0800 Subject: [PATCH] config_tools: verify "iasl" version against IASL_MIN_VER To avoid hardcoding the minimum "iasl" version in multiple places, IASL_MIN_VER is defined in the top-level Makefile and is passed to config_tools. This patch verifies "iasl" version against IASL_MIN_VER directly in config_tools. Tracked-On: #7880 Signed-off-by: Shiqing Gao Reviewed-by: Wang, Yu1 --- Makefile | 2 +- hypervisor/Makefile | 3 ++- misc/config_tools/acpi_gen/bin_gen.py | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 833919fb6..253840528 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ all: hypervisor devicemodel tools python3 misc/packaging/gen_acrn_deb.py acrn_all $(ROOT_OUT) --version=$(FULL_VERSION) --board_name="$$DEB_BOARD" --scenario="$$DEB_SCENARIO"; \ fi -HV_MAKEOPTS := -C $(T)/hypervisor BOARD=$(BOARD) SCENARIO=$(SCENARIO) HV_OBJDIR=$(HV_OUT) RELEASE=$(RELEASE) ASL_COMPILER=$(ASL_COMPILER) +HV_MAKEOPTS := -C $(T)/hypervisor BOARD=$(BOARD) SCENARIO=$(SCENARIO) HV_OBJDIR=$(HV_OUT) RELEASE=$(RELEASE) ASL_COMPILER=$(ASL_COMPILER) IASL_MIN_VER=$(IASL_MIN_VER) board_inspector: @if [ -x "$(DPKG_BIN)" ]; then \ diff --git a/hypervisor/Makefile b/hypervisor/Makefile index d5436c825..bd45b539f 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -12,6 +12,7 @@ GCC_MINOR=$(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) STACK_PROTECTOR := 1 ASL_COMPILER ?= $(shell which iasl) +IASL_MIN_VER ?= "20190703" BASEDIR := $(shell pwd) HV_OBJDIR ?= $(CURDIR)/build HV_MODDIR ?= $(HV_OBJDIR)/modules @@ -426,7 +427,7 @@ pre_build: $(HV_CONFIG_H) $(HV_CONFIG_TIMESTAMP) $(MAKE) -C $(PRE_BUILD_DIR) BOARD=$(BOARD) SCENARIO=$(SCENARIO) TARGET_DIR=$(HV_CONFIG_DIR) @$(HV_OBJDIR)/hv_prebuild_check.out @echo "generate the binary of ACPI tables for pre-launched VMs ..." - python3 ../misc/config_tools/acpi_gen/bin_gen.py --board $(HV_OBJDIR)/.board.xml --scenario $(HV_OBJDIR)/.scenario.xml --asl $(HV_CONFIG_DIR) --out $(HV_OBJDIR) --iasl_path $(ASL_COMPILER) + python3 ../misc/config_tools/acpi_gen/bin_gen.py --board $(HV_OBJDIR)/.board.xml --scenario $(HV_OBJDIR)/.scenario.xml --asl $(HV_CONFIG_DIR) --out $(HV_OBJDIR) --iasl_path $(ASL_COMPILER) --iasl_min_ver $(IASL_MIN_VER) @echo "generate the serial configuration file for service VM ..." python3 ../misc/config_tools/service_vm_config/serial_config.py --allocation $(HV_OBJDIR)/configs/allocation.xml --scenario $(HV_OBJDIR)/.scenario.xml --out $(HV_OBJDIR)/serial.conf diff --git a/misc/config_tools/acpi_gen/bin_gen.py b/misc/config_tools/acpi_gen/bin_gen.py index 049872e36..9e9f7c46c 100644 --- a/misc/config_tools/acpi_gen/bin_gen.py +++ b/misc/config_tools/acpi_gen/bin_gen.py @@ -218,20 +218,21 @@ def exec_command(cmd): return rc -def check_iasl(iasl_path): +def check_iasl(iasl_path, iasl_min_ver): ''' check iasl installed :return: True if iasl installed. ''' try: p_version = 'ASL+ Optimizing Compiler/Disassembler version' - min_version = 20190703 + min_version = int(iasl_min_ver) output = subprocess.check_output([iasl_path, '-v']).decode('utf8') if p_version in output: try: for line in output.split('\n'): if line.find(p_version) >= 0: version = int(line.split(p_version)[1].strip()) + print('iasl version is {}'.format(version)) if version >= min_version: return True except: @@ -269,8 +270,9 @@ def main(args): if os.path.isdir(DEST_ACPI_BIN_PATH): shutil.rmtree(DEST_ACPI_BIN_PATH) - if not check_iasl(args.iasl_path): - print("Please install iasl tool with version >= 20190703 from https://www.acpica.org/downloads before ACPI generation.") + if not check_iasl(args.iasl_path, args.iasl_min_ver): + print('Please install iasl tool with version >= {} from https://www.acpica.org/downloads ' + 'before ACPI generation.'.format(args.iasl_min_ver)) return 1 for config in os.listdir(DEST_ACPI_PATH): @@ -288,12 +290,14 @@ def main(args): if __name__ == '__main__': parser = argparse.ArgumentParser(usage="python3 bin_gen.py --board [board] --scenario [scenario]" " --iasl_path [the path to the iasl compiler]" + " --iasl_min_ver [the minimum iasl version]" "[ --out [output dir of acpi ASL code]]", description="the tool to generate ACPI binary for Pre-launched VMs") parser.add_argument("--board", required=True, help="the XML file summarizing characteristics of the target board") parser.add_argument("--scenario", required=True, help="the XML file specifying the scenario to be set up") parser.add_argument("--asl", default=None, help="the input folder to store the ACPI ASL code. ") parser.add_argument("--iasl_path", default=None, help="the path to the iasl compiler.") + parser.add_argument("--iasl_min_ver", default=None, help="the minimum iasl version.") parser.add_argument("--out", default=None, help="the output folder to store the ACPI binary code. " "If not specified, the path for the binary code is" "build/hypervisor/acpi/")