anolis: arm64: hookers: flush proper tlb range

OpenAnolis Bug Tracker: 0000546

We should flush PMD_SIZE range of tlb if we change prot of a huge pmd.

Signed-off-by: Xu Yu <xuyu@linux.alibaba.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Xunlei Pang <xlpang@linux.alibaba.com>
This commit is contained in:
Xu Yu 2021-04-08 11:13:06 +08:00 committed by Shile Zhang
parent 8422570b0b
commit ddd120fc9c
1 changed files with 4 additions and 4 deletions

View File

@ -299,14 +299,14 @@ static int remove_memprotect(unsigned long addr)
// remove the pmd wirte protect attr if huge page
if (pmd_huge(pmdd)) {
set_pmd(pmd, __pmd(pmd_val(pmdd) & ~PMD_SECT_RDONLY));
flush_tlb_kernel_range(addr_aligned, addr_aligned + PMD_SIZE);
} else {
pte = pte_offset_kernel(pmd, addr);
pted = pte_mkwrite(*pte);
set_pte(pte, pted);
flush_tlb_kernel_range(addr_aligned, addr_aligned + PAGE_SIZE);
}
flush_tlb_kernel_range(addr_aligned, addr_aligned + PAGE_SIZE);
return 0;
}
@ -333,14 +333,14 @@ static int set_memprotect(unsigned long addr)
if (pmd_huge(pmdd)) {
set_pmd(pmd, __pmd(pmd_val(pmdd) | PMD_SECT_RDONLY));
flush_tlb_kernel_range(addr_aligned, addr_aligned + PMD_SIZE);
} else {
pte = pte_offset_kernel(pmd, addr);
pted = pte_wrprotect(*pte);
set_pte(pte, pted);
flush_tlb_kernel_range(addr_aligned, addr_aligned + PAGE_SIZE);
}
flush_tlb_kernel_range(addr_aligned, addr_aligned + PAGE_SIZE);
return 0;
}
#endif