Skip to contentSkip to conversation

update_mmu_cache: Don't dcbst non-readable pages.

PATCH In review Scott Wood 2 participants 2 messages Feb 5, 2008 PowerPC

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/1 update_mmu_cache: Don't dcbst non-readable pages.

Currently, update_mmu_cache will crash if given a no-access PTE. There's no need to synchronize dcache/icache unless it's an exec mapping -- however, due to the existence of older glibc versions that execute out of a read-but-no-exec page, readability is tested instead.

This assumes no exec-only mappings; if such mappings become supported, they will need to go through the kmap_atomic() version of dcache/icache synchronization.

---
This fixes the following bug:
http://ozlabs.org/pipermail/linuxppc-dev/2008-February/051080.html

 arch/powerpc/mm/mem.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
arch/powerpc/mm/mem.c +6 -1
index e812244..c7d7bd4 100644
@@ -483,7 +483,12 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
 		 */
 		_tlbie(address, 0 /* 8xx doesn't care about PID */);
 #endif
-		if (!PageReserved(page)
+		/* The _PAGE_USER test should really be _PAGE_EXEC, but
+		 * older glibc versions execute some code from no-exec
+		 * pages, which for now we are supporting.  If exec-only
+		 * pages are ever implemented, this will have to change.
+		 */
+		if (!PageReserved(page) && (pte_val(pte) & _PAGE_USER)
 		    && !test_bit(PG_arch_1, &page->flags)) {
 			if (vma->vm_mm == current->active_mm) {
 				__flush_dcache_icache((void *) address);
Signature · 1 line
1.5.3.8
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Scott Wood

Currently, update_mmu_cache will crash if given a no-access PTE. There's no need to synchronize dcache/icache unless it's an exec mapping -- however, due to the existence of older glibc versions that execute out of a read-but-no-exec page, readability is tested instead.

This assumes no exec-only mappings; if such mappings become supported, they will need to go through the kmap_atomic() version of dcache/icache synchronization.

Quoted 25 lines

---
This fixes the following bug:
http://ozlabs.org/pipermail/linuxppc-dev/2008-February/051080.html

 arch/powerpc/mm/mem.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
arch/powerpc/mm/mem.c +6 -1
index e812244..c7d7bd4 100644
@@ -483,7 +483,12 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
 		 */
 		_tlbie(address, 0 /* 8xx doesn't care about PID */);
 #endif
-		if (!PageReserved(page)
+		/* The _PAGE_USER test should really be _PAGE_EXEC, but
+		 * older glibc versions execute some code from no-exec
+		 * pages, which for now we are supporting.  If exec-only
+		 * pages are ever implemented, this will have to change.
+		 */
+		if (!PageReserved(page) && (pte_val(pte) & _PAGE_USER)
 		    && !test_bit(PG_arch_1, &page->flags)) {
 			if (vma->vm_mm == current->active_mm) {
 				__flush_dcache_icache((void *) address);