Skip to content

Commit 7fe2ac6

Browse files
author
James Bottomley
committed
Merge branch 'flushing' into for-linus
2 parents 2e7bad5 + b7d4581 commit 7fe2ac6

8 files changed

Lines changed: 182 additions & 124 deletions

File tree

‎arch/parisc/include/asm/cacheflush.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/mm.h>
55
#include <linux/uaccess.h>
6+
#include <asm/tlbflush.h>
67

78
/* The usual comment is "Caches aren't brain-dead on the <architecture>".
89
* Unfortunately, that doesn't apply to PA-RISC. */
@@ -112,8 +113,10 @@ void flush_dcache_page_asm(unsigned long phys_addr, unsigned long vaddr);
112113
static inline void
113114
flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned long vmaddr)
114115
{
115-
if (PageAnon(page))
116+
if (PageAnon(page)) {
117+
flush_tlb_page(vma, vmaddr);
116118
flush_dcache_page_asm(page_to_phys(page), vmaddr);
119+
}
117120
}
118121

119122
#ifdef CONFIG_DEBUG_RODATA

‎arch/parisc/include/asm/pgtable.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ struct vm_area_struct;
177177

178178
#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | _PAGE_DIRTY | _PAGE_ACCESSED)
179179
#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
180-
#define _PAGE_KERNEL (_PAGE_PRESENT | _PAGE_EXEC | _PAGE_READ | _PAGE_WRITE | _PAGE_DIRTY | _PAGE_ACCESSED)
180+
#define _PAGE_KERNEL_RO (_PAGE_PRESENT | _PAGE_READ | _PAGE_DIRTY | _PAGE_ACCESSED)
181+
#define _PAGE_KERNEL_EXEC (_PAGE_KERNEL_RO | _PAGE_EXEC)
182+
#define _PAGE_KERNEL_RWX (_PAGE_KERNEL_EXEC | _PAGE_WRITE)
183+
#define _PAGE_KERNEL (_PAGE_KERNEL_RO | _PAGE_WRITE)
181184

182185
/* The pgd/pmd contains a ptr (in phys addr space); since all pgds/pmds
183186
* are page-aligned, we don't care about the PAGE_OFFSET bits, except
@@ -208,7 +211,9 @@ struct vm_area_struct;
208211
#define PAGE_COPY PAGE_EXECREAD
209212
#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
210213
#define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
211-
#define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)
214+
#define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
215+
#define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
216+
#define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL_RO)
212217
#define PAGE_KERNEL_UNC __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
213218
#define PAGE_GATEWAY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_GATEWAY| _PAGE_READ)
214219

‎arch/parisc/kernel/cache.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,20 @@ void flush_dcache_page(struct page *page)
304304
offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT;
305305
addr = mpnt->vm_start + offset;
306306

307+
/* The TLB is the engine of coherence on parisc: The
308+
* CPU is entitled to speculate any page with a TLB
309+
* mapping, so here we kill the mapping then flush the
310+
* page along a special flush only alias mapping.
311+
* This guarantees that the page is no-longer in the
312+
* cache for any process and nor may it be
313+
* speculatively read in (until the user or kernel
314+
* specifically accesses it, of course) */
315+
316+
flush_tlb_page(mpnt, addr);
307317
if (old_addr == 0 || (old_addr & (SHMLBA - 1)) != (addr & (SHMLBA - 1))) {
308318
__flush_cache_page(mpnt, addr, page_to_phys(page));
309319
if (old_addr)
310-
printk(KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %s\n", old_addr, addr, mpnt->vm_file ? mpnt->vm_file->f_path.dentry->d_name.name : "(null)");
320+
printk(KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %s\n", old_addr, addr, mpnt->vm_file ? (char *)mpnt->vm_file->f_path.dentry->d_name.name : "(null)");
311321
old_addr = addr;
312322
}
313323
}
@@ -499,6 +509,7 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long
499509
{
500510
BUG_ON(!vma->vm_mm->context);
501511

512+
flush_tlb_page(vma, vmaddr);
502513
__flush_cache_page(vma, vmaddr, page_to_phys(pfn_to_page(pfn)));
503514

504515
}

‎arch/parisc/kernel/entry.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,9 @@ ENTRY(fault_vector_11)
692692
END(fault_vector_11)
693693

694694
#endif
695+
/* Fault vector is separately protected and *must* be on its own page */
696+
.align PAGE_SIZE
697+
ENTRY(end_fault_vector)
695698

696699
.import handle_interruption,code
697700
.import do_cpu_irq_mask,code

‎arch/parisc/kernel/head.S‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ $bss_loop:
106106
#endif
107107

108108

109-
/* Now initialize the PTEs themselves */
110-
ldo 0+_PAGE_KERNEL(%r0),%r3 /* Hardwired 0 phys addr start */
109+
/* Now initialize the PTEs themselves. We use RWX for
110+
* everything ... it will get remapped correctly later */
111+
ldo 0+_PAGE_KERNEL_RWX(%r0),%r3 /* Hardwired 0 phys addr start */
111112
ldi (1<<(KERNEL_INITIAL_ORDER-PAGE_SHIFT)),%r11 /* PFN count */
112113
load32 PA(pg0),%r1
113114

‎arch/parisc/kernel/module.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@
6161
#include <linux/string.h>
6262
#include <linux/kernel.h>
6363
#include <linux/bug.h>
64+
#include <linux/mm.h>
6465
#include <linux/slab.h>
6566

67+
#include <asm/pgtable.h>
6668
#include <asm/unwind.h>
6769

6870
#if 0
@@ -214,7 +216,13 @@ void *module_alloc(unsigned long size)
214216
{
215217
if (size == 0)
216218
return NULL;
217-
return vmalloc(size);
219+
/* using RWX means less protection for modules, but it's
220+
* easier than trying to map the text, data, init_text and
221+
* init_data correctly */
222+
return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
223+
GFP_KERNEL | __GFP_HIGHMEM,
224+
PAGE_KERNEL_RWX, -1,
225+
__builtin_return_address(0));
218226
}
219227

220228
#ifndef CONFIG_64BIT

‎arch/parisc/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ SECTIONS
134134
. = ALIGN(16384);
135135
__init_begin = .;
136136
INIT_TEXT_SECTION(16384)
137+
. = ALIGN(PAGE_SIZE);
137138
INIT_DATA_SECTION(16)
138139
/* we have to discard exit text and such at runtime, not link time */
139140
.exit.text :

0 commit comments

Comments
 (0)