Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2984515imu; Mon, 19 Nov 2018 09:00:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/U8CtpDq3FlDZ5GzaaSHApGVucyKC6rgJ69I6Kx5SIwdZqAx0sIqY5lQLx4/35+alJXpcZO X-Received: by 2002:a17:902:6909:: with SMTP id j9mr8306451plk.196.1542646802074; Mon, 19 Nov 2018 09:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646802; cv=none; d=google.com; s=arc-20160816; b=ZYq/6Od3/2N4aXahyOWLiA5mzkQ+cSUphAbK4uRM33T35NDV4CUHEIyn9sfFLfmTu5 9GrzM2LwbSIVdeBif4qoURjGl1e/qkfrQQZxExQJgZs8HupgL93fH0J8xI5ck+Sl1bbW ORNp3YLh2FYlritA/PVtB3L5rR8vhHSgA/9/nwYzonFsuvhzlfLHDPy2KO+g3/LVY67Q jB4dfRVnSbMDD0RxAmGVzJhlcAVC06jWnU/HPa3Z7U/GS84CEoXYRPUadsJk8jcBMmW/ tsGzl7yNshGPZ7ogvt410zN30tklydCybumgh7/fQi7Zi8Bd2TYdMxyT3IVJxKsGXy1Z 30AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w6To0DBLQSwOEQSVExlYHny5M42ojoAo8DpPpCpF7gs=; b=IK14ErnhA+mielEfZl7aRWEe19c2tTWYESTE2TdiDsSo4tjof+rreUrxwqDBYvJ2Iu KiLD3iG8tdOqOHSRiw3ywlWue2ZLZuGYN816K2V3rTOgHUd3kMNcx/+80vdCU6LqwguM TYznBQQghW3JK1tWVzWBIBpXOluT4z9i1pz/IwWIMDXV0Y2eaMzIvtDW6AauKzjyOzvQ 2P+b3fjRRNJPuWkSG+B68SrB6ShO1qPHnt1/V+i4QfwqfEfEFlPEL28KwMim3BOGShFI 76oWNpIKACvL0P8dmQnMnzEdA5SHBml49XU0/tai9QGnjGyxRpbngmJC4GKHtXyFakiF m2eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fI6c3lhV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d82-v6si44755449pfe.190.2018.11.19.08.59.47; Mon, 19 Nov 2018 09:00:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fI6c3lhV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405031AbeKTDXY (ORCPT + 99 others); Mon, 19 Nov 2018 22:23:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:35382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403980AbeKTDXX (ORCPT ); Mon, 19 Nov 2018 22:23:23 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 87BC4214D9; Mon, 19 Nov 2018 16:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646748; bh=5C58OQkm/9HwIsC3tycs8VrqD6+IFEA8GhBdIzQz2Ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fI6c3lhVyvnqjwFUeYt+8vIUcI3T0v9RT8ZUphDVo5sHupzWaSI6+AzrcksphqvIA SA3aEwCbQCEvRRMREWv00v2zhntPlO0j8GCVquLXJqFJoGvhXBuUDWj1IAicDJQsVq rk4hE0esZNuzpYAcqqqeXnE+WhJmKq3uQjtDfIWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sander Eikelenboom , Juergen Gross , Boris Ostrovsky Subject: [PATCH 4.4 076/160] xen: fix xen_qlock_wait() Date: Mon, 19 Nov 2018 17:28:35 +0100 Message-Id: <20181119162638.616346715@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162630.031306128@linuxfoundation.org> References: <20181119162630.031306128@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juergen Gross commit d3132b3860f6cf35ff7609a76bbcdbb814bd027c upstream. Commit a856531951dc80 ("xen: make xen_qlock_wait() nestable") introduced a regression for Xen guests running fully virtualized (HVM or PVH mode). The Xen hypervisor wouldn't return from the poll hypercall with interrupts disabled in case of an interrupt (for PV guests it does). So instead of disabling interrupts in xen_qlock_wait() use a nesting counter to avoid calling xen_clear_irq_pending() in case xen_qlock_wait() is nested. Fixes: a856531951dc80 ("xen: make xen_qlock_wait() nestable") Cc: stable@vger.kernel.org Reported-by: Sander Eikelenboom Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Tested-by: Sander Eikelenboom Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/spinlock.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/arch/x86/xen/spinlock.c +++ b/arch/x86/xen/spinlock.c @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -19,6 +20,7 @@ static DEFINE_PER_CPU(int, lock_kicker_irq) = -1; static DEFINE_PER_CPU(char *, irq_name); +static DEFINE_PER_CPU(atomic_t, xen_qlock_wait_nest); static bool xen_pvspin = true; #ifdef CONFIG_QUEUED_SPINLOCKS @@ -41,25 +43,25 @@ static void xen_qlock_kick(int cpu) */ static void xen_qlock_wait(u8 *byte, u8 val) { - unsigned long flags; int irq = __this_cpu_read(lock_kicker_irq); + atomic_t *nest_cnt = this_cpu_ptr(&xen_qlock_wait_nest); /* If kicker interrupts not initialized yet, just spin */ if (irq == -1 || in_nmi()) return; - /* Guard against reentry. */ - local_irq_save(flags); + /* Detect reentry. */ + atomic_inc(nest_cnt); - /* If irq pending already clear it. */ - if (xen_test_irq_pending(irq)) { + /* If irq pending already and no nested call clear it. */ + if (atomic_read(nest_cnt) == 1 && xen_test_irq_pending(irq)) { xen_clear_irq_pending(irq); } else if (READ_ONCE(*byte) == val) { /* Block until irq becomes pending (or a spurious wakeup) */ xen_poll_irq(irq); } - local_irq_restore(flags); + atomic_dec(nest_cnt); } #else /* CONFIG_QUEUED_SPINLOCKS */