提交 fe357d79 编写于 作者: Z Zhenyu Ye 提交者: Zheng Zengkai

arm64: tlb: fix the TTL value of tlb_get_level

stable inclusion
from stable-5.10.51
commit a11a457820fbb51abd02e35e13e4775a5daf0cb1
bugzilla: 175263 https://gitee.com/openeuler/kernel/issues/I4DT6F

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a11a457820fbb51abd02e35e13e4775a5daf0cb1

--------------------------------

commit 52218fcd upstream.

The TTL field indicates the level of page table walk holding the *leaf*
entry for the address being invalidated. But currently, the TTL field
may be set to an incorrent value in the following stack:

pte_free_tlb
    __pte_free_tlb
        tlb_remove_table
            tlb_table_invalidate
                tlb_flush_mmu_tlbonly
                    tlb_flush

In this case, we just want to flush a PTE page, but the tlb->cleared_pmds
is set and we get tlb_level = 2 in the tlb_get_level() function. This may
cause some unexpected problems.

This patch set the TTL field to 0 if tlb->freed_tables is set. The
tlb->freed_tables indicates page table pages are freed, not the leaf
entry.

Cc: <stable@vger.kernel.org> # 5.9.x
Fixes: c4ab2cbc ("arm64: tlb: Set the TTL field in flush_tlb_range")
Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
Reported-by: NZhuRui <zhurui3@huawei.com>
Signed-off-by: NZhenyu Ye <yezhenyu2@huawei.com>
Link: https://lore.kernel.org/r/b80ead47-1f88-3a00-18e1-cacc22f54cc4@huawei.comSigned-off-by: NWill Deacon <will@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 1f03bf3d
...@@ -28,6 +28,10 @@ static void tlb_flush(struct mmu_gather *tlb); ...@@ -28,6 +28,10 @@ static void tlb_flush(struct mmu_gather *tlb);
*/ */
static inline int tlb_get_level(struct mmu_gather *tlb) static inline int tlb_get_level(struct mmu_gather *tlb)
{ {
/* The TTL field is only valid for the leaf entry. */
if (tlb->freed_tables)
return 0;
if (tlb->cleared_ptes && !(tlb->cleared_pmds || if (tlb->cleared_ptes && !(tlb->cleared_pmds ||
tlb->cleared_puds || tlb->cleared_puds ||
tlb->cleared_p4ds)) tlb->cleared_p4ds))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册