Remove unused registes from the arm pcb

These were kept for ABI reasons. Remove them and bump __FreeBSD_version
so debuggers can be updated to use the new layout.

Reviewed by:	jhb
Sponsored by:	Arm Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35378
This commit is contained in:
Andrew Turner 2023-03-22 12:33:05 +00:00
parent 4a06b28a15
commit 1c1f31a5e5
9 changed files with 24 additions and 22 deletions

View File

@ -145,7 +145,7 @@ db_trace_thread(struct thread *thr, int count)
ctx = kdb_thr_ctx(thr);
frame.fp = (uintptr_t)ctx->pcb_x[PCB_FP];
frame.pc = (uintptr_t)ctx->pcb_lr;
frame.pc = (uintptr_t)ctx->pcb_x[PCB_LR];
db_stack_trace_cmd(thr, &frame);
} else
db_trace_self();

View File

@ -60,10 +60,10 @@ gdb_cpu_getreg(int regnum, size_t *regsz)
switch (regnum) {
case GDB_REG_SP: return (&kdb_thrctx->pcb_sp);
case GDB_REG_PC: /* FALLTHROUGH */
case GDB_REG_LR: return (&kdb_thrctx->pcb_lr);
case GDB_REG_LR: return (&kdb_thrctx->pcb_x[PCB_LR]);
default:
if (regnum >= GDB_REG_X0 && regnum <= GDB_REG_X29)
return (&kdb_thrctx->pcb_x[regnum]);
if (regnum >= GDB_REG_X19 && regnum <= GDB_REG_X29)
return (&kdb_thrctx->pcb_x[regnum - GDB_REG_X19]);
break;
}
@ -89,11 +89,11 @@ gdb_cpu_setreg(int regnum, void *val)
}
switch (regnum) {
case GDB_REG_PC: /* FALLTHROUGH */
case GDB_REG_LR: kdb_thrctx->pcb_lr = regval; break;
case GDB_REG_LR: kdb_thrctx->pcb_x[PCB_LR] = regval; break;
case GDB_REG_SP: kdb_thrctx->pcb_sp = regval; break;
default:
if (regnum >= GDB_REG_X0 && regnum <= GDB_REG_X29) {
kdb_thrctx->pcb_x[regnum] = regval;
if (regnum >= GDB_REG_X19 && regnum <= GDB_REG_X29) {
kdb_thrctx->pcb_x[regnum - GDB_REG_X19] = regval;
}
break;
}

View File

@ -57,7 +57,6 @@ 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));
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));

View File

@ -356,10 +356,10 @@ makectx(struct trapframe *tf, struct pcb *pcb)
int i;
for (i = 0; i < nitems(pcb->pcb_x); i++)
pcb->pcb_x[i] = tf->tf_x[i];
pcb->pcb_x[i] = tf->tf_x[i + PCB_X_START];
/* NB: pcb_lr is the PC, see PC_REGS() in db_machdep.h */
pcb->pcb_lr = tf->tf_elr;
/* NB: pcb_x[PCB_LR] is the PC, see PC_REGS() in db_machdep.h */
pcb->pcb_x[PCB_LR] = tf->tf_elr;
pcb->pcb_sp = tf->tf_sp;
}

View File

@ -69,7 +69,7 @@ stack_save_td(struct stack *st, struct thread *td)
return (EOPNOTSUPP);
frame.fp = td->td_pcb->pcb_x[PCB_FP];
frame.pc = ADDR_MAKE_CANONICAL(td->td_pcb->pcb_lr);
frame.pc = ADDR_MAKE_CANONICAL(td->td_pcb->pcb_x[PCB_LR]);
stack_capture(td, st, &frame);
return (0);

View File

@ -107,7 +107,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
/* Set the return value registers for fork() */
td2->td_pcb->pcb_x[PCB_X19] = (uintptr_t)fork_return;
td2->td_pcb->pcb_x[PCB_X20] = (uintptr_t)td2;
td2->td_pcb->pcb_lr = (uintptr_t)fork_trampoline;
td2->td_pcb->pcb_x[PCB_LR] = (uintptr_t)fork_trampoline;
td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame;
vfp_new_thread(td2, td1, true);
@ -185,7 +185,7 @@ cpu_copy_thread(struct thread *td, struct thread *td0)
td->td_pcb->pcb_x[PCB_X19] = (uintptr_t)fork_return;
td->td_pcb->pcb_x[PCB_X20] = (uintptr_t)td;
td->td_pcb->pcb_lr = (uintptr_t)fork_trampoline;
td->td_pcb->pcb_x[PCB_LR] = (uintptr_t)fork_trampoline;
td->td_pcb->pcb_sp = (uintptr_t)td->td_frame;
/* Update VFP state for the new thread */

View File

@ -44,7 +44,7 @@
typedef vm_offset_t db_addr_t;
typedef long db_expr_t;
#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_lr)
#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_x[PCB_LR])
#define BKPT_INST (0xd4200000)
#define BKPT_SIZE (4)
@ -52,7 +52,7 @@ typedef long db_expr_t;
#define BKPT_SKIP do { \
kdb_frame->tf_elr += BKPT_SIZE; \
kdb_thrctx->pcb_lr += BKPT_SIZE; \
kdb_thrctx->pcb_x[PCB_LR] += BKPT_SIZE; \
} while (0)
#define db_clear_single_step kdb_cpu_clear_singlestep

View File

@ -34,6 +34,7 @@
#define GDB_BUFSZ 4096
#define GDB_NREGS 68
#define GDB_REG_X0 0
#define GDB_REG_X19 19
#define GDB_REG_X29 29
#define GDB_REG_LR 30
#define GDB_REG_SP 31

View File

@ -36,14 +36,16 @@
struct trapframe;
#define PCB_X19 19
#define PCB_X20 20
#define PCB_FP 29
/* The first register in pcb_x is x19 */
#define PCB_X_START 19
#define PCB_X19 0
#define PCB_X20 1
#define PCB_FP 10
#define PCB_LR 11
struct pcb {
uint64_t pcb_x[30];
uint64_t pcb_lr;
uint64_t _reserved; /* Was pcb_pc */
uint64_t pcb_x[12];
/* These two need to be in order as we access them together */
uint64_t pcb_sp;
uint64_t pcb_tpidr_el0;