diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 0ea9a59f5..cdc45a0b5 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -77,6 +77,7 @@ INCLUDE_PATH += include/common INCLUDE_PATH += bsp/include INCLUDE_PATH += bsp/$(PLATFORM)/include/bsp INCLUDE_PATH += boot/include +INCLUDE_PATH += $(HV_OBJDIR)/include CC ?= gcc AS ?= as @@ -180,7 +181,7 @@ DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o') VERSION := bsp/$(PLATFORM)/include/bsp/version.h .PHONY: all -all: $(BUILD_DEPS) $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin +all: $(BUILD_DEPS) $(VERSION) oldconfig $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin rm -f $(VERSION) ifeq ($(PLATFORM), uefi) @@ -247,11 +248,10 @@ $(VERSION): echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$(USER)"\""" >> $(VERSION) -$(HV_OBJDIR)/%.o: %.c +$(HV_OBJDIR)/%.o: %.c $(HV_OBJDIR)/$(HV_CONFIG_H) [ ! -e $@ ] && mkdir -p $(dir $@); \ $(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -c $(CFLAGS) $(ARCH_CFLAGS) $< -o $@ -$(HV_OBJDIR)/%.o: %.S +$(HV_OBJDIR)/%.o: %.S $(HV_OBJDIR)/$(HV_CONFIG_H) [ ! -e $@ ] && mkdir -p $(dir $@); \ $(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. $(ASFLAGS) $(ARCH_ASFLAGS) -c $< -o $@ - diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 001c3bab6..d61d439ae 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -424,7 +424,7 @@ void bsp_boot_init(void) load_gdtr_and_tr(); /* Switch to run-time stack */ - CPU_SP_WRITE(&get_cpu_var(stack)[STACK_SIZE - 1]); + CPU_SP_WRITE(&get_cpu_var(stack)[CONFIG_STACK_SIZE - 1]); #ifdef STACK_PROTECTOR set_fs_base(); @@ -456,8 +456,8 @@ void bsp_boot_init(void) calibrate_tsc(); /* Enable logging */ - init_logmsg(LOG_BUF_SIZE, - LOG_DESTINATION); + init_logmsg(CONFIG_LOG_BUF_SIZE, + CONFIG_LOG_DESTINATION); if (HV_RC_VERSION) pr_acrnlog("HV version %d.%d-rc%d-%s-%s %s build by %s, start time %lluus", @@ -556,7 +556,7 @@ void cpu_secondary_init(void) __bitmap_set(get_cpu_id(), &pcpu_active_bitmap); /* Switch to run-time stack */ - CPU_SP_WRITE(&get_cpu_var(stack)[STACK_SIZE - 1]); + CPU_SP_WRITE(&get_cpu_var(stack)[CONFIG_STACK_SIZE - 1]); #ifdef STACK_PROTECTOR set_fs_base(); @@ -654,7 +654,7 @@ void start_cpus() /* Wait until global count is equal to expected CPU up count or * configured time-out has expired */ - timeout = CPU_UP_TIMEOUT * 1000; + timeout = CONFIG_CPU_UP_TIMEOUT * 1000; while ((up_count != expected_up) && (timeout != 0)) { /* Delay 10us */ udelay(10); @@ -679,7 +679,7 @@ void stop_cpus() int i; uint32_t timeout, expected_up; - timeout = CPU_UP_TIMEOUT * 1000; + timeout = CONFIG_CPU_UP_TIMEOUT * 1000; for (i = 0; i < phy_cpu_num; i++) { if (get_cpu_id() == i) /* avoid offline itself */ continue; diff --git a/hypervisor/arch/x86/gdt.c b/hypervisor/arch/x86/gdt.c index 72c667218..eaad23904 100644 --- a/hypervisor/arch/x86/gdt.c +++ b/hypervisor/arch/x86/gdt.c @@ -34,9 +34,9 @@ void load_gdtr_and_tr(void) /* ring 0 data sel descriptor */ gdt->host_gdt_data_descriptor.value = 0x00cf93000000ffff; - tss->ist1 = (uint64_t)get_cpu_var(mc_stack) + STACK_SIZE; - tss->ist2 = (uint64_t)get_cpu_var(df_stack) + STACK_SIZE; - tss->ist3 = (uint64_t)get_cpu_var(sf_stack) + STACK_SIZE; + tss->ist1 = (uint64_t)get_cpu_var(mc_stack) + CONFIG_STACK_SIZE; + tss->ist2 = (uint64_t)get_cpu_var(df_stack) + CONFIG_STACK_SIZE; + tss->ist3 = (uint64_t)get_cpu_var(sf_stack) + CONFIG_STACK_SIZE; tss->ist4 = 0L; /* tss descriptor */ diff --git a/hypervisor/arch/x86/ioapic.c b/hypervisor/arch/x86/ioapic.c index 9d4ae9feb..18ea5b0b9 100644 --- a/hypervisor/arch/x86/ioapic.c +++ b/hypervisor/arch/x86/ioapic.c @@ -304,7 +304,7 @@ void setup_ioapic_irq(void) spinlock_init(&ioapic_lock); - for (ioapic_id = 0, gsi = 0; ioapic_id < NR_IOAPICS; ioapic_id++) { + for (ioapic_id = 0, gsi = 0; ioapic_id < CONFIG_NR_IOAPICS; ioapic_id++) { int pin; int max_pins; int version; diff --git a/hypervisor/boot/dmar_parse.c b/hypervisor/boot/dmar_parse.c index a7b4b4919..4767dce7e 100644 --- a/hypervisor/boot/dmar_parse.c +++ b/hypervisor/boot/dmar_parse.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: BSD-3-Clause */ -#include "bsp_cfg.h" + #ifdef CONFIG_DMAR_PARSE_ENABLED #include #include "vtd.h" diff --git a/hypervisor/bsp/ld/link_ram.ld.in b/hypervisor/bsp/ld/link_ram.ld.in index 5c58a5fd9..83348f447 100644 --- a/hypervisor/bsp/ld/link_ram.ld.in +++ b/hypervisor/bsp/ld/link_ram.ld.in @@ -1,4 +1,4 @@ -#include "bsp_cfg.h" +#include "config.h" ENTRY(cpu_primary_start_32) @@ -83,4 +83,3 @@ SECTIONS _ld_ram_size = LENGTH(ram) ; _ld_ram_end = _ld_ram_size + _ld_ram_start ; } - diff --git a/hypervisor/bsp/uefi/efi/Makefile b/hypervisor/bsp/uefi/efi/Makefile index abf149aae..ac74f6a95 100644 --- a/hypervisor/bsp/uefi/efi/Makefile +++ b/hypervisor/bsp/uefi/efi/Makefile @@ -36,7 +36,7 @@ HV_FILE:=acrn EFI_OBJDIR:=$(HV_OBJDIR)/bsp/uefi/efi C_SRCS = boot.c pe.c malloc.c ACRN_OBJS := $(patsubst %.c,$(EFI_OBJDIR)/%.o,$(C_SRCS)) -INCLUDE_PATH += ../include/bsp/ +INCLUDE_PATH += $(HV_OBJDIR)/include OBJCOPY=objcopy @@ -68,7 +68,8 @@ endif CFLAGS=-I. -I.. -I$(INCDIR)/efi -I$(INCDIR)/efi/$(ARCH) \ -DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \ - -Wall -I../fs/ -D$(ARCH) -O2 + -Wall -I../fs/ -D$(ARCH) -O2 \ + -include config.h CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-80387 -mno-fp-ret-in-387 @@ -107,11 +108,11 @@ install-conf: $(CONF_FILE) clean: rm -f $(BOOT) $(HV_OBJDIR)/$(HV_FILE).efi $(EFI_OBJDIR)/boot.so $(ACRN_OBJS) $(FS) -$(EFI_OBJDIR)/%.o:%.S +$(EFI_OBJDIR)/%.o:%.S $(HV_OBJDIR)/$(HV_CONFIG_H) [ ! -e $@ ] && mkdir -p $(dir $@); \ $(CC) $(CFLAGS) -c -o $@ $< -$(EFI_OBJDIR)/%.o: %.c +$(EFI_OBJDIR)/%.o: %.c $(HV_OBJDIR)/$(HV_CONFIG_H) [ ! -e $@ ] && mkdir -p $(dir $@); \ $(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -c $(CFLAGS) $(ARCH_CFLAGS) $< -o $@ diff --git a/hypervisor/bsp/uefi/efi/boot.c b/hypervisor/bsp/uefi/efi/boot.c index ba5e26cc8..e4ffe3f3c 100644 --- a/hypervisor/bsp/uefi/efi/boot.c +++ b/hypervisor/bsp/uefi/efi/boot.c @@ -380,7 +380,7 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *_table) /* * If we reach this point, it means we did not receive a specific * bootloader name to be used. Fall back to the default bootloader - * as specified in bsp_cfg.h + * as specified in config.h */ bootloader_name = ch8_2_ch16(CONFIG_UEFI_OS_LOADER_NAME); } @@ -454,4 +454,3 @@ failed: return exit(image, err, ERROR_STRING_LENGTH, error_buf); } - diff --git a/hypervisor/bsp/uefi/efi/boot.h b/hypervisor/bsp/uefi/efi/boot.h index 2968a4c84..abd307a59 100644 --- a/hypervisor/bsp/uefi/efi/boot.h +++ b/hypervisor/bsp/uefi/efi/boot.h @@ -34,7 +34,6 @@ #ifndef __ACRNBOOT_H__ #define __ACRNBOOT_H__ -#include #include "multiboot.h" #define E820_RAM 1 @@ -182,4 +181,3 @@ msr_read(uint32_t reg_num) } #endif - diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c index eabeef27c..9cdbd008e 100644 --- a/hypervisor/common/schedule.c +++ b/hypervisor/common/schedule.c @@ -169,7 +169,7 @@ static void switch_to(struct vcpu *curr) * reset stack pointer here. Otherwise, schedule * is recursive call and stack will overflow finally. */ - uint64_t cur_sp = (uint64_t)&get_cpu_var(stack)[STACK_SIZE]; + uint64_t cur_sp = (uint64_t)&get_cpu_var(stack)[CONFIG_STACK_SIZE]; if (curr == NULL) { asm volatile ("movq %1, %%rsp\n" diff --git a/hypervisor/debug/dump.c b/hypervisor/debug/dump.c index 4f9f91cb6..7da5c19d7 100644 --- a/hypervisor/debug/dump.c +++ b/hypervisor/debug/dump.c @@ -238,7 +238,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint32_t cpu_id) printf("Host Call Trace:\r\n"); if (rsp > - (uint64_t)&per_cpu(stack, cpu_id)[STACK_SIZE - 1] + (uint64_t)&per_cpu(stack, cpu_id)[CONFIG_STACK_SIZE - 1] || rsp < (uint64_t)&per_cpu(stack, cpu_id)[0]) { return; } @@ -257,7 +257,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint32_t cpu_id) * if the address is invalid, it will cause hv page fault * then halt system */ while ((rbp <= - (uint64_t)&per_cpu(stack, cpu_id)[STACK_SIZE - 1]) + (uint64_t)&per_cpu(stack, cpu_id)[CONFIG_STACK_SIZE - 1]) && (rbp >= (uint64_t)&per_cpu(stack, cpu_id)[0]) && (cb_hierarchy++ < CALL_TRACE_HIERARCHY_MAX)) { printf("----> 0x%016llx\r\n", diff --git a/hypervisor/debug/shell_internal.c b/hypervisor/debug/shell_internal.c index 0c366829e..6cf3ffd8c 100644 --- a/hypervisor/debug/shell_internal.c +++ b/hypervisor/debug/shell_internal.c @@ -30,11 +30,11 @@ /* The initial log level*/ uint32_t console_loglevel; uint32_t mem_loglevel; -#ifdef CONSOLE_LOGLEVEL_DEFAULT -uint32_t console_loglevel = CONSOLE_LOGLEVEL_DEFAULT; +#ifdef CONFIG_CONSOLE_LOGLEVEL_DEFAULT +uint32_t console_loglevel = CONFIG_CONSOLE_LOGLEVEL_DEFAULT; #endif -#ifdef MEM_LOGLEVEL_DEFAULT -uint32_t mem_loglevel = MEM_LOGLEVEL_DEFAULT; +#ifdef CONFIG_MEM_LOGLEVEL_DEFAULT +uint32_t mem_loglevel = CONFIG_MEM_LOGLEVEL_DEFAULT; #endif static int string_to_argv(char *argv_str, void *p_argv_mem, diff --git a/hypervisor/include/arch/x86/ioapic.h b/hypervisor/include/arch/x86/ioapic.h index 4d738090e..aa2990234 100644 --- a/hypervisor/include/arch/x86/ioapic.h +++ b/hypervisor/include/arch/x86/ioapic.h @@ -13,7 +13,7 @@ #define IOAPIC_MAX_LINES 120 #define NR_LEGACY_IRQ 16 #define NR_LEGACY_PIN NR_LEGACY_IRQ -#define NR_MAX_GSI (NR_IOAPICS*IOAPIC_MAX_LINES) +#define NR_MAX_GSI (CONFIG_NR_IOAPICS*IOAPIC_MAX_LINES) #define GSI_MASK_IRQ(irq) irq_gsi_mask_unmask((irq), true) #define GSI_UNMASK_IRQ(irq) irq_gsi_mask_unmask((irq), false) diff --git a/hypervisor/include/arch/x86/per_cpu.h b/hypervisor/include/arch/x86/per_cpu.h index f6a88746a..44d25fa76 100644 --- a/hypervisor/include/arch/x86/per_cpu.h +++ b/hypervisor/include/arch/x86/per_cpu.h @@ -32,10 +32,10 @@ struct per_cpu_region { struct host_gdt gdt; struct tss_64 tss; int state; - uint8_t mc_stack[STACK_SIZE] __aligned(16); - uint8_t df_stack[STACK_SIZE] __aligned(16); - uint8_t sf_stack[STACK_SIZE] __aligned(16); - uint8_t stack[STACK_SIZE] __aligned(16); + uint8_t mc_stack[CONFIG_STACK_SIZE] __aligned(16); + uint8_t df_stack[CONFIG_STACK_SIZE] __aligned(16); + uint8_t sf_stack[CONFIG_STACK_SIZE] __aligned(16); + uint8_t stack[CONFIG_STACK_SIZE] __aligned(16); char logbuf[LOG_MESSAGE_MAX_SIZE]; uint8_t lapic_id; } __aligned(CPU_PAGE_SIZE); //per_cpu_region size aligned with CPU_PAGE_SIZE diff --git a/hypervisor/include/hypervisor.h b/hypervisor/include/hypervisor.h index fde338c57..8e3d042f8 100644 --- a/hypervisor/include/hypervisor.h +++ b/hypervisor/include/hypervisor.h @@ -12,8 +12,7 @@ * * DESCRIPTION * - * This file includes config header file "bsp_cfg.h" and other - * hypervisor used header files. + * This file includes hypervisor used header files. * It should be included in all the source files. * * @@ -23,7 +22,6 @@ /* Include config header file containing config options */ #include -#include "bsp_cfg.h" #include "acrn_common.h" #include #include diff --git a/hypervisor/lib/memory.c b/hypervisor/lib/memory.c index e095c5a70..92df2461a 100644 --- a/hypervisor/lib/memory.c +++ b/hypervisor/lib/memory.c @@ -6,14 +6,15 @@ #include /************************************************************************/ -/* Memory pool declaration (block size = MALLOC_ALIGN) */ +/* Memory pool declaration (block size = CONFIG_MALLOC_ALIGN) */ /************************************************************************/ #define __bss_noinit __attribute__((__section__(".bss_noinit"))) -static uint8_t __bss_noinit Malloc_Heap[HEAP_SIZE] __aligned(MALLOC_ALIGN); +static uint8_t __bss_noinit +Malloc_Heap[CONFIG_HEAP_SIZE] __aligned(CONFIG_MALLOC_ALIGN); -#define MALLOC_HEAP_BUFF_SIZE MALLOC_ALIGN -#define MALLOC_HEAP_TOTAL_BUFF (HEAP_SIZE/MALLOC_HEAP_BUFF_SIZE) +#define MALLOC_HEAP_BUFF_SIZE CONFIG_MALLOC_ALIGN +#define MALLOC_HEAP_TOTAL_BUFF (CONFIG_HEAP_SIZE/MALLOC_HEAP_BUFF_SIZE) #define MALLOC_HEAP_BITMAP_SIZE \ INT_DIV_ROUNDUP(MALLOC_HEAP_TOTAL_BUFF, BITMAP_WORD_SIZE) static uint32_t Malloc_Heap_Bitmap[MALLOC_HEAP_BITMAP_SIZE]; @@ -22,7 +23,7 @@ static uint32_t Malloc_Heap_Contiguity_Bitmap[MALLOC_HEAP_BITMAP_SIZE]; struct mem_pool Memory_Pool = { .start_addr = Malloc_Heap, .spinlock = {.head = 0, .tail = 0}, - .size = HEAP_SIZE, + .size = CONFIG_HEAP_SIZE, .buff_size = MALLOC_HEAP_BUFF_SIZE, .total_buffs = MALLOC_HEAP_TOTAL_BUFF, .bmp_size = MALLOC_HEAP_BITMAP_SIZE, @@ -34,10 +35,10 @@ struct mem_pool Memory_Pool = { /* Memory pool declaration (block size = CPU_PAGE_SIZE) */ /************************************************************************/ static uint8_t __bss_noinit -Paging_Heap[NUM_ALLOC_PAGES][CPU_PAGE_SIZE] __aligned(CPU_PAGE_SIZE); +Paging_Heap[CONFIG_NUM_ALLOC_PAGES][CPU_PAGE_SIZE] __aligned(CPU_PAGE_SIZE); #define PAGING_HEAP_BUFF_SIZE CPU_PAGE_SIZE -#define PAGING_HEAP_TOTAL_BUFF NUM_ALLOC_PAGES +#define PAGING_HEAP_TOTAL_BUFF CONFIG_NUM_ALLOC_PAGES #define PAGING_HEAP_BITMAP_SIZE \ INT_DIV_ROUNDUP(PAGING_HEAP_TOTAL_BUFF, BITMAP_WORD_SIZE) static uint32_t Paging_Heap_Bitmap[PAGING_HEAP_BITMAP_SIZE]; @@ -46,7 +47,7 @@ static uint32_t Paging_Heap_Contiguity_Bitmap[MALLOC_HEAP_BITMAP_SIZE]; struct mem_pool Paging_Memory_Pool = { .start_addr = Paging_Heap, .spinlock = {.head = 0, .tail = 0}, - .size = NUM_ALLOC_PAGES * CPU_PAGE_SIZE, + .size = CONFIG_NUM_ALLOC_PAGES * CPU_PAGE_SIZE, .buff_size = PAGING_HEAP_BUFF_SIZE, .total_buffs = PAGING_HEAP_TOTAL_BUFF, .bmp_size = PAGING_HEAP_BITMAP_SIZE, diff --git a/hypervisor/scripts/kconfig/kconfig.mk b/hypervisor/scripts/kconfig/kconfig.mk index 392db2e39..69a619686 100644 --- a/hypervisor/scripts/kconfig/kconfig.mk +++ b/hypervisor/scripts/kconfig/kconfig.mk @@ -46,3 +46,5 @@ minimalconfig: $(HV_OBJDIR)/$(HV_CONFIG) @python $(KCONFIG_DIR)/minimalconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) $(HV_OBJDIR)/$(HV_DEFCONFIG) -include $(HV_OBJDIR)/$(HV_CONFIG_MK) + +CFLAGS += -include $(HV_OBJDIR)/$(HV_CONFIG_H)