Path: blob/master/tools/testing/selftests/kvm/lib/arm64/handlers.S
50618 views
/* SPDX-License-Identifier: GPL-2.0 */1.macro save_registers2add sp, sp, #-16 * 1734stp x0, x1, [sp, #16 * 0]5stp x2, x3, [sp, #16 * 1]6stp x4, x5, [sp, #16 * 2]7stp x6, x7, [sp, #16 * 3]8stp x8, x9, [sp, #16 * 4]9stp x10, x11, [sp, #16 * 5]10stp x12, x13, [sp, #16 * 6]11stp x14, x15, [sp, #16 * 7]12stp x16, x17, [sp, #16 * 8]13stp x18, x19, [sp, #16 * 9]14stp x20, x21, [sp, #16 * 10]15stp x22, x23, [sp, #16 * 11]16stp x24, x25, [sp, #16 * 12]17stp x26, x27, [sp, #16 * 13]18stp x28, x29, [sp, #16 * 14]1920/*21* This stores sp_el1 into ex_regs.sp so exception handlers can "look"22* at it. It will _not_ be used to restore the sp on return from the23* exception so handlers can not update it.24*/25add x1, sp, #16 * 1726stp x30, x1, [sp, #16 * 15] /* x30, SP */2728mrs x1, elr_el129mrs x2, spsr_el130stp x1, x2, [sp, #16 * 16] /* PC, PSTATE */31.endm3233.macro restore_registers34ldp x1, x2, [sp, #16 * 16] /* PC, PSTATE */35msr elr_el1, x136msr spsr_el1, x23738/* sp is not restored */39ldp x30, xzr, [sp, #16 * 15] /* x30, SP */4041ldp x28, x29, [sp, #16 * 14]42ldp x26, x27, [sp, #16 * 13]43ldp x24, x25, [sp, #16 * 12]44ldp x22, x23, [sp, #16 * 11]45ldp x20, x21, [sp, #16 * 10]46ldp x18, x19, [sp, #16 * 9]47ldp x16, x17, [sp, #16 * 8]48ldp x14, x15, [sp, #16 * 7]49ldp x12, x13, [sp, #16 * 6]50ldp x10, x11, [sp, #16 * 5]51ldp x8, x9, [sp, #16 * 4]52ldp x6, x7, [sp, #16 * 3]53ldp x4, x5, [sp, #16 * 2]54ldp x2, x3, [sp, #16 * 1]55ldp x0, x1, [sp, #16 * 0]5657add sp, sp, #16 * 175859eret60.endm6162.pushsection ".entry.text", "ax"63.balign 0x80064.global vectors65vectors:66.popsection6768.set vector, 06970/*71* Build an exception handler for vector and append a jump to it into72* vectors (while making sure that it's 0x80 aligned).73*/74.macro HANDLER, label75handler_\label:76save_registers77mov x0, sp78mov x1, #vector79bl route_exception80restore_registers8182.pushsection ".entry.text", "ax"83.balign 0x8084b handler_\label85.popsection8687.set vector, vector + 188.endm8990.macro HANDLER_INVALID91.pushsection ".entry.text", "ax"92.balign 0x8093/* This will abort so no need to save and restore registers. */94mov x0, #vector95mov x1, #0 /* ec */96mov x2, #0 /* valid_ec */97b kvm_exit_unexpected_exception98.popsection99100.set vector, vector + 1101.endm102103/*104* Caution: be sure to not add anything between the declaration of vectors105* above and these macro calls that will build the vectors table below it.106*/107HANDLER_INVALID // Synchronous EL1t108HANDLER_INVALID // IRQ EL1t109HANDLER_INVALID // FIQ EL1t110HANDLER_INVALID // Error EL1t111112HANDLER el1h_sync // Synchronous EL1h113HANDLER el1h_irq // IRQ EL1h114HANDLER el1h_fiq // FIQ EL1h115HANDLER el1h_error // Error EL1h116117HANDLER el0_sync_64 // Synchronous 64-bit EL0118HANDLER el0_irq_64 // IRQ 64-bit EL0119HANDLER el0_fiq_64 // FIQ 64-bit EL0120HANDLER el0_error_64 // Error 64-bit EL0121122HANDLER el0_sync_32 // Synchronous 32-bit EL0123HANDLER el0_irq_32 // IRQ 32-bit EL0124HANDLER el0_fiq_32 // FIQ 32-bit EL0125HANDLER el0_error_32 // Error 32-bit EL0126127128