All of lore.kernel.org
 help / color / mirror / Atom feed
From: shankerd@codeaurora.org (Shanker Donthineni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] irqchip/gicv3-its: Don't allow devices whose ID is outside range
Date: Tue, 23 Feb 2016 08:15:35 -0600	[thread overview]
Message-ID: <56CC6987.1050107@codeaurora.org> (raw)
In-Reply-To: <56CC1D83.4060503@arm.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: Shanker Donthineni <shankerd@codeaurora.org>
To: Marc Zyngier <marc.zyngier@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: Vikram Sethi <vikrams@codeaurora.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>
Subject: Re: [PATCH] irqchip/gicv3-its: Don't allow devices whose ID is outside range
Date: Tue, 23 Feb 2016 08:15:35 -0600	[thread overview]
Message-ID: <56CC6987.1050107@codeaurora.org> (raw)
In-Reply-To: <56CC1D83.4060503@arm.com>

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

  reply	other threads:[~2016-02-23 14:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23  3:57 [PATCH] irqchip/gicv3-its: Don't allow devices whose ID is outside range Shanker Donthineni
2016-02-23  3:57 ` Shanker Donthineni
2016-02-23  8:51 ` Marc Zyngier
2016-02-23  8:51   ` Marc Zyngier
2016-02-23 14:15   ` Shanker Donthineni [this message]
2016-02-23 14:15     ` Shanker Donthineni
2016-02-23 17:48   ` Shanker Donthineni
2016-02-23 17:48     ` Shanker Donthineni
2016-02-23 17:30 ` Shanker Donthineni
2016-02-23 17:30   ` Shanker Donthineni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56CC6987.1050107@codeaurora.org \
    --to=shankerd@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.