]> 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)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 10 Nov 2025 00:37:06 +0000 (08:37 +0800)
commita073d637c8cfbfbab39b7272226a3fbf3b887580
treee853279e586cdb20be6cffb120fa1b35a2ee67eb
parentce5ad03e459ecb3b4993a8f311fd4f2fb3e6ef81
LoongArch: Let {pte,pmd}_modify() record the status of _PAGE_DIRTY

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>
arch/loongarch/include/asm/pgtable.h