]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
LoongArch: Let {pte,pmd}_modify() record the status of _PAGE_DIRTY
authorTianyang Zhang <zhangtianyang@loongson.cn>
Sun, 9 Nov 2025 08:02:01 +0000 (16:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:12:35 +0000 (06:12 +0900)
commit525f85bec7713b770595f86893f5ba2ebd866acf
tree31b11d0a3a03c208eeb2a82414c17aeb38aba80e
parentc07da554d07a392ab4b9ee3dd56065c3eff8c172
LoongArch: Let {pte,pmd}_modify() record the status of _PAGE_DIRTY

commit a073d637c8cfbfbab39b7272226a3fbf3b887580 upstream.

Now if the PTE/PMD is dirty with _PAGE_DIRTY but without _PAGE_MODIFIED,
after {pte,pmd}_modify() we lose _PAGE_DIRTY, then {pte,pmd}_dirty()
return false and lead to data loss. This can happen in certain scenarios
such as HW PTW doesn't set _PAGE_MODIFIED automatically, so here we need
_PAGE_MODIFIED to record the dirty status (_PAGE_DIRTY).

The new modification involves checking whether the original PTE/PMD has
the _PAGE_DIRTY flag. If it exists, the _PAGE_MODIFIED bit is also set,
ensuring that the {pte,pmd}_dirty() interface can always return accurate
information.

Cc: stable@vger.kernel.org
Co-developed-by: Liupu Wang <wangliupu@loongson.cn>
Signed-off-by: Liupu Wang <wangliupu@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/loongarch/include/asm/pgtable.h