linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] powerpc/mm/radix: Refactor radix__mark_rodata_ro()
@ 2017-07-14  6:51 Michael Ellerman
  2017-07-14  6:51 ` [PATCH 2/3] powerpc/mm/hash: Refactor hash__mark_rodata_ro() Michael Ellerman
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Michael Ellerman @ 2017-07-14  6:51 UTC (permalink / raw)
  To: linuxppc-dev

Move the core logic into a helper, so we can use it for changing permissions
other than _PAGE_WRITE.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/mm/pgtable-radix.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index 8c13e4282308..336e52ec652c 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -112,10 +112,9 @@ int radix__map_kernel_page(unsigned long ea, unsigned long pa,
 }
 
 #ifdef CONFIG_STRICT_KERNEL_RWX
-void radix__mark_rodata_ro(void)
+void radix__change_memory_range(unsigned long start, unsigned long end,
+				unsigned long clear)
 {
-	unsigned long start = (unsigned long)_stext;
-	unsigned long end = (unsigned long)__init_begin;
 	unsigned long idx;
 	pgd_t *pgdp;
 	pud_t *pudp;
@@ -125,7 +124,8 @@ void radix__mark_rodata_ro(void)
 	start = ALIGN_DOWN(start, PAGE_SIZE);
 	end = PAGE_ALIGN(end); // aligns up
 
-	pr_devel("marking ro start %lx, end %lx\n", start, end);
+	pr_debug("Changing flags on range %lx-%lx removing 0x%lx\n",
+		 start, end, clear);
 
 	for (idx = start; idx < end; idx += PAGE_SIZE) {
 		pgdp = pgd_offset_k(idx);
@@ -147,11 +147,21 @@ void radix__mark_rodata_ro(void)
 		if (!ptep)
 			continue;
 update_the_pte:
-		radix__pte_update(&init_mm, idx, ptep, _PAGE_WRITE, 0, 0);
+		radix__pte_update(&init_mm, idx, ptep, clear, 0, 0);
 	}
 
 	radix__flush_tlb_kernel_range(start, end);
 }
+
+void radix__mark_rodata_ro(void)
+{
+	unsigned long start, end;
+
+	start = (unsigned long)_stext;
+	end = (unsigned long)__init_begin;
+
+	radix__change_memory_range(start, end, _PAGE_WRITE);
+}
 #endif /* CONFIG_STRICT_KERNEL_RWX */
 
 static inline void __meminit print_mapping(unsigned long start,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-08-09 13:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-14  6:51 [PATCH 1/3] powerpc/mm/radix: Refactor radix__mark_rodata_ro() Michael Ellerman
2017-07-14  6:51 ` [PATCH 2/3] powerpc/mm/hash: Refactor hash__mark_rodata_ro() Michael Ellerman
2017-07-18  1:05   ` Balbir Singh
2017-07-14  6:51 ` [PATCH 3/3] powerpc/mm: Mark __init memory no-execute when STRICT_KERNEL_RWX=y Michael Ellerman
2017-07-14 23:01   ` kbuild test robot
2017-07-18  9:54     ` Michael Ellerman
2017-08-02 11:01   ` Christophe LEROY
2017-08-09  2:29     ` Michael Ellerman
2017-08-09  6:27       ` Christophe LEROY
2017-08-09 13:13         ` Michael Ellerman
2017-07-18  1:04 ` [PATCH 1/3] powerpc/mm/radix: Refactor radix__mark_rodata_ro() Balbir Singh
2017-07-21 11:13 ` [1/3] " Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).