From: andreas.herrmann@calxeda.com (Andreas Herrmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] iommu/arm-smmu: Check for num_context_irqs > 0 to avoid divide by zero exception
Date: Wed, 25 Sep 2013 12:50:10 +0200 [thread overview]
Message-ID: <20130925105010.GA4845@alberich> (raw)
In-Reply-To: <20130924154048.GE20774@mudshark.cambridge.arm.com>
On Tue, Sep 24, 2013 at 11:40:48AM -0400, Will Deacon wrote:
> On Tue, Sep 24, 2013 at 04:06:58PM +0100, Andreas Herrmann wrote:
> > With the right (or wrong;-) definition of v1 SMMU node in DTB it is
> > possible to trigger a division by zero in arm_smmu_init_domain_context
> > (if number of context irqs is 0):
> >
> > if (smmu->version == 1) {
> > root_cfg->irptndx = atomic_inc_return(&smmu->irptndx);
> > ? root_cfg->irptndx %= smmu->num_context_irqs;
> > } else {
> >
> > Avoid this by checking for num_context_irqs > 0 before trying to
> > assign interrupts to contexts.
> >
> > Signed-off-by: Andreas Herrmann <andreas.herrmann@calxeda.com>
> > ---
> > drivers/iommu/arm-smmu.c | 31 +++++++++++++++++--------------
> > 1 file changed, 17 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> > index f5a856e..0dfd255 100644
> > --- a/drivers/iommu/arm-smmu.c
> > +++ b/drivers/iommu/arm-smmu.c
> > @@ -828,21 +828,24 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
> > return ret;
> >
> > root_cfg->cbndx = ret;
> > - if (smmu->version == 1) {
> > - root_cfg->irptndx = atomic_inc_return(&smmu->irptndx);
> > - root_cfg->irptndx %= smmu->num_context_irqs;
> > - } else {
> > - root_cfg->irptndx = root_cfg->cbndx;
> > - }
> >
> > - irq = smmu->irqs[smmu->num_global_irqs + root_cfg->irptndx];
> > - ret = request_irq(irq, arm_smmu_context_fault, IRQF_SHARED,
> > - "arm-smmu-context-fault", domain);
> > - if (IS_ERR_VALUE(ret)) {
> > - dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n",
> > - root_cfg->irptndx, irq);
> > - root_cfg->irptndx = -1;
> > - goto out_free_context;
> > + if (smmu->num_context_irqs) {
>
> Can we move this check to probe time, to avoid re-evaluating it every time
> we initialise a new domain?
Yes, I'll move this check and issue an error message when there is not
at least one context interrupt available.
Andreas
next prev parent reply other threads:[~2013-09-25 10:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-24 15:06 [PATCH 0/7]: iommu/arm-smmu: Misc fixes/adaptions Andreas Herrmann
2013-09-24 15:06 ` [PATCH 1/7] iommu/arm-smmu: Switch to arch_initcall for driver registration Andreas Herrmann
2013-09-24 15:14 ` Andreas Herrmann
2013-09-24 15:19 ` Will Deacon
2013-09-24 15:06 ` [PATCH 2/7] iommu/arm-smmu: Calculate SMMU_CB_BASE from smmu register values Andreas Herrmann
2013-09-24 15:34 ` Will Deacon
2013-09-24 18:07 ` Andreas Herrmann
2013-09-25 16:43 ` Will Deacon
2013-09-24 15:06 ` [PATCH 3/7] ARM: dma-mapping: Always pass proper prot flags to iommu_map() Andreas Herrmann
2013-09-24 15:36 ` Will Deacon
2013-09-24 17:40 ` Andreas Herrmann
2013-09-24 15:06 ` [PATCH 4/7] iommu/arm-smmu: Check for num_context_irqs > 0 to avoid divide by zero exception Andreas Herrmann
2013-09-24 15:40 ` Will Deacon
2013-09-25 10:50 ` Andreas Herrmann [this message]
2013-09-24 15:06 ` [PATCH 5/7] iommu/arm-smmu: Add function that isolates all masters for all SMMUs Andreas Herrmann
2013-09-24 15:07 ` [PATCH 6/7] iommu/arm-smmu: Add module parameter arm-smmu=off|force_isolation Andreas Herrmann
2013-09-24 15:42 ` Will Deacon
2013-09-25 14:56 ` Andreas Herrmann
2013-09-25 15:57 ` Joerg Roedel
2013-09-24 15:07 ` [PATCH 7/7] iommu/arm-smmu: Clear global and context bank fault status and syndrome registers Andreas Herrmann
2013-09-24 15:42 ` Will Deacon
2013-09-24 18:32 ` Andreas Herrmann
2013-09-25 16:49 ` Will Deacon
2013-09-25 18:20 ` Andreas Herrmann
2013-09-24 15:31 ` [PATCH 0/7]: iommu/arm-smmu: Misc fixes/adaptions Will Deacon
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=20130925105010.GA4845@alberich \
--to=andreas.herrmann@calxeda.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).