In get_fpcontext32() and set_fpcontext32(), we can't just use memcpy() to

copy the VFP registers.
arvm7 VFP uses 32 64bits fp registers (but those could be used in pairs to
make 16 128bits registers), while aarch64 uses 32 128bits fp registers, so
we have to copy the value of each register.
This commit is contained in:
cognet 2019-06-26 22:06:40 +00:00
parent 8646c1fa6b
commit f18057177b

View File

@ -122,6 +122,7 @@ static void
get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp)
{
struct pcb *curpcb;
int i;
critical_enter();
curpcb = curthread->td_pcb;
@ -137,8 +138,8 @@ get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp)
("Called get_fpcontext while the kernel is using the VFP"));
KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
("Non-userspace FPU flags set in get_fpcontext"));
memcpy(mcp->mcv_reg, curpcb->pcb_fpustate.vfp_regs,
sizeof(mcp->mcv_reg));
for (i = 0; i < 32; i++)
mcp->mcv_reg[i] = (uint64_t)curpcb->pcb_fpustate.vfp_regs[i];
mcp->mcv_fpscr = VFP_FPSCR_FROM_SRCR(curpcb->pcb_fpustate.vfp_fpcr,
curpcb->pcb_fpustate.vfp_fpsr);
}
@ -149,13 +150,14 @@ static void
set_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp)
{
struct pcb *pcb;
int i;
critical_enter();
pcb = td->td_pcb;
if (td == curthread)
vfp_discard(td);
memcpy(pcb->pcb_fpustate.vfp_regs, mcp->mcv_reg,
sizeof(pcb->pcb_fpustate.vfp_regs));
for (i = 0; i < 32; i++)
pcb->pcb_fpustate.vfp_regs[i] = mcp->mcv_reg[i];
pcb->pcb_fpustate.vfp_fpsr = VFP_FPSR_FROM_FPSCR(mcp->mcv_fpscr);
pcb->pcb_fpustate.vfp_fpcr = VFP_FPSR_FROM_FPSCR(mcp->mcv_fpscr);
critical_exit();