From 3f0fae81b2ff2ca8524f1869dc7843e2461b41a4 Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Mon, 4 Jul 2022 13:53:36 +0800 Subject: [PATCH] config_tools: use ASL_COMPILER as the path to the "iasl" compiler At build time (on the *dev* machine), config_tools depends on "iasl" to generate the binary of ACPI tables for pre-launched VMs. This patch does: - pass ASL_COMPILER to config_tools By default, ASL_COMPILER is initialized by "which iasl" at build time. User could override it by specifying ASL_COMPILER as the build option, like below: make BOARD=xxxx SCENARIO=yyyy ASL_COMPILER=/usr/local/bin/iasl - use ASL_COMPILER as the path to the "iasl" compiler in config_tools v1 -> v2: - add a check to make sure ASL_COMPILER is initialized to a value Tracked-On: #7880 Signed-off-by: Shiqing Gao Reviewed-by: Wang, Yu1 --- Makefile | 2 +- hypervisor/Makefile | 11 +++++++++-- misc/config_tools/acpi_gen/bin_gen.py | 16 +++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 1e263b77c..833919fb6 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) +HV_MAKEOPTS := -C $(T)/hypervisor BOARD=$(BOARD) SCENARIO=$(SCENARIO) HV_OBJDIR=$(HV_OUT) RELEASE=$(RELEASE) ASL_COMPILER=$(ASL_COMPILER) board_inspector: @if [ -x "$(DPKG_BIN)" ]; then \ diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 25d43b0e7..d5436c825 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -11,6 +11,7 @@ GCC_MINOR=$(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) #enable stack overflow check STACK_PROTECTOR := 1 +ASL_COMPILER ?= $(shell which iasl) BASEDIR := $(shell pwd) HV_OBJDIR ?= $(CURDIR)/build HV_MODDIR ?= $(HV_OBJDIR)/modules @@ -397,7 +398,7 @@ VERSION := $(HV_OBJDIR)/include/version.h PRE_BUILD_DIR := ../misc/hv_prebuild .PHONY: all -all: pre_build $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin +all: env_check pre_build $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin install: $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin install -D $(HV_OBJDIR)/$(HV_FILE).32.out $(DESTDIR)$(libdir)/acrn/$(HV_FILE).$(BOARD).$(SCENARIO).32.out @@ -413,13 +414,19 @@ install-debug: $(HV_OBJDIR)/$(HV_FILE).map $(HV_OBJDIR)/$(HV_FILE).out install -D $(HV_OBJDIR)/$(HV_FILE).out $(DESTDIR)$(libdir)/acrn/$(HV_FILE).$(BOARD).$(SCENARIO).out install -D $(HV_OBJDIR)/$(HV_FILE).map $(DESTDIR)$(libdir)/acrn/$(HV_FILE).$(BOARD).$(SCENARIO).map +.PHONY: env_check +env_check: +ifndef ASL_COMPILER +$(error Please either install "iasl" or provide the path to "iasl" by using the ASL_COMPILER variable) +endif + .PHONY: pre_build pre_build: $(HV_CONFIG_H) $(HV_CONFIG_TIMESTAMP) @echo "Start pre-build static check ..." $(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) + 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) @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 08d719be2..049872e36 100644 --- a/misc/config_tools/acpi_gen/bin_gen.py +++ b/misc/config_tools/acpi_gen/bin_gen.py @@ -46,7 +46,7 @@ def move_rtct_ssram_and_bin_entries(rtct, new_base_addr, new_area_max_size): rtct.header.checksum = 0 rtct.header.checksum = 0 - sum(bytes(rtct)) -def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree): +def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree, iasl_path): ''' compile asl code of ACPI table to aml code. :param dest_vm_acpi_path: the path of the asl code of ACPI tables @@ -61,7 +61,7 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocat for acpi_table in ACPI_TABLE_LIST: if acpi_table[0] == 'tpm2.asl': if 'tpm2.asl' in os.listdir(dest_vm_acpi_path): - rc = exec_command('iasl {}'.format(acpi_table[0])) + rc = exec_command('{} {}'.format(iasl_path, acpi_table[0])) if rc == 0 and os.path.isfile(os.path.join(dest_vm_acpi_path, acpi_table[1])): shutil.move(os.path.join(dest_vm_acpi_path, acpi_table[1]), os.path.join(dest_vm_acpi_bin_path, acpi_table[1])) @@ -86,7 +86,7 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocat fp.close() else: if acpi_table[0].endswith(".asl"): - rc = exec_command('iasl {}'.format(acpi_table[0])) + rc = exec_command('{} {}'.format(iasl_path, acpi_table[0])) if rc == 0 and os.path.isfile(os.path.join(dest_vm_acpi_path, acpi_table[1])): shutil.move(os.path.join(dest_vm_acpi_path, acpi_table[1]), os.path.join(dest_vm_acpi_bin_path, acpi_table[1])) @@ -218,7 +218,7 @@ def exec_command(cmd): return rc -def check_iasl(): +def check_iasl(iasl_path): ''' check iasl installed :return: True if iasl installed. @@ -226,7 +226,7 @@ def check_iasl(): try: p_version = 'ASL+ Optimizing Compiler/Disassembler version' min_version = 20190703 - output = subprocess.check_output(['iasl', '-v']).decode('utf8') + output = subprocess.check_output([iasl_path, '-v']).decode('utf8') if p_version in output: try: for line in output.split('\n'): @@ -269,7 +269,7 @@ def main(args): if os.path.isdir(DEST_ACPI_BIN_PATH): shutil.rmtree(DEST_ACPI_BIN_PATH) - if not check_iasl(): + if not check_iasl(args.iasl_path): print("Please install iasl tool with version >= 20190703 from https://www.acpica.org/downloads before ACPI generation.") return 1 @@ -279,7 +279,7 @@ def main(args): dest_vm_acpi_path = os.path.join(DEST_ACPI_PATH, config) dest_vm_acpi_bin_path = os.path.join(DEST_ACPI_BIN_PATH, config) os.makedirs(dest_vm_acpi_bin_path) - if asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree): + if asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree, args.iasl_path): return 1 aml_to_bin(dest_vm_acpi_path, dest_vm_acpi_bin_path, config+'.bin', board_etree, scenario_etree, allocation_etree) @@ -287,11 +287,13 @@ 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]" "[ --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("--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/")