Changeset View
Standalone View
sys/arm64/arm64/exception.S
| Show All 36 Lines | |||||
| /* | /* | ||||
| * This is limited to 28 instructions as it's placed in the exception vector | * This is limited to 28 instructions as it's placed in the exception vector | ||||
| * slot that is 32 instructions long. We need one for the branch, and three | * slot that is 32 instructions long. We need one for the branch, and three | ||||
| * for the prologue. | * for the prologue. | ||||
| */ | */ | ||||
| .macro save_registers_head el | .macro save_registers_head el | ||||
| .if \el == 1 | .if \el == 1 | ||||
| mov x18, sp | |||||
| stp x0, x1, [sp, #-(TF_SIZE - TF_X + 128)]! | stp x0, x1, [sp, #-(TF_SIZE - TF_X + 128)]! | ||||
| .else | .else | ||||
| stp x0, x1, [sp, #-(TF_SIZE - TF_X)]! | stp x0, x1, [sp, #-(TF_SIZE - TF_X)]! | ||||
| .endif | .endif | ||||
| stp x2, x3, [sp, #(2 * 8)] | stp x2, x3, [sp, #(2 * 8)] | ||||
| stp x4, x5, [sp, #(4 * 8)] | stp x4, x5, [sp, #(4 * 8)] | ||||
| stp x6, x7, [sp, #(6 * 8)] | stp x6, x7, [sp, #(6 * 8)] | ||||
| stp x8, x9, [sp, #(8 * 8)] | stp x8, x9, [sp, #(8 * 8)] | ||||
| stp x10, x11, [sp, #(10 * 8)] | stp x10, x11, [sp, #(10 * 8)] | ||||
| stp x12, x13, [sp, #(12 * 8)] | stp x12, x13, [sp, #(12 * 8)] | ||||
| stp x14, x15, [sp, #(14 * 8)] | stp x14, x15, [sp, #(14 * 8)] | ||||
| stp x16, x17, [sp, #(16 * 8)] | stp x16, x17, [sp, #(16 * 8)] | ||||
| stp x18, x19, [sp, #(18 * 8)] | stp x18, x19, [sp, #(18 * 8)] | ||||
| stp x20, x21, [sp, #(20 * 8)] | stp x20, x21, [sp, #(20 * 8)] | ||||
| stp x22, x23, [sp, #(22 * 8)] | stp x22, x23, [sp, #(22 * 8)] | ||||
| stp x24, x25, [sp, #(24 * 8)] | stp x24, x25, [sp, #(24 * 8)] | ||||
| stp x26, x27, [sp, #(26 * 8)] | stp x26, x27, [sp, #(26 * 8)] | ||||
| stp x28, x29, [sp, #(28 * 8)] | stp x28, x29, [sp, #(28 * 8)] | ||||
| .if \el == 0 | .if \el == 1 | ||||
| add x18, sp, #(TF_SIZE - TF_X + 128) | |||||
andrew: Not a `sub` with a positive value? | |||||
Done Inline ActionsHmm, I could do that if that is cleaner. Probably does read better in fact. jhb: Hmm, I could do that if that is cleaner. Probably does read better in fact. | |||||
Done Inline ActionsOne thing to keep in mind is that TF_X (48) - TF_SIZE (288) is actually negative, so this actually ends up being: add x18, sp, #368 (And logically, sp should be moving down the stack so getting back to the original value should be an add.) jhb: One thing to keep in mind is that TF_X (48) - TF_SIZE (288) is actually negative, so this… | |||||
Not Done Inline ActionsI like having add here to indicate that it "reverts" the stack allocation and that you used "-(the original value)" to easily correlate that with the stack allocation at the beginning of this macro. def: I like having `add` here to indicate that it "reverts" the stack allocation and that you used "… | |||||
Not Done Inline ActionsI think the EL1 stp would be clearer if it used #-(TF_SIZE - TF_X + 128) (and similar for the EL0 case) & this to the positive version. A more intrusive change would be to reorder struct trapframe so tf_x is first & we could just set sp to the base of the trapframe. This would need more testing as we reuse it in vmm.ko. andrew: I think the EL1 `stp` would be clearer if it used `#-(TF_SIZE - TF_X + 128)` (and similar for… | |||||
Done Inline ActionsChanging trapframe is a bit fraught as kgdb hardcodes that knowledge. I would be fine with fixing the arguments to stp to be clearer (and in fact I would prefer that quite a bit). I can add that as a commit before this and post a new review for that. jhb: Changing trapframe is a bit fraught as kgdb hardcodes that knowledge. I would be fine with… | |||||
| .else | |||||
| mrs x18, sp_el0 | mrs x18, sp_el0 | ||||
| .endif | .endif | ||||
| mrs x10, elr_el1 | mrs x10, elr_el1 | ||||
| mrs x11, spsr_el1 | mrs x11, spsr_el1 | ||||
| mrs x12, esr_el1 | mrs x12, esr_el1 | ||||
| mrs x13, far_el1 | mrs x13, far_el1 | ||||
| stp x18, lr, [sp, #(TF_SP - TF_X)]! | stp x18, lr, [sp, #(TF_SP - TF_X)]! | ||||
| stp x10, x11, [sp, #(TF_ELR)] | stp x10, x11, [sp, #(TF_ELR)] | ||||
| ▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines | |||||
Not a sub with a positive value?