hulk inclusion category: feature bugzilla: https://gitee.com/src-openeuler/kernel/issues/ID4NL4 ---------------------------------------- Add pte_clrhuge() helper function for arm64 to convert a huge PTE entry to regular PTE. This function provides the inverse operation of pte_mkhuge() and is needed when splitting huge page mappings, where individual PTE entries are created from the original huge page mapping. Signed-off-by: Yin Tirui <yintirui@huawei.com> --- arch/arm64/include/asm/pgtable.h | 9 +++++++++ arch/x86/include/asm/pgtable.h | 1 + include/linux/pgtable.h | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 38c9d78b639c..e3048b5339aa 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -249,6 +249,15 @@ static inline pte_t pte_mkpresent(pte_t pte) return set_pte_bit(pte, __pgprot(PTE_VALID)); } +static inline pte_t pte_clrhuge(pte_t pte) +{ + pteval_t mask = PTE_TYPE_MASK & ~PTE_VALID; + pteval_t val = PTE_TYPE_PAGE & ~PTE_VALID; + + return __pte((pte_val(pte) & ~mask) | val); +} +#define pte_clrhuge pte_clrhuge + static inline pmd_t pmd_mkcont(pmd_t pmd) { return __pmd(pmd_val(pmd) | PMD_SECT_CONT); diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 9ef5315c931e..c170ca166e78 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -505,6 +505,7 @@ static inline pte_t pte_clrhuge(pte_t pte) { return pte_clear_flags(pte, _PAGE_PSE); } +#define pte_clrhuge pte_clrhuge static inline pte_t pte_mkglobal(pte_t pte) { diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index b69f295b5f91..c8e75b3f8084 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -657,6 +657,12 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, } #endif +#ifdef CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP +#ifndef pte_clrhuge +#define pte_clrhuge(pte) (pte) +#endif +#endif + #ifndef get_and_clear_full_ptes /** * get_and_clear_full_ptes - Clear present PTEs that map consecutive pages of -- 2.43.0