We want to rework how set_pXd() behaves for generic compile-time folded page tables by disallowing its use and triggering a compile-time error when it is used improperly, ensuring that the actual first-level set_pXd() function is used instead.
Therefore, skip collapse_pud_page() and populate_pud() according to CONFIG_PGTABLE_LEVELS. There should be no functional change. Signed-off-by: Yeoreum Yun <[email protected]> --- arch/x86/mm/pat/set_memory.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index d023a40a1e034..cffb1cef869cc 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1326,7 +1326,7 @@ static int collapse_pud_page(pud_t *pud, unsigned long addr, pmd_t *pmd, first; int i; - if (!direct_gbpages) + if (CONFIG_PGTABLE_LEVELS == 2 || !direct_gbpages) return 0; addr &= PUD_MASK; @@ -1710,7 +1710,8 @@ static int populate_pud(struct cpa_data *cpa, unsigned long start, p4d_t *p4d, /* * Map everything starting from the Gb boundary, possibly with 1G pages */ - while (boot_cpu_has(X86_FEATURE_GBPAGES) && end - start >= PUD_SIZE) { + while (CONFIG_PGTABLE_LEVELS > 3 && boot_cpu_has(X86_FEATURE_GBPAGES) && + end - start >= PUD_SIZE) { set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn, canon_pgprot(pud_pgprot)))); -- LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
