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 18f09b9979SNicolas Pitre#include <asm/memory.h> 19753790e7SRussell King#include <asm/glue-df.h> 20753790e7SRussell King#include <asm/glue-pf.h> 211da177e4SLinus Torvalds#include <asm/vfpmacros.h> 22a09e64fbSRussell King#include <mach/entry-macro.S> 23d6551e88SRussell King#include <asm/thread_notify.h> 24c4c5716eSCatalin Marinas#include <asm/unwind.h> 25cc20d429SRussell King#include <asm/unistd.h> 26f159f4edSTony Lindgren#include <asm/tls.h> 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds#include "entry-header.S" 29cd544ce7SMagnus Damm#include <asm/entry-macro-multi.S> 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds/* 32d9600c99SRussell King * Interrupt handling. 33187a51adSRussell King */ 34187a51adSRussell King .macro irq_handler 3552108641Seric miao#ifdef CONFIG_MULTI_IRQ_HANDLER 36d9600c99SRussell King ldr r1, =handle_arch_irq 3752108641Seric miao mov r0, sp 38d9600c99SRussell King ldr r1, [r1] 3952108641Seric miao adr lr, BSYM(9997f) 40d9600c99SRussell King teq r1, #0 41d9600c99SRussell King movne pc, r1 4237ee16aeSRussell King#endif 43cd544ce7SMagnus Damm arch_irq_handler_default 44f00ec48fSRussell King9997: 45187a51adSRussell King .endm 46187a51adSRussell King 47ac8b9c1cSRussell King .macro pabt_helper 488dfe7ac9SRussell King @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5 49ac8b9c1cSRussell King#ifdef MULTI_PABORT 500402beceSRussell King ldr ip, .LCprocfns 51ac8b9c1cSRussell King mov lr, pc 520402beceSRussell King ldr pc, [ip, #PROCESSOR_PABT_FUNC] 53ac8b9c1cSRussell King#else 54ac8b9c1cSRussell King bl CPU_PABORT_HANDLER 55ac8b9c1cSRussell King#endif 56ac8b9c1cSRussell King .endm 57ac8b9c1cSRussell King 58ac8b9c1cSRussell King .macro dabt_helper 59ac8b9c1cSRussell King 60ac8b9c1cSRussell King @ 61ac8b9c1cSRussell King @ Call the processor-specific abort handler: 62ac8b9c1cSRussell King @ 63da740472SRussell King @ r2 - pt_regs 643e287becSRussell King @ r4 - aborted context pc 653e287becSRussell King @ r5 - aborted context psr 66ac8b9c1cSRussell King @ 67ac8b9c1cSRussell King @ The abort handler must return the aborted address in r0, and 68ac8b9c1cSRussell King @ the fault status register in r1. r9 must be preserved. 69ac8b9c1cSRussell King @ 70ac8b9c1cSRussell King#ifdef MULTI_DABORT 710402beceSRussell King ldr ip, .LCprocfns 72ac8b9c1cSRussell King mov lr, pc 730402beceSRussell King ldr pc, [ip, #PROCESSOR_DABT_FUNC] 74ac8b9c1cSRussell King#else 75ac8b9c1cSRussell King bl CPU_DABORT_HANDLER 76ac8b9c1cSRussell King#endif 77ac8b9c1cSRussell King .endm 78ac8b9c1cSRussell King 79785d3cd2SNicolas Pitre#ifdef CONFIG_KPROBES 80785d3cd2SNicolas Pitre .section .kprobes.text,"ax",%progbits 81785d3cd2SNicolas Pitre#else 82785d3cd2SNicolas Pitre .text 83785d3cd2SNicolas Pitre#endif 84785d3cd2SNicolas Pitre 85187a51adSRussell King/* 861da177e4SLinus Torvalds * Invalid mode handlers 871da177e4SLinus Torvalds */ 88ccea7a19SRussell King .macro inv_entry, reason 89ccea7a19SRussell King sub sp, sp, #S_FRAME_SIZE 90b86040a5SCatalin Marinas ARM( stmib sp, {r1 - lr} ) 91b86040a5SCatalin Marinas THUMB( stmia sp, {r0 - r12} ) 92b86040a5SCatalin Marinas THUMB( str sp, [sp, #S_SP] ) 93b86040a5SCatalin Marinas THUMB( str lr, [sp, #S_LR] ) 941da177e4SLinus Torvalds mov r1, #\reason 951da177e4SLinus Torvalds .endm 961da177e4SLinus Torvalds 971da177e4SLinus Torvalds__pabt_invalid: 98ccea7a19SRussell King inv_entry BAD_PREFETCH 99ccea7a19SRussell King b common_invalid 10093ed3970SCatalin MarinasENDPROC(__pabt_invalid) 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvalds__dabt_invalid: 103ccea7a19SRussell King inv_entry BAD_DATA 104ccea7a19SRussell King b common_invalid 10593ed3970SCatalin MarinasENDPROC(__dabt_invalid) 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvalds__irq_invalid: 108ccea7a19SRussell King inv_entry BAD_IRQ 109ccea7a19SRussell King b common_invalid 11093ed3970SCatalin MarinasENDPROC(__irq_invalid) 1111da177e4SLinus Torvalds 1121da177e4SLinus Torvalds__und_invalid: 113ccea7a19SRussell King inv_entry BAD_UNDEFINSTR 1141da177e4SLinus Torvalds 115ccea7a19SRussell King @ 116ccea7a19SRussell King @ XXX fall through to common_invalid 117ccea7a19SRussell King @ 118ccea7a19SRussell King 119ccea7a19SRussell King@ 120ccea7a19SRussell King@ common_invalid - generic code for failed exception (re-entrant version of handlers) 121ccea7a19SRussell King@ 122ccea7a19SRussell Kingcommon_invalid: 123ccea7a19SRussell King zero_fp 124ccea7a19SRussell King 125ccea7a19SRussell King ldmia r0, {r4 - r6} 126ccea7a19SRussell King add r0, sp, #S_PC @ here for interlock avoidance 127ccea7a19SRussell King mov r7, #-1 @ "" "" "" "" 128ccea7a19SRussell King str r4, [sp] @ save preserved r0 129ccea7a19SRussell King stmia r0, {r5 - r7} @ lr_<exception>, 130ccea7a19SRussell King @ cpsr_<exception>, "old_r0" 131ccea7a19SRussell King 1321da177e4SLinus Torvalds mov r0, sp 1331da177e4SLinus Torvalds b bad_mode 13493ed3970SCatalin MarinasENDPROC(__und_invalid) 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds/* 1371da177e4SLinus Torvalds * SVC mode handlers 1381da177e4SLinus Torvalds */ 1392dede2d8SNicolas Pitre 1402dede2d8SNicolas Pitre#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) 1412dede2d8SNicolas Pitre#define SPFIX(code...) code 1422dede2d8SNicolas Pitre#else 1432dede2d8SNicolas Pitre#define SPFIX(code...) 1442dede2d8SNicolas Pitre#endif 1452dede2d8SNicolas Pitre 146d30a0c8bSNicolas Pitre .macro svc_entry, stack_hole=0 147c4c5716eSCatalin Marinas UNWIND(.fnstart ) 148c4c5716eSCatalin Marinas UNWIND(.save {r0 - pc} ) 149b86040a5SCatalin Marinas sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4) 150b86040a5SCatalin Marinas#ifdef CONFIG_THUMB2_KERNEL 151b86040a5SCatalin Marinas SPFIX( str r0, [sp] ) @ temporarily saved 152b86040a5SCatalin Marinas SPFIX( mov r0, sp ) 153b86040a5SCatalin Marinas SPFIX( tst r0, #4 ) @ test original stack alignment 154b86040a5SCatalin Marinas SPFIX( ldr r0, [sp] ) @ restored 155b86040a5SCatalin Marinas#else 1562dede2d8SNicolas Pitre SPFIX( tst sp, #4 ) 157b86040a5SCatalin Marinas#endif 158b86040a5SCatalin Marinas SPFIX( subeq sp, sp, #4 ) 159b86040a5SCatalin Marinas stmia sp, {r1 - r12} 160ccea7a19SRussell King 161b059bdc3SRussell King ldmia r0, {r3 - r5} 162b059bdc3SRussell King add r7, sp, #S_SP - 4 @ here for interlock avoidance 163b059bdc3SRussell King mov r6, #-1 @ "" "" "" "" 164b059bdc3SRussell King add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4) 165b059bdc3SRussell King SPFIX( addeq r2, r2, #4 ) 166b059bdc3SRussell King str r3, [sp, #-4]! @ save the "real" r0 copied 167ccea7a19SRussell King @ from the exception stack 168ccea7a19SRussell King 169b059bdc3SRussell King mov r3, lr 1701da177e4SLinus Torvalds 1711da177e4SLinus Torvalds @ 1721da177e4SLinus Torvalds @ We are now ready to fill in the remaining blanks on the stack: 1731da177e4SLinus Torvalds @ 174b059bdc3SRussell King @ r2 - sp_svc 175b059bdc3SRussell King @ r3 - lr_svc 176b059bdc3SRussell King @ r4 - lr_<exception>, already fixed up for correct return/restart 177b059bdc3SRussell King @ r5 - spsr_<exception> 178b059bdc3SRussell King @ r6 - orig_r0 (see pt_regs definition in ptrace.h) 1791da177e4SLinus Torvalds @ 180b059bdc3SRussell King stmia r7, {r2 - r6} 181f2741b78SRussell King 182f2741b78SRussell King#ifdef CONFIG_TRACE_IRQFLAGS 183f2741b78SRussell King bl trace_hardirqs_off 184f2741b78SRussell King#endif 1851da177e4SLinus Torvalds .endm 1861da177e4SLinus Torvalds 1871da177e4SLinus Torvalds .align 5 1881da177e4SLinus Torvalds__dabt_svc: 189ccea7a19SRussell King svc_entry 1901da177e4SLinus Torvalds mov r2, sp 191da740472SRussell King dabt_helper 1921da177e4SLinus Torvalds 1931da177e4SLinus Torvalds @ 1941da177e4SLinus Torvalds @ IRQs off again before pulling preserved data off the stack 1951da177e4SLinus Torvalds @ 196ac78884eSRussell King disable_irq_notrace 1971da177e4SLinus Torvalds 19802fe2845SRussell King#ifdef CONFIG_TRACE_IRQFLAGS 19902fe2845SRussell King tst r5, #PSR_I_BIT 20002fe2845SRussell King bleq trace_hardirqs_on 20102fe2845SRussell King tst r5, #PSR_I_BIT 20202fe2845SRussell King blne trace_hardirqs_off 20302fe2845SRussell King#endif 204b059bdc3SRussell King svc_exit r5 @ return from exception 205c4c5716eSCatalin Marinas UNWIND(.fnend ) 20693ed3970SCatalin MarinasENDPROC(__dabt_svc) 2071da177e4SLinus Torvalds 2081da177e4SLinus Torvalds .align 5 2091da177e4SLinus Torvalds__irq_svc: 210ccea7a19SRussell King svc_entry 2111613cc11SRussell King irq_handler 2121613cc11SRussell King 2131da177e4SLinus Torvalds#ifdef CONFIG_PREEMPT 214706fdd9fSRussell King get_thread_info tsk 215706fdd9fSRussell King ldr r8, [tsk, #TI_PREEMPT] @ get preempt count 216706fdd9fSRussell King ldr r0, [tsk, #TI_FLAGS] @ get flags 21728fab1a2SRussell King teq r8, #0 @ if preempt count != 0 21828fab1a2SRussell King movne r0, #0 @ force flags to 0 2191da177e4SLinus Torvalds tst r0, #_TIF_NEED_RESCHED 2201da177e4SLinus Torvalds blne svc_preempt 2211da177e4SLinus Torvalds#endif 222*30891c90SRussell King 2237ad1bcb2SRussell King#ifdef CONFIG_TRACE_IRQFLAGS 224fbab1c80SRussell King @ The parent context IRQs must have been enabled to get here in 225fbab1c80SRussell King @ the first place, so there's no point checking the PSR I bit. 226fbab1c80SRussell King bl trace_hardirqs_on 2277ad1bcb2SRussell King#endif 228b059bdc3SRussell King svc_exit r5 @ return from exception 229c4c5716eSCatalin Marinas UNWIND(.fnend ) 23093ed3970SCatalin MarinasENDPROC(__irq_svc) 2311da177e4SLinus Torvalds 2321da177e4SLinus Torvalds .ltorg 2331da177e4SLinus Torvalds 2341da177e4SLinus Torvalds#ifdef CONFIG_PREEMPT 2351da177e4SLinus Torvaldssvc_preempt: 23628fab1a2SRussell King mov r8, lr 2371da177e4SLinus Torvalds1: bl preempt_schedule_irq @ irq en/disable is done inside 238706fdd9fSRussell King ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS 2391da177e4SLinus Torvalds tst r0, #_TIF_NEED_RESCHED 24028fab1a2SRussell King moveq pc, r8 @ go again 2411da177e4SLinus Torvalds b 1b 2421da177e4SLinus Torvalds#endif 2431da177e4SLinus Torvalds 2441da177e4SLinus Torvalds .align 5 2451da177e4SLinus Torvalds__und_svc: 246d30a0c8bSNicolas Pitre#ifdef CONFIG_KPROBES 247d30a0c8bSNicolas Pitre @ If a kprobe is about to simulate a "stmdb sp..." instruction, 248d30a0c8bSNicolas Pitre @ it obviously needs free stack space which then will belong to 249d30a0c8bSNicolas Pitre @ the saved context. 250d30a0c8bSNicolas Pitre svc_entry 64 251d30a0c8bSNicolas Pitre#else 252ccea7a19SRussell King svc_entry 253d30a0c8bSNicolas Pitre#endif 2541da177e4SLinus Torvalds @ 2551da177e4SLinus Torvalds @ call emulation code, which returns using r9 if it has emulated 2561da177e4SLinus Torvalds @ the instruction, or the more conventional lr if we are to treat 2571da177e4SLinus Torvalds @ this as a real undefined instruction 2581da177e4SLinus Torvalds @ 2591da177e4SLinus Torvalds @ r0 - instruction 2601da177e4SLinus Torvalds @ 26183e686eaSCatalin Marinas#ifndef CONFIG_THUMB2_KERNEL 262b059bdc3SRussell King ldr r0, [r4, #-4] 26383e686eaSCatalin Marinas#else 264b059bdc3SRussell King ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2 26583e686eaSCatalin Marinas and r9, r0, #0xf800 26683e686eaSCatalin Marinas cmp r9, #0xe800 @ 32-bit instruction if xx >= 0 267b059bdc3SRussell King ldrhhs r9, [r4] @ bottom 16 bits 26883e686eaSCatalin Marinas orrhs r0, r9, r0, lsl #16 26983e686eaSCatalin Marinas#endif 270b86040a5SCatalin Marinas adr r9, BSYM(1f) 271b059bdc3SRussell King mov r2, r4 2721da177e4SLinus Torvalds bl call_fpe 2731da177e4SLinus Torvalds 2741da177e4SLinus Torvalds mov r0, sp @ struct pt_regs *regs 2751da177e4SLinus Torvalds bl do_undefinstr 2761da177e4SLinus Torvalds 2771da177e4SLinus Torvalds @ 2781da177e4SLinus Torvalds @ IRQs off again before pulling preserved data off the stack 2791da177e4SLinus Torvalds @ 280ac78884eSRussell King1: disable_irq_notrace 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds @ 2831da177e4SLinus Torvalds @ restore SPSR and restart the instruction 2841da177e4SLinus Torvalds @ 285b059bdc3SRussell King ldr r5, [sp, #S_PSR] @ Get SVC cpsr 286df295df6SRussell King#ifdef CONFIG_TRACE_IRQFLAGS 287df295df6SRussell King tst r5, #PSR_I_BIT 288df295df6SRussell King bleq trace_hardirqs_on 289df295df6SRussell King tst r5, #PSR_I_BIT 290df295df6SRussell King blne trace_hardirqs_off 291df295df6SRussell King#endif 292b059bdc3SRussell King svc_exit r5 @ return from exception 293c4c5716eSCatalin Marinas UNWIND(.fnend ) 29493ed3970SCatalin MarinasENDPROC(__und_svc) 2951da177e4SLinus Torvalds 2961da177e4SLinus Torvalds .align 5 2971da177e4SLinus Torvalds__pabt_svc: 298ccea7a19SRussell King svc_entry 2994fb28474SKirill A. Shutemov mov r2, sp @ regs 3008dfe7ac9SRussell King pabt_helper 3011da177e4SLinus Torvalds 3021da177e4SLinus Torvalds @ 3031da177e4SLinus Torvalds @ IRQs off again before pulling preserved data off the stack 3041da177e4SLinus Torvalds @ 305ac78884eSRussell King disable_irq_notrace 3061da177e4SLinus Torvalds 30702fe2845SRussell King#ifdef CONFIG_TRACE_IRQFLAGS 30802fe2845SRussell King tst r5, #PSR_I_BIT 30902fe2845SRussell King bleq trace_hardirqs_on 31002fe2845SRussell King tst r5, #PSR_I_BIT 31102fe2845SRussell King blne trace_hardirqs_off 31202fe2845SRussell King#endif 313b059bdc3SRussell King svc_exit r5 @ return from exception 314c4c5716eSCatalin Marinas UNWIND(.fnend ) 31593ed3970SCatalin MarinasENDPROC(__pabt_svc) 3161da177e4SLinus Torvalds 3171da177e4SLinus Torvalds .align 5 31849f680eaSRussell King.LCcralign: 31949f680eaSRussell King .word cr_alignment 32048d7927bSPaul Brook#ifdef MULTI_DABORT 3211da177e4SLinus Torvalds.LCprocfns: 3221da177e4SLinus Torvalds .word processor 3231da177e4SLinus Torvalds#endif 3241da177e4SLinus Torvalds.LCfp: 3251da177e4SLinus Torvalds .word fp_enter 3261da177e4SLinus Torvalds 3271da177e4SLinus Torvalds/* 3281da177e4SLinus Torvalds * User mode handlers 3292dede2d8SNicolas Pitre * 3302dede2d8SNicolas Pitre * EABI note: sp_svc is always 64-bit aligned here, so should S_FRAME_SIZE 3311da177e4SLinus Torvalds */ 3322dede2d8SNicolas Pitre 3332dede2d8SNicolas Pitre#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) && (S_FRAME_SIZE & 7) 3342dede2d8SNicolas Pitre#error "sizeof(struct pt_regs) must be a multiple of 8" 3352dede2d8SNicolas Pitre#endif 3362dede2d8SNicolas Pitre 337ccea7a19SRussell King .macro usr_entry 338c4c5716eSCatalin Marinas UNWIND(.fnstart ) 339c4c5716eSCatalin Marinas UNWIND(.cantunwind ) @ don't unwind the user space 340ccea7a19SRussell King sub sp, sp, #S_FRAME_SIZE 341b86040a5SCatalin Marinas ARM( stmib sp, {r1 - r12} ) 342b86040a5SCatalin Marinas THUMB( stmia sp, {r0 - r12} ) 343ccea7a19SRussell King 344b059bdc3SRussell King ldmia r0, {r3 - r5} 345ccea7a19SRussell King add r0, sp, #S_PC @ here for interlock avoidance 346b059bdc3SRussell King mov r6, #-1 @ "" "" "" "" 347ccea7a19SRussell King 348b059bdc3SRussell King str r3, [sp] @ save the "real" r0 copied 349ccea7a19SRussell King @ from the exception stack 3501da177e4SLinus Torvalds 3511da177e4SLinus Torvalds @ 3521da177e4SLinus Torvalds @ We are now ready to fill in the remaining blanks on the stack: 3531da177e4SLinus Torvalds @ 354b059bdc3SRussell King @ r4 - lr_<exception>, already fixed up for correct return/restart 355b059bdc3SRussell King @ r5 - spsr_<exception> 356b059bdc3SRussell King @ r6 - orig_r0 (see pt_regs definition in ptrace.h) 3571da177e4SLinus Torvalds @ 3581da177e4SLinus Torvalds @ Also, separately save sp_usr and lr_usr 3591da177e4SLinus Torvalds @ 360b059bdc3SRussell King stmia r0, {r4 - r6} 361b86040a5SCatalin Marinas ARM( stmdb r0, {sp, lr}^ ) 362b86040a5SCatalin Marinas THUMB( store_user_sp_lr r0, r1, S_SP - S_PC ) 3631da177e4SLinus Torvalds 3641da177e4SLinus Torvalds @ 3651da177e4SLinus Torvalds @ Enable the alignment trap while in kernel mode 3661da177e4SLinus Torvalds @ 36749f680eaSRussell King alignment_trap r0 3681da177e4SLinus Torvalds 3691da177e4SLinus Torvalds @ 3701da177e4SLinus Torvalds @ Clear FP to mark the first stack frame 3711da177e4SLinus Torvalds @ 3721da177e4SLinus Torvalds zero_fp 373f2741b78SRussell King 374f2741b78SRussell King#ifdef CONFIG_IRQSOFF_TRACER 375f2741b78SRussell King bl trace_hardirqs_off 376f2741b78SRussell King#endif 3771da177e4SLinus Torvalds .endm 3781da177e4SLinus Torvalds 379b49c0f24SNicolas Pitre .macro kuser_cmpxchg_check 380b49c0f24SNicolas Pitre#if __LINUX_ARM_ARCH__ < 6 && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG) 381b49c0f24SNicolas Pitre#ifndef CONFIG_MMU 382b49c0f24SNicolas Pitre#warning "NPTL on non MMU needs fixing" 383b49c0f24SNicolas Pitre#else 384b49c0f24SNicolas Pitre @ Make sure our user space atomic helper is restarted 385b49c0f24SNicolas Pitre @ if it was interrupted in a critical region. Here we 386b49c0f24SNicolas Pitre @ perform a quick test inline since it should be false 387b49c0f24SNicolas Pitre @ 99.9999% of the time. The rest is done out of line. 388b059bdc3SRussell King cmp r4, #TASK_SIZE 389b49c0f24SNicolas Pitre blhs kuser_cmpxchg_fixup 390b49c0f24SNicolas Pitre#endif 391b49c0f24SNicolas Pitre#endif 392b49c0f24SNicolas Pitre .endm 393b49c0f24SNicolas Pitre 3941da177e4SLinus Torvalds .align 5 3951da177e4SLinus Torvalds__dabt_usr: 396ccea7a19SRussell King usr_entry 397b49c0f24SNicolas Pitre kuser_cmpxchg_check 3981da177e4SLinus Torvalds mov r2, sp 399da740472SRussell King dabt_helper 400da740472SRussell King b ret_from_exception 401c4c5716eSCatalin Marinas UNWIND(.fnend ) 40293ed3970SCatalin MarinasENDPROC(__dabt_usr) 4031da177e4SLinus Torvalds 4041da177e4SLinus Torvalds .align 5 4051da177e4SLinus Torvalds__irq_usr: 406ccea7a19SRussell King usr_entry 407bc089602SRussell King kuser_cmpxchg_check 408187a51adSRussell King irq_handler 4091613cc11SRussell King get_thread_info tsk 4101da177e4SLinus Torvalds mov why, #0 4119fc2552aSMing Lei b ret_to_user_from_irq 412c4c5716eSCatalin Marinas UNWIND(.fnend ) 41393ed3970SCatalin MarinasENDPROC(__irq_usr) 4141da177e4SLinus Torvalds 4151da177e4SLinus Torvalds .ltorg 4161da177e4SLinus Torvalds 4171da177e4SLinus Torvalds .align 5 4181da177e4SLinus Torvalds__und_usr: 419ccea7a19SRussell King usr_entry 420bc089602SRussell King 421b059bdc3SRussell King mov r2, r4 422b059bdc3SRussell King mov r3, r5 4231da177e4SLinus Torvalds 4241da177e4SLinus Torvalds @ 4251da177e4SLinus Torvalds @ fall through to the emulation code, which returns using r9 if 4261da177e4SLinus Torvalds @ it has emulated the instruction, or the more conventional lr 4271da177e4SLinus Torvalds @ if we are to treat this as a real undefined instruction 4281da177e4SLinus Torvalds @ 4291da177e4SLinus Torvalds @ r0 - instruction 4301da177e4SLinus Torvalds @ 431b86040a5SCatalin Marinas adr r9, BSYM(ret_from_exception) 432b86040a5SCatalin Marinas adr lr, BSYM(__und_usr_unknown) 433cb170a45SPaul Brook tst r3, #PSR_T_BIT @ Thumb mode? 434b86040a5SCatalin Marinas itet eq @ explicit IT needed for the 1f label 435cb170a45SPaul Brook subeq r4, r2, #4 @ ARM instr at LR - 4 436cb170a45SPaul Brook subne r4, r2, #2 @ Thumb instr at LR - 2 437cb170a45SPaul Brook1: ldreqt r0, [r4] 43826584853SCatalin Marinas#ifdef CONFIG_CPU_ENDIAN_BE8 43926584853SCatalin Marinas reveq r0, r0 @ little endian instruction 44026584853SCatalin Marinas#endif 441cb170a45SPaul Brook beq call_fpe 442cb170a45SPaul Brook @ Thumb instruction 443cb170a45SPaul Brook#if __LINUX_ARM_ARCH__ >= 7 444b86040a5SCatalin Marinas2: 445b86040a5SCatalin Marinas ARM( ldrht r5, [r4], #2 ) 446b86040a5SCatalin Marinas THUMB( ldrht r5, [r4] ) 447b86040a5SCatalin Marinas THUMB( add r4, r4, #2 ) 448cb170a45SPaul Brook and r0, r5, #0xf800 @ mask bits 111x x... .... .... 449cb170a45SPaul Brook cmp r0, #0xe800 @ 32bit instruction if xx != 0 450cb170a45SPaul Brook blo __und_usr_unknown 451cb170a45SPaul Brook3: ldrht r0, [r4] 452cb170a45SPaul Brook add r2, r2, #2 @ r2 is PC + 2, make it PC + 4 453cb170a45SPaul Brook orr r0, r0, r5, lsl #16 454cb170a45SPaul Brook#else 455cb170a45SPaul Brook b __und_usr_unknown 456cb170a45SPaul Brook#endif 457c4c5716eSCatalin Marinas UNWIND(.fnend ) 45893ed3970SCatalin MarinasENDPROC(__und_usr) 459cb170a45SPaul Brook 4601da177e4SLinus Torvalds @ 4611da177e4SLinus Torvalds @ fallthrough to call_fpe 4621da177e4SLinus Torvalds @ 4631da177e4SLinus Torvalds 4641da177e4SLinus Torvalds/* 4651da177e4SLinus Torvalds * The out of line fixup for the ldrt above. 4661da177e4SLinus Torvalds */ 4674260415fSRussell King .pushsection .fixup, "ax" 468cb170a45SPaul Brook4: mov pc, r9 4694260415fSRussell King .popsection 4704260415fSRussell King .pushsection __ex_table,"a" 471cb170a45SPaul Brook .long 1b, 4b 472cb170a45SPaul Brook#if __LINUX_ARM_ARCH__ >= 7 473cb170a45SPaul Brook .long 2b, 4b 474cb170a45SPaul Brook .long 3b, 4b 475cb170a45SPaul Brook#endif 4764260415fSRussell King .popsection 4771da177e4SLinus Torvalds 4781da177e4SLinus Torvalds/* 4791da177e4SLinus Torvalds * Check whether the instruction is a co-processor instruction. 4801da177e4SLinus Torvalds * If yes, we need to call the relevant co-processor handler. 4811da177e4SLinus Torvalds * 4821da177e4SLinus Torvalds * Note that we don't do a full check here for the co-processor 4831da177e4SLinus Torvalds * instructions; all instructions with bit 27 set are well 4841da177e4SLinus Torvalds * defined. The only instructions that should fault are the 4851da177e4SLinus Torvalds * co-processor instructions. However, we have to watch out 4861da177e4SLinus Torvalds * for the ARM6/ARM7 SWI bug. 4871da177e4SLinus Torvalds * 488b5872db4SCatalin Marinas * NEON is a special case that has to be handled here. Not all 489b5872db4SCatalin Marinas * NEON instructions are co-processor instructions, so we have 490b5872db4SCatalin Marinas * to make a special case of checking for them. Plus, there's 491b5872db4SCatalin Marinas * five groups of them, so we have a table of mask/opcode pairs 492b5872db4SCatalin Marinas * to check against, and if any match then we branch off into the 493b5872db4SCatalin Marinas * NEON handler code. 494b5872db4SCatalin Marinas * 4951da177e4SLinus Torvalds * Emulators may wish to make use of the following registers: 4961da177e4SLinus Torvalds * r0 = instruction opcode. 4971da177e4SLinus Torvalds * r2 = PC+4 498db6ccbb6SRussell King * r9 = normal "successful" return address 4991da177e4SLinus Torvalds * r10 = this threads thread_info structure. 500db6ccbb6SRussell King * lr = unrecognised instruction return address 5011da177e4SLinus Torvalds */ 502cb170a45SPaul Brook @ 503cb170a45SPaul Brook @ Fall-through from Thumb-2 __und_usr 504cb170a45SPaul Brook @ 505cb170a45SPaul Brook#ifdef CONFIG_NEON 506cb170a45SPaul Brook adr r6, .LCneon_thumb_opcodes 507cb170a45SPaul Brook b 2f 508cb170a45SPaul Brook#endif 5091da177e4SLinus Torvaldscall_fpe: 510b5872db4SCatalin Marinas#ifdef CONFIG_NEON 511cb170a45SPaul Brook adr r6, .LCneon_arm_opcodes 512b5872db4SCatalin Marinas2: 513b5872db4SCatalin Marinas ldr r7, [r6], #4 @ mask value 514b5872db4SCatalin Marinas cmp r7, #0 @ end mask? 515b5872db4SCatalin Marinas beq 1f 516b5872db4SCatalin Marinas and r8, r0, r7 517b5872db4SCatalin Marinas ldr r7, [r6], #4 @ opcode bits matching in mask 518b5872db4SCatalin Marinas cmp r8, r7 @ NEON instruction? 519b5872db4SCatalin Marinas bne 2b 520b5872db4SCatalin Marinas get_thread_info r10 521b5872db4SCatalin Marinas mov r7, #1 522b5872db4SCatalin Marinas strb r7, [r10, #TI_USED_CP + 10] @ mark CP#10 as used 523b5872db4SCatalin Marinas strb r7, [r10, #TI_USED_CP + 11] @ mark CP#11 as used 524b5872db4SCatalin Marinas b do_vfp @ let VFP handler handle this 525b5872db4SCatalin Marinas1: 526b5872db4SCatalin Marinas#endif 5271da177e4SLinus Torvalds tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27 528cb170a45SPaul Brook tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2 5291da177e4SLinus Torvalds#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710) 5301da177e4SLinus Torvalds and r8, r0, #0x0f000000 @ mask out op-code bits 5311da177e4SLinus Torvalds teqne r8, #0x0f000000 @ SWI (ARM6/7 bug)? 5321da177e4SLinus Torvalds#endif 5331da177e4SLinus Torvalds moveq pc, lr 5341da177e4SLinus Torvalds get_thread_info r10 @ get current thread 5351da177e4SLinus Torvalds and r8, r0, #0x00000f00 @ mask out CP number 536b86040a5SCatalin Marinas THUMB( lsr r8, r8, #8 ) 5371da177e4SLinus Torvalds mov r7, #1 5381da177e4SLinus Torvalds add r6, r10, #TI_USED_CP 539b86040a5SCatalin Marinas ARM( strb r7, [r6, r8, lsr #8] ) @ set appropriate used_cp[] 540b86040a5SCatalin Marinas THUMB( strb r7, [r6, r8] ) @ set appropriate used_cp[] 5411da177e4SLinus Torvalds#ifdef CONFIG_IWMMXT 5421da177e4SLinus Torvalds @ Test if we need to give access to iWMMXt coprocessors 5431da177e4SLinus Torvalds ldr r5, [r10, #TI_FLAGS] 5441da177e4SLinus Torvalds rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only 5451da177e4SLinus Torvalds movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1) 5461da177e4SLinus Torvalds bcs iwmmxt_task_enable 5471da177e4SLinus Torvalds#endif 548b86040a5SCatalin Marinas ARM( add pc, pc, r8, lsr #6 ) 549b86040a5SCatalin Marinas THUMB( lsl r8, r8, #2 ) 550b86040a5SCatalin Marinas THUMB( add pc, r8 ) 551b86040a5SCatalin Marinas nop 5521da177e4SLinus Torvalds 553a771fe6eSCatalin Marinas movw_pc lr @ CP#0 554b86040a5SCatalin Marinas W(b) do_fpe @ CP#1 (FPE) 555b86040a5SCatalin Marinas W(b) do_fpe @ CP#2 (FPE) 556a771fe6eSCatalin Marinas movw_pc lr @ CP#3 557c17fad11SLennert Buytenhek#ifdef CONFIG_CRUNCH 558c17fad11SLennert Buytenhek b crunch_task_enable @ CP#4 (MaverickCrunch) 559c17fad11SLennert Buytenhek b crunch_task_enable @ CP#5 (MaverickCrunch) 560c17fad11SLennert Buytenhek b crunch_task_enable @ CP#6 (MaverickCrunch) 561c17fad11SLennert Buytenhek#else 562a771fe6eSCatalin Marinas movw_pc lr @ CP#4 563a771fe6eSCatalin Marinas movw_pc lr @ CP#5 564a771fe6eSCatalin Marinas movw_pc lr @ CP#6 565c17fad11SLennert Buytenhek#endif 566a771fe6eSCatalin Marinas movw_pc lr @ CP#7 567a771fe6eSCatalin Marinas movw_pc lr @ CP#8 568a771fe6eSCatalin Marinas movw_pc lr @ CP#9 5691da177e4SLinus Torvalds#ifdef CONFIG_VFP 570b86040a5SCatalin Marinas W(b) do_vfp @ CP#10 (VFP) 571b86040a5SCatalin Marinas W(b) do_vfp @ CP#11 (VFP) 5721da177e4SLinus Torvalds#else 573a771fe6eSCatalin Marinas movw_pc lr @ CP#10 (VFP) 574a771fe6eSCatalin Marinas movw_pc lr @ CP#11 (VFP) 5751da177e4SLinus Torvalds#endif 576a771fe6eSCatalin Marinas movw_pc lr @ CP#12 577a771fe6eSCatalin Marinas movw_pc lr @ CP#13 578a771fe6eSCatalin Marinas movw_pc lr @ CP#14 (Debug) 579a771fe6eSCatalin Marinas movw_pc lr @ CP#15 (Control) 5801da177e4SLinus Torvalds 581b5872db4SCatalin Marinas#ifdef CONFIG_NEON 582b5872db4SCatalin Marinas .align 6 583b5872db4SCatalin Marinas 584cb170a45SPaul Brook.LCneon_arm_opcodes: 585b5872db4SCatalin Marinas .word 0xfe000000 @ mask 586b5872db4SCatalin Marinas .word 0xf2000000 @ opcode 587b5872db4SCatalin Marinas 588b5872db4SCatalin Marinas .word 0xff100000 @ mask 589b5872db4SCatalin Marinas .word 0xf4000000 @ opcode 590b5872db4SCatalin Marinas 591b5872db4SCatalin Marinas .word 0x00000000 @ mask 592b5872db4SCatalin Marinas .word 0x00000000 @ opcode 593cb170a45SPaul Brook 594cb170a45SPaul Brook.LCneon_thumb_opcodes: 595cb170a45SPaul Brook .word 0xef000000 @ mask 596cb170a45SPaul Brook .word 0xef000000 @ opcode 597cb170a45SPaul Brook 598cb170a45SPaul Brook .word 0xff100000 @ mask 599cb170a45SPaul Brook .word 0xf9000000 @ opcode 600cb170a45SPaul Brook 601cb170a45SPaul Brook .word 0x00000000 @ mask 602cb170a45SPaul Brook .word 0x00000000 @ opcode 603b5872db4SCatalin Marinas#endif 604b5872db4SCatalin Marinas 6051da177e4SLinus Torvaldsdo_fpe: 6065d25ac03SRussell King enable_irq 6071da177e4SLinus Torvalds ldr r4, .LCfp 6081da177e4SLinus Torvalds add r10, r10, #TI_FPSTATE @ r10 = workspace 6091da177e4SLinus Torvalds ldr pc, [r4] @ Call FP module USR entry point 6101da177e4SLinus Torvalds 6111da177e4SLinus Torvalds/* 6121da177e4SLinus Torvalds * The FP module is called with these registers set: 6131da177e4SLinus Torvalds * r0 = instruction 6141da177e4SLinus Torvalds * r2 = PC+4 6151da177e4SLinus Torvalds * r9 = normal "successful" return address 6161da177e4SLinus Torvalds * r10 = FP workspace 6171da177e4SLinus Torvalds * lr = unrecognised FP instruction return address 6181da177e4SLinus Torvalds */ 6191da177e4SLinus Torvalds 620124efc27SSantosh Shilimkar .pushsection .data 6211da177e4SLinus TorvaldsENTRY(fp_enter) 622db6ccbb6SRussell King .word no_fp 623124efc27SSantosh Shilimkar .popsection 6241da177e4SLinus Torvalds 62583e686eaSCatalin MarinasENTRY(no_fp) 62683e686eaSCatalin Marinas mov pc, lr 62783e686eaSCatalin MarinasENDPROC(no_fp) 628db6ccbb6SRussell King 629db6ccbb6SRussell King__und_usr_unknown: 630ecbab71cSRussell King enable_irq 6311da177e4SLinus Torvalds mov r0, sp 632b86040a5SCatalin Marinas adr lr, BSYM(ret_from_exception) 6331da177e4SLinus Torvalds b do_undefinstr 63493ed3970SCatalin MarinasENDPROC(__und_usr_unknown) 6351da177e4SLinus Torvalds 6361da177e4SLinus Torvalds .align 5 6371da177e4SLinus Torvalds__pabt_usr: 638ccea7a19SRussell King usr_entry 6394fb28474SKirill A. Shutemov mov r2, sp @ regs 6408dfe7ac9SRussell King pabt_helper 641c4c5716eSCatalin Marinas UNWIND(.fnend ) 6421da177e4SLinus Torvalds /* fall through */ 6431da177e4SLinus Torvalds/* 6441da177e4SLinus Torvalds * This is the return code to user mode for abort handlers 6451da177e4SLinus Torvalds */ 6461da177e4SLinus TorvaldsENTRY(ret_from_exception) 647c4c5716eSCatalin Marinas UNWIND(.fnstart ) 648c4c5716eSCatalin Marinas UNWIND(.cantunwind ) 6491da177e4SLinus Torvalds get_thread_info tsk 6501da177e4SLinus Torvalds mov why, #0 6511da177e4SLinus Torvalds b ret_to_user 652c4c5716eSCatalin Marinas UNWIND(.fnend ) 65393ed3970SCatalin MarinasENDPROC(__pabt_usr) 65493ed3970SCatalin MarinasENDPROC(ret_from_exception) 6551da177e4SLinus Torvalds 6561da177e4SLinus Torvalds/* 6571da177e4SLinus Torvalds * Register switch for ARMv3 and ARMv4 processors 6581da177e4SLinus Torvalds * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info 6591da177e4SLinus Torvalds * previous and next are guaranteed not to be the same. 6601da177e4SLinus Torvalds */ 6611da177e4SLinus TorvaldsENTRY(__switch_to) 662c4c5716eSCatalin Marinas UNWIND(.fnstart ) 663c4c5716eSCatalin Marinas UNWIND(.cantunwind ) 6641da177e4SLinus Torvalds add ip, r1, #TI_CPU_SAVE 6651da177e4SLinus Torvalds ldr r3, [r2, #TI_TP_VALUE] 666b86040a5SCatalin Marinas ARM( stmia ip!, {r4 - sl, fp, sp, lr} ) @ Store most regs on stack 667b86040a5SCatalin Marinas THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack 668b86040a5SCatalin Marinas THUMB( str sp, [ip], #4 ) 669b86040a5SCatalin Marinas THUMB( str lr, [ip], #4 ) 670247055aaSCatalin Marinas#ifdef CONFIG_CPU_USE_DOMAINS 671d6551e88SRussell King ldr r6, [r2, #TI_CPU_DOMAIN] 672afeb90caSHyok S. Choi#endif 673f159f4edSTony Lindgren set_tls r3, r4, r5 674df0698beSNicolas Pitre#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 675df0698beSNicolas Pitre ldr r7, [r2, #TI_TASK] 676df0698beSNicolas Pitre ldr r8, =__stack_chk_guard 677df0698beSNicolas Pitre ldr r7, [r7, #TSK_STACK_CANARY] 678df0698beSNicolas Pitre#endif 679247055aaSCatalin Marinas#ifdef CONFIG_CPU_USE_DOMAINS 6801da177e4SLinus Torvalds mcr p15, 0, r6, c3, c0, 0 @ Set domain register 681afeb90caSHyok S. Choi#endif 682d6551e88SRussell King mov r5, r0 683d6551e88SRussell King add r4, r2, #TI_CPU_SAVE 684d6551e88SRussell King ldr r0, =thread_notify_head 685d6551e88SRussell King mov r1, #THREAD_NOTIFY_SWITCH 686d6551e88SRussell King bl atomic_notifier_call_chain 687df0698beSNicolas Pitre#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 688df0698beSNicolas Pitre str r7, [r8] 689df0698beSNicolas Pitre#endif 690b86040a5SCatalin Marinas THUMB( mov ip, r4 ) 691d6551e88SRussell King mov r0, r5 692b86040a5SCatalin Marinas ARM( ldmia r4, {r4 - sl, fp, sp, pc} ) @ Load all regs saved previously 693b86040a5SCatalin Marinas THUMB( ldmia ip!, {r4 - sl, fp} ) @ Load all regs saved previously 694b86040a5SCatalin Marinas THUMB( ldr sp, [ip], #4 ) 695b86040a5SCatalin Marinas THUMB( ldr pc, [ip] ) 696c4c5716eSCatalin Marinas UNWIND(.fnend ) 69793ed3970SCatalin MarinasENDPROC(__switch_to) 6981da177e4SLinus Torvalds 6991da177e4SLinus Torvalds __INIT 7002d2669b6SNicolas Pitre 7012d2669b6SNicolas Pitre/* 7022d2669b6SNicolas Pitre * User helpers. 7032d2669b6SNicolas Pitre * 7042d2669b6SNicolas Pitre * These are segment of kernel provided user code reachable from user space 7052d2669b6SNicolas Pitre * at a fixed address in kernel memory. This is used to provide user space 7062d2669b6SNicolas Pitre * with some operations which require kernel help because of unimplemented 7072d2669b6SNicolas Pitre * native feature and/or instructions in many ARM CPUs. The idea is for 7082d2669b6SNicolas Pitre * this code to be executed directly in user mode for best efficiency but 7092d2669b6SNicolas Pitre * which is too intimate with the kernel counter part to be left to user 7102d2669b6SNicolas Pitre * libraries. In fact this code might even differ from one CPU to another 7112d2669b6SNicolas Pitre * depending on the available instruction set and restrictions like on 7122d2669b6SNicolas Pitre * SMP systems. In other words, the kernel reserves the right to change 7132d2669b6SNicolas Pitre * this code as needed without warning. Only the entry points and their 7142d2669b6SNicolas Pitre * results are guaranteed to be stable. 7152d2669b6SNicolas Pitre * 7162d2669b6SNicolas Pitre * Each segment is 32-byte aligned and will be moved to the top of the high 7172d2669b6SNicolas Pitre * vector page. New segments (if ever needed) must be added in front of 7182d2669b6SNicolas Pitre * existing ones. This mechanism should be used only for things that are 7192d2669b6SNicolas Pitre * really small and justified, and not be abused freely. 7202d2669b6SNicolas Pitre * 7212d2669b6SNicolas Pitre * User space is expected to implement those things inline when optimizing 7222d2669b6SNicolas Pitre * for a processor that has the necessary native support, but only if such 7232d2669b6SNicolas Pitre * resulting binaries are already to be incompatible with earlier ARM 7242d2669b6SNicolas Pitre * processors due to the use of unsupported instructions other than what 7252d2669b6SNicolas Pitre * is provided here. In other words don't make binaries unable to run on 7262d2669b6SNicolas Pitre * earlier processors just for the sake of not using these kernel helpers 7272d2669b6SNicolas Pitre * if your compiled code is not going to use the new instructions for other 7282d2669b6SNicolas Pitre * purpose. 7292d2669b6SNicolas Pitre */ 730b86040a5SCatalin Marinas THUMB( .arm ) 7312d2669b6SNicolas Pitre 732ba9b5d76SNicolas Pitre .macro usr_ret, reg 733ba9b5d76SNicolas Pitre#ifdef CONFIG_ARM_THUMB 734ba9b5d76SNicolas Pitre bx \reg 735ba9b5d76SNicolas Pitre#else 736ba9b5d76SNicolas Pitre mov pc, \reg 737ba9b5d76SNicolas Pitre#endif 738ba9b5d76SNicolas Pitre .endm 739ba9b5d76SNicolas Pitre 7402d2669b6SNicolas Pitre .align 5 7412d2669b6SNicolas Pitre .globl __kuser_helper_start 7422d2669b6SNicolas Pitre__kuser_helper_start: 7432d2669b6SNicolas Pitre 7442d2669b6SNicolas Pitre/* 7452d2669b6SNicolas Pitre * Reference prototype: 7462d2669b6SNicolas Pitre * 7477c612bfdSNicolas Pitre * void __kernel_memory_barrier(void) 7487c612bfdSNicolas Pitre * 7497c612bfdSNicolas Pitre * Input: 7507c612bfdSNicolas Pitre * 7517c612bfdSNicolas Pitre * lr = return address 7527c612bfdSNicolas Pitre * 7537c612bfdSNicolas Pitre * Output: 7547c612bfdSNicolas Pitre * 7557c612bfdSNicolas Pitre * none 7567c612bfdSNicolas Pitre * 7577c612bfdSNicolas Pitre * Clobbered: 7587c612bfdSNicolas Pitre * 759b49c0f24SNicolas Pitre * none 7607c612bfdSNicolas Pitre * 7617c612bfdSNicolas Pitre * Definition and user space usage example: 7627c612bfdSNicolas Pitre * 7637c612bfdSNicolas Pitre * typedef void (__kernel_dmb_t)(void); 7647c612bfdSNicolas Pitre * #define __kernel_dmb (*(__kernel_dmb_t *)0xffff0fa0) 7657c612bfdSNicolas Pitre * 7667c612bfdSNicolas Pitre * Apply any needed memory barrier to preserve consistency with data modified 7677c612bfdSNicolas Pitre * manually and __kuser_cmpxchg usage. 7687c612bfdSNicolas Pitre * 7697c612bfdSNicolas Pitre * This could be used as follows: 7707c612bfdSNicolas Pitre * 7717c612bfdSNicolas Pitre * #define __kernel_dmb() \ 7727c612bfdSNicolas Pitre * asm volatile ( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #95" \ 7736896eec0SPaul Brook * : : : "r0", "lr","cc" ) 7747c612bfdSNicolas Pitre */ 7757c612bfdSNicolas Pitre 7767c612bfdSNicolas Pitre__kuser_memory_barrier: @ 0xffff0fa0 777ed3768a8SDave Martin smp_dmb arm 778ba9b5d76SNicolas Pitre usr_ret lr 7797c612bfdSNicolas Pitre 7807c612bfdSNicolas Pitre .align 5 7817c612bfdSNicolas Pitre 7827c612bfdSNicolas Pitre/* 7837c612bfdSNicolas Pitre * Reference prototype: 7847c612bfdSNicolas Pitre * 7852d2669b6SNicolas Pitre * int __kernel_cmpxchg(int oldval, int newval, int *ptr) 7862d2669b6SNicolas Pitre * 7872d2669b6SNicolas Pitre * Input: 7882d2669b6SNicolas Pitre * 7892d2669b6SNicolas Pitre * r0 = oldval 7902d2669b6SNicolas Pitre * r1 = newval 7912d2669b6SNicolas Pitre * r2 = ptr 7922d2669b6SNicolas Pitre * lr = return address 7932d2669b6SNicolas Pitre * 7942d2669b6SNicolas Pitre * Output: 7952d2669b6SNicolas Pitre * 7962d2669b6SNicolas Pitre * r0 = returned value (zero or non-zero) 7972d2669b6SNicolas Pitre * C flag = set if r0 == 0, clear if r0 != 0 7982d2669b6SNicolas Pitre * 7992d2669b6SNicolas Pitre * Clobbered: 8002d2669b6SNicolas Pitre * 8012d2669b6SNicolas Pitre * r3, ip, flags 8022d2669b6SNicolas Pitre * 8032d2669b6SNicolas Pitre * Definition and user space usage example: 8042d2669b6SNicolas Pitre * 8052d2669b6SNicolas Pitre * typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr); 8062d2669b6SNicolas Pitre * #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0) 8072d2669b6SNicolas Pitre * 8082d2669b6SNicolas Pitre * Atomically store newval in *ptr if *ptr is equal to oldval for user space. 8092d2669b6SNicolas Pitre * Return zero if *ptr was changed or non-zero if no exchange happened. 8102d2669b6SNicolas Pitre * The C flag is also set if *ptr was changed to allow for assembly 8112d2669b6SNicolas Pitre * optimization in the calling code. 8122d2669b6SNicolas Pitre * 8135964eae8SNicolas Pitre * Notes: 8145964eae8SNicolas Pitre * 8155964eae8SNicolas Pitre * - This routine already includes memory barriers as needed. 8165964eae8SNicolas Pitre * 8172d2669b6SNicolas Pitre * For example, a user space atomic_add implementation could look like this: 8182d2669b6SNicolas Pitre * 8192d2669b6SNicolas Pitre * #define atomic_add(ptr, val) \ 8202d2669b6SNicolas Pitre * ({ register unsigned int *__ptr asm("r2") = (ptr); \ 8212d2669b6SNicolas Pitre * register unsigned int __result asm("r1"); \ 8222d2669b6SNicolas Pitre * asm volatile ( \ 8232d2669b6SNicolas Pitre * "1: @ atomic_add\n\t" \ 8242d2669b6SNicolas Pitre * "ldr r0, [r2]\n\t" \ 8252d2669b6SNicolas Pitre * "mov r3, #0xffff0fff\n\t" \ 8262d2669b6SNicolas Pitre * "add lr, pc, #4\n\t" \ 8272d2669b6SNicolas Pitre * "add r1, r0, %2\n\t" \ 8282d2669b6SNicolas Pitre * "add pc, r3, #(0xffff0fc0 - 0xffff0fff)\n\t" \ 8292d2669b6SNicolas Pitre * "bcc 1b" \ 8302d2669b6SNicolas Pitre * : "=&r" (__result) \ 8312d2669b6SNicolas Pitre * : "r" (__ptr), "rIL" (val) \ 8322d2669b6SNicolas Pitre * : "r0","r3","ip","lr","cc","memory" ); \ 8332d2669b6SNicolas Pitre * __result; }) 8342d2669b6SNicolas Pitre */ 8352d2669b6SNicolas Pitre 8362d2669b6SNicolas Pitre__kuser_cmpxchg: @ 0xffff0fc0 8372d2669b6SNicolas Pitre 838dcef1f63SNicolas Pitre#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG) 8392d2669b6SNicolas Pitre 840dcef1f63SNicolas Pitre /* 841dcef1f63SNicolas Pitre * Poor you. No fast solution possible... 842dcef1f63SNicolas Pitre * The kernel itself must perform the operation. 843dcef1f63SNicolas Pitre * A special ghost syscall is used for that (see traps.c). 844dcef1f63SNicolas Pitre */ 8455e097445SNicolas Pitre stmfd sp!, {r7, lr} 84655afd264SDave Martin ldr r7, 1f @ it's 20 bits 847cc20d429SRussell King swi __ARM_NR_cmpxchg 8485e097445SNicolas Pitre ldmfd sp!, {r7, pc} 849cc20d429SRussell King1: .word __ARM_NR_cmpxchg 850dcef1f63SNicolas Pitre 851dcef1f63SNicolas Pitre#elif __LINUX_ARM_ARCH__ < 6 8522d2669b6SNicolas Pitre 85349bca4c2SNicolas Pitre#ifdef CONFIG_MMU 854b49c0f24SNicolas Pitre 855b49c0f24SNicolas Pitre /* 856b49c0f24SNicolas Pitre * The only thing that can break atomicity in this cmpxchg 857b49c0f24SNicolas Pitre * implementation is either an IRQ or a data abort exception 858b49c0f24SNicolas Pitre * causing another process/thread to be scheduled in the middle 859b49c0f24SNicolas Pitre * of the critical sequence. To prevent this, code is added to 860b49c0f24SNicolas Pitre * the IRQ and data abort exception handlers to set the pc back 861b49c0f24SNicolas Pitre * to the beginning of the critical section if it is found to be 862b49c0f24SNicolas Pitre * within that critical section (see kuser_cmpxchg_fixup). 863b49c0f24SNicolas Pitre */ 864b49c0f24SNicolas Pitre1: ldr r3, [r2] @ load current val 865b49c0f24SNicolas Pitre subs r3, r3, r0 @ compare with oldval 866b49c0f24SNicolas Pitre2: streq r1, [r2] @ store newval if eq 867b49c0f24SNicolas Pitre rsbs r0, r3, #0 @ set return val and C flag 868b49c0f24SNicolas Pitre usr_ret lr 869b49c0f24SNicolas Pitre 870b49c0f24SNicolas Pitre .text 871b49c0f24SNicolas Pitrekuser_cmpxchg_fixup: 872b49c0f24SNicolas Pitre @ Called from kuser_cmpxchg_check macro. 873b059bdc3SRussell King @ r4 = address of interrupted insn (must be preserved). 874b49c0f24SNicolas Pitre @ sp = saved regs. r7 and r8 are clobbered. 875b49c0f24SNicolas Pitre @ 1b = first critical insn, 2b = last critical insn. 876b059bdc3SRussell King @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b. 877b49c0f24SNicolas Pitre mov r7, #0xffff0fff 878b49c0f24SNicolas Pitre sub r7, r7, #(0xffff0fff - (0xffff0fc0 + (1b - __kuser_cmpxchg))) 879b059bdc3SRussell King subs r8, r4, r7 880b49c0f24SNicolas Pitre rsbcss r8, r8, #(2b - 1b) 881b49c0f24SNicolas Pitre strcs r7, [sp, #S_PC] 882b49c0f24SNicolas Pitre mov pc, lr 883b49c0f24SNicolas Pitre .previous 884b49c0f24SNicolas Pitre 88549bca4c2SNicolas Pitre#else 88649bca4c2SNicolas Pitre#warning "NPTL on non MMU needs fixing" 88749bca4c2SNicolas Pitre mov r0, #-1 88849bca4c2SNicolas Pitre adds r0, r0, #0 889ba9b5d76SNicolas Pitre usr_ret lr 890b49c0f24SNicolas Pitre#endif 8912d2669b6SNicolas Pitre 8922d2669b6SNicolas Pitre#else 8932d2669b6SNicolas Pitre 894ed3768a8SDave Martin smp_dmb arm 895b49c0f24SNicolas Pitre1: ldrex r3, [r2] 8962d2669b6SNicolas Pitre subs r3, r3, r0 8972d2669b6SNicolas Pitre strexeq r3, r1, [r2] 898b49c0f24SNicolas Pitre teqeq r3, #1 899b49c0f24SNicolas Pitre beq 1b 9002d2669b6SNicolas Pitre rsbs r0, r3, #0 901b49c0f24SNicolas Pitre /* beware -- each __kuser slot must be 8 instructions max */ 902f00ec48fSRussell King ALT_SMP(b __kuser_memory_barrier) 903f00ec48fSRussell King ALT_UP(usr_ret lr) 9042d2669b6SNicolas Pitre 9052d2669b6SNicolas Pitre#endif 9062d2669b6SNicolas Pitre 9072d2669b6SNicolas Pitre .align 5 9082d2669b6SNicolas Pitre 9092d2669b6SNicolas Pitre/* 9102d2669b6SNicolas Pitre * Reference prototype: 9112d2669b6SNicolas Pitre * 9122d2669b6SNicolas Pitre * int __kernel_get_tls(void) 9132d2669b6SNicolas Pitre * 9142d2669b6SNicolas Pitre * Input: 9152d2669b6SNicolas Pitre * 9162d2669b6SNicolas Pitre * lr = return address 9172d2669b6SNicolas Pitre * 9182d2669b6SNicolas Pitre * Output: 9192d2669b6SNicolas Pitre * 9202d2669b6SNicolas Pitre * r0 = TLS value 9212d2669b6SNicolas Pitre * 9222d2669b6SNicolas Pitre * Clobbered: 9232d2669b6SNicolas Pitre * 924b49c0f24SNicolas Pitre * none 9252d2669b6SNicolas Pitre * 9262d2669b6SNicolas Pitre * Definition and user space usage example: 9272d2669b6SNicolas Pitre * 9282d2669b6SNicolas Pitre * typedef int (__kernel_get_tls_t)(void); 9292d2669b6SNicolas Pitre * #define __kernel_get_tls (*(__kernel_get_tls_t *)0xffff0fe0) 9302d2669b6SNicolas Pitre * 9312d2669b6SNicolas Pitre * Get the TLS value as previously set via the __ARM_NR_set_tls syscall. 9322d2669b6SNicolas Pitre * 9332d2669b6SNicolas Pitre * This could be used as follows: 9342d2669b6SNicolas Pitre * 9352d2669b6SNicolas Pitre * #define __kernel_get_tls() \ 9362d2669b6SNicolas Pitre * ({ register unsigned int __val asm("r0"); \ 9372d2669b6SNicolas Pitre * asm( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #31" \ 9382d2669b6SNicolas Pitre * : "=r" (__val) : : "lr","cc" ); \ 9392d2669b6SNicolas Pitre * __val; }) 9402d2669b6SNicolas Pitre */ 9412d2669b6SNicolas Pitre 9422d2669b6SNicolas Pitre__kuser_get_tls: @ 0xffff0fe0 943f159f4edSTony Lindgren ldr r0, [pc, #(16 - 8)] @ read TLS, set in kuser_get_tls_init 944ba9b5d76SNicolas Pitre usr_ret lr 945f159f4edSTony Lindgren mrc p15, 0, r0, c13, c0, 3 @ 0xffff0fe8 hardware TLS code 946f159f4edSTony Lindgren .rep 4 947f159f4edSTony Lindgren .word 0 @ 0xffff0ff0 software TLS value, then 948f159f4edSTony Lindgren .endr @ pad up to __kuser_helper_version 9492d2669b6SNicolas Pitre 9502d2669b6SNicolas Pitre/* 9512d2669b6SNicolas Pitre * Reference declaration: 9522d2669b6SNicolas Pitre * 9532d2669b6SNicolas Pitre * extern unsigned int __kernel_helper_version; 9542d2669b6SNicolas Pitre * 9552d2669b6SNicolas Pitre * Definition and user space usage example: 9562d2669b6SNicolas Pitre * 9572d2669b6SNicolas Pitre * #define __kernel_helper_version (*(unsigned int *)0xffff0ffc) 9582d2669b6SNicolas Pitre * 9592d2669b6SNicolas Pitre * User space may read this to determine the curent number of helpers 9602d2669b6SNicolas Pitre * available. 9612d2669b6SNicolas Pitre */ 9622d2669b6SNicolas Pitre 9632d2669b6SNicolas Pitre__kuser_helper_version: @ 0xffff0ffc 9642d2669b6SNicolas Pitre .word ((__kuser_helper_end - __kuser_helper_start) >> 5) 9652d2669b6SNicolas Pitre 9662d2669b6SNicolas Pitre .globl __kuser_helper_end 9672d2669b6SNicolas Pitre__kuser_helper_end: 9682d2669b6SNicolas Pitre 969b86040a5SCatalin Marinas THUMB( .thumb ) 9702d2669b6SNicolas Pitre 9711da177e4SLinus Torvalds/* 9721da177e4SLinus Torvalds * Vector stubs. 9731da177e4SLinus Torvalds * 9747933523dSRussell King * This code is copied to 0xffff0200 so we can use branches in the 9757933523dSRussell King * vectors, rather than ldr's. Note that this code must not 9767933523dSRussell King * exceed 0x300 bytes. 9771da177e4SLinus Torvalds * 9781da177e4SLinus Torvalds * Common stub entry macro: 9791da177e4SLinus Torvalds * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC 980ccea7a19SRussell King * 981ccea7a19SRussell King * SP points to a minimal amount of processor-private memory, the address 982ccea7a19SRussell King * of which is copied into r0 for the mode specific abort handler. 9831da177e4SLinus Torvalds */ 984b7ec4795SNicolas Pitre .macro vector_stub, name, mode, correction=0 9851da177e4SLinus Torvalds .align 5 9861da177e4SLinus Torvalds 9871da177e4SLinus Torvaldsvector_\name: 9881da177e4SLinus Torvalds .if \correction 9891da177e4SLinus Torvalds sub lr, lr, #\correction 9901da177e4SLinus Torvalds .endif 9911da177e4SLinus Torvalds 992ccea7a19SRussell King @ 993ccea7a19SRussell King @ Save r0, lr_<exception> (parent PC) and spsr_<exception> 994ccea7a19SRussell King @ (parent CPSR) 995ccea7a19SRussell King @ 996ccea7a19SRussell King stmia sp, {r0, lr} @ save r0, lr 997ccea7a19SRussell King mrs lr, spsr 998ccea7a19SRussell King str lr, [sp, #8] @ save spsr 999ccea7a19SRussell King 1000ccea7a19SRussell King @ 1001ccea7a19SRussell King @ Prepare for SVC32 mode. IRQs remain disabled. 1002ccea7a19SRussell King @ 1003ccea7a19SRussell King mrs r0, cpsr 1004b86040a5SCatalin Marinas eor r0, r0, #(\mode ^ SVC_MODE | PSR_ISETSTATE) 1005ccea7a19SRussell King msr spsr_cxsf, r0 1006ccea7a19SRussell King 1007ccea7a19SRussell King @ 1008ccea7a19SRussell King @ the branch table must immediately follow this code 1009ccea7a19SRussell King @ 1010ccea7a19SRussell King and lr, lr, #0x0f 1011b86040a5SCatalin Marinas THUMB( adr r0, 1f ) 1012b86040a5SCatalin Marinas THUMB( ldr lr, [r0, lr, lsl #2] ) 1013b7ec4795SNicolas Pitre mov r0, sp 1014b86040a5SCatalin Marinas ARM( ldr lr, [pc, lr, lsl #2] ) 1015ccea7a19SRussell King movs pc, lr @ branch to handler in SVC mode 101693ed3970SCatalin MarinasENDPROC(vector_\name) 101788987ef9SCatalin Marinas 101888987ef9SCatalin Marinas .align 2 101988987ef9SCatalin Marinas @ handler addresses follow this label 102088987ef9SCatalin Marinas1: 10211da177e4SLinus Torvalds .endm 10221da177e4SLinus Torvalds 10237933523dSRussell King .globl __stubs_start 10241da177e4SLinus Torvalds__stubs_start: 10251da177e4SLinus Torvalds/* 10261da177e4SLinus Torvalds * Interrupt dispatcher 10271da177e4SLinus Torvalds */ 1028b7ec4795SNicolas Pitre vector_stub irq, IRQ_MODE, 4 10291da177e4SLinus Torvalds 10301da177e4SLinus Torvalds .long __irq_usr @ 0 (USR_26 / USR_32) 10311da177e4SLinus Torvalds .long __irq_invalid @ 1 (FIQ_26 / FIQ_32) 10321da177e4SLinus Torvalds .long __irq_invalid @ 2 (IRQ_26 / IRQ_32) 10331da177e4SLinus Torvalds .long __irq_svc @ 3 (SVC_26 / SVC_32) 10341da177e4SLinus Torvalds .long __irq_invalid @ 4 10351da177e4SLinus Torvalds .long __irq_invalid @ 5 10361da177e4SLinus Torvalds .long __irq_invalid @ 6 10371da177e4SLinus Torvalds .long __irq_invalid @ 7 10381da177e4SLinus Torvalds .long __irq_invalid @ 8 10391da177e4SLinus Torvalds .long __irq_invalid @ 9 10401da177e4SLinus Torvalds .long __irq_invalid @ a 10411da177e4SLinus Torvalds .long __irq_invalid @ b 10421da177e4SLinus Torvalds .long __irq_invalid @ c 10431da177e4SLinus Torvalds .long __irq_invalid @ d 10441da177e4SLinus Torvalds .long __irq_invalid @ e 10451da177e4SLinus Torvalds .long __irq_invalid @ f 10461da177e4SLinus Torvalds 10471da177e4SLinus Torvalds/* 10481da177e4SLinus Torvalds * Data abort dispatcher 10491da177e4SLinus Torvalds * Enter in ABT mode, spsr = USR CPSR, lr = USR PC 10501da177e4SLinus Torvalds */ 1051b7ec4795SNicolas Pitre vector_stub dabt, ABT_MODE, 8 10521da177e4SLinus Torvalds 10531da177e4SLinus Torvalds .long __dabt_usr @ 0 (USR_26 / USR_32) 10541da177e4SLinus Torvalds .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32) 10551da177e4SLinus Torvalds .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32) 10561da177e4SLinus Torvalds .long __dabt_svc @ 3 (SVC_26 / SVC_32) 10571da177e4SLinus Torvalds .long __dabt_invalid @ 4 10581da177e4SLinus Torvalds .long __dabt_invalid @ 5 10591da177e4SLinus Torvalds .long __dabt_invalid @ 6 10601da177e4SLinus Torvalds .long __dabt_invalid @ 7 10611da177e4SLinus Torvalds .long __dabt_invalid @ 8 10621da177e4SLinus Torvalds .long __dabt_invalid @ 9 10631da177e4SLinus Torvalds .long __dabt_invalid @ a 10641da177e4SLinus Torvalds .long __dabt_invalid @ b 10651da177e4SLinus Torvalds .long __dabt_invalid @ c 10661da177e4SLinus Torvalds .long __dabt_invalid @ d 10671da177e4SLinus Torvalds .long __dabt_invalid @ e 10681da177e4SLinus Torvalds .long __dabt_invalid @ f 10691da177e4SLinus Torvalds 10701da177e4SLinus Torvalds/* 10711da177e4SLinus Torvalds * Prefetch abort dispatcher 10721da177e4SLinus Torvalds * Enter in ABT mode, spsr = USR CPSR, lr = USR PC 10731da177e4SLinus Torvalds */ 1074b7ec4795SNicolas Pitre vector_stub pabt, ABT_MODE, 4 10751da177e4SLinus Torvalds 10761da177e4SLinus Torvalds .long __pabt_usr @ 0 (USR_26 / USR_32) 10771da177e4SLinus Torvalds .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32) 10781da177e4SLinus Torvalds .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32) 10791da177e4SLinus Torvalds .long __pabt_svc @ 3 (SVC_26 / SVC_32) 10801da177e4SLinus Torvalds .long __pabt_invalid @ 4 10811da177e4SLinus Torvalds .long __pabt_invalid @ 5 10821da177e4SLinus Torvalds .long __pabt_invalid @ 6 10831da177e4SLinus Torvalds .long __pabt_invalid @ 7 10841da177e4SLinus Torvalds .long __pabt_invalid @ 8 10851da177e4SLinus Torvalds .long __pabt_invalid @ 9 10861da177e4SLinus Torvalds .long __pabt_invalid @ a 10871da177e4SLinus Torvalds .long __pabt_invalid @ b 10881da177e4SLinus Torvalds .long __pabt_invalid @ c 10891da177e4SLinus Torvalds .long __pabt_invalid @ d 10901da177e4SLinus Torvalds .long __pabt_invalid @ e 10911da177e4SLinus Torvalds .long __pabt_invalid @ f 10921da177e4SLinus Torvalds 10931da177e4SLinus Torvalds/* 10941da177e4SLinus Torvalds * Undef instr entry dispatcher 10951da177e4SLinus Torvalds * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC 10961da177e4SLinus Torvalds */ 1097b7ec4795SNicolas Pitre vector_stub und, UND_MODE 10981da177e4SLinus Torvalds 10991da177e4SLinus Torvalds .long __und_usr @ 0 (USR_26 / USR_32) 11001da177e4SLinus Torvalds .long __und_invalid @ 1 (FIQ_26 / FIQ_32) 11011da177e4SLinus Torvalds .long __und_invalid @ 2 (IRQ_26 / IRQ_32) 11021da177e4SLinus Torvalds .long __und_svc @ 3 (SVC_26 / SVC_32) 11031da177e4SLinus Torvalds .long __und_invalid @ 4 11041da177e4SLinus Torvalds .long __und_invalid @ 5 11051da177e4SLinus Torvalds .long __und_invalid @ 6 11061da177e4SLinus Torvalds .long __und_invalid @ 7 11071da177e4SLinus Torvalds .long __und_invalid @ 8 11081da177e4SLinus Torvalds .long __und_invalid @ 9 11091da177e4SLinus Torvalds .long __und_invalid @ a 11101da177e4SLinus Torvalds .long __und_invalid @ b 11111da177e4SLinus Torvalds .long __und_invalid @ c 11121da177e4SLinus Torvalds .long __und_invalid @ d 11131da177e4SLinus Torvalds .long __und_invalid @ e 11141da177e4SLinus Torvalds .long __und_invalid @ f 11151da177e4SLinus Torvalds 11161da177e4SLinus Torvalds .align 5 11171da177e4SLinus Torvalds 11181da177e4SLinus Torvalds/*============================================================================= 11191da177e4SLinus Torvalds * Undefined FIQs 11201da177e4SLinus Torvalds *----------------------------------------------------------------------------- 11211da177e4SLinus Torvalds * Enter in FIQ mode, spsr = ANY CPSR, lr = ANY PC 11221da177e4SLinus Torvalds * MUST PRESERVE SVC SPSR, but need to switch to SVC mode to show our msg. 11231da177e4SLinus Torvalds * Basically to switch modes, we *HAVE* to clobber one register... brain 11241da177e4SLinus Torvalds * damage alert! I don't think that we can execute any code in here in any 11251da177e4SLinus Torvalds * other mode than FIQ... Ok you can switch to another mode, but you can't 11261da177e4SLinus Torvalds * get out of that mode without clobbering one register. 11271da177e4SLinus Torvalds */ 11281da177e4SLinus Torvaldsvector_fiq: 11291da177e4SLinus Torvalds disable_fiq 11301da177e4SLinus Torvalds subs pc, lr, #4 11311da177e4SLinus Torvalds 11321da177e4SLinus Torvalds/*============================================================================= 11331da177e4SLinus Torvalds * Address exception handler 11341da177e4SLinus Torvalds *----------------------------------------------------------------------------- 11351da177e4SLinus Torvalds * These aren't too critical. 11361da177e4SLinus Torvalds * (they're not supposed to happen, and won't happen in 32-bit data mode). 11371da177e4SLinus Torvalds */ 11381da177e4SLinus Torvalds 11391da177e4SLinus Torvaldsvector_addrexcptn: 11401da177e4SLinus Torvalds b vector_addrexcptn 11411da177e4SLinus Torvalds 11421da177e4SLinus Torvalds/* 11431da177e4SLinus Torvalds * We group all the following data together to optimise 11441da177e4SLinus Torvalds * for CPUs with separate I & D caches. 11451da177e4SLinus Torvalds */ 11461da177e4SLinus Torvalds .align 5 11471da177e4SLinus Torvalds 11481da177e4SLinus Torvalds.LCvswi: 11491da177e4SLinus Torvalds .word vector_swi 11501da177e4SLinus Torvalds 11517933523dSRussell King .globl __stubs_end 11521da177e4SLinus Torvalds__stubs_end: 11531da177e4SLinus Torvalds 11547933523dSRussell King .equ stubs_offset, __vectors_start + 0x200 - __stubs_start 11551da177e4SLinus Torvalds 11567933523dSRussell King .globl __vectors_start 11577933523dSRussell King__vectors_start: 1158b86040a5SCatalin Marinas ARM( swi SYS_ERROR0 ) 1159b86040a5SCatalin Marinas THUMB( svc #0 ) 1160b86040a5SCatalin Marinas THUMB( nop ) 1161b86040a5SCatalin Marinas W(b) vector_und + stubs_offset 1162b86040a5SCatalin Marinas W(ldr) pc, .LCvswi + stubs_offset 1163b86040a5SCatalin Marinas W(b) vector_pabt + stubs_offset 1164b86040a5SCatalin Marinas W(b) vector_dabt + stubs_offset 1165b86040a5SCatalin Marinas W(b) vector_addrexcptn + stubs_offset 1166b86040a5SCatalin Marinas W(b) vector_irq + stubs_offset 1167b86040a5SCatalin Marinas W(b) vector_fiq + stubs_offset 11681da177e4SLinus Torvalds 11697933523dSRussell King .globl __vectors_end 11707933523dSRussell King__vectors_end: 11711da177e4SLinus Torvalds 11721da177e4SLinus Torvalds .data 11731da177e4SLinus Torvalds 11741da177e4SLinus Torvalds .globl cr_alignment 11751da177e4SLinus Torvalds .globl cr_no_alignment 11761da177e4SLinus Torvaldscr_alignment: 11771da177e4SLinus Torvalds .space 4 11781da177e4SLinus Torvaldscr_no_alignment: 11791da177e4SLinus Torvalds .space 4 118052108641Seric miao 118152108641Seric miao#ifdef CONFIG_MULTI_IRQ_HANDLER 118252108641Seric miao .globl handle_arch_irq 118352108641Seric miaohandle_arch_irq: 118452108641Seric miao .space 4 118552108641Seric miao#endif 1186