1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/cris/mm/fault.c
5 * Low level bus fault handler
8 * Copyright (C) 2000-2007 Axis Communications AB
10 * Authors: Bjorn Wesen
15 #include <linux/uaccess.h>
16 #include <asm/pgtable.h>
17 #include <arch/svinto.h>
18 #include <asm/mmu_context.h>
20 /* debug of low-level TLB reload */
29 extern const struct exception_table_entry
30 *search_exception_tables(unsigned long addr
);
32 asmlinkage
void do_page_fault(unsigned long address
, struct pt_regs
*regs
,
33 int protection
, int writeaccess
);
35 /* fast TLB-fill fault handler
36 * this is called from entry.S with interrupts disabled
40 handle_mmu_bus_fault(struct pt_regs
*regs
)
49 pgd_t
* pgd
= (pgd_t
*)per_cpu(current_pgd
, smp_processor_id());
52 int miss
, we
, writeac
;
53 unsigned long address
;
58 address
= cause
& PAGE_MASK
; /* get faulting address */
59 select
= *R_TLB_SELECT
;
62 page_id
= IO_EXTRACT(R_MMU_CAUSE
, page_id
, cause
);
63 acc
= IO_EXTRACT(R_MMU_CAUSE
, acc_excp
, cause
);
64 inv
= IO_EXTRACT(R_MMU_CAUSE
, inv_excp
, cause
);
65 index
= IO_EXTRACT(R_TLB_SELECT
, index
, select
);
67 miss
= IO_EXTRACT(R_MMU_CAUSE
, miss_excp
, cause
);
68 we
= IO_EXTRACT(R_MMU_CAUSE
, we_excp
, cause
);
69 writeac
= IO_EXTRACT(R_MMU_CAUSE
, wr_rd
, cause
);
71 D(printk("bus_fault from IRP 0x%lx: addr 0x%lx, miss %d, inv %d, we %d, acc %d, dx %d pid %d\n",
72 regs
->irp
, address
, miss
, inv
, we
, acc
, index
, page_id
));
74 /* leave it to the MM system fault handler */
76 do_page_fault(address
, regs
, 0, writeac
);
78 do_page_fault(address
, regs
, 1, we
);
80 /* Reload TLB with new entry to avoid an extra miss exception.
81 * do_page_fault may have flushed the TLB so we have to restore
84 local_irq_save(flags
);
85 pmd
= (pmd_t
*)(pgd
+ pgd_index(address
));
88 pte
= *pte_offset_kernel(pmd
, address
);
89 if (!pte_present(pte
))
91 *R_TLB_SELECT
= select
;
93 *R_TLB_LO
= pte_val(pte
);
95 local_irq_restore(flags
);