Commit 6b3efc2a authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

[PATCH] arch/parisc/mm

Update arch/parisc/mm
parent 1e0b058c
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
# Makefile for the linux parisc-specific parts of the memory manager. # Makefile for the linux parisc-specific parts of the memory manager.
# #
objs-y := init.o fault.o kmap.o extable.o obj-y := init.o fault.o extable.o ioremap.o
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
...@@ -46,17 +46,17 @@ search_one_table (const struct exception_table_entry *first, ...@@ -46,17 +46,17 @@ search_one_table (const struct exception_table_entry *first,
const struct exception_table_entry * const struct exception_table_entry *
search_exception_table (unsigned long addr) search_exception_table (unsigned long addr)
{ {
#ifndef CONFIG_MODULE #ifndef CONFIG_MODULES
/* There is only the kernel to search. */ /* There is only the kernel to search. */
return search_one_table(__start___ex_table, return search_one_table(__start___ex_table,
__stop___ex_table - 1, __stop___ex_table - 1,
addr); addr);
#else #else
struct exception_table_entry *ret;
/* The kernel is the last "module" -- no need to treat it special. */ /* The kernel is the last "module" -- no need to treat it special. */
struct module *mp; struct module *mp;
for (mp = module_list; mp ; mp = mp->next) { for (mp = module_list; mp ; mp = mp->next) {
const struct exception_table_entry *ret;
if (!mp->ex_table_start) if (!mp->ex_table_start)
continue; continue;
ret = search_one_table(mp->ex_table_start, mp->ex_table_end - 1, ret = search_one_table(mp->ex_table_start, mp->ex_table_end - 1,
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/traps.h>
#define PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
/* dumped to the console via printk) */
/* Defines for parisc_acctyp() */ /* Defines for parisc_acctyp() */
...@@ -114,59 +118,31 @@ parisc_acctyp(unsigned long code, unsigned int inst) ...@@ -114,59 +118,31 @@ parisc_acctyp(unsigned long code, unsigned int inst)
#undef isGraphicsFlushRead #undef isGraphicsFlushRead
#undef BITSSET #undef BITSSET
/* This is similar to expand_stack(), except that it is for stacks
* that grow upwards.
*/
static inline int expand_stackup(struct vm_area_struct * vma, unsigned long address)
{
unsigned long grow;
address += 4 + PAGE_SIZE - 1;
address &= PAGE_MASK;
grow = (address - vma->vm_end) >> PAGE_SHIFT;
if (address - vma->vm_start > current->rlim[RLIMIT_STACK].rlim_cur ||
((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur)
return -ENOMEM;
vma->vm_end = address;
vma->vm_mm->total_vm += grow;
if (vma->vm_flags & VM_LOCKED)
vma->vm_mm->locked_vm += grow;
return 0;
}
/* This is similar to find_vma(), except that it understands that stacks #if 0
* grow up rather than down. /* This is the treewalk to find a vma which is the highest that has
* XXX Optimise by making use of cache and avl tree as per find_vma(). * a start < addr. We're using find_vma_prev instead right now, but
* we might want to use this at some point in the future. Probably
* not, but I want it committed to CVS so I don't lose it :-)
*/ */
while (tree != vm_avl_empty) {
struct vm_area_struct * pa_find_vma(struct mm_struct * mm, unsigned long addr) if (tree->vm_start > addr) {
{ tree = tree->vm_avl_left;
struct vm_area_struct *vma = NULL; } else {
prev = tree;
if (mm) { if (prev->vm_next == NULL)
vma = mm->mmap; break;
if (!vma || addr < vma->vm_start) if (prev->vm_next->vm_start > addr)
return NULL; break;
while (vma->vm_next && addr >= vma->vm_next->vm_start) tree = tree->vm_avl_right;
vma = vma->vm_next;
} }
return vma; }
} #endif
/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
* routines.
*/
extern void parisc_terminate(char *, struct pt_regs *, int, unsigned long);
void do_page_fault(struct pt_regs *regs, unsigned long code, void do_page_fault(struct pt_regs *regs, unsigned long code,
unsigned long address) unsigned long address)
{ {
struct vm_area_struct * vma; struct vm_area_struct *vma, *prev_vma;
struct task_struct *tsk = current; struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm; struct mm_struct *mm = tsk->mm;
const struct exception_table_entry *fix; const struct exception_table_entry *fix;
...@@ -176,13 +152,9 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, ...@@ -176,13 +152,9 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
goto no_context; goto no_context;
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
vma = pa_find_vma(mm, address); vma = find_vma_prev(mm, address, &prev_vma);
if (!vma) if (!vma || address < vma->vm_start)
goto bad_area; goto check_expansion;
if (address < vma->vm_end)
goto good_area;
if (!(vma->vm_flags & VM_GROWSUP) || expand_stackup(vma, address))
goto bad_area;
/* /*
* Ok, we have a good vm_area for this memory access. We still need to * Ok, we have a good vm_area for this memory access. We still need to
* check the access permissions. * check the access permissions.
...@@ -221,6 +193,11 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, ...@@ -221,6 +193,11 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
return; return;
check_expansion:
vma = prev_vma;
if (vma && (expand_stack(vma, address) == 0))
goto good_area;
/* /*
* Something tried to access memory that isn't in our memory map.. * Something tried to access memory that isn't in our memory map..
*/ */
...@@ -230,9 +207,16 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, ...@@ -230,9 +207,16 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
if (user_mode(regs)) { if (user_mode(regs)) {
struct siginfo si; struct siginfo si;
printk("\ndo_page_fault() pid=%d command='%s'\n", #ifdef PRINT_USER_FAULTS
tsk->pid, tsk->comm); printk(KERN_DEBUG "\n");
printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
tsk->pid, tsk->comm, code, address);
if (vma) {
printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
vma->vm_start, vma->vm_end);
}
show_regs(regs); show_regs(regs);
#endif
/* FIXME: actually we need to get the signo and code correct */ /* FIXME: actually we need to get the signo and code correct */
si.si_signo = SIGSEGV; si.si_signo = SIGSEGV;
si.si_errno = 0; si.si_errno = 0;
...@@ -272,11 +256,11 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, ...@@ -272,11 +256,11 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
} }
} }
parisc_terminate("Bad Address (null pointer deref?)",regs,code,address); parisc_terminate("Bad Address (null pointer deref?)", regs, code, address);
out_of_memory: out_of_memory:
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
printk("VM: killing process %s\n", current->comm); printk(KERN_CRIT "VM: killing process %s\n", current->comm);
if (user_mode(regs)) if (user_mode(regs))
do_exit(SIGKILL); do_exit(SIGKILL);
goto no_context; goto no_context;
......
This diff is collapsed.
/*
* arch/parisc/mm/ioremap.c
*
* Re-map IO memory to kernel address space so that we can access it.
* This is needed for high PCI addresses that aren't mapped in the
* 640k-1MB IO memory area on PC's
*
* (C) Copyright 1995 1996 Linus Torvalds
* (C) Copyright 2001 Helge Deller <deller@gmx.de>
*/
#include <linux/vmalloc.h>
#include <linux/errno.h>
#include <asm/io.h>
#include <asm/pgalloc.h>
static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
unsigned long phys_addr, unsigned long flags)
{
unsigned long end;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
if (address >= end)
BUG();
do {
if (!pte_none(*pte)) {
printk(KERN_ERR "remap_area_pte: page already exists\n");
BUG();
}
set_pte(pte, mk_pte_phys(phys_addr, __pgprot(_PAGE_PRESENT | _PAGE_RW |
_PAGE_DIRTY | _PAGE_ACCESSED | flags)));
address += PAGE_SIZE;
phys_addr += PAGE_SIZE;
pte++;
} while (address && (address < end));
}
static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
unsigned long phys_addr, unsigned long flags)
{
unsigned long end;
address &= ~PGDIR_MASK;
end = address + size;
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
phys_addr -= address;
if (address >= end)
BUG();
do {
pte_t * pte = pte_alloc_kernel(NULL, pmd, address);
if (!pte)
return -ENOMEM;
remap_area_pte(pte, address, end - address, address + phys_addr, flags);
address = (address + PMD_SIZE) & PMD_MASK;
pmd++;
} while (address && (address < end));
return 0;
}
#if (USE_HPPA_IOREMAP)
static int remap_area_pages(unsigned long address, unsigned long phys_addr,
unsigned long size, unsigned long flags)
{
int error;
pgd_t * dir;
unsigned long end = address + size;
phys_addr -= address;
dir = pgd_offset(&init_mm, address);
flush_cache_all();
if (address >= end)
BUG();
spin_lock(&init_mm.page_table_lock);
do {
pmd_t *pmd;
pmd = pmd_alloc(dir, address);
error = -ENOMEM;
if (!pmd)
break;
if (remap_area_pmd(pmd, address, end - address,
phys_addr + address, flags))
break;
error = 0;
address = (address + PGDIR_SIZE) & PGDIR_MASK;
dir++;
} while (address && (address < end));
spin_unlock(&init_mm.page_table_lock);
flush_tlb_all();
return error;
}
#endif /* USE_HPPA_IOREMAP */
/*
* Generic mapping function (not visible outside):
*/
/*
* Remap an arbitrary physical address space into the kernel virtual
* address space. Needed when the kernel wants to access high addresses
* directly.
*
* NOTE! We need to allow non-page-aligned mappings too: we will obviously
* have to convert them into an offset in a page-aligned mapping, but the
* caller shouldn't need to know that small detail.
*/
void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
{
#if !(USE_HPPA_IOREMAP)
unsigned long end = phys_addr + size - 1;
/* Support EISA addresses */
if ((phys_addr >= 0x00080000 && end < 0x000fffff)
|| (phys_addr >= 0x00500000 && end < 0x03bfffff)) {
phys_addr |= 0xfc000000;
}
return (void *)phys_addr;
#else
void * addr;
struct vm_struct * area;
unsigned long offset, last_addr;
/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
if (!size || last_addr < phys_addr)
return NULL;
/*
* Don't allow anybody to remap normal RAM that we're using..
*/
if (phys_addr < virt_to_phys(high_memory)) {
char *t_addr, *t_end;
struct page *page;
t_addr = __va(phys_addr);
t_end = t_addr + (size - 1);
for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++)
if(!PageReserved(page))
return NULL;
}
/*
* Mappings have to be page-aligned
*/
offset = phys_addr & ~PAGE_MASK;
phys_addr &= PAGE_MASK;
size = PAGE_ALIGN(last_addr) - phys_addr;
/*
* Ok, go for it..
*/
area = get_vm_area(size, VM_IOREMAP);
if (!area)
return NULL;
addr = area->addr;
if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
vfree(addr);
return NULL;
}
return (void *) (offset + (char *)addr);
#endif
}
void iounmap(void *addr)
{
#if !(USE_HPPA_IOREMAP)
return;
#else
if (addr > high_memory)
return vfree((void *) (PAGE_MASK & (unsigned long) addr));
#endif
}
/* $Id: pa11.c,v 1.1 1999/03/17 01:05:41 pjlahaie Exp $
*
* pa11.c: PA 1.1 specific mmu/cache code.
*
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/system.h>
#include <asm/sgialib.h>
#include <asm/mmu_context.h>
extern unsigned long mips_tlb_entries;
/* page functions */
void pa11_clear_page(unsigned long page)
{
}
static void pa11_copy_page(unsigned long to, unsigned long from)
{
}
/* Cache operations. */
static inline void pa11_flush_cache_all(void) { }
static void pa11_flush_cache_mm(struct mm_struct *mm) { }
static void pa11_flush_cache_range(struct vm_area_struct *vma,
unsigned long start,
unsigned long end)
{
}
static void pa11_flush_cache_page(struct vm_area_struct *vma,
unsigned long page)
{
}
static void pa11_flush_page_to_ram(unsigned long page)
{
}
static void pa11_flush_cache_sigtramp(unsigned long page)
{
}
/* TLB operations. */
static inline void pa11_flush_tlb_all(void)
{
unsigned long flags;
int entry;
save_and_cli(flags);
/* Here we will need to flush all the TLBs */
restore_flags(flags);
}
static void pa11_flush_tlb_mm(struct mm_struct *mm)
{
/* This is what the MIPS does.. Is it the right thing for PA-RISC? */
if(mm == current->mm)
pa11_flush_tlb_all();
}
static void pa11_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end)
{
if (vma == NULL || vma->vm_mm == current->mm)
pa11_flush_tlb_all();
}
static void pa11_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
{
if(vma->vm_mm == current->mm)
pa11_flush_tlb_all();
}
static void pa11_load_pgd(unsigned long pg_dir)
{
unsigned long flags;
/* We need to do the right thing here */
}
/*
* Initialize new page directory with pointers to invalid ptes
*/
static void pa11_pgd_init(unsigned long page)
{
unsigned long dummy1, dummy2;
}
static void pa11_update_mmu_cache(struct vm_area_struct * vma,
unsigned long address, pte_t pte)
{
pa11_flush_tlb_page(vma, address);
}
static void pa11_show_regs(struct pt_regs * regs)
{
/*
* Saved main processor registers
*/
printk("$0 : %08x %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
0, (unsigned long) regs->regs[1], (unsigned long) regs->regs[2],
(unsigned long) regs->regs[3], (unsigned long) regs->regs[4],
(unsigned long) regs->regs[5], (unsigned long) regs->regs[6],
(unsigned long) regs->regs[7]);
printk("$8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
(unsigned long) regs->regs[8], (unsigned long) regs->regs[9],
(unsigned long) regs->regs[10], (unsigned long) regs->regs[11],
(unsigned long) regs->regs[12], (unsigned long) regs->regs[13],
(unsigned long) regs->regs[14], (unsigned long) regs->regs[15]);
printk("$16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
(unsigned long) regs->regs[16], (unsigned long) regs->regs[17],
(unsigned long) regs->regs[18], (unsigned long) regs->regs[19],
(unsigned long) regs->regs[20], (unsigned long) regs->regs[21],
(unsigned long) regs->regs[22], (unsigned long) regs->regs[23]);
printk("$24: %08lx %08lx %08lx %08lx %08lx %08lx\n",
(unsigned long) regs->regs[24], (unsigned long) regs->regs[25],
(unsigned long) regs->regs[28], (unsigned long) regs->regs[29],
(unsigned long) regs->regs[30], (unsigned long) regs->regs[31]);
/*
* Saved cp0 registers
*/
printk("epc : %08lx %s\nStatus: %08x\nCause : %08x\n",
(unsigned long) regs->cp0_epc, print_tainted(),
(unsigned int) regs->cp0_status,
(unsigned int) regs->cp0_cause);
}
static int pa11_user_mode(struct pt_regs *regs)
{
/* Return user mode stuff?? */
}
__initfunc(void ld_mmu_pa11(void))
{
/* Taken directly from the MIPS arch.. Lots of bad things here */
clear_page = pa11_clear_page;
copy_page = pa11_copy_page;
flush_cache_all = pa11_flush_cache_all;
flush_cache_mm = pa11_flush_cache_mm;
flush_cache_range = pa11_flush_cache_range;
flush_cache_page = pa11_flush_cache_page;
flush_cache_sigtramp = pa11_flush_cache_sigtramp;
flush_page_to_ram = pa11_flush_page_to_ram;
flush_tlb_all = pa11_flush_tlb_all;
flush_tlb_mm = pa11_flush_tlb_mm;
flush_tlb_range = pa11_flush_tlb_range;
flush_tlb_page = pa11_flush_tlb_page;
pa11_asid_setup();
load_pgd = pa11_load_pgd;
pgd_init = pa11_pgd_init;
update_mmu_cache = pa11_update_mmu_cache;
show_regs = pa11_show_regs;
add_wired_entry = pa11_add_wired_entry;
user_mode = pa11_user_mode;
flush_tlb_all();
}
/* $Id: pa20.c,v 1.1 1999/03/17 01:05:41 pjlahaie Exp $
*
* pa20.c: PA 2.0 specific mmu/cache code.
*
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/system.h>
#include <asm/sgialib.h>
#include <asm/mmu_context.h>
extern unsigned long mips_tlb_entries;
/* page functions */
void pa20_clear_page(unsigned long page)
{
}
static void pa20_copy_page(unsigned long to, unsigned long from)
{
}
/* Cache operations. */
static inline void pa20_flush_cache_all(void) { }
static void pa20_flush_cache_mm(struct mm_struct *mm) { }
static void pa20_flush_cache_range(struct vm_area_struct *vma,
unsigned long start,
unsigned long end)
{
}
static void pa20_flush_cache_page(struct vm_area_struct *vma,
unsigned long page)
{
}
static void pa20_flush_page_to_ram(unsigned long page)
{
}
static void pa20_flush_cache_sigtramp(unsigned long page)
{
}
/* TLB operations. */
static inline void pa20_flush_tlb_all(void)
{
unsigned long flags;
int entry;
save_and_cli(flags);
/* Here we will need to flush all the TLBs */
restore_flags(flags);
}
static void pa20_flush_tlb_mm(struct mm_struct *mm)
{
/* This is what the MIPS does.. Is it the right thing for PA-RISC? */
if(mm == current->mm)
pa20_flush_tlb_all();
}
static void pa20_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end)
{
if (vma == NULL || vma->vm_mm == current->mm)
pa20_flush_tlb_all();
}
static void pa20_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
{
if(vma->vm_mm == current->mm)
pa20_flush_tlb_all();
}
static void pa20_load_pgd(unsigned long pg_dir)
{
unsigned long flags;
/* We need to do the right thing here */
}
/*
* Initialize new page directory with pointers to invalid ptes
*/
static void pa20_pgd_init(unsigned long page)
{
unsigned long dummy1, dummy2;
}
static void pa20_update_mmu_cache(struct vm_area_struct * vma,
unsigned long address, pte_t pte)
{
pa20_flush_tlb_page(vma, address);
}
static void pa20_show_regs(struct pt_regs * regs)
{
/*
* Saved main processor registers
*/
printk("$0 : %08x %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
0, (unsigned long) regs->regs[1], (unsigned long) regs->regs[2],
(unsigned long) regs->regs[3], (unsigned long) regs->regs[4],
(unsigned long) regs->regs[5], (unsigned long) regs->regs[6],
(unsigned long) regs->regs[7]);
printk("$8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
(unsigned long) regs->regs[8], (unsigned long) regs->regs[9],
(unsigned long) regs->regs[10], (unsigned long) regs->regs[11],
(unsigned long) regs->regs[12], (unsigned long) regs->regs[13],
(unsigned long) regs->regs[14], (unsigned long) regs->regs[15]);
printk("$16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
(unsigned long) regs->regs[16], (unsigned long) regs->regs[17],
(unsigned long) regs->regs[18], (unsigned long) regs->regs[19],
(unsigned long) regs->regs[20], (unsigned long) regs->regs[21],
(unsigned long) regs->regs[22], (unsigned long) regs->regs[23]);
printk("$24: %08lx %08lx %08lx %08lx %08lx %08lx\n",
(unsigned long) regs->regs[24], (unsigned long) regs->regs[25],
(unsigned long) regs->regs[28], (unsigned long) regs->regs[29],
(unsigned long) regs->regs[30], (unsigned long) regs->regs[31]);
/*
* Saved cp0 registers
*/
printk("epc : %08lx %s\nStatus: %08x\nCause : %08x\n",
(unsigned long) regs->cp0_epc, print_tainted(),
(unsigned int) regs->cp0_status,
(unsigned int) regs->cp0_cause);
}
static int pa20_user_mode(struct pt_regs *regs)
{
/* Return user mode stuff?? */
}
__initfunc(void ld_mmu_pa20(void))
{
/* Taken directly from the MIPS arch.. Lots of bad things here */
clear_page = pa20_clear_page;
copy_page = pa20_copy_page;
flush_cache_all = pa20_flush_cache_all;
flush_cache_mm = pa20_flush_cache_mm;
flush_cache_range = pa20_flush_cache_range;
flush_cache_page = pa20_flush_cache_page;
flush_cache_sigtramp = pa20_flush_cache_sigtramp;
flush_page_to_ram = pa20_flush_page_to_ram;
flush_tlb_all = pa20_flush_tlb_all;
flush_tlb_mm = pa20_flush_tlb_mm;
flush_tlb_range = pa20_flush_tlb_range;
flush_tlb_page = pa20_flush_tlb_page;
pa20_asid_setup();
load_pgd = pa20_load_pgd;
pgd_init = pa20_pgd_init;
update_mmu_cache = pa20_update_mmu_cache;
show_regs = pa20_show_regs;
add_wired_entry = pa20_add_wired_entry;
user_mode = pa20_user_mode;
flush_tlb_all();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment