mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 01:34:12 +00:00
exception: Make space in the stack for full exception context
This is step 1 of the rework to make reentrant exceptions work Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
04668b370a
commit
bce239b36f
8 changed files with 53 additions and 22 deletions
|
@ -67,14 +67,14 @@ class EXC_RET(IntEnum):
|
|||
STEP = 4
|
||||
|
||||
ExcInfo = Struct(
|
||||
"cpu_id" / Int64ul,
|
||||
"regs" / Array(32, Int64ul),
|
||||
"spsr" / RegAdapter(SPSR),
|
||||
"elr" / Int64ul,
|
||||
"esr" / RegAdapter(ESR),
|
||||
"far" / Int64ul,
|
||||
"afsr1" / Int64ul,
|
||||
"regs" / Array(31, Int64ul),
|
||||
"sp" / Array(3, Int64ul),
|
||||
"cpu_id" / Int64ul,
|
||||
"mpidr" / Int64ul,
|
||||
"elr_phys" / Int64ul,
|
||||
"far_phys" / Int64ul,
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
#ifndef __EXCEPTION_H__
|
||||
#define __EXCEPTION_H__
|
||||
|
||||
#define SIZEOF_EXC_INFO (64 * 8)
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "types.h"
|
||||
|
@ -16,6 +21,24 @@ enum exc_guard_t {
|
|||
GUARD_SILENT = 0x100,
|
||||
};
|
||||
|
||||
struct exc_info {
|
||||
u64 regs[32];
|
||||
u64 spsr;
|
||||
u64 elr;
|
||||
u64 esr;
|
||||
u64 far;
|
||||
u64 afsr1;
|
||||
u64 sp[3];
|
||||
u64 cpu_id;
|
||||
u64 mpidr;
|
||||
u64 elr_phys;
|
||||
u64 far_phys;
|
||||
u64 sp_phys;
|
||||
void *extra;
|
||||
};
|
||||
static_assert(sizeof(struct exc_info) <= SIZEOF_EXC_INFO, "Please increase SIZEOF_EXC_INFO");
|
||||
static_assert((sizeof(struct exc_info) & 15) == 0, "SIZEOF_EXC_INFO must be a multiple of 16");
|
||||
|
||||
extern volatile enum exc_guard_t exc_guard;
|
||||
extern volatile int exc_count;
|
||||
|
||||
|
@ -28,3 +51,5 @@ uint64_t el0_call(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
|||
uint64_t el1_call(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
#include "exception.h"
|
||||
#include "memory.h"
|
||||
|
||||
.globl exc_sync
|
||||
|
@ -13,6 +14,7 @@
|
|||
.type _v_sp0_sync, @function
|
||||
_v_sp0_sync:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _exc_entry
|
||||
bl exc_sync
|
||||
|
@ -23,6 +25,7 @@ _v_sp0_sync:
|
|||
.type _v_sp0_irq, @function
|
||||
_v_sp0_irq:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _exc_entry
|
||||
bl exc_irq
|
||||
|
@ -33,6 +36,7 @@ _v_sp0_irq:
|
|||
.type _v_sp0_fiq, @function
|
||||
_v_sp0_fiq:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _exc_entry
|
||||
bl exc_fiq
|
||||
|
@ -43,6 +47,7 @@ _v_sp0_fiq:
|
|||
.type _v_sp0_serr, @function
|
||||
_v_sp0_serr:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _exc_entry
|
||||
bl exc_serr
|
||||
|
@ -84,10 +89,11 @@ _exc_return:
|
|||
ldp x14, x15, [sp], #16
|
||||
ldp x16, x17, [sp], #16
|
||||
ldr x18, [sp], #8
|
||||
|
||||
add sp, sp, #88
|
||||
|
||||
ldr x30, [sp], #16
|
||||
|
||||
add sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
|
||||
eret
|
||||
|
||||
.globl el0_call
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
#include "cpu_regs.h"
|
||||
#include "gxf.h"
|
||||
#include "cpu_regs.h"
|
||||
#include "exception.h"
|
||||
|
||||
#define genter .long 0x00201420
|
||||
#define gexit .long 0x00201400
|
||||
|
@ -161,6 +162,7 @@ _gxf_vectors:
|
|||
|
||||
_gxf_exc_sync:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _gxf_exc_entry
|
||||
bl exc_sync
|
||||
|
@ -168,6 +170,7 @@ _gxf_exc_sync:
|
|||
|
||||
_gxf_serr:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _gxf_exc_entry
|
||||
bl exc_serr
|
||||
|
@ -225,6 +228,9 @@ _gxf_exc_return:
|
|||
ldp x26, x27, [sp], #16
|
||||
ldp x28, x29, [sp], #16
|
||||
ldr x30, [sp], #16
|
||||
|
||||
add sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
|
||||
isb
|
||||
|
||||
gexit
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* spDx-License-Identifier: MIT */
|
||||
|
||||
#include "exception.h"
|
||||
|
||||
.align 11
|
||||
.globl _hv_vectors_start
|
||||
_hv_vectors_start:
|
||||
|
@ -96,12 +98,16 @@ _hv_return:
|
|||
ldp x26, x27, [sp], #16
|
||||
ldp x28, x29, [sp], #16
|
||||
ldr x30, [sp], #16
|
||||
|
||||
add sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
|
||||
eret
|
||||
|
||||
.globl _v_hv_sync
|
||||
.type _v_hv_sync, @function
|
||||
_v_hv_sync:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _hv_entry
|
||||
bl hv_exc_sync
|
||||
|
@ -112,6 +118,7 @@ _v_hv_sync:
|
|||
.type _v_hv_irq, @function
|
||||
_v_hv_irq:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _hv_entry
|
||||
bl hv_exc_irq
|
||||
|
@ -122,6 +129,7 @@ _v_hv_irq:
|
|||
.type _v_hv_fiq, @function
|
||||
_v_hv_fiq:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _hv_entry
|
||||
bl hv_exc_fiq
|
||||
|
@ -132,6 +140,7 @@ _v_hv_fiq:
|
|||
.type _v_hv_serr, @function
|
||||
_v_hv_serr:
|
||||
msr pan, #0
|
||||
sub sp, sp, #(SIZEOF_EXC_INFO - 32 * 8)
|
||||
str x30, [sp, #-16]!
|
||||
bl _hv_entry
|
||||
bl hv_exc_serr
|
||||
|
|
|
@ -49,7 +49,7 @@ void hv_exc_proxy(u64 *regs, uartproxy_boot_reason_t reason, uartproxy_exc_code_
|
|||
u64 entry_time = mrs(CNTPCT_EL0);
|
||||
#endif
|
||||
|
||||
struct uartproxy_exc_info exc_info = {
|
||||
struct exc_info exc_info = {
|
||||
.cpu_id = smp_id(),
|
||||
.spsr = hv_get_spsr(),
|
||||
.elr = hv_get_elr(),
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "hv.h"
|
||||
#include "assert.h"
|
||||
#include "cpu_regs.h"
|
||||
#include "exception.h"
|
||||
#include "iodev.h"
|
||||
#include "malloc.h"
|
||||
#include "smp.h"
|
||||
|
|
|
@ -32,22 +32,6 @@ typedef enum _uartproxy_event_type_t {
|
|||
EVT_IRQTRACE = 2,
|
||||
} uartproxy_event_type_t;
|
||||
|
||||
struct uartproxy_exc_info {
|
||||
u64 cpu_id;
|
||||
u64 spsr;
|
||||
u64 elr;
|
||||
u64 esr;
|
||||
u64 far;
|
||||
u64 afsr1;
|
||||
u64 regs[31];
|
||||
u64 sp[3];
|
||||
u64 mpidr;
|
||||
u64 elr_phys;
|
||||
u64 far_phys;
|
||||
u64 sp_phys;
|
||||
void *extra;
|
||||
};
|
||||
|
||||
struct uartproxy_msg_start {
|
||||
u32 reason;
|
||||
u32 code;
|
||||
|
|
Loading…
Reference in a new issue