Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2174404pxa; Fri, 7 Aug 2020 05:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPgqPDaKHcXWHQd+q1iq3f+MNImT29W+f9T+7vHv6mqd3RpwRnxbCc2Snz89khwYiYhdLp X-Received: by 2002:a17:907:2082:: with SMTP id pv2mr8796469ejb.188.1596802177052; Fri, 07 Aug 2020 05:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596802177; cv=none; d=google.com; s=arc-20160816; b=myj6W6/QRMrAKkv3wztNoKTJM/P/cNOEX8njFI1MFFDavBOy3h1+ZAmESD/CBshoRh NEY1OR3+p2Yp7ax1XOLCgaz2TdUy6inJlX0Kf5YLLouXOgsFWOdexKOtteY+23AdXIkT mm8R62JJb6O66SHaqiz4iavEoAHcJPRwiF/97U8sUZqG+9RzrqgJDuekFvWtKHXlUaMP TSplsbLC1++kbophh+AT+lyhT3q/PugV1yZcY0udFefic7rzB5kFIGX3dZi+jaQDUqmK evCLWMNb2WmtqFi/uBQTn9xJ2WTJSPYVOeQrtkmPqJbaBwq6u/LaL78MOlG1myvlCrf6 uyig== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ay16CW272QYTKkAOwUiRs236ospoi7GV3k++PHOMjNM=; b=IaGbTKNjOfNiMtSN4lAnIb/8aClOYf5a73PQ80OZJEIzyHo8mDkJqn6QE04QTCFp4D HHpD7MkHQJ1kMWMzDF+g8CTsq2K+XT3leQWUnwFIato/EboPlVQCgSpXthI17Pby/uY0 TrI/kh0gWePlC4h1hzfADQCAFN46qRkcUplRrdgh8eu0r29hEMrKkokcgEc9FmMrG6Ph cSm1XCCQBTbRKbCjAn0nNUVNiJb6Hi1hJWRGZK6HdM9eyKo+SF5fL8vwRzTfFXidq+KE j0frAbzdAkDRqkFYu7qrjtxYD6HYxomdkI6UwzNVCGXbw7LIoH46FRlJ/snpIgAhlcGU zXMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cuta9FDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si5105472ejr.700.2020.08.07.05.09.13; Fri, 07 Aug 2020 05:09:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cuta9FDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbgHGMI1 (ORCPT + 99 others); Fri, 7 Aug 2020 08:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbgHGMIY (ORCPT ); Fri, 7 Aug 2020 08:08:24 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8577C061574 for ; Fri, 7 Aug 2020 05:08:24 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id z22so1711515oid.1 for ; Fri, 07 Aug 2020 05:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ay16CW272QYTKkAOwUiRs236ospoi7GV3k++PHOMjNM=; b=Cuta9FDJbicH7ciZGUJOHWchBBbaLqjwqa0uPBtbSTLSxIyX/sx7nXURWR+O73KTVZ /I/eGITHvvT326sPFg6eATE+mfgY9SdUDTsZgbpZa2RdLfKr5fWpR4Dp7JRJ5BByC8J4 WC7GxBqSciBBf4tPsSWNsdWfmvn73GoUj9Kp4okfExPkQL0PXhSAz30AEDs5CNeU8bDT LIPE7BIFbHF/lJZ7EJi1iblRRKYFMu4H3/r6QeQ9n8GrzsGrD9P0JcIxTo+l33ktORWy UoXXTK5TKopRw/biRd9PfLpI8F+2vdRQrdpB+iA6/F06qOzkzpNUsStbBprQag30FK7h e1Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ay16CW272QYTKkAOwUiRs236ospoi7GV3k++PHOMjNM=; b=hEvjTne743DCQC4oHlCmSwNYBCKg6G0mVDsTjU5wzHgnfQCsyt/950Otq23Zf8yoKQ Rxm7DMuNr98qZNaGfSHB51JfPNSF3YbNqlm+7a7LLzKUvdV3nwYXmMOuoel7RSvyQxiE wKfpONTbk8Dyr/DBHYQH9RWKCz+6gUa6xrTVyBLOef6R9k+fRm0mQ2WNHLDjNkDPFwLn m0LA0GhwL7XqLZXX8+LB+a4juzirifSWndKPOQQ4rfdCzsiugJvnzFQt9g1bKlZIAnxX tIBwqSRhTa/4C87EInz9VZkS+HYPEmkAaPXTuZo9fSWSb7S+eF5++1dhrjOOZNd4SFD+ hvsw== X-Gm-Message-State: AOAM533se0N6SE5MjAQDApfyDgKnYWqbgP7E1doIhkyWlm9hnQNn9XGF WUdmK07B1oyrIIzo6qhq3h6M19lgnVY4/5uCx5mC+g== X-Received: by 2002:aca:b8c4:: with SMTP id i187mr11210808oif.121.1596802103701; Fri, 07 Aug 2020 05:08:23 -0700 (PDT) MIME-Version: 1.0 References: <20200806074723.GA2364872@elver.google.com> <20200806113236.GZ2674@hirez.programming.kicks-ass.net> <20200806131702.GA3029162@elver.google.com> <20200807095032.GA3528289@elver.google.com> <16671cf3-3885-eb06-79ff-4cbfaeeaea79@suse.com> <20200807113838.GA3547125@elver.google.com> In-Reply-To: From: Marco Elver Date: Fri, 7 Aug 2020 14:08:11 +0200 Message-ID: Subject: Re: [PATCH] x86/paravirt: Add missing noinstr to arch_local*() helpers To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: Peter Zijlstra , Borislav Petkov , Dave Hansen , fenghua.yu@intel.com, "H. Peter Anvin" , LKML , Ingo Molnar , syzkaller-bugs , Thomas Gleixner , "Luck, Tony" , "the arch/x86 maintainers" , yu-cheng.yu@intel.com, sdeep@vmware.com, virtualization@lists.linux-foundation.org, kasan-dev , syzbot , "Paul E. McKenney" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 Aug 2020 at 14:04, J=C3=BCrgen Gro=C3=9F wrote: > > On 07.08.20 13:38, Marco Elver wrote: > > On Fri, Aug 07, 2020 at 12:35PM +0200, J=C3=BCrgen Gro=C3=9F wrote: > >> On 07.08.20 11:50, Marco Elver wrote: > >>> On Fri, Aug 07, 2020 at 11:24AM +0200, J=C3=BCrgen Gro=C3=9F wrote: > >>>> On 07.08.20 11:01, Marco Elver wrote: > >>>>> On Thu, 6 Aug 2020 at 18:06, Marco Elver wrote: > >>>>>> On Thu, 6 Aug 2020 at 15:17, Marco Elver wrote: > >>>>>>> On Thu, Aug 06, 2020 at 01:32PM +0200, peterz@infradead.org wrote= : > >>>>>>>> On Thu, Aug 06, 2020 at 09:47:23AM +0200, Marco Elver wrote: > >>>>>>>>> Testing my hypothesis that raw then nested non-raw > >>>>>>>>> local_irq_save/restore() breaks IRQ state tracking -- see the r= eproducer > >>>>>>>>> below. This is at least 1 case I can think of that we're bound = to hit. > >>>>>>> ... > >>>>>>>> > >>>>>>>> /me goes ponder things... > >>>>>>>> > >>>>>>>> How's something like this then? > >>>>>>>> > >>>>>>>> --- > >>>>>>>> include/linux/sched.h | 3 --- > >>>>>>>> kernel/kcsan/core.c | 62 +++++++++++++++++++++++++++++++++= +++--------------- > >>>>>>>> 2 files changed, 44 insertions(+), 21 deletions(-) > >>>>>>> > >>>>>>> Thank you! That approach seems to pass syzbot (also with > >>>>>>> CONFIG_PARAVIRT) and kcsan-test tests. > >>>>>>> > >>>>>>> I had to modify it some, so that report.c's use of the restore lo= gic > >>>>>>> works and not mess up the IRQ trace printed on KCSAN reports (wit= h > >>>>>>> CONFIG_KCSAN_VERBOSE). > >>>>>>> > >>>>>>> I still need to fully convince myself all is well now and we don'= t end > >>>>>>> up with more fixes. :-) If it passes further testing, I'll send i= t as a > >>>>>>> real patch (I want to add you as Co-developed-by, but would need = your > >>>>>>> Signed-off-by for the code you pasted, I think.) > >>>>> > >>>>> I let it run on syzbot through the night, and it's fine without > >>>>> PARAVIRT (see below). I have sent the patch (need your Signed-off-b= y > >>>>> as it's based on your code, thank you!): > >>>>> https://lkml.kernel.org/r/20200807090031.3506555-1-elver@google.com > >>>>> > >>>>>> With CONFIG_PARAVIRT=3Dy (without the notrace->noinstr patch), I s= till > >>>>>> get lockdep DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled()), alth= ough > >>>>>> it takes longer for syzbot to hit them. But I think that's expecte= d > >>>>>> because we can still get the recursion that I pointed out, and wil= l > >>>>>> need that patch. > >>>>> > >>>>> Never mind, I get these warnings even if I don't turn on KCSAN > >>>>> (CONFIG_KCSAN=3Dn). Something else is going on with PARAVIRT=3Dy th= at > >>>>> throws off IRQ state tracking. :-/ > >>>> > >>>> What are the settings of CONFIG_PARAVIRT_XXL and > >>>> CONFIG_PARAVIRT_SPINLOCKS in this case? > >>> > >>> I attached a config. > >>> > >>> $> grep PARAVIRT .config > >>> CONFIG_PARAVIRT=3Dy > >>> CONFIG_PARAVIRT_XXL=3Dy > >>> # CONFIG_PARAVIRT_DEBUG is not set > >>> CONFIG_PARAVIRT_SPINLOCKS=3Dy > >>> # CONFIG_PARAVIRT_TIME_ACCOUNTING is not set > >>> CONFIG_PARAVIRT_CLOCK=3Dy > >> > >> Anything special I need to do to reproduce the problem? Or would you b= e > >> willing to do some more rounds with different config settings? > > > > I can only test it with syzkaller, but that probably doesn't help if yo= u > > don't already have it set up. It can't seem to find a C reproducer. > > > > I did some more rounds with different configs. > > > >> I think CONFIG_PARAVIRT_XXL shouldn't matter, but I'm not completely > >> sure about that. CONFIG_PARAVIRT_SPINLOCKS would be my primary suspect= . > > > > Yes, PARAVIRT_XXL doesn't make a different. When disabling > > PARAVIRT_SPINLOCKS, however, the warnings go away. > > Thanks for testing! > > I take it you are doing the tests in a KVM guest? Yes, correct. > If so I have a gut feeling that the use of local_irq_save() and > local_irq_restore() in kvm_wait() might be fishy. I might be completely > wrong here, though. Happy to help debug more, although I might need patches or pointers what to play with. > BTW, I think Xen's variant of pv spinlocks is fine (no playing with IRQ > on/off). > > Hyper-V seems to do the same as KVM, and kicking another vcpu could be > problematic as well, as it is just using IPI. > > > Juergen