From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752264AbdJROeQ (ORCPT ); Wed, 18 Oct 2017 10:34:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52648 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751243AbdJROeN (ORCPT ); Wed, 18 Oct 2017 10:34:13 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1BCCA695F7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com Subject: Re: [PATCH v4 06/11] KVM: arm/arm64: vgic-its: Check GITS_CBASER validity before processing commands To: Christoffer Dall References: <1508224209-15366-1-git-send-email-eric.auger@redhat.com> <1508224209-15366-7-git-send-email-eric.auger@redhat.com> <20171017221016.GF8326@lvm> Cc: eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, peter.maydell@linaro.org, andre.przywara@arm.com, wanghaibin.wang@huawei.com, wu.wubin@huawei.com, drjones@redhat.com, wei@redhat.com From: Auger Eric Message-ID: Date: Wed, 18 Oct 2017 16:34:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20171017221016.GF8326@lvm> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 18 Oct 2017 14:34:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoffer, On 18/10/2017 00:10, Christoffer Dall wrote: > On Tue, Oct 17, 2017 at 09:10:04AM +0200, Eric Auger wrote: >> At the moment vgic_its_process_commands() does not >> check the CBASER is valid before processing any command. >> Let's fix that. >> >> Also rename cbaser local variable into cbaser_pa to avoid >> any confusion with the full register. >> >> Signed-off-by: Eric Auger >> --- >> virt/kvm/arm/vgic/vgic-its.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c >> index 3b539d4..e18f1e4 100644 >> --- a/virt/kvm/arm/vgic/vgic-its.c >> +++ b/virt/kvm/arm/vgic/vgic-its.c >> @@ -1301,17 +1301,20 @@ static void vgic_mmio_write_its_cbaser(struct kvm *kvm, struct vgic_its *its, >> /* Must be called with the cmd_lock held. */ >> static void vgic_its_process_commands(struct kvm *kvm, struct vgic_its *its) >> { >> - gpa_t cbaser; >> + gpa_t cbaser_pa; >> u64 cmd_buf[4]; >> >> - /* Commands are only processed when the ITS is enabled. */ >> - if (!its->enabled) >> + /* >> + * Commands are only processed when the ITS is enabled and >> + * CBASER is valid >> + */ >> + if (!its->enabled || (!(its->cbaser & GITS_CBASER_VALID))) > > Is it valid to clear the CBASER valid bit after having enabled the ITS? > If not, I think you should check changes to CBASER and then this > shouldn't be necessary. Yes you're right. the spec says: When GITS_CTLR.Enable == 1 or GITS_CTLR.Quiescent == 0, writing this register (CBASER) is UNPREDICTABLE . Given we already check its->enabled in vgic_mmio_write_its_cbaser, I think it is safe to remove this patch. Thanks Eric > > > >> return; >> >> - cbaser = CBASER_ADDRESS(its->cbaser); >> + cbaser_pa = CBASER_ADDRESS(its->cbaser); >> >> while (its->cwriter != its->creadr) { >> - int ret = kvm_read_guest(kvm, cbaser + its->creadr, >> + int ret = kvm_read_guest(kvm, cbaser_pa + its->creadr, >> cmd_buf, ITS_CMD_SIZE); >> /* >> * If kvm_read_guest() fails, this could be due to the guest >> -- >> 2.5.5 >> > > Otherwise, this looks fine. > > Thanks, > -Christoffer > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Auger Eric Subject: Re: [PATCH v4 06/11] KVM: arm/arm64: vgic-its: Check GITS_CBASER validity before processing commands Date: Wed, 18 Oct 2017 16:34:04 +0200 Message-ID: References: <1508224209-15366-1-git-send-email-eric.auger@redhat.com> <1508224209-15366-7-git-send-email-eric.auger@redhat.com> <20171017221016.GF8326@lvm> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, marc.zyngier@arm.com, andre.przywara@arm.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, wu.wubin@huawei.com, eric.auger.pro@gmail.com To: Christoffer Dall Return-path: In-Reply-To: <20171017221016.GF8326@lvm> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org Hi Christoffer, On 18/10/2017 00:10, Christoffer Dall wrote: > On Tue, Oct 17, 2017 at 09:10:04AM +0200, Eric Auger wrote: >> At the moment vgic_its_process_commands() does not >> check the CBASER is valid before processing any command. >> Let's fix that. >> >> Also rename cbaser local variable into cbaser_pa to avoid >> any confusion with the full register. >> >> Signed-off-by: Eric Auger >> --- >> virt/kvm/arm/vgic/vgic-its.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c >> index 3b539d4..e18f1e4 100644 >> --- a/virt/kvm/arm/vgic/vgic-its.c >> +++ b/virt/kvm/arm/vgic/vgic-its.c >> @@ -1301,17 +1301,20 @@ static void vgic_mmio_write_its_cbaser(struct kvm *kvm, struct vgic_its *its, >> /* Must be called with the cmd_lock held. */ >> static void vgic_its_process_commands(struct kvm *kvm, struct vgic_its *its) >> { >> - gpa_t cbaser; >> + gpa_t cbaser_pa; >> u64 cmd_buf[4]; >> >> - /* Commands are only processed when the ITS is enabled. */ >> - if (!its->enabled) >> + /* >> + * Commands are only processed when the ITS is enabled and >> + * CBASER is valid >> + */ >> + if (!its->enabled || (!(its->cbaser & GITS_CBASER_VALID))) > > Is it valid to clear the CBASER valid bit after having enabled the ITS? > If not, I think you should check changes to CBASER and then this > shouldn't be necessary. Yes you're right. the spec says: When GITS_CTLR.Enable == 1 or GITS_CTLR.Quiescent == 0, writing this register (CBASER) is UNPREDICTABLE . Given we already check its->enabled in vgic_mmio_write_its_cbaser, I think it is safe to remove this patch. Thanks Eric > > > >> return; >> >> - cbaser = CBASER_ADDRESS(its->cbaser); >> + cbaser_pa = CBASER_ADDRESS(its->cbaser); >> >> while (its->cwriter != its->creadr) { >> - int ret = kvm_read_guest(kvm, cbaser + its->creadr, >> + int ret = kvm_read_guest(kvm, cbaser_pa + its->creadr, >> cmd_buf, ITS_CMD_SIZE); >> /* >> * If kvm_read_guest() fails, this could be due to the guest >> -- >> 2.5.5 >> > > Otherwise, this looks fine. > > Thanks, > -Christoffer >