ACRN:DM: Check the alignment of mem_size

Now the memory region is aligned down to 2M if 2M hugetlb is supported.
Maybe some contents are dropped if it is not aligned. 

Tracked-On: #7210

Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
This commit is contained in:
Zhao Yakui 2022-04-01 10:56:46 +08:00 committed by acrnsi-robot
parent 9a4cb33f39
commit 3bf11d9285
1 changed files with 9 additions and 0 deletions

View File

@ -42,6 +42,8 @@
extern char *vmname;
#define ALIGN_CHECK(x, align) (((x) & ((align)-1)) ? 1 : 0)
#define HUGETLB_LV1 0
#define HUGETLB_LV2 1
#define HUGETLB_LV_MAX 2
@ -718,6 +720,13 @@ int hugetlb_setup_memory(struct vmctx *ctx)
}
}
if (ALIGN_CHECK(ctx->lowmem, hugetlb_priv[HUGETLB_LV1].pg_size) ||
ALIGN_CHECK(ctx->highmem, hugetlb_priv[HUGETLB_LV1].pg_size) ||
ALIGN_CHECK(ctx->biosmem, hugetlb_priv[HUGETLB_LV1].pg_size) ||
ALIGN_CHECK(ctx->fbmem, hugetlb_priv[HUGETLB_LV1].pg_size)) {
pr_err("Memory size is not aligned to 2M.\n");
goto err;
}
/* all memory should be at least aligned with
* hugetlb_priv[HUGETLB_LV1].pg_size */
ctx->lowmem =