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.

The behaviour of pXd_page() will change with generic compile-time folded
page tables by disallowing its use and triggering a compile-time error
when it's used improperly, ensuring that the actual.

To prepare fot that, 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 078689aa7206..91b33a265a43 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -1346,7 +1346,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;
@@ -1730,7 +1730,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))));
 

-- 
2.43.0


Reply via email to