From 649406b049e9269e141dcec09537d8246a87c58f Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Tue, 5 Mar 2019 11:21:54 +0800 Subject: [PATCH] HV: refine location of platform_acpi_info header platform_acpi_info.h should be BOARD specific so move the header file to configs/$(CONFIG_BOARD)/ folder. So the target acpi info file detect process is: Compiler search for $(CONFIG_BOARD)_acpi_info.h under hypervisor/arch/x86/$(CONFIG_BOARD)/ first (the file is supposed to be generated by offline tool so it is not included in original source), if found, then the file is the target acpi info file. If not and at the same time the ENFORCE_VALIDATED_ACPI_INFO Kconfig was set, the compiler will stop and hint user to add target acpi info file by offline tool. If ENFORCE_VALIDATED_ACPI_INFO was unset, then compiler will continue to search for platform_acpi_info.h as target acpi info file under hypervisor/arch/x86/$(CONFIG_BOARD) folder (with this file we could bypass ENFORCE_VALIDATED_ACPI_INFO check and benifit for development). If this file is not exist, then hypervisor/arch/x86/configs/platform_acpi_info.h will be included as final target acpi info. The process should work for UEFI path also, with a valid platform acpi info file, S3/S5 should work on UEFI platform. Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/Makefile | 13 ++- .../x86/configs/apl-mrb}/platform_acpi_info.h | 6 +- .../arch/x86/configs/platform_acpi_info.h | 83 +++++++++++++++++++ hypervisor/arch/x86/guest/pm.c | 1 + hypervisor/bsp/include/bsp_extern.h | 3 - .../bsp/include/uefi/platform_acpi_info.h | 21 ----- hypervisor/bsp/sbl/const_dmar.c | 1 + .../arch/x86}/default_acpi_info.h | 0 8 files changed, 98 insertions(+), 30 deletions(-) rename hypervisor/{bsp/include/sbl => arch/x86/configs/apl-mrb}/platform_acpi_info.h (91%) create mode 100644 hypervisor/arch/x86/configs/platform_acpi_info.h delete mode 100644 hypervisor/bsp/include/uefi/platform_acpi_info.h rename hypervisor/{bsp/include => include/arch/x86}/default_acpi_info.h (100%) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index ca5fecf51..3ff9bc821 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -231,7 +231,6 @@ INCLUDE_PATH += bsp/include/uefi C_SRCS += bsp/uefi/uefi.c C_SRCS += bsp/uefi/cmdline.c C_SRCS += boot/uefi/uefi_boot.c -TEMPLATE_ACPI_INFO_HEADER := bsp/include/uefi/platform_acpi_info.h else ifeq ($(CONFIG_PLATFORM_SBL),y) C_SRCS += bsp/sbl/sbl.c @@ -239,7 +238,6 @@ C_SRCS += bsp/sbl/const_dmar.c C_SRCS += boot/sbl/multiboot.c C_SRCS += boot/sbl/sbl_seed_parse.c C_SRCS += boot/sbl/abl_seed_parse.c -TEMPLATE_ACPI_INFO_HEADER := bsp/include/sbl/platform_acpi_info.h endif endif @@ -266,7 +264,9 @@ DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o') VERSION := $(HV_OBJDIR)/include/version.h # Create platform_acpi_info.h -SOURCE_ACPI_INFO_HEADER := bsp/include/$(CONFIG_BOARD)_acpi_info.h +TEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/platform_acpi_info.h +BOARDTEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/$(CONFIG_BOARD)/platform_acpi_info.h +SOURCE_ACPI_INFO_HEADER := arch/x86/configs/$(CONFIG_BOARD)/$(CONFIG_BOARD)_acpi_info.h TARGET_ACPI_INFO_HEADER := $(HV_OBJDIR)/include/platform_acpi_info.h $(TARGET_ACPI_INFO_HEADER): $(HV_OBJDIR)/$(HV_CONFIG) @@ -282,11 +282,16 @@ ifdef CONFIG_ENFORCE_VALIDATED_ACPI_INFO echo "If you want to build the hypervisor with the template ACPI info," && \ echo "unset ENFORCE_VALIDATED_ACPI_INFO using 'make menuconfig'." && \ false -else +else ifeq (,$(wildcard $(BOARDTEMPLATE_ACPI_INFO_HEADER))) @echo "" && \ echo "Using the template at $(TEMPLATE_ACPI_INFO_HEADER) instead" && \ echo "**********************************" @cp $(TEMPLATE_ACPI_INFO_HEADER) $(TARGET_ACPI_INFO_HEADER) +else + @echo "" && \ + echo "Using the template at $(BOARDTEMPLATE_ACPI_INFO_HEADER) instead" && \ + echo "**********************************" + @cp $(BOARDTEMPLATE_ACPI_INFO_HEADER) $(TARGET_ACPI_INFO_HEADER) endif else @cp $(SOURCE_ACPI_INFO_HEADER) $(TARGET_ACPI_INFO_HEADER) diff --git a/hypervisor/bsp/include/sbl/platform_acpi_info.h b/hypervisor/arch/x86/configs/apl-mrb/platform_acpi_info.h similarity index 91% rename from hypervisor/bsp/include/sbl/platform_acpi_info.h rename to hypervisor/arch/x86/configs/apl-mrb/platform_acpi_info.h index 9a73dc640..0e5c09f7b 100644 --- a/hypervisor/bsp/include/sbl/platform_acpi_info.h +++ b/hypervisor/arch/x86/configs/apl-mrb/platform_acpi_info.h @@ -4,8 +4,10 @@ * SPDX-License-Identifier: BSD-3-Clause */ -/* This is a template header file for platform ACPI info definition, - * we should use a user space tool running on target to generate this file. +/* This is a template header file for apl-mrb platform ACPI info definition, + * we should use a user space tool running on target to generate apl-mrb + * specific acpi info file named as apl-mrb_acpi_info.h + * and put it in hypervisor/arch/x86/configs/apl-mrb/. */ #ifndef PLATFORM_ACPI_INFO_H #define PLATFORM_ACPI_INFO_H diff --git a/hypervisor/arch/x86/configs/platform_acpi_info.h b/hypervisor/arch/x86/configs/platform_acpi_info.h new file mode 100644 index 000000000..619959dea --- /dev/null +++ b/hypervisor/arch/x86/configs/platform_acpi_info.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2018 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* This is a template header file for platform ACPI info definition, + * we should use a user space tool running on target to generate + * board specific acpi info file named as $(CONFIG_BOARD)_acpi_info.h + * and put it in hypervisor/arch/x86/configs/$(CONFIG_BOARD)/. + */ +#ifndef PLATFORM_ACPI_INFO_H +#define PLATFORM_ACPI_INFO_H + +/* pm sstate data */ +#define PM1A_EVT_ACCESS_SIZE 0U +#define PM1A_EVT_ADDRESS 0UL +#define PM1A_CNT_ADDRESS 0UL + +#define WAKE_VECTOR_32 0UL +#define WAKE_VECTOR_64 0UL + +/* DRHD of DMAR */ +#define DRHD_COUNT 0U + +#define DRHD0_DEV_CNT 0U +#define DRHD0_SEGMENT 0U +#define DRHD0_FLAGS 0U +#define DRHD0_REG_BASE 0UL +#define DRHD0_IGNORE false +#define DRHD0_DEVSCOPE0_BUS 0U +#define DRHD0_DEVSCOPE0_PATH 0U +#define DRHD0_DEVSCOPE1_BUS 0U +#define DRHD0_DEVSCOPE1_PATH 0U +#define DRHD0_DEVSCOPE2_BUS 0U +#define DRHD0_DEVSCOPE2_PATH 0U +#define DRHD0_DEVSCOPE3_BUS 0U +#define DRHD0_DEVSCOPE3_PATH 0U + +#define DRHD1_DEV_CNT 0U +#define DRHD1_SEGMENT 0U +#define DRHD1_FLAGS 0U +#define DRHD1_REG_BASE 0UL +#define DRHD1_IGNORE false +#define DRHD1_DEVSCOPE0_BUS 0U +#define DRHD1_DEVSCOPE0_PATH 0U +#define DRHD1_DEVSCOPE1_BUS 0U +#define DRHD1_DEVSCOPE1_PATH 0U +#define DRHD1_DEVSCOPE2_BUS 0U +#define DRHD1_DEVSCOPE2_PATH 0U +#define DRHD1_DEVSCOPE3_BUS 0U +#define DRHD1_DEVSCOPE3_PATH 0U +#define DRHD1_IOAPIC_ID 0U + +#define DRHD2_DEV_CNT 0U +#define DRHD2_SEGMENT 0U +#define DRHD2_FLAGS 0U +#define DRHD2_REG_BASE 0U +#define DRHD2_IGNORE false +#define DRHD2_DEVSCOPE0_BUS 0U +#define DRHD2_DEVSCOPE0_PATH 0U +#define DRHD2_DEVSCOPE1_BUS 0U +#define DRHD2_DEVSCOPE1_PATH 0U +#define DRHD2_DEVSCOPE2_BUS 0U +#define DRHD2_DEVSCOPE2_PATH 0U +#define DRHD2_DEVSCOPE3_BUS 0U +#define DRHD2_DEVSCOPE3_PATH 0U + +#define DRHD3_DEV_CNT 0U +#define DRHD3_SEGMENT 0U +#define DRHD3_FLAGS 0U +#define DRHD3_REG_BASE 0U +#define DRHD3_IGNORE false +#define DRHD3_DEVSCOPE0_BUS 0U +#define DRHD3_DEVSCOPE0_PATH 0U +#define DRHD3_DEVSCOPE1_BUS 0U +#define DRHD3_DEVSCOPE1_PATH 0U +#define DRHD3_DEVSCOPE2_BUS 0U +#define DRHD3_DEVSCOPE2_PATH 0U +#define DRHD3_DEVSCOPE3_BUS 0U +#define DRHD3_DEVSCOPE3_PATH 0U + +#endif /* PLATFORM_ACPI_INFO_H */ diff --git a/hypervisor/arch/x86/guest/pm.c b/hypervisor/arch/x86/guest/pm.c index d3f4367db..9a0c30959 100644 --- a/hypervisor/arch/x86/guest/pm.c +++ b/hypervisor/arch/x86/guest/pm.c @@ -9,6 +9,7 @@ #include #include #include +#include int32_t validate_pstate(const struct acrn_vm *vm, uint64_t perf_ctl) { diff --git a/hypervisor/bsp/include/bsp_extern.h b/hypervisor/bsp/include/bsp_extern.h index 674ec97a2..79235e533 100644 --- a/hypervisor/bsp/include/bsp_extern.h +++ b/hypervisor/bsp/include/bsp_extern.h @@ -18,9 +18,6 @@ #ifndef BSP_EXTERN_H #define BSP_EXTERN_H -#include "default_acpi_info.h" -#include "platform_acpi_info.h" - /* BSP Interfaces */ void init_bsp(void); uint64_t bsp_get_ap_trampoline(void); diff --git a/hypervisor/bsp/include/uefi/platform_acpi_info.h b/hypervisor/bsp/include/uefi/platform_acpi_info.h deleted file mode 100644 index 2e5baed8d..000000000 --- a/hypervisor/bsp/include/uefi/platform_acpi_info.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* This is a template header file for platform ACPI info definition, - * we should use a user space tool running on target to generate this file. - */ -#ifndef PLATFORM_ACPI_INFO_H -#define PLATFORM_ACPI_INFO_H - -/* pm sstate data */ -#define PM1A_EVT_ACCESS_SIZE 0U -#define PM1A_EVT_ADDRESS 0UL -#define PM1A_CNT_ADDRESS 0UL - -#define WAKE_VECTOR_32 0UL -#define WAKE_VECTOR_64 0UL - -#endif /* PLATFORM_ACPI_INFO_H */ diff --git a/hypervisor/bsp/sbl/const_dmar.c b/hypervisor/bsp/sbl/const_dmar.c index 392152fee..fd8259608 100644 --- a/hypervisor/bsp/sbl/const_dmar.c +++ b/hypervisor/bsp/sbl/const_dmar.c @@ -6,6 +6,7 @@ #include #include +#include #ifndef CONFIG_DMAR_PARSE_ENABLED diff --git a/hypervisor/bsp/include/default_acpi_info.h b/hypervisor/include/arch/x86/default_acpi_info.h similarity index 100% rename from hypervisor/bsp/include/default_acpi_info.h rename to hypervisor/include/arch/x86/default_acpi_info.h