dm: verify the "iasl" version

This patch does:
- define IASL_MIN_VER in the top-level Makefile and pass it Device Model
- verify the "iasl" version at run time
  if "iasl" version is older than IASL_MIN_VER, refuse to launch the
  post-launched VM and exit directly.

Tracked-On: #7880

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Shiqing Gao 2022-07-04 09:47:59 +08:00 committed by acrnsi-robot
parent cc309bd973
commit 59b6d7b404
5 changed files with 48 additions and 1 deletions

View File

@ -86,6 +86,7 @@ ASL_COMPILER ?= $(shell which iasl)
DPKG_BIN ?= $(shell which dpkg)
YARN_BIN ?= $(shell which yarn)
CARGO_BIN ?= $(shell which cargo)
IASL_MIN_VER = "20190703"
.PHONY: all hypervisor devicemodel tools life_mngr doc
all: hypervisor devicemodel tools
@ -132,7 +133,7 @@ hvapplydiffconfig:
@$(MAKE) applydiffconfig $(HV_MAKEOPTS) PATCH=$(abspath $(PATCH))
devicemodel: tools
$(MAKE) -C $(T)/devicemodel DM_OBJDIR=$(DM_OUT) DM_BUILD_VERSION=$(BUILD_VERSION) DM_BUILD_TAG=$(BUILD_TAG) TOOLS_OUT=$(TOOLS_OUT) RELEASE=$(RELEASE)
$(MAKE) -C $(T)/devicemodel DM_OBJDIR=$(DM_OUT) DM_BUILD_VERSION=$(BUILD_VERSION) DM_BUILD_TAG=$(BUILD_TAG) TOOLS_OUT=$(TOOLS_OUT) RELEASE=$(RELEASE) IASL_MIN_VER=$(IASL_MIN_VER)
tools:
mkdir -p $(TOOLS_OUT)

View File

@ -45,6 +45,8 @@ CFLAGS += -I$(SYSROOT)/usr/include/SDL2
CFLAGS += -I$(SYSROOT)/usr/include/EGL
CFLAGS += -I$(SYSROOT)/usr/include/GLES2
CFLAGS += -DIASL_MIN_VER=\"$(IASL_MIN_VER)\"
GCC_MAJOR=$(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1)
GCC_MINOR=$(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1)

View File

@ -1034,6 +1034,13 @@ main(int argc, char *argv[])
exit(1);
}
if (check_iasl_version() != 0) {
pr_err("Please install iasl tool with version >= %s from https://www.acpica.org/downloads, "
"and provide the path to iasl (by using --iasl) if it's not on the PATH \n",
IASL_MIN_VER);
exit(1);
}
argc -= optind;
argv += optind;

View File

@ -96,6 +96,9 @@
#define ASL_TEMPLATE "dm.XXXXXXX"
#define ASL_SUFFIX ".aml"
#define ASL_VER_PATTERN "ASL+ Optimizing Compiler/Disassembler version "
#define ASL_VER_STR_LEN 256
static char asl_compiler[MAXPATHLEN] = {0};
uint64_t audio_nhlt_len = 0;
@ -1150,6 +1153,39 @@ acrn_parse_iasl(char *arg)
return -1;
}
int
check_iasl_version(void)
{
int ret = -1;
static char cmd_iasl_ver[MAXPATHLEN + 10];
static char buf[ASL_VER_STR_LEN];
char *ver_str, *cp;
uint32_t ver, min_ver;
snprintf(cmd_iasl_ver, sizeof(cmd_iasl_ver),
"%s -v", asl_compiler);
FILE *fd_iasl_ver = popen(cmd_iasl_ver, "r");
if (fd_iasl_ver != NULL)
{
while (fgets(buf, ASL_VER_STR_LEN, fd_iasl_ver) != NULL) {
if (strstr(buf, ASL_VER_PATTERN)) {
ver_str = buf + strlen(ASL_VER_PATTERN);
pr_info("iasl version: %s", ver_str);
if ((!dm_strtoui(ver_str, &cp, 10, &ver)) &&
(!dm_strtoui(IASL_MIN_VER, &cp, 10, &min_ver)) &&
(ver >= min_ver)) {
ret = 0;
}
}
}
pclose(fd_iasl_ver);
}
return ret;
}
int
get_iasl_compiler(void)
{

View File

@ -123,5 +123,6 @@ int lapic_to_pcpu(int lapic);
int parse_madt(void);
int acrn_parse_iasl(char *arg);
int get_iasl_compiler(void);
int check_iasl_version(void);
#endif /* _ACPI_H_ */