Re: [RESEND][PATCH] powerpc/powernv : Save/Restore SPRG3 on entry/exit from stop.

From: Michael Neuling
Date: Thu Jul 19 2018 - 20:27:16 EST


On Wed, 2018-07-18 at 13:42 +0530, Gautham R Shenoy wrote:
> Hello Mikey,
>
> On Wed, Jul 18, 2018 at 09:24:19AM +1000, Michael Neuling wrote:
> >
> > > DEFINE(PPC_DBELL_SERVER, PPC_DBELL_SERVER);
> > > diff --git a/arch/powerpc/kernel/idle_book3s.S
> > > b/arch/powerpc/kernel/idle_book3s.S
> > > index d85d551..5069d42 100644
> > > --- a/arch/powerpc/kernel/idle_book3s.S
> > > +++ b/arch/powerpc/kernel/idle_book3s.S
> > > @@ -120,6 +120,9 @@ power9_save_additional_sprs:
> > > mfspr r4, SPRN_MMCR2
> > > std r3, STOP_MMCR1(r13)
> > > std r4, STOP_MMCR2(r13)
> > > +
> > > + mfspr r3, SPRN_SPRG3
> > > + std r3, STOP_SPRG3(r13)
> >
> > We don't need to save it. Just restore it from paca->sprg_vdso which should
> > never change.
>
> Ok. I will respin a patch to restore SPRG3 from paca->sprg_vdso.
>
> >
> > How can we do better at catching these missing SPRGs?
>
> We can go through the list of SPRs from the POWER9 User Manual and
> document explicitly why we don't have to save/restore certain SPRs
> during the execution of the stop instruction. Does this sound ok ?
>
> (Ref: Table 4-8, Section 4.7.3.4 from the POWER9 User Manual
> accessible from
> https://openpowerfoundation.org/?resource_lib=power9-processor-users-manual)

I was thinking of a boot time test case built into linux. linux has some boot
time test cases which you can enable via CONFIG options.

Firstly you could see if an SPR exists using the same trick xmon does in
dump_one_spr(). Then once you have a list of usable SPRs, you could write all
the known ones (I assume you'd have to leave out some, like the PSSCR), then set
the appropriate stop level, make sure you got into that stop level, and then see
if that register was changed. Then you'd have an automated list of registers you
need to make sure you save/restore at each stop level.

Could something like that work?

Mikey