From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51F0EC433FE for ; Fri, 18 Feb 2022 18:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237131AbiBRS0E (ORCPT ); Fri, 18 Feb 2022 13:26:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239286AbiBRS0B (ORCPT ); Fri, 18 Feb 2022 13:26:01 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C90FE4AE1E for ; Fri, 18 Feb 2022 10:25:44 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id l9so7850737plg.0 for ; Fri, 18 Feb 2022 10:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/YY6gHmhRlidn/sY9OLwMpBqcTm3U79RSE+/6MPGrJA=; b=Yikg60aEeMXc80GolC4gFuR/bCOvdyO1+bgorzH57I67lv589wT3iZ9TqMt+rjvOh8 H8KWOYa5PNS0FNo7DZ2Agm9k7fVGWhXapa6dpQ9huUdCNFN4rfqx28UCJlTIeU4nIZYw bzk/srr8FDPJtk1MHlC6HZGRCbYRKOKe+5eIpUECPeAD/ke9yHdvdmhmBxBkJ61ufoj8 Dq1x3lJeVTVfUmOr+etb76YXjwuMyrl1bkN7YKNFoAcMdfZJh5YjI1HHRrQko5Udffol 7rS+shfUUfDbvZqxep/a6EPgOH1S+Qcco6yiASWw57vXjlRQAO0hAPJC0O5G/afKME81 0+kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/YY6gHmhRlidn/sY9OLwMpBqcTm3U79RSE+/6MPGrJA=; b=6L9dF6Ojx1LQcybUAtrV+wOgYvqhfHO2bbQl5PDN0CThn6zKhsoT4xZy1TwtVZoiUa Bx5+mCgoeSTt97skVR42pfI9bhgmb529YEKQ1j5vvdF+XpkKtYjSesGCnfiTMIW+2o+k ex66YmDSVRnfrYxexKH3nQXp8yWRsQk8fUGbgnxgTyZmHECrqRQysY/TBlgSCm82sBDb gK7oqtRryBOJVQnT79nOxkKrGn737xM1VVxCWifJ0HQoQ96mBswgcRtPDwSxk57rKmwg 8yGV3GP5QEdRUQgIlVtDbNMLGiSE0CjIPKqIjJo/gz2B4Vg5oN1e4v3DdjuVyi66xj5X 9JPg== X-Gm-Message-State: AOAM531UEYKtzJA2MOXHqxH9PDo7lT2ZBA1YtRh86xoxBRXWsEwWYjD3 /eunD6IvlLEZZHqGhB0u8jC+1w== X-Google-Smtp-Source: ABdhPJwggBWLIivAjldbUymbvPVfh/gDQqm0tN/nVKFq9v/jYAjSkDjVptJ8J0RWsg1nUGnzVBaXhw== X-Received: by 2002:a17:90a:bb88:b0:1b9:eaf6:fe09 with SMTP id v8-20020a17090abb8800b001b9eaf6fe09mr9473590pjr.95.1645208744140; Fri, 18 Feb 2022 10:25:44 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id z9sm11531437pgz.32.2022.02.18.10.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 10:25:43 -0800 (PST) Date: Fri, 18 Feb 2022 18:25:39 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: Like Xu , Eric Hankland , Jim Mattson , Wanpeng Li , Vitaly Kuznetsov , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] KVM: x86/pmu: Protect kvm->arch.pmu_event_filter with SRCU Message-ID: References: <20220217083601.24829-1-likexu@tencent.com> <20220217083601.24829-2-likexu@tencent.com> <12b84d17-94cc-6ee7-bde4-340b609c16d2@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12b84d17-94cc-6ee7-bde4-340b609c16d2@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 18, 2022, Paolo Bonzini wrote: > On 2/17/22 09:36, Like Xu wrote: > > From: Like Xu > > > > Fix the following positive warning: > > > > ============================= > > WARNING: suspicious RCU usage > > arch/x86/kvm/pmu.c:190 suspicious rcu_dereference_check() usage! > > other info that might help us debug this: > > rcu_scheduler_active = 2, debug_locks = 1 > > 1 lock held by CPU 28/KVM/370841: > > #0: ff11004089f280b8 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x87/0x730 [kvm] > > Call Trace: > > > > dump_stack_lvl+0x59/0x73 > > reprogram_fixed_counter+0x15d/0x1a0 [kvm] > > kvm_pmu_trigger_event+0x1a3/0x260 [kvm] > > ? free_moved_vector+0x1b4/0x1e0 > > complete_fast_pio_in+0x8a/0xd0 [kvm] > > [...] > > I think the right fix is to add SRCU protection to complete_userspace_io in > kvm_arch_vcpu_ioctl_run. Most calls of complete_userspace_io can execute > similar code to vmexits. Agreed, I bet similar warnings can be triggered on SVM with nrips=false due to svm_skip_emulated_instruction() dropping into the emulator, e.g. for HyperV and Xen usage where next_rip doesn't appear to be filled in all paths.