summaryrefslogtreecommitdiff
path: root/arch/loongarch/include/asm/hugetlb.h
diff options
context:
space:
mode:
authorHuacai Chen <chenhuacai@loongson.cn>2024-08-07 17:37:11 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2024-08-07 17:37:11 +0800
commit4574815abf43e2bf05643e1b3f7a2e5d6df894f0 (patch)
treec4f114dabbaa5c9529dd5d0c9a5e97837a564785 /arch/loongarch/include/asm/hugetlb.h
parente688c220732e518c2eb1639e9ef77d4a9311713c (diff)
LoongArch: Use accessors to page table entries instead of direct dereference
As very well explained in commit 20a004e7b017cce282 ("arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables"), an architecture whose page table walker can modify the PTE in parallel must use READ_ONCE()/ WRITE_ONCE() macro to avoid any compiler transformation. So apply that to LoongArch which is such an architecture, in order to avoid potential problems. Similar to commit edf955647269422e ("riscv: Use accessors to page table entries instead of direct dereference"). Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/include/asm/hugetlb.h')
-rw-r--r--arch/loongarch/include/asm/hugetlb.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/loongarch/include/asm/hugetlb.h b/arch/loongarch/include/asm/hugetlb.h
index aa44b3fe43dd..5da32c00d483 100644
--- a/arch/loongarch/include/asm/hugetlb.h
+++ b/arch/loongarch/include/asm/hugetlb.h
@@ -34,7 +34,7 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
unsigned long addr, pte_t *ptep)
{
pte_t clear;
- pte_t pte = *ptep;
+ pte_t pte = ptep_get(ptep);
pte_val(clear) = (unsigned long)invalid_pte_table;
set_pte_at(mm, addr, ptep, clear);
@@ -65,7 +65,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
pte_t *ptep, pte_t pte,
int dirty)
{
- int changed = !pte_same(*ptep, pte);
+ int changed = !pte_same(ptep_get(ptep), pte);
if (changed) {
set_pte_at(vma->vm_mm, addr, ptep, pte);