lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H4CC0S7ciLCqdb_AoQ+3-24uo6TZb9Pz7H1yu+mvspFDw@mail.gmail.com>
Date:   Sat, 27 May 2023 13:32:42 +0800
From:   Huacai Chen <chenhuacai@...nel.org>
To:     Hongchen Zhang <zhanghongchen@...ngson.cn>
Cc:     WANG Xuerui <kernel@...0n.name>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Anshuman Khandual <anshuman.khandual@....com>,
        David Hildenbrand <david@...hat.com>,
        Mike Rapoport <rppt@...nel.org>,
        Jiaxun Yang <jiaxun.yang@...goat.com>,
        Feiyang Chen <chenfeiyang@...ngson.cn>,
        Qi Zheng <zhengqi.arch@...edance.com>,
        loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
        loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH] LoongArch: let pmd_present return true when splitting pmd

Hi, Anshuman,

Excuse me, but could you please tell me something that why commit
b65399f6111b ("arm64/mm: Change THP helpers to comply with generic MM
semantics") needn't be backported to 5.4LTS and 4.19LTS series. The
discussion link you referred is as early as in 2018, before 4.19
released. I think this information is important for us because we want
to know how to handle our 4.19-loongarch codebase.

Huacai

On Wed, May 24, 2023 at 3:42 PM Hongchen Zhang
<zhanghongchen@...ngson.cn> wrote:
>
> when we split a pmd into ptes, pmd_present() and pmd_trans_huge() should
> return true,otherwise it would be treated as a swap pmd.
> As arm64 does in
> commit b65399f6111b ("arm64/mm: Change THP helpers to comply with generic MM semantics")
> we add a _PAGE_PRESENT_INVALID bit for LoongArch.
>
> Signed-off-by: Hongchen Zhang <zhanghongchen@...ngson.cn>
> ---
>  arch/loongarch/include/asm/pgtable-bits.h | 2 ++
>  arch/loongarch/include/asm/pgtable.h      | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/include/asm/pgtable-bits.h b/arch/loongarch/include/asm/pgtable-bits.h
> index 8b98d22a145b..a7469d28d9d0 100644
> --- a/arch/loongarch/include/asm/pgtable-bits.h
> +++ b/arch/loongarch/include/asm/pgtable-bits.h
> @@ -22,12 +22,14 @@
>  #define        _PAGE_PFN_SHIFT         12
>  #define        _PAGE_SWP_EXCLUSIVE_SHIFT 23
>  #define        _PAGE_PFN_END_SHIFT     48
> +#define _PAGE_PRESENT_INVALID_SHIFT 60
>  #define        _PAGE_NO_READ_SHIFT     61
>  #define        _PAGE_NO_EXEC_SHIFT     62
>  #define        _PAGE_RPLV_SHIFT        63
>
>  /* Used by software */
>  #define _PAGE_PRESENT          (_ULCAST_(1) << _PAGE_PRESENT_SHIFT)
> +#define _PAGE_PRESENT_INVALID  (_ULCAST_(1) << _PAGE_PRESENT_INVALID_SHIFT)
>  #define _PAGE_WRITE            (_ULCAST_(1) << _PAGE_WRITE_SHIFT)
>  #define _PAGE_ACCESSED         (_ULCAST_(1) << _PAGE_ACCESSED_SHIFT)
>  #define _PAGE_MODIFIED         (_ULCAST_(1) << _PAGE_MODIFIED_SHIFT)
> diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
> index d28fb9dbec59..9a9f9ff9b709 100644
> --- a/arch/loongarch/include/asm/pgtable.h
> +++ b/arch/loongarch/include/asm/pgtable.h
> @@ -213,7 +213,7 @@ static inline int pmd_bad(pmd_t pmd)
>  static inline int pmd_present(pmd_t pmd)
>  {
>         if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
> -               return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE));
> +               return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PRESENT_INVALID));
>
>         return pmd_val(pmd) != (unsigned long)invalid_pte_table;
>  }
> @@ -558,6 +558,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
>
>  static inline pmd_t pmd_mkinvalid(pmd_t pmd)
>  {
> +       pmd_val(pmd) |= _PAGE_PRESENT_INVALID;
>         pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY | _PAGE_PROTNONE);
>
>         return pmd;
>
> base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
> --
> 2.31.1
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ