From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753719AbcBWOPo (ORCPT ); Tue, 23 Feb 2016 09:15:44 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:46627 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753176AbcBWOPj (ORCPT ); Tue, 23 Feb 2016 09:15:39 -0500 Subject: Re: [PATCH] irqchip/gicv3-its: Don't allow devices whose ID is outside range To: Marc Zyngier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1456199868-9054-1-git-send-email-shankerd@codeaurora.org> <56CC1D83.4060503@arm.com> Cc: Vikram Sethi , Thomas Gleixner , Jason Cooper From: Shanker Donthineni Message-ID: <56CC6987.1050107@codeaurora.org> Date: Tue, 23 Feb 2016 08:15:35 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56CC1D83.4060503@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On 02/23/2016 02:51 AM, Marc Zyngier wrote: > On 23/02/16 03:57, Shanker Donthineni wrote: >> We are not checking whether the requested device identifier fits into >> table or not. The ITS MAPD command fails if 'Device ID' is outside of >> device table range. >> >> Add a simple validation check to avoid MAPD failures since we are >> not handling ITS command errors. This change also helps to return an >> error -ENOMEM instead of success to caller. >> > In which circumstances do you see this failing? We allocate memory for > the whole DevID range (as advertised by the ITS), so anything that comes > up outside of that range cannot be handled anyway, and is a HW > integration issue. You might as well pretend that these devices do not > exist. > > Thanks, > > M. We will try to allocate maximum memory as much as possible to cover whole DevID. sparse. We may not always successful, sometimes we limit memory allocation size for two reasons MAX_ORDER and ITS flat table capacity. 1) According to ARM-GIC spec, ITS hw can access maximum of 256 (ITS-pages) * 64K (ITS-pageszie) bytes. 21bits = 16 MBytes / 8 (flat table size / device table entry size) Assuming: minimum device table entry size 8 Bytes 2) On 4K page size kernel with default arch/arm64/defconfig. 19bits = 4 MBytes / 8 (flat table size / device table entry size) Assuming: minimum device table entry size 8 Bytes This is definitely a problem if DevID range is much more than 19Bits and we fail to allocate enough memory. Our ITS hardware has capable of supporting all 32bits, so it advertises DevID 32. I am preparing an another patch to support ITS-Indirection (two-level table walk) feature. -- Shanker Donthineni Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project From mboxrd@z Thu Jan 1 00:00:00 1970 From: shankerd@codeaurora.org (Shanker Donthineni) Date: Tue, 23 Feb 2016 08:15:35 -0600 Subject: [PATCH] irqchip/gicv3-its: Don't allow devices whose ID is outside range In-Reply-To: <56CC1D83.4060503@arm.com> References: <1456199868-9054-1-git-send-email-shankerd@codeaurora.org> <56CC1D83.4060503@arm.com> Message-ID: <56CC6987.1050107@codeaurora.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Marc, On 02/23/2016 02:51 AM, Marc Zyngier wrote: > On 23/02/16 03:57, Shanker Donthineni wrote: >> We are not checking whether the requested device identifier fits into >> table or not. The ITS MAPD command fails if 'Device ID' is outside of >> device table range. >> >> Add a simple validation check to avoid MAPD failures since we are >> not handling ITS command errors. This change also helps to return an >> error -ENOMEM instead of success to caller. >> > In which circumstances do you see this failing? We allocate memory for > the whole DevID range (as advertised by the ITS), so anything that comes > up outside of that range cannot be handled anyway, and is a HW > integration issue. You might as well pretend that these devices do not > exist. > > Thanks, > > M. We will try to allocate maximum memory as much as possible to cover whole DevID. sparse. We may not always successful, sometimes we limit memory allocation size for two reasons MAX_ORDER and ITS flat table capacity. 1) According to ARM-GIC spec, ITS hw can access maximum of 256 (ITS-pages) * 64K (ITS-pageszie) bytes. 21bits = 16 MBytes / 8 (flat table size / device table entry size) Assuming: minimum device table entry size 8 Bytes 2) On 4K page size kernel with default arch/arm64/defconfig. 19bits = 4 MBytes / 8 (flat table size / device table entry size) Assuming: minimum device table entry size 8 Bytes This is definitely a problem if DevID range is much more than 19Bits and we fail to allocate enough memory. Our ITS hardware has capable of supporting all 32bits, so it advertises DevID 32. I am preparing an another patch to support ITS-Indirection (two-level table walk) feature. -- Shanker Donthineni Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project