Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp886023imu; Fri, 9 Nov 2018 07:38:31 -0800 (PST) X-Google-Smtp-Source: AJdET5c9LJrGvDnurW7of2oXVym8chGiHQD87QtbXMGCIDqC8WHL8PEgKJgtPnL/d+O/1jvY+J34 X-Received: by 2002:a63:2744:: with SMTP id n65mr7785561pgn.65.1541777911022; Fri, 09 Nov 2018 07:38:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541777910; cv=none; d=google.com; s=arc-20160816; b=SfwvIA3Xp/WlwmNH59TSFA1zxZNoXe3skzt18/BHXy98vc2Lyf+f1JLscNDAtobqce LoFr1tASRRoi0QMK5nHN0ixS9ueHI+QqLrstL5i5nUR7pl1OeuvzqiKcV+1L/iopAk8w piFygbRVRPHadu5zWaxAx2BVRetkdsHJVSE4StLQSH7LDfVYOgicF4wmR0csbZf1KOHj nW7G85iQ9aJD0GN1HNfy8TdzRxlk00KKahnNViS+ZBr75wc95CxsCTmvG5G4UHB9grDK 7z+DPkPCOqgtj4Zh4nSjbgB6fIOLbHZN54OYxz9N9/RVfjslhKuCDavIgNwbmrYBP/Gs Wp9A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=2S87To//NEIn5v52UpLazlahK1WIIWZP/P5TTEZP/CM=; b=fC3ayS01WS6r+hLKFKYuq/2iONLl/v44Afs2lqB9JyLPk2g4PZFSb7+lDRYpWOPqyu VbkN121M1JUhRALlFEOVEwdDQVFK1CzxtYIG8hkV8d7r7gcF5+3bQFwnO3XmJTor4cFz 6IyjG9p7DWDB5vAy5+UxOgtr3ImbMa8ui+2Y+/xFhKZE7KW2fKKRxEqFXHwpS8bjAsl7 JDcIBrZhzOt650RE4GJaiwGoReJELWe+AEaX/TeixDJym29blMu2I1gmZZ412jqIZmjw Vz+3hLUIUMsB5qJffWvMtC5JaZ9r3OdCQCWBgdL1TZYpcVvHyyUy5O3eOrG2F6nXz2hx sBeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@eikelenboom.it header.s=20180706 header.b=YimkJMHN; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eikelenboom.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si6647613pgj.60.2018.11.09.07.37.47; Fri, 09 Nov 2018 07:38:30 -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=fail header.i=@eikelenboom.it header.s=20180706 header.b=YimkJMHN; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eikelenboom.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728265AbeKJBRQ (ORCPT + 99 others); Fri, 9 Nov 2018 20:17:16 -0500 Received: from server.eikelenboom.it ([91.121.65.215]:57396 "EHLO server.eikelenboom.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728172AbeKJBRQ (ORCPT ); Fri, 9 Nov 2018 20:17:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=eikelenboom.it; s=20180706; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2S87To//NEIn5v52UpLazlahK1WIIWZP/P5TTEZP/CM=; b=YimkJMHN6qvOLYjlWKV883vHRE MKWd0TwzmEADE6EmkTrjt+LOhbmU5SDtrJzeUvavt95o0db3lq950fiOmXNNWBK+9ipIxFhrGXVvc EJEzMAGiHsFGV8vONnI4GQUcGXV5T0sbMQ43yCPm7oyoBn9idIze9BHpu6psDcMUSZsk=; Received: from ip4da85049.direct-adsl.nl ([77.168.80.73]:50976 helo=[172.16.1.49]) by server.eikelenboom.it with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1gL8IC-0002nG-Ik; Fri, 09 Nov 2018 16:01:52 +0100 Subject: Re: [Xen-devel] [PATCH] xen: fix xen_qlock_wait() To: Juergen Gross , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Cc: boris.ostrovsky@oracle.com, sstabellini@kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, stable@vger.kernel.org References: <20181109120413.9539-1-jgross@suse.com> From: Sander Eikelenboom Message-ID: <400409f5-397e-780b-d13b-19a1ee578f44@eikelenboom.it> Date: Fri, 9 Nov 2018 16:02:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181109120413.9539-1-jgross@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11/18 13:04, Juergen Gross wrote: > 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 > Signed-off-by: Juergen Gross Although you don't seem too interested, you can stick on a: Tested-by: Sander Eikelenboom if you like. -- Sander > --- > arch/x86/xen/spinlock.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c > index 441c88262169..1c8a8816a402 100644 > --- 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) >