From: Bibo Mao Date: Wed, 27 May 2020 02:25:20 +0000 (+0800) Subject: MIPS: mm: add page valid judgement in function pte_modify X-Git-Tag: v5.8-rc1~173^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=273b5fa00fadabd587fac858ea61a17b3653892d;p=thirdparty%2Fkernel%2Flinux.git MIPS: mm: add page valid judgement in function pte_modify If original PTE has _PAGE_ACCESSED bit set, and new pte has no _PAGE_NO_READ bit set, we can add _PAGE_SILENT_READ bit to enable page valid bit. Signed-off-by: Bibo Mao Signed-off-by: Thomas Bogendoerfer --- diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index d9772aff2f02e..85b39c9fd09ec 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -532,8 +532,11 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) #else static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { - return __pte((pte_val(pte) & _PAGE_CHG_MASK) | - (pgprot_val(newprot) & ~_PAGE_CHG_MASK)); + pte_val(pte) &= _PAGE_CHG_MASK; + pte_val(pte) |= pgprot_val(newprot) & ~_PAGE_CHG_MASK; + if ((pte_val(pte) & _PAGE_ACCESSED) && !(pte_val(pte) & _PAGE_NO_READ)) + pte_val(pte) |= _PAGE_SILENT_READ; + return pte; } #endif