arm64: Use the new PCB macros in swtch.S

Rather than hard coding the location of these registers in the array
use the new macros to find the correct offset.

Sponsored by:	Arm Ltd
This commit is contained in:
Andrew Turner 2023-03-22 13:42:00 +00:00
parent 1c33a94ab0
commit 787bf3bcd6
2 changed files with 25 additions and 24 deletions

View File

@ -56,6 +56,7 @@ ASSYM(PC_SSBD, offsetof(struct pcpu, pc_ssbd));
ASSYM(PCB_SIZE, roundup2(sizeof(struct pcb), STACKALIGNBYTES + 1));
ASSYM(PCB_SINGLE_STEP_SHIFT, PCB_SINGLE_STEP_SHIFT);
ASSYM(PCB_REGS, offsetof(struct pcb, pcb_x));
ASSYM(PCB_X19, PCB_X19);
ASSYM(PCB_LR, offsetof(struct pcb, pcb_lr));
ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp));
ASSYM(PCB_TPIDRRO, offsetof(struct pcb, pcb_tpidrro_el0));

View File

@ -102,12 +102,12 @@ ENTRY(cpu_throw)
msr tpidr_el0, x6
ldr x6, [x4, #PCB_TPIDRRO]
msr tpidrro_el0, x6
ldp x19, x20, [x4, #PCB_REGS + 19 * 8]
ldp x21, x22, [x4, #PCB_REGS + 21 * 8]
ldp x23, x24, [x4, #PCB_REGS + 23 * 8]
ldp x25, x26, [x4, #PCB_REGS + 25 * 8]
ldp x27, x28, [x4, #PCB_REGS + 27 * 8]
ldp x29, lr, [x4, #PCB_REGS + 29 * 8]
ldp x19, x20, [x4, #PCB_REGS + (PCB_X19 + 0) * 8]
ldp x21, x22, [x4, #PCB_REGS + (PCB_X19 + 2) * 8]
ldp x23, x24, [x4, #PCB_REGS + (PCB_X19 + 4) * 8]
ldp x25, x26, [x4, #PCB_REGS + (PCB_X19 + 6) * 8]
ldp x27, x28, [x4, #PCB_REGS + (PCB_X19 + 8) * 8]
ldp x29, lr, [x4, #PCB_REGS + (PCB_X19 + 10) * 8]
ret
END(cpu_throw)
@ -127,12 +127,12 @@ ENTRY(cpu_switch)
ldr x4, [x0, #TD_PCB]
/* Store the callee-saved registers */
stp x19, x20, [x4, #PCB_REGS + 19 * 8]
stp x21, x22, [x4, #PCB_REGS + 21 * 8]
stp x23, x24, [x4, #PCB_REGS + 23 * 8]
stp x25, x26, [x4, #PCB_REGS + 25 * 8]
stp x27, x28, [x4, #PCB_REGS + 27 * 8]
stp x29, lr, [x4, #PCB_REGS + 29 * 8]
stp x19, x20, [x4, #PCB_REGS + (PCB_X19 + 0) * 8]
stp x21, x22, [x4, #PCB_REGS + (PCB_X19 + 2) * 8]
stp x23, x24, [x4, #PCB_REGS + (PCB_X19 + 4) * 8]
stp x25, x26, [x4, #PCB_REGS + (PCB_X19 + 6) * 8]
stp x27, x28, [x4, #PCB_REGS + (PCB_X19 + 8) * 8]
stp x29, lr, [x4, #PCB_REGS + (PCB_X19 + 10) * 8]
/* And the old stack pointer */
mov x5, sp
mrs x6, tpidrro_el0
@ -196,12 +196,12 @@ ENTRY(cpu_switch)
msr tpidr_el0, x6
ldr x6, [x4, #PCB_TPIDRRO]
msr tpidrro_el0, x6
ldp x19, x20, [x4, #PCB_REGS + 19 * 8]
ldp x21, x22, [x4, #PCB_REGS + 21 * 8]
ldp x23, x24, [x4, #PCB_REGS + 23 * 8]
ldp x25, x26, [x4, #PCB_REGS + 25 * 8]
ldp x27, x28, [x4, #PCB_REGS + 27 * 8]
ldp x29, lr, [x4, #PCB_REGS + 29 * 8]
ldp x19, x20, [x4, #PCB_REGS + (PCB_X19 + 0) * 8]
ldp x21, x22, [x4, #PCB_REGS + (PCB_X19 + 2) * 8]
ldp x23, x24, [x4, #PCB_REGS + (PCB_X19 + 4) * 8]
ldp x25, x26, [x4, #PCB_REGS + (PCB_X19 + 6) * 8]
ldp x27, x28, [x4, #PCB_REGS + (PCB_X19 + 8) * 8]
ldp x29, lr, [x4, #PCB_REGS + (PCB_X19 + 10) * 8]
str xzr, [x4, #PCB_REGS + 18 * 8]
ret
@ -258,12 +258,12 @@ END(fork_trampoline)
ENTRY(savectx)
/* Store the callee-saved registers */
stp x19, x20, [x0, #PCB_REGS + 19 * 8]
stp x21, x22, [x0, #PCB_REGS + 21 * 8]
stp x23, x24, [x0, #PCB_REGS + 23 * 8]
stp x25, x26, [x0, #PCB_REGS + 25 * 8]
stp x27, x28, [x0, #PCB_REGS + 27 * 8]
stp x29, lr, [x0, #PCB_REGS + 29 * 8]
stp x19, x20, [x0, #PCB_REGS + (PCB_X19 + 0) * 8]
stp x21, x22, [x0, #PCB_REGS + (PCB_X19 + 2) * 8]
stp x23, x24, [x0, #PCB_REGS + (PCB_X19 + 4) * 8]
stp x25, x26, [x0, #PCB_REGS + (PCB_X19 + 6) * 8]
stp x27, x28, [x0, #PCB_REGS + (PCB_X19 + 8) * 8]
stp x29, lr, [x0, #PCB_REGS + (PCB_X19 + 10) * 8]
/* And the old stack pointer */
mov x5, sp
mrs x6, tpidrro_el0