From mboxrd@z Thu Jan 1 00:00:00 1970 From: Auger Eric Subject: Re: [PATCH v2 02/10] KVM: arm/arm64: vgic-its: Always allow clearing GITS_CREADR/CWRITER Date: Fri, 13 Oct 2017 13:54:34 +0200 Message-ID: <065e1e4c-e16d-5df6-ceff-3415a2d91e8d@redhat.com> References: <1506518920-18571-1-git-send-email-eric.auger@redhat.com> <1506518920-18571-3-git-send-email-eric.auger@redhat.com> <4315e223-a843-50d9-506d-a3902ee8d18d@arm.com> <20171013114412.GG8927@cbox> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: Andre Przywara , eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, marc.zyngier@arm.com, peter.maydell@linaro.org, wanghaibin.wang@huawei.com, wu.wubin@huawei.com To: Christoffer Dall Return-path: In-Reply-To: <20171013114412.GG8927@cbox> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Hi Christoffer, On 13/10/2017 13:44, Christoffer Dall wrote: > On Fri, Oct 06, 2017 at 05:29:02PM +0200, Auger Eric wrote: >> Hi, >> >> On 06/10/2017 16:37, Andre Przywara wrote: >>> Hi, >>> >>> On 27/09/17 14:28, Eric Auger wrote: >>>> If the GITS_CBASER Size field is 0, which can correspond to a >>>> reset value, the userspace fails to set the GITS_CREADR/CWRITER >>>> offsets to 0. This failure is not justified. >>>> >>>> Let's allow this setting which can also correspond to a reset value. >>> >>> But the GITS_CBASER size field has a +1 encoding, so can never be 0, if >>> I understand the manual (and ITS_CMD_BUFFER_SIZE) correctly. >> Oh OK, you're. I missed that. I would have sworn I've seen that failure >> but I must have misinterpreted it. >> > > What is CWRITER is written to a brand new ITS before the CBASER is > written? > > I don't see us initializing the cbaser field anywhere? in vgic_its_create() its is allocated with kzalloc so its->cbaser is initialized at this moment. Thanks Eric > > Thanks, > -Christoffer > >>> >>> What am I missing here? >>> >>> Cheers, >>> Andre. >>> >>>> Signed-off-by: Eric Auger >>>> >>>> --- >>>> >>>> need to CC stable >>>> --- >>>> virt/kvm/arm/vgic/vgic-its.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c >>>> index fbbc97b..76bed2d 100644 >>>> --- a/virt/kvm/arm/vgic/vgic-its.c >>>> +++ b/virt/kvm/arm/vgic/vgic-its.c >>>> @@ -1329,7 +1329,7 @@ static void vgic_mmio_write_its_cwriter(struct kvm *kvm, struct vgic_its *its, >>>> >>>> reg = update_64bit_reg(its->cwriter, addr & 7, len, val); >>>> reg = ITS_CMD_OFFSET(reg); >>>> - if (reg >= ITS_CMD_BUFFER_SIZE(its->cbaser)) { >>>> + if (reg && reg >= ITS_CMD_BUFFER_SIZE(its->cbaser)) { >>>> mutex_unlock(&its->cmd_lock); >>>> return; >>>> } >>>> @@ -1370,7 +1370,7 @@ static int vgic_mmio_uaccess_write_its_creadr(struct kvm *kvm, >>>> } >>>> >>>> cmd_offset = ITS_CMD_OFFSET(val); >>>> - if (cmd_offset >= ITS_CMD_BUFFER_SIZE(its->cbaser)) { >>>> + if (cmd_offset && cmd_offset >= ITS_CMD_BUFFER_SIZE(its->cbaser)) { >>>> ret = -EINVAL; >>>> goto out; >>>> } >>>>