All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gaurav Kohli <gkohli@codeaurora.org>
To: tglx@linutronix.de, maz@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Gaurav Kohli <gkohli@codeaurora.org>
Subject: [PATCH v0] irqchip/gic-v3: Avoid check of lpi configuration for non existent cpu
Date: Thu,  5 Dec 2019 16:25:57 +0530	[thread overview]
Message-ID: <1575543357-31892-1-git-send-email-gkohli@codeaurora.org> (raw)

As per GIC specification, we can configure gic for more no of cpus
then the available cpus in the soc, But this can cause mem abort
while iterating lpi region for non existent cpu as we don't map
redistrubutor region for non-existent cpu.

To avoid this issue, put one more check of valid mpidr.

Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 1edc993..adc9186 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -766,6 +766,7 @@ static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *))
 {
 	int ret = -ENODEV;
 	int i;
+	int cpu = 0;
 
 	for (i = 0; i < gic_data.nr_redist_regions; i++) {
 		void __iomem *ptr = gic_data.redist_regions[i].redist_base;
@@ -780,6 +781,7 @@ static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *))
 		}
 
 		do {
+			cpu++;
 			typer = gic_read_typer(ptr + GICR_TYPER);
 			ret = fn(gic_data.redist_regions + i, ptr);
 			if (!ret)
@@ -795,7 +797,8 @@ static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *))
 				if (typer & GICR_TYPER_VLPIS)
 					ptr += SZ_64K * 2; /* Skip VLPI_base + reserved page */
 			}
-		} while (!(typer & GICR_TYPER_LAST));
+		} while (!(typer & GICR_TYPER_LAST) &&
+					cpu_logical_map(cpu) != INVALID_HWID);
 	}
 
 	return ret ? -ENODEV : 0;
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


             reply	other threads:[~2019-12-05 10:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 10:55 Gaurav Kohli [this message]
2019-12-05 12:47 ` [PATCH v0] irqchip/gic-v3: Avoid check of lpi configuration for non existent cpu Marc Zyngier
2019-12-05 13:01   ` Gaurav Kohli
     [not found]   ` <209f30c6-c03a-daeb-1f01-e03c489f41d8@codeaurora.org>
2019-12-05 13:18     ` Marc Zyngier
2019-12-06  8:45       ` Gaurav Kohli
     [not found]       ` <cfec6054-0ebe-f70b-b1a8-6c7bd7fc4450@codeaurora.org>
2019-12-06  8:54         ` Marc Zyngier
2019-12-09 20:55 ` kbuild test robot
2019-12-09 20:55   ` kbuild test robot
2019-12-10  0:39 ` kbuild test robot
2019-12-10  0:39   ` kbuild test robot

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=1575543357-31892-1-git-send-email-gkohli@codeaurora.org \
    --to=gkohli@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    /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.