Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3640290imm; Mon, 1 Oct 2018 01:54:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV63HFJFQNL572YikefknPmPRcGuRdg6rp4SzLio/4BMcqqjGm/VBFYsn2k0ZhXheMyL2r53/ X-Received: by 2002:a63:e216:: with SMTP id q22-v6mr9271390pgh.206.1538384086118; Mon, 01 Oct 2018 01:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538384086; cv=none; d=google.com; s=arc-20160816; b=ZfBHU9EyChIWnwhC3Ehmx+rcX2uMSPw6tciSna1zJ0EI4rWTABkt+15eQR7X8vDBi0 Q/Mu4XbMsPvMy3CXi7e/qNofP036TQ7MaVmqF3KLQ7tWwhlQGZFosBsr+xcts41l+MF0 iWxWaiL5VwIgpNJGyYf8liD0S4TV2UsMPfyAJaZjDNdl+YPM6cipw2mSFiJURwxmSMLQ ptTPR47zuOYcRPZ4vc7R8Sa+bh6Xfvpy4CtQPkxLZ5g16n0Pl7mY+zPluT5fKmBR/Txz M7pyGsH4TGmIug9Ft6m0gOZQcXOZ4abQpPyHlbnBVkIppNAdwwaJhIDWoYAVbENaYABU lUDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:in-reply-to:references :subject:cc:to:from:date:message-id; bh=bve8Zk4gH0Buukjjv/g0tH4rjo4ynf8xClIC8l16IEU=; b=j97y13+kjK/K7fJ+FbuoyC/z2Lys/RMGw3pBKhcMpeCY/fNP2Wg2pGs0CMC05hTWCh +ee1DE5CMb0puobP65UfyaudsTu1ldL2Nh+qE+s3As0GwEUY8eGVUJK4URrZKE5ePDGI DVQBnbJAfZZE7WatKTWtT3m/247TZBwnyyocvNazmTfcZhliqpbbxEKZv+ksyvZwTk7A trHsgaG2xdFfSsvKA1U7C/SNFBtdwlmG95o9ram+h9FJJMS9HMRO2ApXax+Zx0XQ99Si 9PZoHm9BTn1Y+Bt5QVTEW7CEaJUxSP8HYC+cVyhcRiqeySxYNh1vWRGmGdn7WqIAcIYr jhIg== ARC-Authentication-Results: i=1; mx.google.com; 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 w9-v6si12469371pfg.234.2018.10.01.01.54.31; Mon, 01 Oct 2018 01:54:46 -0700 (PDT) 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; 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 S1728889AbeJAPa7 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 1 Oct 2018 11:30:59 -0400 Received: from prv1-mh.provo.novell.com ([137.65.248.33]:40988 "EHLO prv1-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728826AbeJAPa7 (ORCPT ); Mon, 1 Oct 2018 11:30:59 -0400 Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Mon, 01 Oct 2018 02:54:17 -0600 Message-Id: <5BB1E0B502000078001ED124@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.0.2 Date: Mon, 01 Oct 2018 02:54:13 -0600 From: "Jan Beulich" To: "Juergen Gross" Cc: "Borislav Petkov" , "Peter Zijlstra" , "the arch/x86 maintainers" , , "xen-devel" , "Boris Ostrovsky" , , , , , Subject: Re: [Xen-devel] [PATCH 1/2] xen: fix race in xen_qlock_wait() References: <20181001071641.19282-1-jgross@suse.com> <20181001071641.19282-2-jgross@suse.com> In-Reply-To: <20181001071641.19282-2-jgross@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> On 01.10.18 at 09:16, wrote: > In the following situation a vcpu waiting for a lock might not be > woken up from xen_poll_irq(): > > CPU 1: CPU 2: CPU 3: > takes a spinlock > tries to get lock > -> xen_qlock_wait() > -> xen_clear_irq_pending() Doesn't the last line above ... > frees the lock > -> xen_qlock_kick(cpu2) ... need to be below here? > takes lock again > tries to get lock > -> *lock = _Q_SLOW_VAL > -> *lock == _Q_SLOW_VAL ? > -> xen_poll_irq() > frees the lock > -> xen_qlock_kick(cpu3) > > And cpu 2 will sleep forever. > > This can be avoided easily by modifying xen_qlock_wait() to call > xen_poll_irq() only if the related irq was not pending and to call > xen_clear_irq_pending() only if it was pending. > > Cc: stable@vger.kernel.org > Cc: Waiman.Long@hp.com > Cc: peterz@infradead.org > Signed-off-by: Juergen Gross Patch itself Reviewed-by: Jan Beulich Jan