Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1626025

[PATCH 1/3] powerpc/mm: Ensure change_page_attr() doesn't invalidate pinned TLBs

From Christophe Leroy <christophe.leroy@c-s.fr>
Newsgroups linux.kernel
Subject [PATCH 1/3] powerpc/mm: Ensure change_page_attr() doesn't invalidate pinned TLBs
Date 2017-04-19 13:10 +0200
Message-ID <txVEK-2Kc-25@gated-at.bofh.it> (permalink)
References <txVEJ-2Kc-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


__change_page_attr() uses flush_tlb_page().
flush_tlb_page() uses tlbie instruction, which also invalidates
pinned TLBs, which is not what we expect.

This patch modifies the implementation to use flush_tlb_kernel_range()
instead. This will make use of tlbia which will preserve pinned TLBs.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/mm/pgtable_32.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index a65c0b4c0669..8e8940fad12f 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -325,7 +325,7 @@ get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep, pmd_t **pmdp)
 
 #ifdef CONFIG_DEBUG_PAGEALLOC
 
-static int __change_page_attr(struct page *page, pgprot_t prot)
+static int __change_page_attr_noflush(struct page *page, pgprot_t prot)
 {
 	pte_t *kpte;
 	pmd_t *kpmd;
@@ -339,8 +339,6 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
 	if (!get_pteptr(&init_mm, address, &kpte, &kpmd))
 		return -EINVAL;
 	__set_pte_at(&init_mm, address, kpte, mk_pte(page, prot), 0);
-	wmb();
-	flush_tlb_page(NULL, address);
 	pte_unmap(kpte);
 
 	return 0;
@@ -355,13 +353,17 @@ static int change_page_attr(struct page *page, int numpages, pgprot_t prot)
 {
 	int i, err = 0;
 	unsigned long flags;
+	struct page *start = page;
 
 	local_irq_save(flags);
 	for (i = 0; i < numpages; i++, page++) {
-		err = __change_page_attr(page, prot);
+		err = __change_page_attr_noflush(page, prot);
 		if (err)
 			break;
 	}
+	wmb();
+	flush_tlb_kernel_range((unsigned long)page_address(start),
+			       (unsigned long)page_address(page));
 	local_irq_restore(flags);
 	return err;
 }
-- 
2.12.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] powerpc/mm: Fix kernel protection and implement CONFIG_DEBUG_RODATA on PPC32 Christophe Leroy <christophe.leroy@c-s.fr> - 2017-04-19 13:10 +0200
  [PATCH 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32 Christophe Leroy <christophe.leroy@c-s.fr> - 2017-04-19 13:10 +0200
    Re: [PATCH 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32 Michael Ellerman <mpe@ellerman.id.au> - 2017-04-19 16:10 +0200
      Re: [PATCH 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32 Christophe LEROY <christophe.leroy@c-s.fr> - 2017-04-19 16:30 +0200
        Re: [PATCH 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32 christophe leroy <christophe.leroy@c-s.fr> - 2017-04-19 20:40 +0200
          Re: [PATCH 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32 Michael Ellerman <mpe@ellerman.id.au> - 2017-04-20 08:10 +0200
  [PATCH 2/3] powerpc/mm: Fix kernel RAM protection after freeing  unused memory on PPC32 Christophe Leroy <christophe.leroy@c-s.fr> - 2017-04-19 13:10 +0200
  [PATCH 1/3] powerpc/mm: Ensure change_page_attr() doesn't invalidate  pinned TLBs Christophe Leroy <christophe.leroy@c-s.fr> - 2017-04-19 13:10 +0200

csiph-web