lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 11 Sep 2015 00:01:02 +0000
From:	jakeo@...rosoft.com
To:	gregkh@...uxfoundation.org, kys@...rosoft.com,
	linux-kernel@...r.kernel.org, devel@...uxdriverproject.org,
	olaf@...fle.de, apw@...onical.com, vkuznets@...hat.com,
	linux-pci@...r.kernel.org, bhelgaas@...gle.com, tglx@...utronix.de
Cc:	Jake Oshins <jakeo@...rosoft.com>
Subject: [PATCH v2 03/12] kernel:irq: Allow for ranked matches on IRQ domains

From: Jake Oshins <jakeo@...rosoft.com>

The existing IRQ domain match code cycles through all the IRQ domains looking
for the first one to return a non-zero value from its match() function.  There's
even a comment that says "this isn't a problem so far..."

This patch changes the semantics on the match() function so that the value
returned is a ranking, where zero means "no match."  The function now runs the
list of IRQ domains twice, finding the highest ranked matches on the first pass
and returning the first one of those (to preserve existing behavior, where there
might have been multiple matches) on the second pass.

This allows for a situation where a default IRQ domain (specifically the one
for message-signaled interrupts on x86 PCs) is always present, but where it can
be overriden by an IRQ domain implementation that is targeted at specific PCIe
root complexes.

Signed-off-by: Jake Oshins <jakeo@...rosoft.com>
---
 include/linux/irqdomain.h |  2 +-
 kernel/irq/irqdomain.c    | 44 ++++++++++++++++++++++++++++++--------------
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 12acddb..2d48deb 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -62,7 +62,7 @@ enum irq_domain_bus_token {
 /**
  * struct irq_domain_ops - Methods for irq_domain objects
  * @match: Match an interrupt controller device node to a host, returns
- *         1 on a match
+ *         a ranking (non-zero) on a match
  * @map: Create or update a mapping between a virtual irq number and a hw
  *       irq number. This is called only once for a given mapping.
  * @unmap: Dispose of such a mapping
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index b4c15af..385c16e 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -197,30 +197,46 @@ struct irq_domain *irq_find_matching_host(struct device_node *node,
 					  void *bus_data)
 {
 	struct irq_domain *h, *found = NULL;
-	int rc;
+	int match_rank = 0x7fffffff;
+	int found_rank = 0;
+	int rank;
+	int pass;
 
 	/* We might want to match the legacy controller last since
 	 * it might potentially be set to match all interrupts in
-	 * the absence of a device node. This isn't a problem so far
-	 * yet though...
+	 * the absence of a device node.  In this case, the match
+	 * of highest rank is returned.
 	 *
 	 * bus_token == DOMAIN_BUS_ANY matches any domain, any other
 	 * values must generate an exact match for the domain to be
 	 * selected.
 	 */
 	mutex_lock(&irq_domain_mutex);
-	list_for_each_entry(h, &irq_domain_list, link) {
-		if (h->ops->match)
-			rc = h->ops->match(h, node, bus_token, bus_data);
-		else
-			rc = ((h->of_node != NULL) && (h->of_node == node) &&
-			      ((bus_token == DOMAIN_BUS_ANY) ||
-			       (h->bus_token == bus_token)));
-
-		if (rc) {
-			found = h;
-			break;
+	for (pass = 0; pass < 2; pass++) {
+		list_for_each_entry(h, &irq_domain_list, link) {
+			if (h->ops->match)
+				rank = h->ops->match(h, node, bus_token,
+						     bus_data);
+			else
+				if ((h->of_node != NULL) &&
+				    (h->of_node == node) &&
+				    ((bus_token == DOMAIN_BUS_ANY) ||
+				       (h->bus_token == bus_token)))
+					rank = 1;
+				else
+					rank = 0;
+
+			if (rank > found_rank)
+				found_rank = rank;
+
+			if (found_rank == match_rank) {
+				found = h;
+				break;
+			}
 		}
+
+		if (found_rank != 0)
+			match_rank = found_rank;
 	}
 	mutex_unlock(&irq_domain_mutex);
 	return found;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ