From 659e5420df406bd6b16d524892a6807294f299a5 Mon Sep 17 00:00:00 2001 From: Zide Chen Date: Wed, 26 Feb 2020 15:51:16 -0800 Subject: [PATCH] hv: add static check for CONFIG_HV_RAM_START and CONFIG_HV_RAM_SIZE Hypervisor uses 2MB large page, and if either CONFIG_HV_RAM_START or CONFIG_HV_RAM_SIZE is not aligned to 2MB, ACRN won't boot. Add static check to avoid unexpected boot failures. If CONFIG_RELOC is enabled, CONFIG_HV_RAM_START is not directly referred by the code, but it causes problems because ld_text_end could be relocated to an address that is not 2MB aligned which fails mmu_modify_or_del(). Tracked-On: #4441 Reviewed-by: Yin Fengwei Signed-off-by: Zide Chen --- hypervisor/pre_build/static_checks.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hypervisor/pre_build/static_checks.c b/hypervisor/pre_build/static_checks.c index 373bb9c4f..950df9957 100644 --- a/hypervisor/pre_build/static_checks.c +++ b/hypervisor/pre_build/static_checks.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define CAT__(A,B) A ## B @@ -20,6 +21,14 @@ typedef int32_t CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1] #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 + /* Build time sanity checks to make sure hard-coded offset * is matching the actual offset! */