powerpc64: kern_slbtrap double mtlr, one from (PC_SLBSAVE+120)(%r1) and one from (PC_SLBSAVE+136)(%r1)?

Mark Millard marklmi at yahoo.com
Mon May 6 20:52:51 UTC 2019


kern_slbtrap has . . .
(I have capitalized to make specific MFLR,
MTLR, LD, and STD and related register usage
stand out. Also note PC_SLBSAVE+136 and
PC_SLBSAVE+120 usage.)

CNAME(slbtrap):
. . .
2:      MFLR    %R2                     /* Save the old LR in r2 */
        nop
        bl      3f                      /* Begin dance to jump to kern_slbtrap*/
        .llong  kern_slbtrap
3:      mflr    %r1
        ld      %r1,0(%r1)
        mtlr    %r1
        GET_CPUINFO(%r1)
        blrl                            /* 124 bytes -- 4 to spare */
CNAME(slbtrapend):

kern_slbtrap:
        STD     %R2,(PC_SLBSAVE+136)(%R1) /* old LR */
. . .
3:      /* Real kernel SLB miss */
. . .
        mfxer   %r2                     /* save XER */
        std     %r2,(PC_SLBSAVE+112)(%r1)
        MFLR    %R2                     /* save LR (SP already saved) */
        STD     %R2,(PC_SLBSAVE+120)(%R1)
. . .
        LD      %R2,(PC_SLBSAVE+120)(%R1)
        MTLR    %R2
        ld      %r2,(PC_SLBSAVE+128)(%r1)
        mtctr   %r2
        LD      %R2,(PC_SLBSAVE+136)(%R1)
        MTLR    %R2

        /* Restore r0-r3 */


It appears that PC_SLBSAVE+120(%r1) is being used
to save and restore an "internal" lr value,
despite overall being replaced before lr is used.

If I gather right, the ld from PC_SLBSAVE+120(%r1)
is effectively unneeded. May be the store to
PC_SLBSAVE+120(%r1) serves for being able to
see the value in a standard place, but my guess
would be that it is also unneeded in the above
code. Similarly for the matching mtlr and mflr.


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-ppc mailing list