Re: [PATCH v3 1/9] s390/alternatives: Add new ALT_TYPE_PERCPU type

From: Heiko Carstens

Date: Wed May 20 2026 - 09:51:38 EST


On Wed, May 20, 2026 at 01:43:17PM +0100, David Laight wrote:
> On Wed, 20 May 2026 11:22:35 +0200
> Heiko Carstens <hca@xxxxxxxxxxxxx> wrote:
>
> > The upcoming percpu section code uses two mviy instructions to guard the
> > beginning and end of a percpu code section.
> >
> > The first mviy instruction writes the register number, which contains the
> > percpu address to lowcore. This indicates both the beginning of a percpu
> > code section and which register contains the percpu address.
> >
> > During compile time the mviy instruction is generated in a way that its
> > base register contains the percpu register, and the immediate field is
> > zero. This needs to be patched so that the base register is zero, and the
> > immediate field contains the register number. For example
> >
> > 101424: eb 00 23 c0 00 52 mviy 960(%r2),0
> >
> > needs to be patched to
> >
> > 101424: eb 20 03 c0 00 52 mviy 960(%r0),2
>
> I'm sure it is possible get the preprocessor to extract the register number
> for you.
> The exception table logic almost certainly already does it.
> (The x86 version certainly does - and that is far less trivial.)

That's true, the s390 extable logic is doing the same. However I failed to
feed the extracted register number as constant into the same inline assembly
it was extracted from.