Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3426193imu; Sun, 11 Nov 2018 14:49:58 -0800 (PST) X-Google-Smtp-Source: AJdET5cp1BwL/nWogMEGjsXDDhbSj5A4Dtd0/bLwKCY+k5Ks7JXyKKNipnrXQ9WD4lOfrdHD6rGm X-Received: by 2002:a63:5c22:: with SMTP id q34mr7842478pgb.417.1541976598827; Sun, 11 Nov 2018 14:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976598; cv=none; d=google.com; s=arc-20160816; b=zQVjv4/viCCygStuGibbUG1mvxrDQoG5a97QgIjclg7dC9ROcz70vN/e8wmYQrZZaG 9/zfK+KufcZkDb4M+BfBOMi4O9ox5AV0nt6n2MUM3b1ERIe6kRhjneKb4xHevEBb5iGf qqIOKJp31jW/VUU3dgQmR9ng3sB+1cV6rzDU0YXjyrSH6DLWZR28EvJ+5Mk9uoh1T73k cMN59mGUrVTkc4L54/FbnG7izG68/GZ24RNk1JbZusuUFJaO8H65v3sUUUEa7SP61AIe dvScWFDZKd9+WqV7C0jdqraE96OvYYZULaRsyRDiH7B11sPfquMBXJxO+pZIEn/iZ4ZU zfFw== 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=M/hBWxGwX4v3dAktcDOx0lCSUZHWaqdojXJbut+aPjw=; b=TzxaMsQn69aNdlgAGzE9cwmdCq0AipUZXQgXdgS6GxulpZdmTVGxpKHXWWVDzFNPCg uvNnhcgS7zZ1yw/gu6FnsKQ0rh6ERB9mZZ+Xka3C9ZFeos5HXKE8Fu6d/odX521TgbpG SWNV1fNZuZ9v/QUUbRUW/BouevMt3vXr5L6MA7f8TeT7CPMqe1rnU42UPpQag3pfaq9A pGumXo+mI3ACBvwFrmEVFYeOwf9VgnVV/ZzDhGF2AG4gZwoX/h9suSA3UWmj7Zn3YhIK 4HqCwlBYiTE5UOnxAnmZnqoai2BHxpF8MiZhGhPo6ZIO8j4gFivc7ZYP++fHojlUcBbU ol/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Zyj1Us/j"; 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 y15-v6si15079621pfl.255.2018.11.11.14.49.43; Sun, 11 Nov 2018 14:49:58 -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="Zyj1Us/j"; 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 S2404329AbeKLIXQ (ORCPT + 99 others); Mon, 12 Nov 2018 03:23:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:56418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404304AbeKLIXP (ORCPT ); Mon, 12 Nov 2018 03:23:15 -0500 Received: from localhost (unknown [206.108.79.134]) (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 97AA421780; Sun, 11 Nov 2018 22:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975597; bh=czucewhKiRb97M8ahOGDdqsPMfEojUKjNdDw6PmX7nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zyj1Us/jETB7E3ZcJaIJcC1+uZkptljwzCZDWGOYv7ZDKKT3a188vSwj/jw5+oExy tkFfCtBuZe1YmwbCCRNEkDDD7F/87EiUJFhYUyBsreg4oCL1ZZxuebVztweAcb1UvP 8zbIKeU4qs0EprqL/hhucpUV1SMg8vdWmYsrj8+E= 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.14 182/222] xen: fix xen_qlock_wait() Date: Sun, 11 Nov 2018 14:24:39 -0800 Message-Id: <20181111221703.301587880@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -20,6 +21,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; #include @@ -40,25 +42,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); } static irqreturn_t dummy_handler(int irq, void *dev_id)