mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
HV: move vm configuration check to pre-build time
This patch will move the VM configuration check to pre-build stage, a test program will do the check for pre-defined VM configuration data before making hypervisor binary. If test failed, the make process will be aborted. So once the hypervisor binary is built successfully or start to run, it means the VM configuration has been sanitized. The patch did not add any new VM configuration check function, it just port the original sanitize_vm_config() function from cpu.c to static_checks.c with below change: 1. remove runtime rdt detection for clos check; 2. replace pr_err() from logmsg.h with printf() from stdio.h; 3. replace runtime call get_pcpu_nums() in ALL_CPUS_MASK macro with static defined MAX_PCPU_NUM; 4. remove cpu_affinity check since pre-launched VM might share pcpu with SOS VM; The BOARD/SCENARIO parameter check and configuration folder check is also moved to prebuild Makefile. Tracked-On: #5077 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -166,6 +166,8 @@ INCLUDE_PATH += $(BOARD_INFO_DIR)
|
||||
INCLUDE_PATH += $(BOARD_CFG_DIR)
|
||||
INCLUDE_PATH += $(SCENARIO_CFG_DIR)
|
||||
|
||||
override INCLUDE_PATH := $(realpath $(INCLUDE_PATH))
|
||||
|
||||
CC ?= gcc
|
||||
AS ?= as
|
||||
AR ?= ar
|
||||
@@ -352,8 +354,6 @@ endif
|
||||
ifneq ($(FIRMWARE),uefi)
|
||||
CFLAGS += -DCONFIG_LAST_LEVEL_EPT_AT_BOOT
|
||||
endif
|
||||
PRE_BUILD_SRCS += pre_build/static_checks.c
|
||||
PRE_BUILD_OBJS := $(patsubst %.c,$(HV_OBJDIR)/%.o,$(PRE_BUILD_SRCS))
|
||||
|
||||
MODULES += $(LIB_MOD)
|
||||
MODULES += $(BOOT_MOD)
|
||||
@@ -376,6 +376,8 @@ MODULES += $(SYS_INIT_MOD)
|
||||
DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o')
|
||||
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
|
||||
|
||||
@@ -388,7 +390,10 @@ install-debug: $(HV_OBJDIR)/$(HV_FILE).map $(HV_OBJDIR)/$(HV_FILE).out
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).map $(DESTDIR)$(libdir)/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO).map
|
||||
|
||||
.PHONY: pre_build
|
||||
pre_build: $(PRE_BUILD_OBJS)
|
||||
pre_build: $(HV_OBJDIR)/$(HV_CONFIG_H)
|
||||
@echo "Start pre-build static check ..."
|
||||
$(MAKE) -C $(PRE_BUILD_DIR) BOARD=$(BOARD) SCENARIO=$(SCENARIO) TARGET_DIR=$(TARGET_DIR)
|
||||
@$(HV_OBJDIR)/hv_prebuild_check.out
|
||||
|
||||
.PHONY: header
|
||||
header: $(VERSION) $(HV_OBJDIR)/$(HV_CONFIG_H)
|
||||
@@ -467,19 +472,6 @@ distclean:
|
||||
|
||||
PHONY: (VERSION)
|
||||
$(VERSION): $(HV_OBJDIR)/$(HV_CONFIG_H)
|
||||
@if [ "$(SCENARIO)" = "" ]; then echo "Please specify SCENARIO for the build!"; exit 1; fi;
|
||||
@if [ "$(BOARD)" = "" ]; then echo "Please specify BOARD for the build!"; exit 1; fi;
|
||||
@echo "SCENARIO <$(SCENARIO)> for BOARD <$(BOARD)> is specified."
|
||||
@if [ ! -d $(BOARD_CFG_DIR) ]; then \
|
||||
echo "Configurations for BOARD $(BOARD) is not found."; exit 1; \
|
||||
else \
|
||||
echo "Found BOARD configurations under $(BOARD_CFG_DIR)"; \
|
||||
fi;
|
||||
@if [ ! -d $(SCENARIO_CFG_DIR) ]; then \
|
||||
echo "Configurations for SCENARIO $(SCENARIO) is not found."; exit 1; \
|
||||
else \
|
||||
echo "Found SCENARIO configurations under $(SCENARIO_CFG_DIR)"; \
|
||||
fi;
|
||||
touch $(VERSION)
|
||||
@COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\
|
||||
DIRTY=`git diff-index --name-only HEAD`;\
|
||||
|
@@ -23,7 +23,7 @@ uint8_t get_vm_severity(uint16_t vm_id)
|
||||
return vm_configs[vm_id].severity;
|
||||
}
|
||||
|
||||
static inline bool uuid_is_equal(const uint8_t *uuid1, const uint8_t *uuid2)
|
||||
bool uuid_is_equal(const uint8_t *uuid1, const uint8_t *uuid2)
|
||||
{
|
||||
uint64_t uuid1_h = *(const uint64_t *)uuid1;
|
||||
uint64_t uuid1_l = *(const uint64_t *)(uuid1 + 8);
|
||||
|
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <util.h>
|
||||
#include <boot_context.h>
|
||||
#include <acrn_common.h>
|
||||
#include <vcpu.h>
|
||||
#include <mmu.h>
|
||||
#include <trusty.h>
|
||||
|
||||
#define CAT__(A,B) A ## B
|
||||
#define CAT_(A,B) CAT__(A,B)
|
||||
#define CTASSERT(expr) \
|
||||
typedef int32_t CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]
|
||||
|
||||
/* This is to make sure the 16 bits vpid won't overflow */
|
||||
#if ((CONFIG_MAX_VM_NUM * MAX_VCPUS_PER_VM) > 0xffffU)
|
||||
#error "VM number or VCPU number are too big"
|
||||
#endif
|
||||
|
||||
#if ((CONFIG_HV_RAM_START & (MEM_2M - 1UL)) != 0UL)
|
||||
#error "CONFIG_HV_RAM_START must be aligned to 2MB"
|
||||
#endif
|
||||
|
||||
#if ((CONFIG_HV_RAM_SIZE & (MEM_2M - 1UL)) != 0UL)
|
||||
#error "CONFIG_HV_RAM_SIZE must be integral multiple of 2MB"
|
||||
#endif
|
||||
|
||||
#if ((CONFIG_MAX_IR_ENTRIES < 256U) || (CONFIG_MAX_IR_ENTRIES & (CONFIG_MAX_IR_ENTRIES -1)) != 0U)
|
||||
#error "CONFIG_MAX_IR_ENTRIES must >=256 and be 2^n"
|
||||
#endif
|
||||
|
||||
/* Build time sanity checks to make sure hard-coded offset
|
||||
* is matching the actual offset!
|
||||
*/
|
||||
CTASSERT(BOOT_CTX_CR0_OFFSET == offsetof(struct acrn_vcpu_regs, cr0));
|
||||
CTASSERT(BOOT_CTX_CR3_OFFSET == offsetof(struct acrn_vcpu_regs, cr3));
|
||||
CTASSERT(BOOT_CTX_CR4_OFFSET == offsetof(struct acrn_vcpu_regs, cr4));
|
||||
CTASSERT(BOOT_CTX_IDT_OFFSET == offsetof(struct acrn_vcpu_regs, idt));
|
||||
CTASSERT(BOOT_CTX_GDT_OFFSET == offsetof(struct acrn_vcpu_regs, gdt));
|
||||
CTASSERT(BOOT_CTX_LDT_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, ldt_sel));
|
||||
CTASSERT(BOOT_CTX_TR_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, tr_sel));
|
||||
CTASSERT(BOOT_CTX_CS_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, cs_sel));
|
||||
CTASSERT(BOOT_CTX_SS_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, ss_sel));
|
||||
CTASSERT(BOOT_CTX_DS_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, ds_sel));
|
||||
CTASSERT(BOOT_CTX_ES_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, es_sel));
|
||||
CTASSERT(BOOT_CTX_FS_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, fs_sel));
|
||||
CTASSERT(BOOT_CTX_GS_SEL_OFFSET == offsetof(struct acrn_vcpu_regs, gs_sel));
|
||||
CTASSERT(BOOT_CTX_CS_AR_OFFSET == offsetof(struct acrn_vcpu_regs, cs_ar));
|
||||
CTASSERT(BOOT_CTX_EFER_LOW_OFFSET == offsetof(struct acrn_vcpu_regs, ia32_efer));
|
||||
CTASSERT(BOOT_CTX_EFER_HIGH_OFFSET == offsetof(struct acrn_vcpu_regs, ia32_efer) + 4);
|
||||
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RAX == offsetof(struct acrn_gp_regs, rax));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RBX == offsetof(struct acrn_gp_regs, rbx));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RCX == offsetof(struct acrn_gp_regs, rcx));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RDX == offsetof(struct acrn_gp_regs, rdx));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RBP == offsetof(struct acrn_gp_regs, rbp));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RSI == offsetof(struct acrn_gp_regs, rsi));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RDI == offsetof(struct acrn_gp_regs, rdi));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R8 == offsetof(struct acrn_gp_regs, r8));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R9 == offsetof(struct acrn_gp_regs, r9));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R10 == offsetof(struct acrn_gp_regs, r10));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R11 == offsetof(struct acrn_gp_regs, r11));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R12 == offsetof(struct acrn_gp_regs, r12));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R13 == offsetof(struct acrn_gp_regs, r13));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R14 == offsetof(struct acrn_gp_regs, r14));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_R15 == offsetof(struct acrn_gp_regs, r15));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_CR2 == offsetof(struct run_context, cr2));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_IA32_SPEC_CTRL
|
||||
== offsetof(struct run_context, ia32_spec_ctrl));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_RFLAGS == offsetof(struct run_context, rflags));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_CR3 - CPU_CONTEXT_OFFSET_EXTCTX_START
|
||||
== offsetof(struct ext_context, cr3));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_IDTR - CPU_CONTEXT_OFFSET_EXTCTX_START
|
||||
== offsetof(struct ext_context, idtr));
|
||||
CTASSERT(CPU_CONTEXT_OFFSET_LDTR - CPU_CONTEXT_OFFSET_EXTCTX_START
|
||||
== offsetof(struct ext_context, ldtr));
|
||||
CTASSERT((sizeof(struct trusty_startup_param)
|
||||
+ sizeof(struct trusty_key_info)) < 0x1000U);
|
||||
CTASSERT(NR_WORLD == 2);
|
||||
CTASSERT(sizeof(struct vhm_request) == (4096U/VHM_REQUEST_MAX));
|
Reference in New Issue
Block a user