Re: [PATCH 03/18] arm64: kvm: stop treating register x18 as caller save

From: Sami Tolvanen
Date: Tue Oct 22 2019 - 17:46:10 EST


On Tue, Oct 22, 2019 at 10:22 AM Marc Zyngier <maz@xxxxxxxxxx> wrote:
> > .macro save_callee_saved_regs ctxt
> > + str x18, [\ctxt, #CPU_XREG_OFFSET(18)]
> > stp x19, x20, [\ctxt, #CPU_XREG_OFFSET(19)]
> > stp x21, x22, [\ctxt, #CPU_XREG_OFFSET(21)]
> > stp x23, x24, [\ctxt, #CPU_XREG_OFFSET(23)]
> > @@ -38,6 +39,7 @@
> > ldp x25, x26, [\ctxt, #CPU_XREG_OFFSET(25)]
> > ldp x27, x28, [\ctxt, #CPU_XREG_OFFSET(27)]
> > ldp x29, lr, [\ctxt, #CPU_XREG_OFFSET(29)]
> > + ldr x18, [\ctxt, #CPU_XREG_OFFSET(18)]
>
> There is now an assumption that ctxt is x18 (otherwise why would it be
> out of order?). Please add a comment to that effect.

> > - // Restore guest regs x19-x29, lr
> > + // Restore guest regs x18-x29, lr
> > restore_callee_saved_regs x18
>
> Or you could elect another register such as x29 as the base, and keep
> the above in a reasonable order.

I'm fine with either option. Ard, any thoughts?

Sami