> Date: Wed, 23 Feb 2022 14:18:40 +0000
> From: Visa Hankala <[email protected]>
> 
> So far this patch has worked fine on my test system.

Cool.  I'm a little bit bothered by that 0x10 in the calculation, and
maybe that can go now.  But that is cleanup for later.  Making the
allocation explicit is progress.

ok kettenis@

> On Tue, Feb 22, 2022 at 06:41:31PM +0000, Visa Hankala wrote:
> > Index: arch/riscv64/include/frame.h
> > ===================================================================
> > RCS file: src/sys/arch/riscv64/include/frame.h,v
> > retrieving revision 1.2
> > diff -u -p -r1.2 frame.h
> > --- arch/riscv64/include/frame.h    12 May 2021 01:20:52 -0000      1.2
> > +++ arch/riscv64/include/frame.h    22 Feb 2022 18:20:46 -0000
> > @@ -64,6 +64,7 @@ typedef struct trapframe {
> >     register_t tf_sstatus;
> >     register_t tf_stval;
> >     register_t tf_scause;
> > +   register_t tf_pad;
> >  } trapframe_t;
> >  
> >  /*
> > @@ -85,6 +86,7 @@ struct sigframe {
> >  struct switchframe {
> >     register_t sf_s[12];
> >     register_t sf_ra;
> > +   register_t sf_pad;
> >  };
> >  
> >  struct callframe {
> > Index: arch/riscv64/riscv64/vm_machdep.c
> > ===================================================================
> > RCS file: src/sys/arch/riscv64/riscv64/vm_machdep.c,v
> > retrieving revision 1.8
> > diff -u -p -r1.8 vm_machdep.c
> > --- arch/riscv64/riscv64/vm_machdep.c       22 Feb 2022 07:47:46 -0000      
> > 1.8
> > +++ arch/riscv64/riscv64/vm_machdep.c       22 Feb 2022 18:20:46 -0000
> > @@ -62,6 +62,10 @@ cpu_fork(struct proc *p1, struct proc *p
> >     struct trapframe *tf;
> >     struct switchframe *sf;
> >  
> > +   /* Ensure proper stack alignment. */
> > +   CTASSERT((sizeof(struct trapframe) & STACKALIGNBYTES) == 0);
> > +   CTASSERT((sizeof(struct switchframe) & STACKALIGNBYTES) == 0);
> > +
> >     /* Save FPU state to PCB if necessary. */
> >     if (pcb1->pcb_flags & PCB_FPU)
> >             fpu_save(p1, pcb1->pcb_tf);
> > @@ -74,6 +78,7 @@ cpu_fork(struct proc *p1, struct proc *p
> >     tf = (struct trapframe *)((u_long)p2->p_addr
> >         + USPACE
> >         - sizeof(struct trapframe)
> > +       - sizeof(register_t)        /* for holding curcpu */
> >         - 0x10);
> >  
> >     tf = (struct trapframe *)STACKALIGN(tf);
> > 
> 

Reply via email to