2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* linux/arch/cris/mm/fault.c
|
|
|
|
*
|
|
|
|
* Low level bus fault handler
|
|
|
|
*
|
|
|
|
*
|
2008-01-21 10:14:59 +00:00
|
|
|
* Copyright (C) 2000-2007 Axis Communications AB
|
|
|
|
*
|
|
|
|
* Authors: Bjorn Wesen
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/pgtable.h>
|
2008-10-21 15:45:58 +00:00
|
|
|
#include <arch/svinto.h>
|
2005-07-27 18:44:42 +00:00
|
|
|
#include <asm/mmu_context.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* debug of low-level TLB reload */
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define D(x) x
|
|
|
|
#else
|
|
|
|
#define D(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern const struct exception_table_entry
|
|
|
|
*search_exception_tables(unsigned long addr);
|
|
|
|
|
|
|
|
asmlinkage void do_page_fault(unsigned long address, struct pt_regs *regs,
|
|
|
|
int protection, int writeaccess);
|
|
|
|
|
|
|
|
/* fast TLB-fill fault handler
|
|
|
|
* this is called from entry.S with interrupts disabled
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
handle_mmu_bus_fault(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
int cause;
|
|
|
|
int select;
|
|
|
|
#ifdef DEBUG
|
|
|
|
int index;
|
|
|
|
int page_id;
|
|
|
|
int acc, inv;
|
|
|
|
#endif
|
2005-07-27 18:44:42 +00:00
|
|
|
pgd_t* pgd = (pgd_t*)per_cpu(current_pgd, smp_processor_id());
|
2005-04-16 22:20:36 +00:00
|
|
|
pmd_t *pmd;
|
|
|
|
pte_t pte;
|
|
|
|
int miss, we, writeac;
|
|
|
|
unsigned long address;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
cause = *R_MMU_CAUSE;
|
|
|
|
|
|
|
|
address = cause & PAGE_MASK; /* get faulting address */
|
|
|
|
select = *R_TLB_SELECT;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
page_id = IO_EXTRACT(R_MMU_CAUSE, page_id, cause);
|
|
|
|
acc = IO_EXTRACT(R_MMU_CAUSE, acc_excp, cause);
|
2008-01-21 10:14:59 +00:00
|
|
|
inv = IO_EXTRACT(R_MMU_CAUSE, inv_excp, cause);
|
2005-04-16 22:20:36 +00:00
|
|
|
index = IO_EXTRACT(R_TLB_SELECT, index, select);
|
|
|
|
#endif
|
|
|
|
miss = IO_EXTRACT(R_MMU_CAUSE, miss_excp, cause);
|
|
|
|
we = IO_EXTRACT(R_MMU_CAUSE, we_excp, cause);
|
|
|
|
writeac = IO_EXTRACT(R_MMU_CAUSE, wr_rd, cause);
|
|
|
|
|
|
|
|
D(printk("bus_fault from IRP 0x%lx: addr 0x%lx, miss %d, inv %d, we %d, acc %d, dx %d pid %d\n",
|
|
|
|
regs->irp, address, miss, inv, we, acc, index, page_id));
|
|
|
|
|
|
|
|
/* leave it to the MM system fault handler */
|
|
|
|
if (miss)
|
|
|
|
do_page_fault(address, regs, 0, writeac);
|
|
|
|
else
|
|
|
|
do_page_fault(address, regs, 1, we);
|
|
|
|
|
|
|
|
/* Reload TLB with new entry to avoid an extra miss exception.
|
|
|
|
* do_page_fault may have flushed the TLB so we have to restore
|
|
|
|
* the MMU registers.
|
|
|
|
*/
|
2009-10-09 09:26:14 +00:00
|
|
|
local_irq_save(flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
pmd = (pmd_t *)(pgd + pgd_index(address));
|
|
|
|
if (pmd_none(*pmd))
|
2008-01-21 10:14:59 +00:00
|
|
|
goto exit;
|
2005-04-16 22:20:36 +00:00
|
|
|
pte = *pte_offset_kernel(pmd, address);
|
|
|
|
if (!pte_present(pte))
|
2008-01-21 10:14:59 +00:00
|
|
|
goto exit;
|
2005-04-16 22:20:36 +00:00
|
|
|
*R_TLB_SELECT = select;
|
|
|
|
*R_TLB_HI = cause;
|
|
|
|
*R_TLB_LO = pte_val(pte);
|
2008-01-21 10:14:59 +00:00
|
|
|
exit:
|
2005-04-16 22:20:36 +00:00
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|