Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3843632pxb; Tue, 17 Nov 2020 05:12:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0OxHwWRbA71zYNdy0ApEuNZsqlBoG/xNW4xcmlbh/YNYe+5haOLduBudR32v6sl2TMdE1 X-Received: by 2002:a50:9fe6:: with SMTP id c93mr20215501edf.30.1605618749984; Tue, 17 Nov 2020 05:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605618749; cv=none; d=google.com; s=arc-20160816; b=duntoqkeMf3+4lkjLW2L+vgatu/nuqb/zCbpAZDGz0oA/zN+fgcmochhFleFxVDt4h taCmxZdu4kMLZfSP4ivwhRjUv3er+ygNYdPIN2CyViSqu8W7fkJXASIiKWf2/2teHloD GuSS2RM6cdsXZDU8dM+KafDwDgoGgzyHgzKCfKWUxwpeNiSuxmBcAyr0v8pzBxv9D2fa +Oo8BJZXVI8C2ntOObhaFZJEmBDDX5FbsoNCIrnSPPxs3KtEpkFnlx58+ELI1LIKwkq/ Q/oyrLFypcKGOlNyrtoW1LKleSTo53FBEzj2f3QVUpy/pLY/9cPwTyCtQ93bqOjPZHsk Hu6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dShzvWaLxIPBOPK5FDbOp17N7jBC+ivGiWVOVY5vwA4=; b=ZEliS0yRfxSjB9mB9xDFx7MqBArzaIDFA2sJlY6xPS8OEeWkyHKzZzzSXAbYMHwaKK eU0kZ6fWKCAfawyLOIEbdFbUVlos2x0A7gFn45PEwqQCKYIpoIgo3jqN4H8datelQRFL 8gI0BlA7Ik1WEPLlWzNollYcESZNq/ZjspHE+yPe1o1giYjFhWn/DThUxK6hc1MfGTqY iog0c5px0ZSFQ0IwccUHdk0EtHoaLC98XEQqIVGlldtIJniI4/xI102vF6EIW+c3KVNB 4trDn1QFkeugtOJANsFwnhYTZlQHIrmKTClRTtkT6e8OxGxR1vwMofuJiN+HsrgXondg +I3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+XFc2dS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu4si4622918ejb.195.2020.11.17.05.12.07; Tue, 17 Nov 2020 05:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+XFc2dS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729291AbgKQNIe (ORCPT + 99 others); Tue, 17 Nov 2020 08:08:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:36848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729272AbgKQNIY (ORCPT ); Tue, 17 Nov 2020 08:08:24 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C69F4221EB; Tue, 17 Nov 2020 13:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618502; bh=8AI+wv/0W4+FExRGgwH8qDs9IV9XEX+dQkaWQqLRWMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+XFc2dS0dWIpUTxl1eic84KMfvxSp+0FGUu/Pg4WI9I6C9Z5A4jdQWkkvTZDQiMk 9RQAlSZ0kLwwy5ERAdwx6eLW1C7sOcmOXP3GPdPM0Y0bDcBJvjSSR8m3fXiNrya9dn ey67/6so5U6EQ3KvdMkrt0EMac79qET5XqGnaqyU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Julien Grall , Juergen Gross , Jan Beulich , Wei Liu Subject: [PATCH 4.4 54/64] xen/scsiback: use lateeoi irq binding Date: Tue, 17 Nov 2020 14:05:17 +0100 Message-Id: <20201117122108.834543616@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122106.144800239@linuxfoundation.org> References: <20201117122106.144800239@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 86991b6e7ea6c613b7692f65106076943449b6b7 upstream. 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. Cc: stable@vger.kernel.org Reported-by: Julien Grall Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Reviewed-by: Wei Liu Signed-off-by: Greg Kroah-Hartman --- drivers/xen/xen-scsiback.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) --- 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; @@ -698,7 +697,8 @@ static int prepare_pending_reqs(struct v return 0; } -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; @@ -715,11 +715,12 @@ static int scsiback_do_cmd_fn(struct vsc 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; pending_req = kmem_cache_alloc(scsiback_cachep, GFP_KERNEL); @@ -782,13 +783,16 @@ static int scsiback_do_cmd_fn(struct vsc 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; } @@ -809,7 +813,7 @@ static int scsiback_init_sring(struct vs 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; @@ -1210,7 +1214,6 @@ static int scsiback_probe(struct xenbus_ 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;