Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: stable@vger.kernel.org
Subject: [PATCH v2 01/14] xen/events: don't use chip_data for legacy IRQs
Date: Tue,  3 Nov 2020 15:19:09 +0100	[thread overview]
Message-ID: <20201103141922.21026-2-jgross@suse.com> (raw)
In-Reply-To: <20201103141922.21026-1-jgross@suse.com>

Since commit c330fb1ddc0a ("XEN uses irqdesc::irq_data_common::handler_data to store a per interrupt XEN data pointer which contains XEN specific information.")
Xen is using the chip_data pointer for storing IRQ specific data. When
running as a HVM domain this can result in problems for legacy IRQs, as
those might use chip_data for their own purposes.

Use a local array for this purpose in case of legacy IRQs, avoiding the
double use.

This is upstream commit 0891fb39ba67bd7ae023ea0d367297ffff010781

Cc: stable@vger.kernel.org
Fixes: c330fb1ddc0a ("XEN uses irqdesc::irq_data_common::handler_data to store a per interrupt XEN data pointer which contains XEN specific information.")
Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Stefan Bader <stefan.bader@canonical.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20200930091614.13660-1-jgross@suse.com
---
 drivers/xen/events/events_base.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 95e5a9300ff0..fdeeef2b9947 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -90,6 +90,8 @@ static bool (*pirq_needs_eoi)(unsigned irq);
 /* Xen will never allocate port zero for any purpose. */
 #define VALID_EVTCHN(chn)	((chn) != 0)
 
+static struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY];
+
 static struct irq_chip xen_dynamic_chip;
 static struct irq_chip xen_percpu_chip;
 static struct irq_chip xen_pirq_chip;
@@ -154,7 +156,18 @@ int get_evtchn_to_irq(unsigned evtchn)
 /* Get info for IRQ */
 struct irq_info *info_for_irq(unsigned irq)
 {
-	return irq_get_chip_data(irq);
+	if (irq < nr_legacy_irqs())
+		return legacy_info_ptrs[irq];
+	else
+		return irq_get_chip_data(irq);
+}
+
+static void set_info_for_irq(unsigned int irq, struct irq_info *info)
+{
+	if (irq < nr_legacy_irqs())
+		legacy_info_ptrs[irq] = info;
+	else
+		irq_set_chip_data(irq, info);
 }
 
 /* Constructors for packed IRQ information. */
@@ -375,7 +388,7 @@ static void xen_irq_init(unsigned irq)
 	info->type = IRQT_UNBOUND;
 	info->refcnt = -1;
 
-	irq_set_chip_data(irq, info);
+	set_info_for_irq(irq, info);
 
 	list_add_tail(&info->list, &xen_irq_list_head);
 }
@@ -424,14 +437,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
 
 static void xen_free_irq(unsigned irq)
 {
-	struct irq_info *info = irq_get_chip_data(irq);
+	struct irq_info *info = info_for_irq(irq);
 
 	if (WARN_ON(!info))
 		return;
 
 	list_del(&info->list);
 
-	irq_set_chip_data(irq, NULL);
+	set_info_for_irq(irq, NULL);
 
 	WARN_ON(info->refcnt > 0);
 
@@ -601,7 +614,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
 static void __unbind_from_irq(unsigned int irq)
 {
 	int evtchn = evtchn_from_irq(irq);
-	struct irq_info *info = irq_get_chip_data(irq);
+	struct irq_info *info = info_for_irq(irq);
 
 	if (info->refcnt > 0) {
 		info->refcnt--;
@@ -1105,7 +1118,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
 
 void unbind_from_irqhandler(unsigned int irq, void *dev_id)
 {
-	struct irq_info *info = irq_get_chip_data(irq);
+	struct irq_info *info = info_for_irq(irq);
 
 	if (WARN_ON(!info))
 		return;
@@ -1139,7 +1152,7 @@ int evtchn_make_refcounted(unsigned int evtchn)
 	if (irq == -1)
 		return -ENOENT;
 
-	info = irq_get_chip_data(irq);
+	info = info_for_irq(irq);
 
 	if (!info)
 		return -ENOENT;
@@ -1167,7 +1180,7 @@ int evtchn_get(unsigned int evtchn)
 	if (irq == -1)
 		goto done;
 
-	info = irq_get_chip_data(irq);
+	info = info_for_irq(irq);
 
 	if (!info)
 		goto done;
-- 
2.26.2


  reply	other threads:[~2020-11-03 14:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 14:19 [PATCH v2 00/14] Backport of patch series for stable 4.19 branch Juergen Gross
2020-11-03 14:19 ` Juergen Gross [this message]
2020-11-03 14:19 ` [PATCH v2 02/14] xen/events: avoid removing an event channel while handling it Juergen Gross
2020-11-03 14:19 ` [PATCH v2 03/14] xen/events: add a proper barrier to 2-level uevent unmasking Juergen Gross
2020-11-03 14:19 ` [PATCH v2 04/14] xen/events: fix race in evtchn_fifo_unmask() Juergen Gross
2020-11-03 14:19 ` [PATCH v2 05/14] xen/events: add a new "late EOI" evtchn framework Juergen Gross
2020-11-03 14:19 ` [PATCH v2 06/14] xen/blkback: use lateeoi irq binding Juergen Gross
2020-11-03 14:19 ` [PATCH v2 07/14] xen/netback: " Juergen Gross
2020-11-03 14:19 ` [PATCH v2 08/14] xen/scsiback: " Juergen Gross
2020-11-03 14:19 ` [PATCH v2 09/14] xen/pvcallsback: " Juergen Gross
2020-11-03 14:19 ` [PATCH v2 10/14] xen/pciback: " Juergen Gross
2020-11-03 14:19 ` [PATCH v2 11/14] xen/events: switch user event channels to lateeoi model Juergen Gross
2020-11-03 14:19 ` [PATCH v2 12/14] xen/events: use a common cpu hotplug hook for event channels Juergen Gross
2020-11-03 14:19 ` [PATCH v2 13/14] xen/events: defer eoi in case of excessive number of events Juergen Gross
2020-11-03 14:19 ` [PATCH v2 14/14] xen/events: block rogue events for some time Juergen Gross
2020-11-03 16:21 ` [PATCH v2 00/14] Backport of patch series for stable 4.19 branch Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2020-11-03 14:28 [PATCH v2 00/14] Backport of patch series for stable 4.14 branch Juergen Gross
2020-11-03 14:28 ` [PATCH v2 01/14] xen/events: don't use chip_data for legacy IRQs Juergen Gross

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=20201103141922.21026-2-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=stable@vger.kernel.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