11da177e4SLinus Torvalds/* 21da177e4SLinus Torvalds * linux/arch/arm/kernel/entry-armv.S 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 1996,1997,1998 Russell King. 51da177e4SLinus Torvalds * ARM700 fix by Matthew Godbolt (linux-user@willothewisp.demon.co.uk) 6afeb90caSHyok S. Choi * nommu support by Hyok S. Choi (hyok.choi@samsung.com) 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 91da177e4SLinus Torvalds * it under the terms of the GNU General Public License version 2 as 101da177e4SLinus Torvalds * published by the Free Software Foundation. 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * Low-level vector interface routines 131da177e4SLinus Torvalds * 1470b6f2b4SNicolas Pitre * Note: there is a StrongARM bug in the STMIA rn, {regs}^ instruction 1570b6f2b4SNicolas Pitre * that causes it to save wrong values... Be aware! 161da177e4SLinus Torvalds */ 171da177e4SLinus Torvalds 186f6f6a70SRob Herring#include <asm/assembler.h> 19f09b9979SNicolas Pitre#include <asm/memory.h> 20753790e7SRussell King#include <asm/glue-df.h> 21753790e7SRussell King#include <asm/glue-pf.h> 221da177e4SLinus Torvalds#include <asm/vfpmacros.h> 23243c8654SRob Herring#ifndef CONFIG_MULTI_IRQ_HANDLER 24a09e64fbSRussell King#include <mach/entry-macro.S> 25243c8654SRob Herring#endif 26d6551e88SRussell King#include <asm/thread_notify.h> 27c4c5716eSCatalin Marinas#include <asm/unwind.h> 28cc20d429SRussell King#include <asm/unistd.h> 29f159f4edSTony Lindgren#include <asm/tls.h> 309f97da78SDavid Howells#include <asm/system_info.h> 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds#include "entry-header.S" 33cd544ce7SMagnus Damm#include <asm/entry-macro-multi.S> 34a0266c21SWang Nan#include <asm/probes.h> 351da177e4SLinus Torvalds 361da177e4SLinus Torvalds/* 37d9600c99SRussell King * Interrupt handling. 38187a51adSRussell King */ 39187a51adSRussell King .macro irq_handler 4052108641Seric miao#ifdef CONFIG_MULTI_IRQ_HANDLER 41d9600c99SRussell King ldr r1, =handle_arch_irq 4252108641Seric miao mov r0, sp 4352108641Seric miao adr lr, BSYM(9997f) 44abeb24aeSMarc Zyngier ldr pc, [r1] 45abeb24aeSMarc Zyngier#else 46cd544ce7SMagnus Damm arch_irq_handler_default 47abeb24aeSMarc Zyngier#endif 48f00ec48fSRussell King9997: 49187a51adSRussell King .endm 50187a51adSRussell King 51ac8b9c1cSRussell King .macro pabt_helper 528dfe7ac9SRussell King @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5 53ac8b9c1cSRussell King#ifdef MULTI_PABORT 540402beceSRussell King ldr ip, .LCprocfns 55ac8b9c1cSRussell King mov lr, pc 560402beceSRussell King ldr pc, [ip, #PROCESSOR_PABT_FUNC] 57ac8b9c1cSRussell King#else 58ac8b9c1cSRussell King bl CPU_PABORT_HANDLER 59ac8b9c1cSRussell King#endif 60ac8b9c1cSRussell King .endm 61ac8b9c1cSRussell King 62ac8b9c1cSRussell King .macro dabt_helper 63ac8b9c1cSRussell King 64ac8b9c1cSRussell King @ 65ac8b9c1cSRussell King @ Call the processor-specific abort handler: 66ac8b9c1cSRussell King @ 67da740472SRussell King @ r2 - pt_regs 683e287becSRussell King @ r4 - aborted context pc 693e287becSRussell King @ r5 - aborted context psr 70ac8b9c1cSRussell King @ 71ac8b9c1cSRussell King @ The abort handler must return the aborted address in r0, and 72ac8b9c1cSRussell King @ the fault status register in r1. r9 must be preserved. 73ac8b9c1cSRussell King @ 74ac8b9c1cSRussell King#ifdef MULTI_DABORT 750402beceSRussell King ldr ip, .LCprocfns 76ac8b9c1cSRussell King mov lr, pc 770402beceSRussell King ldr pc, [ip, #PROCESSOR_DABT_FUNC] 78ac8b9c1cSRussell King#else 79ac8b9c1cSRussell King bl CPU_DABORT_HANDLER 80ac8b9c1cSRussell King#endif 81ac8b9c1cSRussell King .endm 82ac8b9c1cSRussell King 83785d3cd2SNicolas Pitre#ifdef CONFIG_KPROBES 84785d3cd2SNicolas Pitre .section .kprobes.text,"ax",%progbits 85785d3cd2SNicolas Pitre#else 86785d3cd2SNicolas Pitre .text 87785d3cd2SNicolas Pitre#endif 88785d3cd2SNicolas Pitre 89187a51adSRussell King/* 901da177e4SLinus Torvalds * Invalid mode handlers 911da177e4SLinus Torvalds */ 92ccea7a19SRussell King .macro inv_entry, reason 93ccea7a19SRussell King sub sp, sp, #S_FRAME_SIZE 94b86040a5SCatalin Marinas ARM( stmib sp, {r1 - lr} ) 95b86040a5SCatalin Marinas THUMB( stmia sp, {r0 - r12} ) 96b86040a5SCatalin Marinas THUMB( str sp, [sp, #S_SP] ) 97b86040a5SCatalin Marinas THUMB( str lr, [sp, #S_LR] ) 981da177e4SLinus Torvalds mov r1, #\reason 991da177e4SLinus Torvalds .endm 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds__pabt_invalid: 102ccea7a19SRussell King inv_entry BAD_PREFETCH 103ccea7a19SRussell King b common_invalid 10493ed3970SCatalin MarinasENDPROC(__pabt_invalid) 1051da177e4SLinus Torvalds 1061da177e4SLinus Torvalds__dabt_invalid: 107ccea7a19SRussell King inv_entry BAD_DATA 108ccea7a19SRussell King b common_invalid 10993ed3970SCatalin MarinasENDPROC(__dabt_invalid) 1101da177e4SLinus Torvalds 1111da177e4SLinus Torvalds__irq_invalid: 112ccea7a19SRussell King inv_entry BAD_IRQ 113ccea7a19SRussell King b common_invalid 11493ed3970SCatalin MarinasENDPROC(__irq_invalid) 1151da177e4SLinus Torvalds 1161da177e4SLinus Torvalds__und_invalid: 117ccea7a19SRussell King inv_entry BAD_UNDEFINSTR 1181da177e4SLinus Torvalds 119ccea7a19SRussell King @ 120ccea7a19SRussell King @ XXX fall through to common_invalid 121ccea7a19SRussell King @ 122ccea7a19SRussell King 123ccea7a19SRussell King@ 124ccea7a19SRussell King@ common_invalid - generic code for failed exception (re-entrant version of handlers) 125ccea7a19SRussell King@ 126ccea7a19SRussell Kingcommon_invalid: 127ccea7a19SRussell King zero_fp 128ccea7a19SRussell King 129ccea7a19SRussell King ldmia r0, {r4 - r6} 130ccea7a19SRussell King add r0, sp, #S_PC @ here for interlock avoidance 131ccea7a19SRussell King mov r7, #-1 @ "" "" "" "" 132ccea7a19SRussell King str r4, [sp] @ save preserved r0 133ccea7a19SRussell King stmia r0, {r5 - r7} @ lr_<exception>, 134ccea7a19SRussell King @ cpsr_<exception>, "old_r0" 135ccea7a19SRussell King 1361da177e4SLinus Torvalds mov r0, sp 1371da177e4SLinus Torvalds b bad_mode 13893ed3970SCatalin MarinasENDPROC(__und_invalid) 1391da177e4SLinus Torvalds 1401da177e4SLinus Torvalds/* 1411da177e4SLinus Torvalds * SVC mode handlers 1421da177e4SLinus Torvalds */ 1432dede2d8SNicolas Pitre 1442dede2d8SNicolas Pitre#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) 1452dede2d8SNicolas Pitre#define SPFIX(code...) code 1462dede2d8SNicolas Pitre#else 1472dede2d8SNicolas Pitre#define SPFIX(code...) 1482dede2d8SNicolas Pitre#endif 1492dede2d8SNicolas Pitre 150c0e7f7eeSDaniel Thompson .macro svc_entry, stack_hole=0, trace=1 151c4c5716eSCatalin Marinas UNWIND(.fnstart ) 152c4c5716eSCatalin Marinas UNWIND(.save {r0 - pc} ) 153b86040a5SCatalin Marinas sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4) 154b86040a5SCatalin Marinas#ifdef CONFIG_THUMB2_KERNEL 155b86040a5SCatalin Marinas SPFIX( str r0, [sp] ) @ temporarily saved 156b86040a5SCatalin Marinas SPFIX( mov r0, sp ) 157b86040a5SCatalin Marinas SPFIX( tst r0, #4 ) @ test original stack alignment 158b86040a5SCatalin Marinas SPFIX( ldr r0, [sp] ) @ restored 159b86040a5SCatalin Marinas#else 1602dede2d8SNicolas Pitre SPFIX( tst sp, #4 ) 161b86040a5SCatalin Marinas#endif 162b86040a5SCatalin Marinas SPFIX( subeq sp, sp, #4 ) 163b86040a5SCatalin Marinas stmia sp, {r1 - r12} 164ccea7a19SRussell King 165b059bdc3SRussell King ldmia r0, {r3 - r5} 166b059bdc3SRussell King add r7, sp, #S_SP - 4 @ here for interlock avoidance 167b059bdc3SRussell King mov r6, #-1 @ "" "" "" "" 168b059bdc3SRussell King add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4) 169b059bdc3SRussell King SPFIX( addeq r2, r2, #4 ) 170b059bdc3SRussell King str r3, [sp, #-4]! @ save the "real" r0 copied 171ccea7a19SRussell King @ from the exception stack 172ccea7a19SRussell King 173b059bdc3SRussell King mov r3, lr 1741da177e4SLinus Torvalds 1751da177e4SLinus Torvalds @ 1761da177e4SLinus Torvalds @ We are now ready to fill in the remaining blanks on the stack: 1771da177e4SLinus Torvalds @ 178b059bdc3SRussell King @ r2 - sp_svc 179b059bdc3SRussell King @ r3 - lr_svc 180b059bdc3SRussell King @ r4 - lr_<exception>, already fixed up for correct return/restart 181b059bdc3SRussell King @ r5 - spsr_<exception> 182b059bdc3SRussell King @ r6 - orig_r0 (see pt_regs definition in ptrace.h) 1831da177e4SLinus Torvalds @ 184b059bdc3SRussell King stmia r7, {r2 - r6} 185f2741b78SRussell King 186c0e7f7eeSDaniel Thompson .if \trace 187f2741b78SRussell King#ifdef CONFIG_TRACE_IRQFLAGS 188f2741b78SRussell King bl trace_hardirqs_off 189f2741b78SRussell King#endif 190c0e7f7eeSDaniel Thompson .endif 1911da177e4SLinus Torvalds .endm 1921da177e4SLinus Torvalds 1931da177e4SLinus Torvalds .align 5 1941da177e4SLinus Torvalds__dabt_svc: 195ccea7a19SRussell King svc_entry 1961da177e4SLinus Torvalds mov r2, sp 197da740472SRussell King dabt_helper 198e16b31bfSMarc Zyngier THUMB( ldr r5, [sp, #S_PSR] ) @ potentially updated CPSR 199b059bdc3SRussell King svc_exit r5 @ return from exception 200c4c5716eSCatalin Marinas UNWIND(.fnend ) 20193ed3970SCatalin MarinasENDPROC(__dabt_svc) 2021da177e4SLinus Torvalds 2031da177e4SLinus Torvalds .align 5 2041da177e4SLinus Torvalds__irq_svc: 205ccea7a19SRussell King svc_entry 2061613cc11SRussell King irq_handler 2071613cc11SRussell King 2081da177e4SLinus Torvalds#ifdef CONFIG_PREEMPT 209706fdd9fSRussell King get_thread_info tsk 210706fdd9fSRussell King ldr r8, [tsk, #TI_PREEMPT] @ get preempt count 211706fdd9fSRussell King ldr r0, [tsk, #TI_FLAGS] @ get flags 21228fab1a2SRussell King teq r8, #0 @ if preempt count != 0 21328fab1a2SRussell King movne r0, #0 @ force flags to 0 2141da177e4SLinus Torvalds tst r0, #_TIF_NEED_RESCHED 2151da177e4SLinus Torvalds blne svc_preempt 2161da177e4SLinus Torvalds#endif 21730891c90SRussell King 2189b56febeSRussell King svc_exit r5, irq = 1 @ return from exception 219c4c5716eSCatalin Marinas UNWIND(.fnend ) 22093ed3970SCatalin MarinasENDPROC(__irq_svc) 2211da177e4SLinus Torvalds 2221da177e4SLinus Torvalds .ltorg 2231da177e4SLinus Torvalds 2241da177e4SLinus Torvalds#ifdef CONFIG_PREEMPT 2251da177e4SLinus Torvaldssvc_preempt: 22628fab1a2SRussell King mov r8, lr 2271da177e4SLinus Torvalds1: bl preempt_schedule_irq @ irq en/disable is done inside 228706fdd9fSRussell King ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS 2291da177e4SLinus Torvalds tst r0, #_TIF_NEED_RESCHED 2306ebbf2ceSRussell King reteq r8 @ go again 2311da177e4SLinus Torvalds b 1b 2321da177e4SLinus Torvalds#endif 2331da177e4SLinus Torvalds 23415ac49b6SRussell King__und_fault: 23515ac49b6SRussell King @ Correct the PC such that it is pointing at the instruction 23615ac49b6SRussell King @ which caused the fault. If the faulting instruction was ARM 23715ac49b6SRussell King @ the PC will be pointing at the next instruction, and have to 23815ac49b6SRussell King @ subtract 4. Otherwise, it is Thumb, and the PC will be 23915ac49b6SRussell King @ pointing at the second half of the Thumb instruction. We 24015ac49b6SRussell King @ have to subtract 2. 24115ac49b6SRussell King ldr r2, [r0, #S_PC] 24215ac49b6SRussell King sub r2, r2, r1 24315ac49b6SRussell King str r2, [r0, #S_PC] 24415ac49b6SRussell King b do_undefinstr 24515ac49b6SRussell KingENDPROC(__und_fault) 24615ac49b6SRussell King 2471da177e4SLinus Torvalds .align 5 2481da177e4SLinus Torvalds__und_svc: 249d30a0c8bSNicolas Pitre#ifdef CONFIG_KPROBES 250d30a0c8bSNicolas Pitre @ If a kprobe is about to simulate a "stmdb sp..." instruction, 251d30a0c8bSNicolas Pitre @ it obviously needs free stack space which then will belong to 252d30a0c8bSNicolas Pitre @ the saved context. 253a0266c21SWang Nan svc_entry MAX_STACK_SIZE 254d30a0c8bSNicolas Pitre#else 255ccea7a19SRussell King svc_entry 256d30a0c8bSNicolas Pitre#endif 2571da177e4SLinus Torvalds @ 2581da177e4SLinus Torvalds @ call emulation code, which returns using r9 if it has emulated 2591da177e4SLinus Torvalds @ the instruction, or the more conventional lr if we are to treat 2601da177e4SLinus Torvalds @ this as a real undefined instruction 2611da177e4SLinus Torvalds @ 2621da177e4SLinus Torvalds @ r0 - instruction 2631da177e4SLinus Torvalds @ 26483e686eaSCatalin Marinas#ifndef CONFIG_THUMB2_KERNEL 265b059bdc3SRussell King ldr r0, [r4, #-4] 26683e686eaSCatalin Marinas#else 26715ac49b6SRussell King mov r1, #2 268b059bdc3SRussell King ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2 26985519189SDave Martin cmp r0, #0xe800 @ 32-bit instruction if xx >= 0 27015ac49b6SRussell King blo __und_svc_fault 27115ac49b6SRussell King ldrh r9, [r4] @ bottom 16 bits 27215ac49b6SRussell King add r4, r4, #2 27315ac49b6SRussell King str r4, [sp, #S_PC] 27415ac49b6SRussell King orr r0, r9, r0, lsl #16 27583e686eaSCatalin Marinas#endif 27615ac49b6SRussell King adr r9, BSYM(__und_svc_finish) 277b059bdc3SRussell King mov r2, r4 2781da177e4SLinus Torvalds bl call_fpe 2791da177e4SLinus Torvalds 28015ac49b6SRussell King mov r1, #4 @ PC correction to apply 28115ac49b6SRussell King__und_svc_fault: 2821da177e4SLinus Torvalds mov r0, sp @ struct pt_regs *regs 28315ac49b6SRussell King bl __und_fault 2841da177e4SLinus Torvalds 28515ac49b6SRussell King__und_svc_finish: 286b059bdc3SRussell King ldr r5, [sp, #S_PSR] @ Get SVC cpsr 287b059bdc3SRussell King svc_exit r5 @ return from exception 288c4c5716eSCatalin Marinas UNWIND(.fnend ) 28993ed3970SCatalin MarinasENDPROC(__und_svc) 2901da177e4SLinus Torvalds 2911da177e4SLinus Torvalds .align 5 2921da177e4SLinus Torvalds__pabt_svc: 293ccea7a19SRussell King svc_entry 2944fb28474SKirill A. Shutemov mov r2, sp @ regs 2958dfe7ac9SRussell King pabt_helper 296b059bdc3SRussell King svc_exit r5 @ return from exception 297c4c5716eSCatalin Marinas UNWIND(.fnend ) 29893ed3970SCatalin MarinasENDPROC(__pabt_svc) 2991da177e4SLinus Torvalds 3001da177e4SLinus Torvalds .align 5 301c0e7f7eeSDaniel Thompson__fiq_svc: 302c0e7f7eeSDaniel Thompson svc_entry trace=0 303c0e7f7eeSDaniel Thompson mov r0, sp @ struct pt_regs *regs 304c0e7f7eeSDaniel Thompson bl handle_fiq_as_nmi 305c0e7f7eeSDaniel Thompson svc_exit_via_fiq 306c0e7f7eeSDaniel Thompson UNWIND(.fnend ) 307c0e7f7eeSDaniel ThompsonENDPROC(__fiq_svc) 308c0e7f7eeSDaniel Thompson 309c0e7f7eeSDaniel Thompson .align 5 31049f680eaSRussell King.LCcralign: 31149f680eaSRussell King .word cr_alignment 31248d7927bSPaul Brook#ifdef MULTI_DABORT 3131da177e4SLinus Torvalds.LCprocfns: 3141da177e4SLinus Torvalds .word processor 3151da177e4SLinus Torvalds#endif 3161da177e4SLinus Torvalds.LCfp: 3171da177e4SLinus Torvalds .word fp_enter 3181da177e4SLinus Torvalds 3191da177e4SLinus Torvalds/* 320c0e7f7eeSDaniel Thompson * Abort mode handlers 321c0e7f7eeSDaniel Thompson */ 322c0e7f7eeSDaniel Thompson 323c0e7f7eeSDaniel Thompson@ 324c0e7f7eeSDaniel Thompson@ Taking a FIQ in abort mode is similar to taking a FIQ in SVC mode 325c0e7f7eeSDaniel Thompson@ and reuses the same macros. However in abort mode we must also 326c0e7f7eeSDaniel Thompson@ save/restore lr_abt and spsr_abt to make nested aborts safe. 327c0e7f7eeSDaniel Thompson@ 328c0e7f7eeSDaniel Thompson .align 5 329c0e7f7eeSDaniel Thompson__fiq_abt: 330c0e7f7eeSDaniel Thompson svc_entry trace=0 331c0e7f7eeSDaniel Thompson 332c0e7f7eeSDaniel Thompson ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT ) 333c0e7f7eeSDaniel Thompson THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT ) 334c0e7f7eeSDaniel Thompson THUMB( msr cpsr_c, r0 ) 335c0e7f7eeSDaniel Thompson mov r1, lr @ Save lr_abt 336c0e7f7eeSDaniel Thompson mrs r2, spsr @ Save spsr_abt, abort is now safe 337c0e7f7eeSDaniel Thompson ARM( msr cpsr_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT ) 338c0e7f7eeSDaniel Thompson THUMB( mov r0, #SVC_MODE | PSR_I_BIT | PSR_F_BIT ) 339c0e7f7eeSDaniel Thompson THUMB( msr cpsr_c, r0 ) 340c0e7f7eeSDaniel Thompson stmfd sp!, {r1 - r2} 341c0e7f7eeSDaniel Thompson 342c0e7f7eeSDaniel Thompson add r0, sp, #8 @ struct pt_regs *regs 343c0e7f7eeSDaniel Thompson bl handle_fiq_as_nmi 344c0e7f7eeSDaniel Thompson 345c0e7f7eeSDaniel Thompson ldmfd sp!, {r1 - r2} 346c0e7f7eeSDaniel Thompson ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT ) 347c0e7f7eeSDaniel Thompson THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT ) 348c0e7f7eeSDaniel Thompson THUMB( msr cpsr_c, r0 ) 349c0e7f7eeSDaniel Thompson mov lr, r1 @ Restore lr_abt, abort is unsafe 350c0e7f7eeSDaniel Thompson msr spsr_cxsf, r2 @ Restore spsr_abt 351c0e7f7eeSDaniel Thompson ARM( msr cpsr_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT ) 352c0e7f7eeSDaniel Thompson THUMB( mov r0, #SVC_MODE | PSR_I_BIT | PSR_F_BIT ) 353c0e7f7eeSDaniel Thompson THUMB( msr cpsr_c, r0 ) 354c0e7f7eeSDaniel Thompson 355c0e7f7eeSDaniel Thompson svc_exit_via_fiq 356c0e7f7eeSDaniel Thompson UNWIND(.fnend ) 357c0e7f7eeSDaniel ThompsonENDPROC(__fiq_abt) 358c0e7f7eeSDaniel Thompson 359c0e7f7eeSDaniel Thompson/* 3601da177e4SLinus Torvalds * User mode handlers 3612dede2d8SNicolas Pitre * 3622dede2d8SNicolas Pitre * EABI note: sp_svc is always 64-bit aligned here, so should S_FRAME_SIZE 3631da177e4SLinus Torvalds */ 3642dede2d8SNicolas Pitre 3652dede2d8SNicolas Pitre#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) && (S_FRAME_SIZE & 7) 3662dede2d8SNicolas Pitre#error "sizeof(struct pt_regs) must be a multiple of 8" 3672dede2d8SNicolas Pitre#endif 3682dede2d8SNicolas Pitre 369c0e7f7eeSDaniel Thompson .macro usr_entry, trace=1 370c4c5716eSCatalin Marinas UNWIND(.fnstart ) 371c4c5716eSCatalin Marinas UNWIND(.cantunwind ) @ don't unwind the user space 372ccea7a19SRussell King sub sp, sp, #S_FRAME_SIZE 373b86040a5SCatalin Marinas ARM( stmib sp, {r1 - r12} ) 374b86040a5SCatalin Marinas THUMB( stmia sp, {r0 - r12} ) 375ccea7a19SRussell King 376195b58adSRussell King ATRAP( mrc p15, 0, r7, c1, c0, 0) 377195b58adSRussell King ATRAP( ldr r8, .LCcralign) 378195b58adSRussell King 379b059bdc3SRussell King ldmia r0, {r3 - r5} 380ccea7a19SRussell King add r0, sp, #S_PC @ here for interlock avoidance 381b059bdc3SRussell King mov r6, #-1 @ "" "" "" "" 382ccea7a19SRussell King 383b059bdc3SRussell King str r3, [sp] @ save the "real" r0 copied 384ccea7a19SRussell King @ from the exception stack 3851da177e4SLinus Torvalds 386195b58adSRussell King ATRAP( ldr r8, [r8, #0]) 387195b58adSRussell King 3881da177e4SLinus Torvalds @ 3891da177e4SLinus Torvalds @ We are now ready to fill in the remaining blanks on the stack: 3901da177e4SLinus Torvalds @ 391b059bdc3SRussell King @ r4 - lr_<exception>, already fixed up for correct return/restart 392b059bdc3SRussell King @ r5 - spsr_<exception> 393b059bdc3SRussell King @ r6 - orig_r0 (see pt_regs definition in ptrace.h) 3941da177e4SLinus Torvalds @ 3951da177e4SLinus Torvalds @ Also, separately save sp_usr and lr_usr 3961da177e4SLinus Torvalds @ 397b059bdc3SRussell King stmia r0, {r4 - r6} 398b86040a5SCatalin Marinas ARM( stmdb r0, {sp, lr}^ ) 399b86040a5SCatalin Marinas THUMB( store_user_sp_lr r0, r1, S_SP - S_PC ) 4001da177e4SLinus Torvalds 4011da177e4SLinus Torvalds @ Enable the alignment trap while in kernel mode 402195b58adSRussell King ATRAP( teq r8, r7) 403195b58adSRussell King ATRAP( mcrne p15, 0, r8, c1, c0, 0) 4041da177e4SLinus Torvalds 4051da177e4SLinus Torvalds @ 4061da177e4SLinus Torvalds @ Clear FP to mark the first stack frame 4071da177e4SLinus Torvalds @ 4081da177e4SLinus Torvalds zero_fp 409f2741b78SRussell King 410c0e7f7eeSDaniel Thompson .if \trace 411f2741b78SRussell King#ifdef CONFIG_IRQSOFF_TRACER 412f2741b78SRussell King bl trace_hardirqs_off 413f2741b78SRussell King#endif 414b0088480SKevin Hilman ct_user_exit save = 0 415c0e7f7eeSDaniel Thompson .endif 4161da177e4SLinus Torvalds .endm 4171da177e4SLinus Torvalds 418b49c0f24SNicolas Pitre .macro kuser_cmpxchg_check 4191b16c4bcSRussell King#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \ 4201b16c4bcSRussell King !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG) 421b49c0f24SNicolas Pitre#ifndef CONFIG_MMU 422b49c0f24SNicolas Pitre#warning "NPTL on non MMU needs fixing" 423b49c0f24SNicolas Pitre#else 424b49c0f24SNicolas Pitre @ Make sure our user space atomic helper is restarted 425b49c0f24SNicolas Pitre @ if it was interrupted in a critical region. Here we 426b49c0f24SNicolas Pitre @ perform a quick test inline since it should be false 427b49c0f24SNicolas Pitre @ 99.9999% of the time. The rest is done out of line. 428b059bdc3SRussell King cmp r4, #TASK_SIZE 42940fb79c8SNicolas Pitre blhs kuser_cmpxchg64_fixup 430b49c0f24SNicolas Pitre#endif 431b49c0f24SNicolas Pitre#endif 432b49c0f24SNicolas Pitre .endm 433b49c0f24SNicolas Pitre 4341da177e4SLinus Torvalds .align 5 4351da177e4SLinus Torvalds__dabt_usr: 436ccea7a19SRussell King usr_entry 437b49c0f24SNicolas Pitre kuser_cmpxchg_check 4381da177e4SLinus Torvalds mov r2, sp 439da740472SRussell King dabt_helper 440da740472SRussell King b ret_from_exception 441c4c5716eSCatalin Marinas UNWIND(.fnend ) 44293ed3970SCatalin MarinasENDPROC(__dabt_usr) 4431da177e4SLinus Torvalds 4441da177e4SLinus Torvalds .align 5 4451da177e4SLinus Torvalds__irq_usr: 446ccea7a19SRussell King usr_entry 447bc089602SRussell King kuser_cmpxchg_check 448187a51adSRussell King irq_handler 4491613cc11SRussell King get_thread_info tsk 4501da177e4SLinus Torvalds mov why, #0 4519fc2552aSMing Lei b ret_to_user_from_irq 452c4c5716eSCatalin Marinas UNWIND(.fnend ) 45393ed3970SCatalin MarinasENDPROC(__irq_usr) 4541da177e4SLinus Torvalds 4551da177e4SLinus Torvalds .ltorg 4561da177e4SLinus Torvalds 4571da177e4SLinus Torvalds .align 5 4581da177e4SLinus Torvalds__und_usr: 459ccea7a19SRussell King usr_entry 460bc089602SRussell King 461b059bdc3SRussell King mov r2, r4 462b059bdc3SRussell King mov r3, r5 4631da177e4SLinus Torvalds 46415ac49b6SRussell King @ r2 = regs->ARM_pc, which is either 2 or 4 bytes ahead of the 46515ac49b6SRussell King @ faulting instruction depending on Thumb mode. 46615ac49b6SRussell King @ r3 = regs->ARM_cpsr 4671da177e4SLinus Torvalds @ 46815ac49b6SRussell King @ The emulation code returns using r9 if it has emulated the 46915ac49b6SRussell King @ instruction, or the more conventional lr if we are to treat 47015ac49b6SRussell King @ this as a real undefined instruction 4711da177e4SLinus Torvalds @ 472b86040a5SCatalin Marinas adr r9, BSYM(ret_from_exception) 47315ac49b6SRussell King 4741417a6b8SCatalin Marinas @ IRQs must be enabled before attempting to read the instruction from 4751417a6b8SCatalin Marinas @ user space since that could cause a page/translation fault if the 4761417a6b8SCatalin Marinas @ page table was modified by another CPU. 4771417a6b8SCatalin Marinas enable_irq 4781417a6b8SCatalin Marinas 479cb170a45SPaul Brook tst r3, #PSR_T_BIT @ Thumb mode? 48015ac49b6SRussell King bne __und_usr_thumb 48115ac49b6SRussell King sub r4, r2, #4 @ ARM instr at LR - 4 48215ac49b6SRussell King1: ldrt r0, [r4] 483457c2403SBen Dooks ARM_BE8(rev r0, r0) @ little endian instruction 484457c2403SBen Dooks 48515ac49b6SRussell King @ r0 = 32-bit ARM instruction which caused the exception 48615ac49b6SRussell King @ r2 = PC value for the following instruction (:= regs->ARM_pc) 48715ac49b6SRussell King @ r4 = PC value for the faulting instruction 48815ac49b6SRussell King @ lr = 32-bit undefined instruction function 48915ac49b6SRussell King adr lr, BSYM(__und_usr_fault_32) 49015ac49b6SRussell King b call_fpe 49115ac49b6SRussell King 49215ac49b6SRussell King__und_usr_thumb: 493cb170a45SPaul Brook @ Thumb instruction 49415ac49b6SRussell King sub r4, r2, #2 @ First half of thumb instr at LR - 2 495ef4c5368SDave Martin#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7 496ef4c5368SDave Martin/* 497ef4c5368SDave Martin * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms 498ef4c5368SDave Martin * can never be supported in a single kernel, this code is not applicable at 499ef4c5368SDave Martin * all when __LINUX_ARM_ARCH__ < 6. This allows simplifying assumptions to be 500ef4c5368SDave Martin * made about .arch directives. 501ef4c5368SDave Martin */ 502ef4c5368SDave Martin#if __LINUX_ARM_ARCH__ < 7 503ef4c5368SDave Martin/* If the target CPU may not be Thumb-2-capable, a run-time check is needed: */ 504ef4c5368SDave Martin#define NEED_CPU_ARCHITECTURE 505ef4c5368SDave Martin ldr r5, .LCcpu_architecture 506ef4c5368SDave Martin ldr r5, [r5] 507ef4c5368SDave Martin cmp r5, #CPU_ARCH_ARMv7 50815ac49b6SRussell King blo __und_usr_fault_16 @ 16bit undefined instruction 509ef4c5368SDave Martin/* 510ef4c5368SDave Martin * The following code won't get run unless the running CPU really is v7, so 511ef4c5368SDave Martin * coding round the lack of ldrht on older arches is pointless. Temporarily 512ef4c5368SDave Martin * override the assembler target arch with the minimum required instead: 513ef4c5368SDave Martin */ 514ef4c5368SDave Martin .arch armv6t2 515ef4c5368SDave Martin#endif 51615ac49b6SRussell King2: ldrht r5, [r4] 517f8fe23ecSVictor KamenskyARM_BE8(rev16 r5, r5) @ little endian instruction 51885519189SDave Martin cmp r5, #0xe800 @ 32bit instruction if xx != 0 51915ac49b6SRussell King blo __und_usr_fault_16 @ 16bit undefined instruction 52015ac49b6SRussell King3: ldrht r0, [r2] 521f8fe23ecSVictor KamenskyARM_BE8(rev16 r0, r0) @ little endian instruction 522cb170a45SPaul Brook add r2, r2, #2 @ r2 is PC + 2, make it PC + 4 52315ac49b6SRussell King str r2, [sp, #S_PC] @ it's a 2x16bit instr, update 524cb170a45SPaul Brook orr r0, r0, r5, lsl #16 52515ac49b6SRussell King adr lr, BSYM(__und_usr_fault_32) 52615ac49b6SRussell King @ r0 = the two 16-bit Thumb instructions which caused the exception 52715ac49b6SRussell King @ r2 = PC value for the following Thumb instruction (:= regs->ARM_pc) 52815ac49b6SRussell King @ r4 = PC value for the first 16-bit Thumb instruction 52915ac49b6SRussell King @ lr = 32bit undefined instruction function 530ef4c5368SDave Martin 531ef4c5368SDave Martin#if __LINUX_ARM_ARCH__ < 7 532ef4c5368SDave Martin/* If the target arch was overridden, change it back: */ 533ef4c5368SDave Martin#ifdef CONFIG_CPU_32v6K 534ef4c5368SDave Martin .arch armv6k 535cb170a45SPaul Brook#else 536ef4c5368SDave Martin .arch armv6 537ef4c5368SDave Martin#endif 538ef4c5368SDave Martin#endif /* __LINUX_ARM_ARCH__ < 7 */ 539ef4c5368SDave Martin#else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */ 54015ac49b6SRussell King b __und_usr_fault_16 541cb170a45SPaul Brook#endif 542c4c5716eSCatalin Marinas UNWIND(.fnend) 54393ed3970SCatalin MarinasENDPROC(__und_usr) 544cb170a45SPaul Brook 5451da177e4SLinus Torvalds/* 54615ac49b6SRussell King * The out of line fixup for the ldrt instructions above. 5471da177e4SLinus Torvalds */ 548*c4a84ae3SArd Biesheuvel .pushsection .text.fixup, "ax" 549667d1b48SWill Deacon .align 2 5503780f7abSArun K S4: str r4, [sp, #S_PC] @ retry current instruction 5516ebbf2ceSRussell King ret r9 5524260415fSRussell King .popsection 5534260415fSRussell King .pushsection __ex_table,"a" 554cb170a45SPaul Brook .long 1b, 4b 555c89cefedSGuennadi Liakhovetski#if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7 556cb170a45SPaul Brook .long 2b, 4b 557cb170a45SPaul Brook .long 3b, 4b 558cb170a45SPaul Brook#endif 5594260415fSRussell King .popsection 5601da177e4SLinus Torvalds 5611da177e4SLinus Torvalds/* 5621da177e4SLinus Torvalds * Check whether the instruction is a co-processor instruction. 5631da177e4SLinus Torvalds * If yes, we need to call the relevant co-processor handler. 5641da177e4SLinus Torvalds * 5651da177e4SLinus Torvalds * Note that we don't do a full check here for the co-processor 5661da177e4SLinus Torvalds * instructions; all instructions with bit 27 set are well 5671da177e4SLinus Torvalds * defined. The only instructions that should fault are the 5681da177e4SLinus Torvalds * co-processor instructions. However, we have to watch out 5691da177e4SLinus Torvalds * for the ARM6/ARM7 SWI bug. 5701da177e4SLinus Torvalds * 571b5872db4SCatalin Marinas * NEON is a special case that has to be handled here. Not all 572b5872db4SCatalin Marinas * NEON instructions are co-processor instructions, so we have 573b5872db4SCatalin Marinas * to make a special case of checking for them. Plus, there's 574b5872db4SCatalin Marinas * five groups of them, so we have a table of mask/opcode pairs 575b5872db4SCatalin Marinas * to check against, and if any match then we branch off into the 576b5872db4SCatalin Marinas * NEON handler code. 577b5872db4SCatalin Marinas * 5781da177e4SLinus Torvalds * Emulators may wish to make use of the following registers: 57915ac49b6SRussell King * r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) 58015ac49b6SRussell King * r2 = PC value to resume execution after successful emulation 581db6ccbb6SRussell King * r9 = normal "successful" return address 58215ac49b6SRussell King * r10 = this threads thread_info structure 583db6ccbb6SRussell King * lr = unrecognised instruction return address 5841417a6b8SCatalin Marinas * IRQs enabled, FIQs enabled. 5851da177e4SLinus Torvalds */ 586cb170a45SPaul Brook @ 587cb170a45SPaul Brook @ Fall-through from Thumb-2 __und_usr 588cb170a45SPaul Brook @ 589cb170a45SPaul Brook#ifdef CONFIG_NEON 590d3f79584SRussell King get_thread_info r10 @ get current thread 591cb170a45SPaul Brook adr r6, .LCneon_thumb_opcodes 592cb170a45SPaul Brook b 2f 593cb170a45SPaul Brook#endif 5941da177e4SLinus Torvaldscall_fpe: 595d3f79584SRussell King get_thread_info r10 @ get current thread 596b5872db4SCatalin Marinas#ifdef CONFIG_NEON 597cb170a45SPaul Brook adr r6, .LCneon_arm_opcodes 598d3f79584SRussell King2: ldr r5, [r6], #4 @ mask value 599b5872db4SCatalin Marinas ldr r7, [r6], #4 @ opcode bits matching in mask 600d3f79584SRussell King cmp r5, #0 @ end mask? 601d3f79584SRussell King beq 1f 602d3f79584SRussell King and r8, r0, r5 603b5872db4SCatalin Marinas cmp r8, r7 @ NEON instruction? 604b5872db4SCatalin Marinas bne 2b 605b5872db4SCatalin Marinas mov r7, #1 606b5872db4SCatalin Marinas strb r7, [r10, #TI_USED_CP + 10] @ mark CP#10 as used 607b5872db4SCatalin Marinas strb r7, [r10, #TI_USED_CP + 11] @ mark CP#11 as used 608b5872db4SCatalin Marinas b do_vfp @ let VFP handler handle this 609b5872db4SCatalin Marinas1: 610b5872db4SCatalin Marinas#endif 6111da177e4SLinus Torvalds tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27 612cb170a45SPaul Brook tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2 6136ebbf2ceSRussell King reteq lr 6141da177e4SLinus Torvalds and r8, r0, #0x00000f00 @ mask out CP number 615b86040a5SCatalin Marinas THUMB( lsr r8, r8, #8 ) 6161da177e4SLinus Torvalds mov r7, #1 6171da177e4SLinus Torvalds add r6, r10, #TI_USED_CP 618b86040a5SCatalin Marinas ARM( strb r7, [r6, r8, lsr #8] ) @ set appropriate used_cp[] 619b86040a5SCatalin Marinas THUMB( strb r7, [r6, r8] ) @ set appropriate used_cp[] 6201da177e4SLinus Torvalds#ifdef CONFIG_IWMMXT 6211da177e4SLinus Torvalds @ Test if we need to give access to iWMMXt coprocessors 6221da177e4SLinus Torvalds ldr r5, [r10, #TI_FLAGS] 6231da177e4SLinus Torvalds rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only 6241da177e4SLinus Torvalds movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1) 6251da177e4SLinus Torvalds bcs iwmmxt_task_enable 6261da177e4SLinus Torvalds#endif 627b86040a5SCatalin Marinas ARM( add pc, pc, r8, lsr #6 ) 628b86040a5SCatalin Marinas THUMB( lsl r8, r8, #2 ) 629b86040a5SCatalin Marinas THUMB( add pc, r8 ) 630b86040a5SCatalin Marinas nop 6311da177e4SLinus Torvalds 6326ebbf2ceSRussell King ret.w lr @ CP#0 633b86040a5SCatalin Marinas W(b) do_fpe @ CP#1 (FPE) 634b86040a5SCatalin Marinas W(b) do_fpe @ CP#2 (FPE) 6356ebbf2ceSRussell King ret.w lr @ CP#3 636c17fad11SLennert Buytenhek#ifdef CONFIG_CRUNCH 637c17fad11SLennert Buytenhek b crunch_task_enable @ CP#4 (MaverickCrunch) 638c17fad11SLennert Buytenhek b crunch_task_enable @ CP#5 (MaverickCrunch) 639c17fad11SLennert Buytenhek b crunch_task_enable @ CP#6 (MaverickCrunch) 640c17fad11SLennert Buytenhek#else 6416ebbf2ceSRussell King ret.w lr @ CP#4 6426ebbf2ceSRussell King ret.w lr @ CP#5 6436ebbf2ceSRussell King ret.w lr @ CP#6 644c17fad11SLennert Buytenhek#endif 6456ebbf2ceSRussell King ret.w lr @ CP#7 6466ebbf2ceSRussell King ret.w lr @ CP#8 6476ebbf2ceSRussell King ret.w lr @ CP#9 6481da177e4SLinus Torvalds#ifdef CONFIG_VFP 649b86040a5SCatalin Marinas W(b) do_vfp @ CP#10 (VFP) 650b86040a5SCatalin Marinas W(b) do_vfp @ CP#11 (VFP) 6511da177e4SLinus Torvalds#else 6526ebbf2ceSRussell King ret.w lr @ CP#10 (VFP) 6536ebbf2ceSRussell King ret.w lr @ CP#11 (VFP) 6541da177e4SLinus Torvalds#endif 6556ebbf2ceSRussell King ret.w lr @ CP#12 6566ebbf2ceSRussell King ret.w lr @ CP#13 6576ebbf2ceSRussell King ret.w lr @ CP#14 (Debug) 6586ebbf2ceSRussell King ret.w lr @ CP#15 (Control) 6591da177e4SLinus Torvalds 660ef4c5368SDave Martin#ifdef NEED_CPU_ARCHITECTURE 661ef4c5368SDave Martin .align 2 662ef4c5368SDave Martin.LCcpu_architecture: 663ef4c5368SDave Martin .word __cpu_architecture 664ef4c5368SDave Martin#endif 665ef4c5368SDave Martin 666b5872db4SCatalin Marinas#ifdef CONFIG_NEON 667b5872db4SCatalin Marinas .align 6 668b5872db4SCatalin Marinas 669cb170a45SPaul Brook.LCneon_arm_opcodes: 670b5872db4SCatalin Marinas .word 0xfe000000 @ mask 671b5872db4SCatalin Marinas .word 0xf2000000 @ opcode 672b5872db4SCatalin Marinas 673b5872db4SCatalin Marinas .word 0xff100000 @ mask 674b5872db4SCatalin Marinas .word 0xf4000000 @ opcode 675b5872db4SCatalin Marinas 676b5872db4SCatalin Marinas .word 0x00000000 @ mask 677b5872db4SCatalin Marinas .word 0x00000000 @ opcode 678cb170a45SPaul Brook 679cb170a45SPaul Brook.LCneon_thumb_opcodes: 680cb170a45SPaul Brook .word 0xef000000 @ mask 681cb170a45SPaul Brook .word 0xef000000 @ opcode 682cb170a45SPaul Brook 683cb170a45SPaul Brook .word 0xff100000 @ mask 684cb170a45SPaul Brook .word 0xf9000000 @ opcode 685cb170a45SPaul Brook 686cb170a45SPaul Brook .word 0x00000000 @ mask 687cb170a45SPaul Brook .word 0x00000000 @ opcode 688b5872db4SCatalin Marinas#endif 689b5872db4SCatalin Marinas 6901da177e4SLinus Torvaldsdo_fpe: 6911da177e4SLinus Torvalds ldr r4, .LCfp 6921da177e4SLinus Torvalds add r10, r10, #TI_FPSTATE @ r10 = workspace 6931da177e4SLinus Torvalds ldr pc, [r4] @ Call FP module USR entry point 6941da177e4SLinus Torvalds 6951da177e4SLinus Torvalds/* 6961da177e4SLinus Torvalds * The FP module is called with these registers set: 6971da177e4SLinus Torvalds * r0 = instruction 6981da177e4SLinus Torvalds * r2 = PC+4 6991da177e4SLinus Torvalds * r9 = normal "successful" return address 7001da177e4SLinus Torvalds * r10 = FP workspace 7011da177e4SLinus Torvalds * lr = unrecognised FP instruction return address 7021da177e4SLinus Torvalds */ 7031da177e4SLinus Torvalds 704124efc27SSantosh Shilimkar .pushsection .data 7051da177e4SLinus TorvaldsENTRY(fp_enter) 706db6ccbb6SRussell King .word no_fp 707124efc27SSantosh Shilimkar .popsection 7081da177e4SLinus Torvalds 70983e686eaSCatalin MarinasENTRY(no_fp) 7106ebbf2ceSRussell King ret lr 71183e686eaSCatalin MarinasENDPROC(no_fp) 712db6ccbb6SRussell King 71315ac49b6SRussell King__und_usr_fault_32: 71415ac49b6SRussell King mov r1, #4 71515ac49b6SRussell King b 1f 71615ac49b6SRussell King__und_usr_fault_16: 71715ac49b6SRussell King mov r1, #2 7181417a6b8SCatalin Marinas1: mov r0, sp 719b86040a5SCatalin Marinas adr lr, BSYM(ret_from_exception) 72015ac49b6SRussell King b __und_fault 72115ac49b6SRussell KingENDPROC(__und_usr_fault_32) 72215ac49b6SRussell KingENDPROC(__und_usr_fault_16) 7231da177e4SLinus Torvalds 7241da177e4SLinus Torvalds .align 5 7251da177e4SLinus Torvalds__pabt_usr: 726ccea7a19SRussell King usr_entry 7274fb28474SKirill A. Shutemov mov r2, sp @ regs 7288dfe7ac9SRussell King pabt_helper 729c4c5716eSCatalin Marinas UNWIND(.fnend ) 7301da177e4SLinus Torvalds /* fall through */ 7311da177e4SLinus Torvalds/* 7321da177e4SLinus Torvalds * This is the return code to user mode for abort handlers 7331da177e4SLinus Torvalds */ 7341da177e4SLinus TorvaldsENTRY(ret_from_exception) 735c4c5716eSCatalin Marinas UNWIND(.fnstart ) 736c4c5716eSCatalin Marinas UNWIND(.cantunwind ) 7371da177e4SLinus Torvalds get_thread_info tsk 7381da177e4SLinus Torvalds mov why, #0 7391da177e4SLinus Torvalds b ret_to_user 740c4c5716eSCatalin Marinas UNWIND(.fnend ) 74193ed3970SCatalin MarinasENDPROC(__pabt_usr) 74293ed3970SCatalin MarinasENDPROC(ret_from_exception) 7431da177e4SLinus Torvalds 744c0e7f7eeSDaniel Thompson .align 5 745c0e7f7eeSDaniel Thompson__fiq_usr: 746c0e7f7eeSDaniel Thompson usr_entry trace=0 747c0e7f7eeSDaniel Thompson kuser_cmpxchg_check 748c0e7f7eeSDaniel Thompson mov r0, sp @ struct pt_regs *regs 749c0e7f7eeSDaniel Thompson bl handle_fiq_as_nmi 750c0e7f7eeSDaniel Thompson get_thread_info tsk 751c0e7f7eeSDaniel Thompson restore_user_regs fast = 0, offset = 0 752c0e7f7eeSDaniel Thompson UNWIND(.fnend ) 753c0e7f7eeSDaniel ThompsonENDPROC(__fiq_usr) 754c0e7f7eeSDaniel Thompson 7551da177e4SLinus Torvalds/* 7561da177e4SLinus Torvalds * Register switch for ARMv3 and ARMv4 processors 7571da177e4SLinus Torvalds * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info 7581da177e4SLinus Torvalds * previous and next are guaranteed not to be the same. 7591da177e4SLinus Torvalds */ 7601da177e4SLinus TorvaldsENTRY(__switch_to) 761c4c5716eSCatalin Marinas UNWIND(.fnstart ) 762c4c5716eSCatalin Marinas UNWIND(.cantunwind ) 7631da177e4SLinus Torvalds add ip, r1, #TI_CPU_SAVE 764b86040a5SCatalin Marinas ARM( stmia ip!, {r4 - sl, fp, sp, lr} ) @ Store most regs on stack 765b86040a5SCatalin Marinas THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack 766b86040a5SCatalin Marinas THUMB( str sp, [ip], #4 ) 767b86040a5SCatalin Marinas THUMB( str lr, [ip], #4 ) 768a4780adeSAndré Hentschel ldr r4, [r2, #TI_TP_VALUE] 769a4780adeSAndré Hentschel ldr r5, [r2, #TI_TP_VALUE + 4] 770247055aaSCatalin Marinas#ifdef CONFIG_CPU_USE_DOMAINS 771d6551e88SRussell King ldr r6, [r2, #TI_CPU_DOMAIN] 772afeb90caSHyok S. Choi#endif 773a4780adeSAndré Hentschel switch_tls r1, r4, r5, r3, r7 774df0698beSNicolas Pitre#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 775df0698beSNicolas Pitre ldr r7, [r2, #TI_TASK] 776df0698beSNicolas Pitre ldr r8, =__stack_chk_guard 777df0698beSNicolas Pitre ldr r7, [r7, #TSK_STACK_CANARY] 778df0698beSNicolas Pitre#endif 779247055aaSCatalin Marinas#ifdef CONFIG_CPU_USE_DOMAINS 7801da177e4SLinus Torvalds mcr p15, 0, r6, c3, c0, 0 @ Set domain register 781afeb90caSHyok S. Choi#endif 782d6551e88SRussell King mov r5, r0 783d6551e88SRussell King add r4, r2, #TI_CPU_SAVE 784d6551e88SRussell King ldr r0, =thread_notify_head 785d6551e88SRussell King mov r1, #THREAD_NOTIFY_SWITCH 786d6551e88SRussell King bl atomic_notifier_call_chain 787df0698beSNicolas Pitre#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 788df0698beSNicolas Pitre str r7, [r8] 789df0698beSNicolas Pitre#endif 790b86040a5SCatalin Marinas THUMB( mov ip, r4 ) 791d6551e88SRussell King mov r0, r5 792b86040a5SCatalin Marinas ARM( ldmia r4, {r4 - sl, fp, sp, pc} ) @ Load all regs saved previously 793b86040a5SCatalin Marinas THUMB( ldmia ip!, {r4 - sl, fp} ) @ Load all regs saved previously 794b86040a5SCatalin Marinas THUMB( ldr sp, [ip], #4 ) 795b86040a5SCatalin Marinas THUMB( ldr pc, [ip] ) 796c4c5716eSCatalin Marinas UNWIND(.fnend ) 79793ed3970SCatalin MarinasENDPROC(__switch_to) 7981da177e4SLinus Torvalds 7991da177e4SLinus Torvalds __INIT 8002d2669b6SNicolas Pitre 8012d2669b6SNicolas Pitre/* 8022d2669b6SNicolas Pitre * User helpers. 8032d2669b6SNicolas Pitre * 8042d2669b6SNicolas Pitre * Each segment is 32-byte aligned and will be moved to the top of the high 8052d2669b6SNicolas Pitre * vector page. New segments (if ever needed) must be added in front of 8062d2669b6SNicolas Pitre * existing ones. This mechanism should be used only for things that are 8072d2669b6SNicolas Pitre * really small and justified, and not be abused freely. 8082d2669b6SNicolas Pitre * 80937b83046SNicolas Pitre * See Documentation/arm/kernel_user_helpers.txt for formal definitions. 8102d2669b6SNicolas Pitre */ 811b86040a5SCatalin Marinas THUMB( .arm ) 8122d2669b6SNicolas Pitre 813ba9b5d76SNicolas Pitre .macro usr_ret, reg 814ba9b5d76SNicolas Pitre#ifdef CONFIG_ARM_THUMB 815ba9b5d76SNicolas Pitre bx \reg 816ba9b5d76SNicolas Pitre#else 8176ebbf2ceSRussell King ret \reg 818ba9b5d76SNicolas Pitre#endif 819ba9b5d76SNicolas Pitre .endm 820ba9b5d76SNicolas Pitre 8215b43e7a3SRussell King .macro kuser_pad, sym, size 8225b43e7a3SRussell King .if (. - \sym) & 3 8235b43e7a3SRussell King .rept 4 - (. - \sym) & 3 8245b43e7a3SRussell King .byte 0 8255b43e7a3SRussell King .endr 8265b43e7a3SRussell King .endif 8275b43e7a3SRussell King .rept (\size - (. - \sym)) / 4 8285b43e7a3SRussell King .word 0xe7fddef1 8295b43e7a3SRussell King .endr 8305b43e7a3SRussell King .endm 8315b43e7a3SRussell King 832f6f91b0dSRussell King#ifdef CONFIG_KUSER_HELPERS 8332d2669b6SNicolas Pitre .align 5 8342d2669b6SNicolas Pitre .globl __kuser_helper_start 8352d2669b6SNicolas Pitre__kuser_helper_start: 8362d2669b6SNicolas Pitre 8372d2669b6SNicolas Pitre/* 83840fb79c8SNicolas Pitre * Due to the length of some sequences, __kuser_cmpxchg64 spans 2 regular 83940fb79c8SNicolas Pitre * kuser "slots", therefore 0xffff0f80 is not used as a valid entry point. 8407c612bfdSNicolas Pitre */ 8417c612bfdSNicolas Pitre 84240fb79c8SNicolas Pitre__kuser_cmpxchg64: @ 0xffff0f60 84340fb79c8SNicolas Pitre 84440fb79c8SNicolas Pitre#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG) 84540fb79c8SNicolas Pitre 84640fb79c8SNicolas Pitre /* 84740fb79c8SNicolas Pitre * Poor you. No fast solution possible... 84840fb79c8SNicolas Pitre * The kernel itself must perform the operation. 84940fb79c8SNicolas Pitre * A special ghost syscall is used for that (see traps.c). 85040fb79c8SNicolas Pitre */ 85140fb79c8SNicolas Pitre stmfd sp!, {r7, lr} 85240fb79c8SNicolas Pitre ldr r7, 1f @ it's 20 bits 85340fb79c8SNicolas Pitre swi __ARM_NR_cmpxchg64 85440fb79c8SNicolas Pitre ldmfd sp!, {r7, pc} 85540fb79c8SNicolas Pitre1: .word __ARM_NR_cmpxchg64 85640fb79c8SNicolas Pitre 85740fb79c8SNicolas Pitre#elif defined(CONFIG_CPU_32v6K) 85840fb79c8SNicolas Pitre 85940fb79c8SNicolas Pitre stmfd sp!, {r4, r5, r6, r7} 86040fb79c8SNicolas Pitre ldrd r4, r5, [r0] @ load old val 86140fb79c8SNicolas Pitre ldrd r6, r7, [r1] @ load new val 86240fb79c8SNicolas Pitre smp_dmb arm 86340fb79c8SNicolas Pitre1: ldrexd r0, r1, [r2] @ load current val 86440fb79c8SNicolas Pitre eors r3, r0, r4 @ compare with oldval (1) 86540fb79c8SNicolas Pitre eoreqs r3, r1, r5 @ compare with oldval (2) 86640fb79c8SNicolas Pitre strexdeq r3, r6, r7, [r2] @ store newval if eq 86740fb79c8SNicolas Pitre teqeq r3, #1 @ success? 86840fb79c8SNicolas Pitre beq 1b @ if no then retry 86940fb79c8SNicolas Pitre smp_dmb arm 87040fb79c8SNicolas Pitre rsbs r0, r3, #0 @ set returned val and C flag 87140fb79c8SNicolas Pitre ldmfd sp!, {r4, r5, r6, r7} 8725a97d0aeSWill Deacon usr_ret lr 87340fb79c8SNicolas Pitre 87440fb79c8SNicolas Pitre#elif !defined(CONFIG_SMP) 87540fb79c8SNicolas Pitre 87640fb79c8SNicolas Pitre#ifdef CONFIG_MMU 87740fb79c8SNicolas Pitre 87840fb79c8SNicolas Pitre /* 87940fb79c8SNicolas Pitre * The only thing that can break atomicity in this cmpxchg64 88040fb79c8SNicolas Pitre * implementation is either an IRQ or a data abort exception 88140fb79c8SNicolas Pitre * causing another process/thread to be scheduled in the middle of 88240fb79c8SNicolas Pitre * the critical sequence. The same strategy as for cmpxchg is used. 88340fb79c8SNicolas Pitre */ 88440fb79c8SNicolas Pitre stmfd sp!, {r4, r5, r6, lr} 88540fb79c8SNicolas Pitre ldmia r0, {r4, r5} @ load old val 88640fb79c8SNicolas Pitre ldmia r1, {r6, lr} @ load new val 88740fb79c8SNicolas Pitre1: ldmia r2, {r0, r1} @ load current val 88840fb79c8SNicolas Pitre eors r3, r0, r4 @ compare with oldval (1) 88940fb79c8SNicolas Pitre eoreqs r3, r1, r5 @ compare with oldval (2) 89040fb79c8SNicolas Pitre2: stmeqia r2, {r6, lr} @ store newval if eq 89140fb79c8SNicolas Pitre rsbs r0, r3, #0 @ set return val and C flag 89240fb79c8SNicolas Pitre ldmfd sp!, {r4, r5, r6, pc} 89340fb79c8SNicolas Pitre 89440fb79c8SNicolas Pitre .text 89540fb79c8SNicolas Pitrekuser_cmpxchg64_fixup: 89640fb79c8SNicolas Pitre @ Called from kuser_cmpxchg_fixup. 8973ad55155SRussell King @ r4 = address of interrupted insn (must be preserved). 89840fb79c8SNicolas Pitre @ sp = saved regs. r7 and r8 are clobbered. 89940fb79c8SNicolas Pitre @ 1b = first critical insn, 2b = last critical insn. 9003ad55155SRussell King @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b. 90140fb79c8SNicolas Pitre mov r7, #0xffff0fff 90240fb79c8SNicolas Pitre sub r7, r7, #(0xffff0fff - (0xffff0f60 + (1b - __kuser_cmpxchg64))) 9033ad55155SRussell King subs r8, r4, r7 90440fb79c8SNicolas Pitre rsbcss r8, r8, #(2b - 1b) 90540fb79c8SNicolas Pitre strcs r7, [sp, #S_PC] 90640fb79c8SNicolas Pitre#if __LINUX_ARM_ARCH__ < 6 90740fb79c8SNicolas Pitre bcc kuser_cmpxchg32_fixup 90840fb79c8SNicolas Pitre#endif 9096ebbf2ceSRussell King ret lr 91040fb79c8SNicolas Pitre .previous 91140fb79c8SNicolas Pitre 91240fb79c8SNicolas Pitre#else 91340fb79c8SNicolas Pitre#warning "NPTL on non MMU needs fixing" 91440fb79c8SNicolas Pitre mov r0, #-1 91540fb79c8SNicolas Pitre adds r0, r0, #0 91640fb79c8SNicolas Pitre usr_ret lr 91740fb79c8SNicolas Pitre#endif 91840fb79c8SNicolas Pitre 91940fb79c8SNicolas Pitre#else 92040fb79c8SNicolas Pitre#error "incoherent kernel configuration" 92140fb79c8SNicolas Pitre#endif 92240fb79c8SNicolas Pitre 9235b43e7a3SRussell King kuser_pad __kuser_cmpxchg64, 64 92440fb79c8SNicolas Pitre 9257c612bfdSNicolas Pitre__kuser_memory_barrier: @ 0xffff0fa0 926ed3768a8SDave Martin smp_dmb arm 927ba9b5d76SNicolas Pitre usr_ret lr 9287c612bfdSNicolas Pitre 9295b43e7a3SRussell King kuser_pad __kuser_memory_barrier, 32 9307c612bfdSNicolas Pitre 9312d2669b6SNicolas Pitre__kuser_cmpxchg: @ 0xffff0fc0 9322d2669b6SNicolas Pitre 933dcef1f63SNicolas Pitre#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG) 9342d2669b6SNicolas Pitre 935dcef1f63SNicolas Pitre /* 936dcef1f63SNicolas Pitre * Poor you. No fast solution possible... 937dcef1f63SNicolas Pitre * The kernel itself must perform the operation. 938dcef1f63SNicolas Pitre * A special ghost syscall is used for that (see traps.c). 939dcef1f63SNicolas Pitre */ 9405e097445SNicolas Pitre stmfd sp!, {r7, lr} 94155afd264SDave Martin ldr r7, 1f @ it's 20 bits 942cc20d429SRussell King swi __ARM_NR_cmpxchg 9435e097445SNicolas Pitre ldmfd sp!, {r7, pc} 944cc20d429SRussell King1: .word __ARM_NR_cmpxchg 945dcef1f63SNicolas Pitre 946dcef1f63SNicolas Pitre#elif __LINUX_ARM_ARCH__ < 6 9472d2669b6SNicolas Pitre 94849bca4c2SNicolas Pitre#ifdef CONFIG_MMU 949b49c0f24SNicolas Pitre 950b49c0f24SNicolas Pitre /* 951b49c0f24SNicolas Pitre * The only thing that can break atomicity in this cmpxchg 952b49c0f24SNicolas Pitre * implementation is either an IRQ or a data abort exception 953b49c0f24SNicolas Pitre * causing another process/thread to be scheduled in the middle 954b49c0f24SNicolas Pitre * of the critical sequence. To prevent this, code is added to 955b49c0f24SNicolas Pitre * the IRQ and data abort exception handlers to set the pc back 956b49c0f24SNicolas Pitre * to the beginning of the critical section if it is found to be 957b49c0f24SNicolas Pitre * within that critical section (see kuser_cmpxchg_fixup). 958b49c0f24SNicolas Pitre */ 959b49c0f24SNicolas Pitre1: ldr r3, [r2] @ load current val 960b49c0f24SNicolas Pitre subs r3, r3, r0 @ compare with oldval 961b49c0f24SNicolas Pitre2: streq r1, [r2] @ store newval if eq 962b49c0f24SNicolas Pitre rsbs r0, r3, #0 @ set return val and C flag 963b49c0f24SNicolas Pitre usr_ret lr 964b49c0f24SNicolas Pitre 965b49c0f24SNicolas Pitre .text 96640fb79c8SNicolas Pitrekuser_cmpxchg32_fixup: 967b49c0f24SNicolas Pitre @ Called from kuser_cmpxchg_check macro. 968b059bdc3SRussell King @ r4 = address of interrupted insn (must be preserved). 969b49c0f24SNicolas Pitre @ sp = saved regs. r7 and r8 are clobbered. 970b49c0f24SNicolas Pitre @ 1b = first critical insn, 2b = last critical insn. 971b059bdc3SRussell King @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b. 972b49c0f24SNicolas Pitre mov r7, #0xffff0fff 973b49c0f24SNicolas Pitre sub r7, r7, #(0xffff0fff - (0xffff0fc0 + (1b - __kuser_cmpxchg))) 974b059bdc3SRussell King subs r8, r4, r7 975b49c0f24SNicolas Pitre rsbcss r8, r8, #(2b - 1b) 976b49c0f24SNicolas Pitre strcs r7, [sp, #S_PC] 9776ebbf2ceSRussell King ret lr 978b49c0f24SNicolas Pitre .previous 979b49c0f24SNicolas Pitre 98049bca4c2SNicolas Pitre#else 98149bca4c2SNicolas Pitre#warning "NPTL on non MMU needs fixing" 98249bca4c2SNicolas Pitre mov r0, #-1 98349bca4c2SNicolas Pitre adds r0, r0, #0 984ba9b5d76SNicolas Pitre usr_ret lr 985b49c0f24SNicolas Pitre#endif 9862d2669b6SNicolas Pitre 9872d2669b6SNicolas Pitre#else 9882d2669b6SNicolas Pitre 989ed3768a8SDave Martin smp_dmb arm 990b49c0f24SNicolas Pitre1: ldrex r3, [r2] 9912d2669b6SNicolas Pitre subs r3, r3, r0 9922d2669b6SNicolas Pitre strexeq r3, r1, [r2] 993b49c0f24SNicolas Pitre teqeq r3, #1 994b49c0f24SNicolas Pitre beq 1b 9952d2669b6SNicolas Pitre rsbs r0, r3, #0 996b49c0f24SNicolas Pitre /* beware -- each __kuser slot must be 8 instructions max */ 997f00ec48fSRussell King ALT_SMP(b __kuser_memory_barrier) 998f00ec48fSRussell King ALT_UP(usr_ret lr) 9992d2669b6SNicolas Pitre 10002d2669b6SNicolas Pitre#endif 10012d2669b6SNicolas Pitre 10025b43e7a3SRussell King kuser_pad __kuser_cmpxchg, 32 10032d2669b6SNicolas Pitre 10042d2669b6SNicolas Pitre__kuser_get_tls: @ 0xffff0fe0 1005f159f4edSTony Lindgren ldr r0, [pc, #(16 - 8)] @ read TLS, set in kuser_get_tls_init 1006ba9b5d76SNicolas Pitre usr_ret lr 1007f159f4edSTony Lindgren mrc p15, 0, r0, c13, c0, 3 @ 0xffff0fe8 hardware TLS code 10085b43e7a3SRussell King kuser_pad __kuser_get_tls, 16 10095b43e7a3SRussell King .rep 3 1010f159f4edSTony Lindgren .word 0 @ 0xffff0ff0 software TLS value, then 1011f159f4edSTony Lindgren .endr @ pad up to __kuser_helper_version 10122d2669b6SNicolas Pitre 10132d2669b6SNicolas Pitre__kuser_helper_version: @ 0xffff0ffc 10142d2669b6SNicolas Pitre .word ((__kuser_helper_end - __kuser_helper_start) >> 5) 10152d2669b6SNicolas Pitre 10162d2669b6SNicolas Pitre .globl __kuser_helper_end 10172d2669b6SNicolas Pitre__kuser_helper_end: 10182d2669b6SNicolas Pitre 1019f6f91b0dSRussell King#endif 1020f6f91b0dSRussell King 1021b86040a5SCatalin Marinas THUMB( .thumb ) 10222d2669b6SNicolas Pitre 10231da177e4SLinus Torvalds/* 10241da177e4SLinus Torvalds * Vector stubs. 10251da177e4SLinus Torvalds * 102619accfd3SRussell King * This code is copied to 0xffff1000 so we can use branches in the 102719accfd3SRussell King * vectors, rather than ldr's. Note that this code must not exceed 102819accfd3SRussell King * a page size. 10291da177e4SLinus Torvalds * 10301da177e4SLinus Torvalds * Common stub entry macro: 10311da177e4SLinus Torvalds * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC 1032ccea7a19SRussell King * 1033ccea7a19SRussell King * SP points to a minimal amount of processor-private memory, the address 1034ccea7a19SRussell King * of which is copied into r0 for the mode specific abort handler. 10351da177e4SLinus Torvalds */ 1036b7ec4795SNicolas Pitre .macro vector_stub, name, mode, correction=0 10371da177e4SLinus Torvalds .align 5 10381da177e4SLinus Torvalds 10391da177e4SLinus Torvaldsvector_\name: 10401da177e4SLinus Torvalds .if \correction 10411da177e4SLinus Torvalds sub lr, lr, #\correction 10421da177e4SLinus Torvalds .endif 10431da177e4SLinus Torvalds 1044ccea7a19SRussell King @ 1045ccea7a19SRussell King @ Save r0, lr_<exception> (parent PC) and spsr_<exception> 1046ccea7a19SRussell King @ (parent CPSR) 1047ccea7a19SRussell King @ 1048ccea7a19SRussell King stmia sp, {r0, lr} @ save r0, lr 1049ccea7a19SRussell King mrs lr, spsr 1050ccea7a19SRussell King str lr, [sp, #8] @ save spsr 1051ccea7a19SRussell King 1052ccea7a19SRussell King @ 1053ccea7a19SRussell King @ Prepare for SVC32 mode. IRQs remain disabled. 1054ccea7a19SRussell King @ 1055ccea7a19SRussell King mrs r0, cpsr 1056b86040a5SCatalin Marinas eor r0, r0, #(\mode ^ SVC_MODE | PSR_ISETSTATE) 1057ccea7a19SRussell King msr spsr_cxsf, r0 1058ccea7a19SRussell King 1059ccea7a19SRussell King @ 1060ccea7a19SRussell King @ the branch table must immediately follow this code 1061ccea7a19SRussell King @ 1062ccea7a19SRussell King and lr, lr, #0x0f 1063b86040a5SCatalin Marinas THUMB( adr r0, 1f ) 1064b86040a5SCatalin Marinas THUMB( ldr lr, [r0, lr, lsl #2] ) 1065b7ec4795SNicolas Pitre mov r0, sp 1066b86040a5SCatalin Marinas ARM( ldr lr, [pc, lr, lsl #2] ) 1067ccea7a19SRussell King movs pc, lr @ branch to handler in SVC mode 106893ed3970SCatalin MarinasENDPROC(vector_\name) 106988987ef9SCatalin Marinas 107088987ef9SCatalin Marinas .align 2 107188987ef9SCatalin Marinas @ handler addresses follow this label 107288987ef9SCatalin Marinas1: 10731da177e4SLinus Torvalds .endm 10741da177e4SLinus Torvalds 1075b9b32bf7SRussell King .section .stubs, "ax", %progbits 10761da177e4SLinus Torvalds__stubs_start: 107719accfd3SRussell King @ This must be the first word 107819accfd3SRussell King .word vector_swi 107919accfd3SRussell King 108019accfd3SRussell Kingvector_rst: 108119accfd3SRussell King ARM( swi SYS_ERROR0 ) 108219accfd3SRussell King THUMB( svc #0 ) 108319accfd3SRussell King THUMB( nop ) 108419accfd3SRussell King b vector_und 108519accfd3SRussell King 10861da177e4SLinus Torvalds/* 10871da177e4SLinus Torvalds * Interrupt dispatcher 10881da177e4SLinus Torvalds */ 1089b7ec4795SNicolas Pitre vector_stub irq, IRQ_MODE, 4 10901da177e4SLinus Torvalds 10911da177e4SLinus Torvalds .long __irq_usr @ 0 (USR_26 / USR_32) 10921da177e4SLinus Torvalds .long __irq_invalid @ 1 (FIQ_26 / FIQ_32) 10931da177e4SLinus Torvalds .long __irq_invalid @ 2 (IRQ_26 / IRQ_32) 10941da177e4SLinus Torvalds .long __irq_svc @ 3 (SVC_26 / SVC_32) 10951da177e4SLinus Torvalds .long __irq_invalid @ 4 10961da177e4SLinus Torvalds .long __irq_invalid @ 5 10971da177e4SLinus Torvalds .long __irq_invalid @ 6 10981da177e4SLinus Torvalds .long __irq_invalid @ 7 10991da177e4SLinus Torvalds .long __irq_invalid @ 8 11001da177e4SLinus Torvalds .long __irq_invalid @ 9 11011da177e4SLinus Torvalds .long __irq_invalid @ a 11021da177e4SLinus Torvalds .long __irq_invalid @ b 11031da177e4SLinus Torvalds .long __irq_invalid @ c 11041da177e4SLinus Torvalds .long __irq_invalid @ d 11051da177e4SLinus Torvalds .long __irq_invalid @ e 11061da177e4SLinus Torvalds .long __irq_invalid @ f 11071da177e4SLinus Torvalds 11081da177e4SLinus Torvalds/* 11091da177e4SLinus Torvalds * Data abort dispatcher 11101da177e4SLinus Torvalds * Enter in ABT mode, spsr = USR CPSR, lr = USR PC 11111da177e4SLinus Torvalds */ 1112b7ec4795SNicolas Pitre vector_stub dabt, ABT_MODE, 8 11131da177e4SLinus Torvalds 11141da177e4SLinus Torvalds .long __dabt_usr @ 0 (USR_26 / USR_32) 11151da177e4SLinus Torvalds .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32) 11161da177e4SLinus Torvalds .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32) 11171da177e4SLinus Torvalds .long __dabt_svc @ 3 (SVC_26 / SVC_32) 11181da177e4SLinus Torvalds .long __dabt_invalid @ 4 11191da177e4SLinus Torvalds .long __dabt_invalid @ 5 11201da177e4SLinus Torvalds .long __dabt_invalid @ 6 11211da177e4SLinus Torvalds .long __dabt_invalid @ 7 11221da177e4SLinus Torvalds .long __dabt_invalid @ 8 11231da177e4SLinus Torvalds .long __dabt_invalid @ 9 11241da177e4SLinus Torvalds .long __dabt_invalid @ a 11251da177e4SLinus Torvalds .long __dabt_invalid @ b 11261da177e4SLinus Torvalds .long __dabt_invalid @ c 11271da177e4SLinus Torvalds .long __dabt_invalid @ d 11281da177e4SLinus Torvalds .long __dabt_invalid @ e 11291da177e4SLinus Torvalds .long __dabt_invalid @ f 11301da177e4SLinus Torvalds 11311da177e4SLinus Torvalds/* 11321da177e4SLinus Torvalds * Prefetch abort dispatcher 11331da177e4SLinus Torvalds * Enter in ABT mode, spsr = USR CPSR, lr = USR PC 11341da177e4SLinus Torvalds */ 1135b7ec4795SNicolas Pitre vector_stub pabt, ABT_MODE, 4 11361da177e4SLinus Torvalds 11371da177e4SLinus Torvalds .long __pabt_usr @ 0 (USR_26 / USR_32) 11381da177e4SLinus Torvalds .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32) 11391da177e4SLinus Torvalds .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32) 11401da177e4SLinus Torvalds .long __pabt_svc @ 3 (SVC_26 / SVC_32) 11411da177e4SLinus Torvalds .long __pabt_invalid @ 4 11421da177e4SLinus Torvalds .long __pabt_invalid @ 5 11431da177e4SLinus Torvalds .long __pabt_invalid @ 6 11441da177e4SLinus Torvalds .long __pabt_invalid @ 7 11451da177e4SLinus Torvalds .long __pabt_invalid @ 8 11461da177e4SLinus Torvalds .long __pabt_invalid @ 9 11471da177e4SLinus Torvalds .long __pabt_invalid @ a 11481da177e4SLinus Torvalds .long __pabt_invalid @ b 11491da177e4SLinus Torvalds .long __pabt_invalid @ c 11501da177e4SLinus Torvalds .long __pabt_invalid @ d 11511da177e4SLinus Torvalds .long __pabt_invalid @ e 11521da177e4SLinus Torvalds .long __pabt_invalid @ f 11531da177e4SLinus Torvalds 11541da177e4SLinus Torvalds/* 11551da177e4SLinus Torvalds * Undef instr entry dispatcher 11561da177e4SLinus Torvalds * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC 11571da177e4SLinus Torvalds */ 1158b7ec4795SNicolas Pitre vector_stub und, UND_MODE 11591da177e4SLinus Torvalds 11601da177e4SLinus Torvalds .long __und_usr @ 0 (USR_26 / USR_32) 11611da177e4SLinus Torvalds .long __und_invalid @ 1 (FIQ_26 / FIQ_32) 11621da177e4SLinus Torvalds .long __und_invalid @ 2 (IRQ_26 / IRQ_32) 11631da177e4SLinus Torvalds .long __und_svc @ 3 (SVC_26 / SVC_32) 11641da177e4SLinus Torvalds .long __und_invalid @ 4 11651da177e4SLinus Torvalds .long __und_invalid @ 5 11661da177e4SLinus Torvalds .long __und_invalid @ 6 11671da177e4SLinus Torvalds .long __und_invalid @ 7 11681da177e4SLinus Torvalds .long __und_invalid @ 8 11691da177e4SLinus Torvalds .long __und_invalid @ 9 11701da177e4SLinus Torvalds .long __und_invalid @ a 11711da177e4SLinus Torvalds .long __und_invalid @ b 11721da177e4SLinus Torvalds .long __und_invalid @ c 11731da177e4SLinus Torvalds .long __und_invalid @ d 11741da177e4SLinus Torvalds .long __und_invalid @ e 11751da177e4SLinus Torvalds .long __und_invalid @ f 11761da177e4SLinus Torvalds 11771da177e4SLinus Torvalds .align 5 11781da177e4SLinus Torvalds 11791da177e4SLinus Torvalds/*============================================================================= 118019accfd3SRussell King * Address exception handler 118119accfd3SRussell King *----------------------------------------------------------------------------- 118219accfd3SRussell King * These aren't too critical. 118319accfd3SRussell King * (they're not supposed to happen, and won't happen in 32-bit data mode). 118419accfd3SRussell King */ 118519accfd3SRussell King 118619accfd3SRussell Kingvector_addrexcptn: 118719accfd3SRussell King b vector_addrexcptn 118819accfd3SRussell King 118919accfd3SRussell King/*============================================================================= 1190c0e7f7eeSDaniel Thompson * FIQ "NMI" handler 11911da177e4SLinus Torvalds *----------------------------------------------------------------------------- 1192c0e7f7eeSDaniel Thompson * Handle a FIQ using the SVC stack allowing FIQ act like NMI on x86 1193c0e7f7eeSDaniel Thompson * systems. 11941da177e4SLinus Torvalds */ 1195c0e7f7eeSDaniel Thompson vector_stub fiq, FIQ_MODE, 4 1196c0e7f7eeSDaniel Thompson 1197c0e7f7eeSDaniel Thompson .long __fiq_usr @ 0 (USR_26 / USR_32) 1198c0e7f7eeSDaniel Thompson .long __fiq_svc @ 1 (FIQ_26 / FIQ_32) 1199c0e7f7eeSDaniel Thompson .long __fiq_svc @ 2 (IRQ_26 / IRQ_32) 1200c0e7f7eeSDaniel Thompson .long __fiq_svc @ 3 (SVC_26 / SVC_32) 1201c0e7f7eeSDaniel Thompson .long __fiq_svc @ 4 1202c0e7f7eeSDaniel Thompson .long __fiq_svc @ 5 1203c0e7f7eeSDaniel Thompson .long __fiq_svc @ 6 1204c0e7f7eeSDaniel Thompson .long __fiq_abt @ 7 1205c0e7f7eeSDaniel Thompson .long __fiq_svc @ 8 1206c0e7f7eeSDaniel Thompson .long __fiq_svc @ 9 1207c0e7f7eeSDaniel Thompson .long __fiq_svc @ a 1208c0e7f7eeSDaniel Thompson .long __fiq_svc @ b 1209c0e7f7eeSDaniel Thompson .long __fiq_svc @ c 1210c0e7f7eeSDaniel Thompson .long __fiq_svc @ d 1211c0e7f7eeSDaniel Thompson .long __fiq_svc @ e 1212c0e7f7eeSDaniel Thompson .long __fiq_svc @ f 12131da177e4SLinus Torvalds 1214e39e3f3eSRussell King .globl vector_fiq_offset 1215e39e3f3eSRussell King .equ vector_fiq_offset, vector_fiq 1216e39e3f3eSRussell King 1217b9b32bf7SRussell King .section .vectors, "ax", %progbits 12187933523dSRussell King__vectors_start: 1219b9b32bf7SRussell King W(b) vector_rst 1220b9b32bf7SRussell King W(b) vector_und 1221b9b32bf7SRussell King W(ldr) pc, __vectors_start + 0x1000 1222b9b32bf7SRussell King W(b) vector_pabt 1223b9b32bf7SRussell King W(b) vector_dabt 1224b9b32bf7SRussell King W(b) vector_addrexcptn 1225b9b32bf7SRussell King W(b) vector_irq 1226b9b32bf7SRussell King W(b) vector_fiq 12271da177e4SLinus Torvalds 12281da177e4SLinus Torvalds .data 12291da177e4SLinus Torvalds 12301da177e4SLinus Torvalds .globl cr_alignment 12311da177e4SLinus Torvaldscr_alignment: 12321da177e4SLinus Torvalds .space 4 123352108641Seric miao 123452108641Seric miao#ifdef CONFIG_MULTI_IRQ_HANDLER 123552108641Seric miao .globl handle_arch_irq 123652108641Seric miaohandle_arch_irq: 123752108641Seric miao .space 4 123852108641Seric miao#endif 1239