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


Groups > linux.kernel > #1683102 > unrolled thread

[PATCH v2 0/5] powerpc/mm: Fix kernel protection and implement STRICT_KERNEL_RWX on PPC32

Started byChristophe Leroy <christophe.leroy@c-s.fr>
First post2017-07-07 12:10 +0200
Last post2017-07-07 12:10 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/5] powerpc/mm: Fix kernel protection and implement STRICT_KERNEL_RWX on PPC32 Christophe Leroy <christophe.leroy@c-s.fr> - 2017-07-07 12:10 +0200
    [PATCH v2 1/5] powerpc/mm: Ensure change_page_attr() doesn't invalidate  pinned TLBs Christophe Leroy <christophe.leroy@c-s.fr> - 2017-07-07 12:10 +0200

#1683102 — [PATCH v2 0/5] powerpc/mm: Fix kernel protection and implement STRICT_KERNEL_RWX on PPC32

FromChristophe Leroy <christophe.leroy@c-s.fr>
Date2017-07-07 12:10 +0200
Subject[PATCH v2 0/5] powerpc/mm: Fix kernel protection and implement STRICT_KERNEL_RWX on PPC32
Message-ID<u0yn0-2vo-25@gated-at.bofh.it>
This patch set implements STRICT_KERNEL_RWX on Powerpc32
after fixing a few issues related to kernel code page protection.

At the end we take the opportunity to get rid of some unneccessary/outdated
fixmap stuff.

Changes from v1 to v2:
* Rebased on latest linux-next following including of STRICT_KERNEL_RWX for PPC64
* Removed from the serie the two patches already applied.

Christophe Leroy (5):
  powerpc/mm: Ensure change_page_attr() doesn't invalidate pinned TLBs
  powerpc/mm: Fix kernel RAM protection after freeing unused memory on
    PPC32
  powerpc/mm: Implement STRICT_KERNEL_RWX on PPC32
  powerpc/mm: declare some local functions static
  powerpc/mm: Simplify __set_fixmap()

 arch/powerpc/Kconfig                         |  2 +-
 arch/powerpc/include/asm/book3s/32/pgtable.h |  3 --
 arch/powerpc/include/asm/fixmap.h            | 10 +++--
 arch/powerpc/include/asm/nohash/32/pgtable.h |  3 --
 arch/powerpc/kernel/vmlinux.lds.S            |  2 +-
 arch/powerpc/mm/init_32.c                    |  6 +++
 arch/powerpc/mm/mem.c                        |  1 +
 arch/powerpc/mm/mmu_decl.h                   |  3 ++
 arch/powerpc/mm/pgtable_32.c                 | 66 ++++++++++++++++++----------
 9 files changed, 61 insertions(+), 35 deletions(-)

-- 
2.12.0

[toc] | [next] | [standalone]


#1683103 — [PATCH v2 1/5] powerpc/mm: Ensure change_page_attr() doesn't invalidate pinned TLBs

FromChristophe Leroy <christophe.leroy@c-s.fr>
Date2017-07-07 12:10 +0200
Subject[PATCH v2 1/5] powerpc/mm: Ensure change_page_attr() doesn't invalidate pinned TLBs
Message-ID<u0yn1-2vo-35@gated-at.bofh.it>
In reply to#1683102
__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 a9e4bfc025bc..991036f818bb 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web