Check if the huge page size is expected when enabling HPA.

This commit is contained in:
Qi Wang 2024-03-28 16:04:56 -07:00 committed by Qi Wang
parent cd05b19f10
commit 3383b98f1b
2 changed files with 29 additions and 7 deletions

View file

@ -27,6 +27,14 @@ extern size_t os_page;
#define HUGEPAGE ((size_t)(1U << LG_HUGEPAGE))
#define HUGEPAGE_MASK ((size_t)(HUGEPAGE - 1))
/*
* Used to validate that the hugepage size is not unexpectedly high. The huge
* page features (HPA, metadata_thp) are primarily designed with a 2M THP size
* in mind. Much larger sizes are not tested and likely to cause issues such as
* bad fragmentation or simply broken.
*/
#define HUGEPAGE_MAX_EXPECTED_SIZE ((size_t)(16U << 20))
#if LG_HUGEPAGE != 0
# define HUGEPAGE_PAGES (HUGEPAGE / PAGE)
#else