Re: [PATCH 2/4] KVM: s390: vsie: Fix length of facility list shadowed

From: Heiko Carstens
Date: Mon Nov 06 2023 - 08:43:41 EST


On Mon, Nov 06, 2023 at 02:06:22PM +0100, Nina Schoetterl-Glausch wrote:
> > > +unsigned int stfle_size(void)
> > > +{
> > > + static unsigned int size = 0;
> > > + u64 dummy;
> > > +
> > > + if (!size) {
> > > + size = __stfle_asm(&dummy, 1) + 1;
> > > + }

Please get rid of the braces here. checkpatch.pl with "--strict" should
complain too, I guess.

> > Possible races? Should have to use an atomic?
>
> Good point. Calling __stfle_asm multiple times is fine
> and AFAIK torn reads/writes aren't possible. I don't see a way
> for the compiler to break things either.
> But it might indeed be nicer to use an atomic, without
> any downsides.

Please use WRITE_ONCE() and READ_ONCE(); that's more than sufficient here.