From mboxrd@z Thu Jan 1 00:00:00 1970 From: Halil Pasic Subject: Re: [PATCH v6 07/13] KVM: s390: introduce struct kvm_s390_gisa_interrupt Date: Tue, 29 Jan 2019 17:07:03 +0100 Message-ID: <20190129170703.25a81fa5@oc2783563651> References: <20190124125939.130763-1-mimu@linux.ibm.com> <20190124125939.130763-8-mimu@linux.ibm.com> <20190128175054.67979549@oc2783563651> <20190129142220.3f08a1e9.cohuck@redhat.com> <42befe0d-ad84-5e34-a05a-0ffb4fcadd56@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <42befe0d-ad84-5e34-a05a-0ffb4fcadd56@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Archive: List-Post: To: Michael Mueller Cc: Cornelia Huck , KVM Mailing List , Linux-S390 Mailing List , linux-kernel@vger.kernel.org, Martin Schwidefsky , Heiko Carstens , Christian Borntraeger , Janosch Frank , David Hildenbrand , Pierre Morel List-ID: On Tue, 29 Jan 2019 16:47:10 +0100 Michael Mueller wrote: > > > On 29.01.19 14:22, Cornelia Huck wrote: > > On Mon, 28 Jan 2019 17:50:54 +0100 > > Halil Pasic wrote: > > > >> On Thu, 24 Jan 2019 13:59:33 +0100 > >> Michael Mueller wrote: > >> > >>> Use this struct analog to the kvm interruption structs > >>> for kvm emulated floating and local interruptions. > >>> Further fields will be added with this series as > >>> required. > >>> > >>> Signed-off-by: Michael Mueller > >> > >> While looking at this I was asking myself what guards against invalid > >> gisa pointer dereference e.g. when pending_irqs() is called (see below). > >> > >> AFAIU we set up gisa_int.origin only if we have > >> css_general_characteristics.aiv. Opinions? > > > > I think you're right that this is a (pre-existing) problem. > > > >>> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c > >>> index 942cc7d33766..ee91d1de0036 100644 > >>> --- a/arch/s390/kvm/interrupt.c > >>> +++ b/arch/s390/kvm/interrupt.c > >>> @@ -246,7 +246,8 @@ static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu) > >>> static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu) > >>> { > >>> return pending_irqs_no_gisa(vcpu) | > >>> - gisa_get_ipm(vcpu->kvm->arch.gisa) << IRQ_PEND_IO_ISC_7; > >>> + gisa_get_ipm(vcpu->kvm->arch.gisa_int.origin) << > >> > >> Unconditional call to gisa_get_ipm(), and get ipm just accesses ->ipm. > > > > All other callers of this function check for gisa != NULL first, so > > either we should check here as well or move the check into the > > gisa_get_ipm() function. > > I suggest to use an explicit test like this. > > static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu) > { > - return pending_irqs_no_gisa(vcpu) | > - gisa_get_ipm(vcpu->kvm->arch.gisa_int.origin) << > - IRQ_PEND_IO_ISC_7; > + struct kvm_s390_gisa_int *gi = &vcpu->kvm->arch.gisa_int; > + unsigned long pending_mask; > + > + pending_mask = pending_irqs_no_gisa(vcpu); > + if (gi->origin) > + pending_mask |= gisa_get_ipm(gi->origin) << > IRQ_PEND_IO_ISC_7; > + return pending_mask; > } > Works with me! Send a stand alone patch? Regards, Halil