Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3471360imu; Sun, 11 Nov 2018 15:52:32 -0800 (PST) X-Google-Smtp-Source: AJdET5ek3LHDS0MFvBgu+j2pkAHMuUQnGMVuKSkGz0i+Onc8QmK4E7+0BNfA+gpZxr4U2dXfIoS8 X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr17947361plc.307.1541980352530; Sun, 11 Nov 2018 15:52:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980352; cv=none; d=google.com; s=arc-20160816; b=RcPLLY7PSl+L7supOXacttJYu4VakJMFQ9uILyd67mNLP0+33XYHaMKxrV5Ju44UrQ Kzmsb+gm39+wj8N/EEwKiMV4rIioPRHGw6KDDPgMGx07VzxrZvZxYC3YDYkqWRIvcqYh 5CHjeh+k8gxFmFthk3tKq5s0P3qbTDGcXZ8ypQ690ZTYl4DS+6k3oYrn2AW+FZ21b7fs +rXIXs+YCHD/eUm0OxIZSHjsucD4nh0bvIAqjZCzhxjtwuvOaM9lfCisDdjbkHFLELUD 16aTILiJ5+MhpXdSG2qzzMWyCNDtBEBVW4bYWbaLfFbFvK/zNoAQoh1wQm6DDfHyJMT0 0RhQ== 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=KwXkt6TH5cxzAq1ihxQ0/4LJ9wC3gkID7oDRidt1yIo=; b=Mx1+GMt5zm4eyNSqnLGaq97Gz3oIIIsQWfnTCO3aBdVecT/gdLBX93bHnF4WIYHnf8 mnwsryp8VC+A5ajNLUnXaKtbtMSDoL5K05gayHKhoUEoYnWNzIB8rmY5lOxrLpYetNTy hWeDZYXhoGYdoElvOnFFXlpuOZsr46BlkVUVlEfYJlbp28sxXaE+ks3xtu/yyIRuHMAA b+7zoudBZiVbiks5LHmjTrAih0tt+ZFo5wAmXFrBu1tKVGysMsI7s6AFqv6p+/mrYx+h ytxehkfc5GCSiF+PVurwOrmMHGt00r0nImkUqUSviW6L6hIZVV2iPHMmLT6WY5RBv9rY PdQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GXb0gJGc; 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 31-v6si15866927plz.181.2018.11.11.15.52.17; Sun, 11 Nov 2018 15:52:32 -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=GXb0gJGc; 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 S1733041AbeKLJmU (ORCPT + 99 others); Mon, 12 Nov 2018 04:42:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:37518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732819AbeKLIS3 (ORCPT ); Mon, 12 Nov 2018 03:18:29 -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 0112D22353; Sun, 11 Nov 2018 22:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975314; bh=olR7zK+EoOQ0zjNDrS72SGG4gJ/leF+c9/EZG2CGxEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXb0gJGcN95Lq1SS0PYj+wzt8OPIzdFTD760nqgI60s75HG4OaojdvSPs7wsS7M3h jWSulBBsN7BcmD436KCCuGJWEh/37U6WJ3D5fkNIlAAnh3Hme8BERx66AHzrdGJrVc SAtbYiXtlnmmbYgkvVUAvKdg8mesSXcgm8NJpyTQ= 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.19 299/361] xen: fix xen_qlock_wait() Date: Sun, 11 Nov 2018 14:20:46 -0800 Message-Id: <20181111221657.349117875@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 #include @@ -21,6 +22,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; static void xen_qlock_kick(int cpu) @@ -39,25 +41,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)