Re: [PATCH 1/1] KVM: s390: fix LPSWEY handling

Heiko Carstens
2024-06-28T15:02:51Z

On Fri, Jun 28, 2024 at 04:53:20PM +0200, Christian Borntraeger wrote:
> > > +static inline u64 kvm_s390_get_base_disp_siy(struct kvm_vcpu *vcpu, u8 *ar)
> > > +{
> > > + u32 base1 = vcpu->arch.sie_block->ipb >> 28;
> > > + u32 disp1 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16) +
> > > + ((vcpu->arch.sie_block->ipb & 0xff00) << 4);
> > > +
> > > + /* The displacement is a 20bit _SIGNED_ value */
> > > + if (disp1 & 0x80000)
> > > + disp1+=0xfff00000;
> > > +
> > > + if (ar)
> > > + *ar = base1;
> > > +
> > > + return (base1 ? vcpu->run->s.regs.gprs[base1] : 0) + (long)(int)disp1;
> > > +}
> >
> > You may want to use sign_extend32() or sign_extend64() instead of open-coding.
>
> Something like sign_extend64(disp1, 31)
> I actually find that harder to read, but I am open for other opinions.

Feel free to ignore my suggestion. It was just a comment that this
helper exists. If you prefer the open-coded variant then that's fine
too of course.