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] [day] [month] [year] [list]
Message-ID: <CAAhV-H6CyWCqgp_x1OQ0o_UPKeom1CoLgkebwEOPPHS=KGfHmw@mail.gmail.com>
Date: Fri, 7 Nov 2025 15:26:11 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Tianyang Zhang <zhangtianyang@...ngson.cn>
Cc: kernel@...0n.name, akpm@...ux-foundation.org, willy@...radead.org, 
	david@...hat.com, linmag7@...il.com, thuth@...hat.com, maobibo@...ngson.cn, 
	apopple@...dia.com, loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org, 
	Liupu Wang <wangliupu@...ngson.cn>
Subject: Re: [PATCH v2] LoongArch: Let {pte,pmd}_modify() record the status of _PAGE_DIRTY

Applied, thanks.

Huacai

On Fri, Nov 7, 2025 at 11:58 AM Tianyang Zhang
<zhangtianyang@...ngson.cn> wrote:
>
> Now, if the pte is dirty _PAGE_DIRTY but without _PAGE_MODIFIED, after
> pte_modify() we lose _PAGE_DIRTY, then pte_dirty() returns false. So
> we need _PAGE_MODIFIED to record _PAGE_DIRTY here.
>
> The new modification involves checking whether the original PTE has the
> _PAGE_DIRTY flag. If it exists, the _PAGE_MODIFIED bit is set, ensuring
> that the pte_dirty interface can return accurate information.
>
> Co-developed-by: Liupu Wang <wangliupu@...ngson.cn>
> Signed-off-by: Liupu Wang <wangliupu@...ngson.cn>
> Signed-off-by: Tianyang Zhang <zhangtianyang@...ngson.cn>
> ---
>  arch/loongarch/include/asm/pgtable.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
> index bd128696e96d..e0b92fe850b3 100644
> --- a/arch/loongarch/include/asm/pgtable.h
> +++ b/arch/loongarch/include/asm/pgtable.h
> @@ -424,6 +424,9 @@ static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a)
>
>  static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
>  {
> +       if (pte_val(pte) & _PAGE_DIRTY)
> +               pte_val(pte) |= _PAGE_MODIFIED;
> +
>         return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
>                      (pgprot_val(newprot) & ~_PAGE_CHG_MASK));
>  }
> @@ -547,6 +550,9 @@ static inline struct page *pmd_page(pmd_t pmd)
>
>  static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
>  {
> +       if (pmd_val(pmd) & _PAGE_DIRTY)
> +               pmd_val(pmd) |= _PAGE_MODIFIED;
> +
>         pmd_val(pmd) = (pmd_val(pmd) & _HPAGE_CHG_MASK) |
>                                 (pgprot_val(newprot) & ~_HPAGE_CHG_MASK);
>         return pmd;
> --
> 2.41.0
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ