From 03178616604d5d0806fffd46a547c67f1eac54e5 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 30 Jan 2020 19:15:27 +0000 Subject: [PATCH] Remove unused fields from struct pcb. cpu_switch/throw() and savectx() do not save or restore any values in these fields which mostly held non-callee-save registers. makectx() copied these fields from kdb_frame, but they weren't used except for PC_REGS using pcb_sepc. Change PC_REGS to use kdb_frame->tf_sepc directly instead. Reviewed by: br MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23395 --- sys/riscv/include/db_machdep.h | 2 +- sys/riscv/include/pcb.h | 3 --- sys/riscv/riscv/genassym.c | 2 -- sys/riscv/riscv/machdep.c | 3 --- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/sys/riscv/include/db_machdep.h b/sys/riscv/include/db_machdep.h index acbfa676c294..9271a2757cb8 100644 --- a/sys/riscv/include/db_machdep.h +++ b/sys/riscv/include/db_machdep.h @@ -47,7 +47,7 @@ typedef vm_offset_t db_addr_t; typedef long db_expr_t; -#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_sepc) +#define PC_REGS() ((db_addr_t)kdb_frame->tf_sepc) #define BKPT_INST (0x00100073) #define BKPT_SIZE (INSN_SIZE) diff --git a/sys/riscv/include/pcb.h b/sys/riscv/include/pcb.h index 6cc85198a417..44dd23e970e1 100644 --- a/sys/riscv/include/pcb.h +++ b/sys/riscv/include/pcb.h @@ -46,15 +46,12 @@ struct pcb { uint64_t pcb_sp; /* Stack pointer */ uint64_t pcb_gp; /* Global pointer */ uint64_t pcb_tp; /* Thread pointer */ - uint64_t pcb_t[7]; /* Temporary registers */ uint64_t pcb_s[12]; /* Saved registers */ - uint64_t pcb_a[8]; /* Argument registers */ uint64_t pcb_x[32][2]; /* Floating point registers */ uint64_t pcb_fcsr; /* Floating point control reg */ uint64_t pcb_fpflags; /* Floating point flags */ #define PCB_FP_STARTED 0x1 #define PCB_FP_USERMASK 0x1 - uint64_t pcb_sepc; /* Supervisor exception pc */ vm_offset_t pcb_onfault; /* Copyinout fault handler */ }; diff --git a/sys/riscv/riscv/genassym.c b/sys/riscv/riscv/genassym.c index c0c93e5d785c..d164ef8d3263 100644 --- a/sys/riscv/riscv/genassym.c +++ b/sys/riscv/riscv/genassym.c @@ -69,9 +69,7 @@ ASSYM(PCB_RA, offsetof(struct pcb, pcb_ra)); ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); ASSYM(PCB_GP, offsetof(struct pcb, pcb_gp)); ASSYM(PCB_TP, offsetof(struct pcb, pcb_tp)); -ASSYM(PCB_T, offsetof(struct pcb, pcb_t)); ASSYM(PCB_S, offsetof(struct pcb, pcb_s)); -ASSYM(PCB_A, offsetof(struct pcb, pcb_a)); ASSYM(PCB_X, offsetof(struct pcb, pcb_x)); ASSYM(PCB_FCSR, offsetof(struct pcb, pcb_fcsr)); diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 2a4ed10b1def..fe546789c62e 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -558,15 +558,12 @@ void makectx(struct trapframe *tf, struct pcb *pcb) { - memcpy(pcb->pcb_t, tf->tf_t, sizeof(tf->tf_t)); memcpy(pcb->pcb_s, tf->tf_s, sizeof(tf->tf_s)); - memcpy(pcb->pcb_a, tf->tf_a, sizeof(tf->tf_a)); pcb->pcb_ra = tf->tf_ra; pcb->pcb_sp = tf->tf_sp; pcb->pcb_gp = tf->tf_gp; pcb->pcb_tp = tf->tf_tp; - pcb->pcb_sepc = tf->tf_sepc; } void