Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp200194pxa; Tue, 11 Aug 2020 00:06:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzACDN3OwU32cVrf7ea8tbq5iWJWUl0kK0+P/Wc1lDDmjfyI3BF04e7hMGxt86j3KwDE9LM X-Received: by 2002:a17:906:7715:: with SMTP id q21mr24831357ejm.251.1597129582447; Tue, 11 Aug 2020 00:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597129582; cv=none; d=google.com; s=arc-20160816; b=Pta+7/q1vVc718oCKVlWoN1NOUfu5phRZjR0ONJwBypm2LX7ouAkDoo7tZL7zQAoA+ A6waHDSgpUhEko+uYut6H6tOZkHaNGKYJ4dcUF4zB21nDa1aUr6H4hOHcYoXCvBhQgyy kqC92Ud0oBsiyWIJlY9br4Gre8k3cmoRi/FpLKtj0O4HjYuPcWM4SfuJa6Dfkcl9HQcO LLm1hZOa2zFY0IYWqLga/nIlC17uXCuQMfKqoMuEdRK8fvkCH58bFNEnSTMWBZA8+U42 OFwkST+gd6k+yskHuy27FtLMXjSSOON7nvf+Ewj+aB0zt/MVSvozgeFtvHN+BuO8riOG 5MxQ== 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; bh=ZhNUIj6rmGABNgZ7/zudkw64aC6gy4gsxotgHFPqbo0=; b=rtIZsWGCfn1bEOBaC0U3C3NSZGvbYLjlFJYNg1s5jkwSQ22xf+xL2/Rtkg/F2c8WLo IZVbzoZs5RGS8Y8UHIaSMf2pUfVAGZ8gCLTlCRK1IX8NrtYC3I1A8D6VVX9KXmPyNX5R 3ebzbXg2EhBCEXqYoKmdqaPBbmi57ryD7JJO68FNhWrAYIX8LIvjUoQ6O0ITaMkeIj7S jtoIhuun+AR/yFqnZnA4/k7sUYIJL3ap9rq2+5dHv4fTB5bkxOnPF0U1E6MSY19qQuQR LzPxOnV3SGnEg8RE3cbHapOGldcUAMAJlxCoukwhkGgRfgqKf7tetUdO1SJVpQCP1cIg tE4g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb11si11942724edb.344.2020.08.11.00.05.59; Tue, 11 Aug 2020 00:06:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728325AbgHKHEw (ORCPT + 99 others); Tue, 11 Aug 2020 03:04:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:40336 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728271AbgHKHEv (ORCPT ); Tue, 11 Aug 2020 03:04:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 588C8AC7D; Tue, 11 Aug 2020 07:05:10 +0000 (UTC) Subject: Re: [PATCH] x86/paravirt: Add missing noinstr to arch_local*() helpers To: Marco Elver 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" , Wei Liu References: <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> <20200807151903.GA1263469@elver.google.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <26c3214f-7d8a-7b1f-22fc-e864291f50ce@suse.com> Date: Tue, 11 Aug 2020 09:04:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.08.20 09:00, Marco Elver wrote: > On Fri, 7 Aug 2020 at 17:19, Marco Elver wrote: >> On Fri, Aug 07, 2020 at 02:08PM +0200, Marco Elver wrote: >>> On Fri, 7 Aug 2020 at 14:04, Jürgen Groß wrote: >>>> >>>> On 07.08.20 13:38, Marco Elver wrote: >>>>> On Fri, Aug 07, 2020 at 12:35PM +0200, Jürgen Groß wrote: > ... >>>>>> 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. >> >> I experimented a bit more, and the below patch seems to solve the >> warnings. However, that was based on your pointer about kvm_wait(), and >> I can't quite tell if it is the right solution. >> >> My hypothesis here is simply that kvm_wait() may be called in a place >> where we get the same case I mentioned to Peter, >> >> raw_local_irq_save(); /* or other IRQs off without tracing */ >> ... >> kvm_wait() /* IRQ state tracing gets confused */ >> ... >> raw_local_irq_restore(); >> >> and therefore, using raw variants in kvm_wait() works. It's also safe >> because it doesn't call any other libraries that would result in corrupt >> IRQ state AFAIK. > > Just to follow-up, it'd still be nice to fix this. Suggestions? > > I could send the below as a patch, but can only go off my above > hypothesis and the fact that syzbot is happier, so not entirely > convincing. Peter has told me via IRC he will look soon further into this. Your finding suggests that the pv-lock implementation for Hyper-V needs some tweaking, too. For that purpose I'm adding Wei to Cc. Juergen > > Thanks, > -- Marco > >> ------ >8 ------ >> >> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c >> index 233c77d056c9..1d412d1466f0 100644 >> --- a/arch/x86/kernel/kvm.c >> +++ b/arch/x86/kernel/kvm.c >> @@ -797,7 +797,7 @@ static void kvm_wait(u8 *ptr, u8 val) >> if (in_nmi()) >> return; >> >> - local_irq_save(flags); >> + raw_local_irq_save(flags); >> >> if (READ_ONCE(*ptr) != val) >> goto out; >> @@ -810,10 +810,10 @@ static void kvm_wait(u8 *ptr, u8 val) >> if (arch_irqs_disabled_flags(flags)) >> halt(); >> else >> - safe_halt(); >> + raw_safe_halt(); >> >> out: >> - local_irq_restore(flags); >> + raw_local_irq_restore(flags); >> } >> >> #ifdef CONFIG_X86_32 >