Skip to content

Commit 659e542

Browse files
ZideChen0wenlingz
authored andcommitted
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 <fengwei.yin@intel.com> Signed-off-by: Zide Chen <zide.chen@intel.com>
1 parent 696f6c7 commit 659e542

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

hypervisor/pre_build/static_checks.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <boot_context.h>
99
#include <acrn_common.h>
1010
#include <vcpu.h>
11+
#include <mmu.h>
1112
#include <trusty.h>
1213

1314
#define CAT__(A,B) A ## B
@@ -20,6 +21,14 @@ typedef int32_t CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]
2021
#error "VM number or VCPU number are too big"
2122
#endif
2223

24+
#if ((CONFIG_HV_RAM_START & (MEM_2M - 1UL)) != 0UL)
25+
#error "CONFIG_HV_RAM_START must be aligned to 2MB"
26+
#endif
27+
28+
#if ((CONFIG_HV_RAM_SIZE & (MEM_2M - 1UL)) != 0UL)
29+
#error "CONFIG_HV_RAM_SIZE must be integral multiple of 2MB"
30+
#endif
31+
2332
/* Build time sanity checks to make sure hard-coded offset
2433
* is matching the actual offset!
2534
*/

0 commit comments

Comments
 (0)