Received: from eggs.gnu.org ([2001:4830:134:3::10]:55790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMma6-0002yi-Eo for qemu-devel@nongnu.org; Mon, 11 Jul 2016 21:33:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMma1-0000uN-K7 for qemu-devel@nongnu.org; Mon, 11 Jul 2016 21:33:50 -0400 Message-ID: <578448D5.4020208@huawei.com> Date: Tue, 12 Jul 2016 09:33:09 +0800 From: Shannon Zhao MIME-Version: 1.0 References: <1468261372-17508-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1468261372-17508-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] arm_gicv3: Add assert()s to tell Coverity that offsets are aligned List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Paolo Bonzini , patches@linaro.org On 2016/7/12 2:22, Peter Maydell wrote: > Coverity complains that the GICR_IPRIORITYR case in gicv3_readl() > can overflow an array, because it doesn't know that the offsets > passed to that function must be word aligned. Add some assert()s > which hopefully tell Coverity that this isn't possible. > > Signed-off-by: Peter Maydell > --- > I don't have any way to test this except getting it into master > and seeing if Coverity still complains, but if it does then > I'll happily just mark the error as a false positive... > Since the codes are correct, maybe it could ignore the original complain at Coverity instead of adding the assert(). But anyway I'm fine with this patch. > hw/intc/arm_gicv3_redist.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c > index 2f60096..77e5cfa 100644 > --- a/hw/intc/arm_gicv3_redist.c > +++ b/hw/intc/arm_gicv3_redist.c > @@ -420,6 +420,8 @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, > MemTxResult r; > int cpuidx; > > + assert((offset & (size - 1)) == 0); > + > /* This region covers all the redistributor pages; there are > * (for GICv3) two 64K pages per CPU. At the moment they are > * all contiguous (ie in this one region), though we might later > @@ -468,6 +470,8 @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, > MemTxResult r; > int cpuidx; > > + assert((offset & (size - 1)) == 0); > + > /* This region covers all the redistributor pages; there are > * (for GICv3) two 64K pages per CPU. At the moment they are > * all contiguous (ie in this one region), though we might later > -- Shannon