All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: stable@vger.kernel.org
Subject: [PATCH v2 08/14] xen/scsiback: use lateeoi irq binding
Date: Tue,  3 Nov 2020 15:29:05 +0100	[thread overview]
Message-ID: <20201103142911.21980-9-jgross@suse.com> (raw)
In-Reply-To: <20201103142911.21980-1-jgross@suse.com>

In order to reduce the chance for the system becoming unresponsive due
to event storms triggered by a misbehaving scsifront use the lateeoi
irq binding for scsiback and unmask the event channel only just before
leaving the event handling function.

In case of a ring protocol error don't issue an EOI in order to avoid
the possibility to use that for producing an event storm. This at once
will result in no further call of scsiback_irq_fn(), so the ring_error
struct member can be dropped and scsiback_do_cmd_fn() can signal the
protocol error via a negative return value.

This is part of XSA-332.

This is upstream commit 86991b6e7ea6c613b7692f65106076943449b6b7

Cc: stable@vger.kernel.org
Reported-by: Julien Grall <julien@xen.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wl@xen.org>
---
 drivers/xen/xen-scsiback.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index e2f3e8b0fba9..fd32c3459b66 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -91,7 +91,6 @@ struct vscsibk_info {
 	unsigned int irq;
 
 	struct vscsiif_back_ring ring;
-	int ring_error;
 
 	spinlock_t ring_lock;
 	atomic_t nr_unreplied_reqs;
@@ -721,7 +720,8 @@ static struct vscsibk_pend *prepare_pending_reqs(struct vscsibk_info *info,
 	return pending_req;
 }
 
-static int scsiback_do_cmd_fn(struct vscsibk_info *info)
+static int scsiback_do_cmd_fn(struct vscsibk_info *info,
+			      unsigned int *eoi_flags)
 {
 	struct vscsiif_back_ring *ring = &info->ring;
 	struct vscsiif_request ring_req;
@@ -738,11 +738,12 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
 		rc = ring->rsp_prod_pvt;
 		pr_warn("Dom%d provided bogus ring requests (%#x - %#x = %u). Halting ring processing\n",
 			   info->domid, rp, rc, rp - rc);
-		info->ring_error = 1;
-		return 0;
+		return -EINVAL;
 	}
 
 	while ((rc != rp)) {
+		*eoi_flags &= ~XEN_EOI_FLAG_SPURIOUS;
+
 		if (RING_REQUEST_CONS_OVERFLOW(ring, rc))
 			break;
 
@@ -801,13 +802,16 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
 static irqreturn_t scsiback_irq_fn(int irq, void *dev_id)
 {
 	struct vscsibk_info *info = dev_id;
+	int rc;
+	unsigned int eoi_flags = XEN_EOI_FLAG_SPURIOUS;
 
-	if (info->ring_error)
-		return IRQ_HANDLED;
-
-	while (scsiback_do_cmd_fn(info))
+	while ((rc = scsiback_do_cmd_fn(info, &eoi_flags)) > 0)
 		cond_resched();
 
+	/* In case of a ring error we keep the event channel masked. */
+	if (!rc)
+		xen_irq_lateeoi(irq, eoi_flags);
+
 	return IRQ_HANDLED;
 }
 
@@ -828,7 +832,7 @@ static int scsiback_init_sring(struct vscsibk_info *info, grant_ref_t ring_ref,
 	sring = (struct vscsiif_sring *)area;
 	BACK_RING_INIT(&info->ring, sring, PAGE_SIZE);
 
-	err = bind_interdomain_evtchn_to_irq(info->domid, evtchn);
+	err = bind_interdomain_evtchn_to_irq_lateeoi(info->domid, evtchn);
 	if (err < 0)
 		goto unmap_page;
 
@@ -1251,7 +1255,6 @@ static int scsiback_probe(struct xenbus_device *dev,
 
 	info->domid = dev->otherend_id;
 	spin_lock_init(&info->ring_lock);
-	info->ring_error = 0;
 	atomic_set(&info->nr_unreplied_reqs, 0);
 	init_waitqueue_head(&info->waiting_to_free);
 	info->dev = dev;
-- 
2.26.2


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

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