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 39AA7C433F5 for ; Tue, 19 Apr 2022 15:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354011AbiDSPsn (ORCPT ); Tue, 19 Apr 2022 11:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243401AbiDSPsl (ORCPT ); Tue, 19 Apr 2022 11:48:41 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41690B1C5 for ; Tue, 19 Apr 2022 08:45:58 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id x80so18809pfc.1 for ; Tue, 19 Apr 2022 08:45:58 -0700 (PDT) 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=hcC70nEaEjCrZOBwR+bHJFoY8sXKM5tdaihGvVikeUA=; b=nllDsrmMLB7AAvdsCYhHwzGAwZygD09xcbijCyvxam19T71okMswczeidyoTR5SpG0 rh2btGFKQ8mFqLW0jb05ZgH7OBBqFC3qd+RSoYqhjbcOEfsOApUER19sCRfFMfoBIpEI yKTQvKsy4m5GlAWzFu8NEv3LhxslcTTwe6M8afBDFsE8xE+g+gSVzSH2Y6X7wQTu3bZ0 kdi4zB98HqqFf25muMksptD1m9ilqCPvrI6q21hqYsF4bYqxNptCkUe1YhNdH7I5dLV1 d2lkK/LTT2KCvd4gEIWUsK4t0WNBMIpaja6VIf/jz4mIVCTT2/Ja8zo91SL4YY1Ex4Nu siWQ== 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=hcC70nEaEjCrZOBwR+bHJFoY8sXKM5tdaihGvVikeUA=; b=0oL89IvoWHyCfyFan0iVZmvNyDWRP+GixoDAg2p67KOGVDO47bwNyNDgX2U77NSfKy uoJm/wvPwmlSG6KQkrxhnBIgOVS5IwgkJt35rboAMl5CGi4Y7t/ai2ueL/H6KFAkmw9e qffkHeojWV0K0/1PcltSmsPjjC3GlVb+x0j7Q1J+DqteFguvRCCeDueqBIGxHpEj4LwY ZEbdNofD9XqJfuQfeMOJMTrFRm+xv8L52rK+haoeaShMEC2E6En/Do+ZJiwqgrk0fhr3 vOnVg2QFMYC6zYql9HrhSnRj98UCA4GDtUeSL8Ls4ofgOvWPNGgBy7+TdHL9N8a/e8IF hD4w== X-Gm-Message-State: AOAM533ORU2pTV0jQS/z58U49L7Hyz0cc2vMUJxYNe1ZGOLzycAusHs9 KPeVr8e3zYU2fc4lEPdLVZm69g== X-Google-Smtp-Source: ABdhPJxyLXIANNTGiAZfsu1/QG9UANwG5wKin3TjbnrIzeNo7+Th34xV36A6olC5ZeEiVQzlg55+OQ== X-Received: by 2002:a05:6a00:b4d:b0:509:1ed1:570e with SMTP id p13-20020a056a000b4d00b005091ed1570emr18500672pfo.19.1650383157493; Tue, 19 Apr 2022 08:45:57 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id z4-20020a17090a66c400b001d0e448810asm13613064pjl.36.2022.04.19.08.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 08:45:56 -0700 (PDT) Date: Tue, 19 Apr 2022 15:45:52 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , Atish Patra , David Hildenbrand , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] KVM: Add helpers to wrap vcpu->srcu_idx and yell if it's abused Message-ID: References: <20220415004343.2203171-1-seanjc@google.com> <20220415004343.2203171-4-seanjc@google.com> <5b561bf1a0bbf140ea09d516f946a4e8fee8dd2d.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b561bf1a0bbf140ea09d516f946a4e8fee8dd2d.camel@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 19, 2022, Maxim Levitsky wrote: > On Fri, 2022-04-15 at 00:43 +0000, Sean Christopherson wrote: > > Add wrappers to acquire/release KVM's SRCU lock when stashing the index > > in vcpu->src_idx, along with rudimentary detection of illegal usage, > > e.g. re-acquiring SRCU and thus overwriting vcpu->src_idx. Because the > > SRCU index is (currently) either 0 or 1, illegal nesting bugs can go > > unnoticed for quite some time and only cause problems when the nested > > lock happens to get a different index. > > > > Wrap the WARNs in PROVE_RCU=y, and make them ONCE, otherwise KVM will > > likely yell so loudly that it will bring the kernel to its knees. > > > > Signed-off-by: Sean Christopherson > > --- ... > Looks good to me overall. > > Note that there are still places that acquire the lock and store the idx into > a local variable, for example kvm_xen_vcpu_set_attr and such. > I didn't check yet if these should be converted as well. Using a local variable is ok, even desirable. Nested/multiple readers is not an issue, the bug fixed by patch 1 is purely that kvm_vcpu.srcu_idx gets corrupted. In an ideal world, KVM would _only_ track the SRCU index in local variables, but that would require plumbing the local variable down into vcpu_enter_guest() and kvm_vcpu_block() so that SRCU can be unlocked prior to entering the guest or scheduling out the vCPU. 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E993C433EF for ; Tue, 19 Apr 2022 15:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qbpE7Ap+qCosAWtaDElUXyvEXwXYiM6Hr9KeZR8v0Fw=; b=xdegAa1o+UgeRE Srh4vcyfBKvWPs+D1bS7/84fGsG0GRN0hWYe6aQT9n0Bth7r4rhdf9v643SI19A4HmnzBd76DlXQV svZ4AUrkl5qNsI+7WxLKr3jtijrcmzYuCsm+Ar0hYhagS31/ojxcQ+VXAGA74LU0w7W1mebEIIOYd 1bAtPZqFoe+5qA4o71ZSgHqviw00ltY/Qsyz9sKXOtLswjoIC1V886Vjp7yVOQGMJs9/Bj+WI4sk0 ZmimF5cah1i8jD8ZhwhVI+6Z+CriLgUWVpi3jugjWgsJu34GuZwzXx+0hm6P1P6hFropjE0P0l9OE rqQq7uGCkOzNhStcU3Sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngq3I-004ma0-Mh; Tue, 19 Apr 2022 15:46:04 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngq3E-004mVu-OH for linux-riscv@lists.infradead.org; Tue, 19 Apr 2022 15:46:02 +0000 Received: by mail-pf1-x435.google.com with SMTP id h1so1059029pfv.12 for ; Tue, 19 Apr 2022 08:45:58 -0700 (PDT) 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=hcC70nEaEjCrZOBwR+bHJFoY8sXKM5tdaihGvVikeUA=; b=nllDsrmMLB7AAvdsCYhHwzGAwZygD09xcbijCyvxam19T71okMswczeidyoTR5SpG0 rh2btGFKQ8mFqLW0jb05ZgH7OBBqFC3qd+RSoYqhjbcOEfsOApUER19sCRfFMfoBIpEI yKTQvKsy4m5GlAWzFu8NEv3LhxslcTTwe6M8afBDFsE8xE+g+gSVzSH2Y6X7wQTu3bZ0 kdi4zB98HqqFf25muMksptD1m9ilqCPvrI6q21hqYsF4bYqxNptCkUe1YhNdH7I5dLV1 d2lkK/LTT2KCvd4gEIWUsK4t0WNBMIpaja6VIf/jz4mIVCTT2/Ja8zo91SL4YY1Ex4Nu siWQ== 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=hcC70nEaEjCrZOBwR+bHJFoY8sXKM5tdaihGvVikeUA=; b=tIKvO458ekki40hmCLUqsy2hdCa4IE2Xj/xe4m0N8MZ/fDeHfjkkvVNEQy2/Hm6yWA qUYh0LlJeFxGFne052/DyEOsY3ios3h0elf6GFKgj5p3ubjsXVodZ6tb0d1vwEPFQNlP wsmNZYIqBKm+RXqSRlZyFGGrUw7lDnnf+7YF+38a82mIjOyDhNfaocS7AB8zRuCrwuwJ Awgoz18QUa54T8lz/VbYNnNP6up4LEqPkkWieE0Ts8aNSa9I0bokMzupIVchgUd01H9k hLMp2c3Md4VvgzAt0WypxNti1Z2exmitxcfxhlWK02rsrPo90sICrhxhgW1DQpCogWkQ gxFQ== X-Gm-Message-State: AOAM530OotAGyeZU9oIOWdurfHLKA7/m0oRCwtsWI8GmOmR9r2LCL7RH OtzPibwEEC6AwEWFt4dmP45c3Q== X-Google-Smtp-Source: ABdhPJxyLXIANNTGiAZfsu1/QG9UANwG5wKin3TjbnrIzeNo7+Th34xV36A6olC5ZeEiVQzlg55+OQ== X-Received: by 2002:a05:6a00:b4d:b0:509:1ed1:570e with SMTP id p13-20020a056a000b4d00b005091ed1570emr18500672pfo.19.1650383157493; Tue, 19 Apr 2022 08:45:57 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id z4-20020a17090a66c400b001d0e448810asm13613064pjl.36.2022.04.19.08.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 08:45:56 -0700 (PDT) Date: Tue, 19 Apr 2022 15:45:52 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , Atish Patra , David Hildenbrand , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] KVM: Add helpers to wrap vcpu->srcu_idx and yell if it's abused Message-ID: References: <20220415004343.2203171-1-seanjc@google.com> <20220415004343.2203171-4-seanjc@google.com> <5b561bf1a0bbf140ea09d516f946a4e8fee8dd2d.camel@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5b561bf1a0bbf140ea09d516f946a4e8fee8dd2d.camel@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220419_084600_852909_D3C3ADF2 X-CRM114-Status: GOOD ( 18.81 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, Apr 19, 2022, Maxim Levitsky wrote: > On Fri, 2022-04-15 at 00:43 +0000, Sean Christopherson wrote: > > Add wrappers to acquire/release KVM's SRCU lock when stashing the index > > in vcpu->src_idx, along with rudimentary detection of illegal usage, > > e.g. re-acquiring SRCU and thus overwriting vcpu->src_idx. Because the > > SRCU index is (currently) either 0 or 1, illegal nesting bugs can go > > unnoticed for quite some time and only cause problems when the nested > > lock happens to get a different index. > > > > Wrap the WARNs in PROVE_RCU=y, and make them ONCE, otherwise KVM will > > likely yell so loudly that it will bring the kernel to its knees. > > > > Signed-off-by: Sean Christopherson > > --- ... > Looks good to me overall. > > Note that there are still places that acquire the lock and store the idx into > a local variable, for example kvm_xen_vcpu_set_attr and such. > I didn't check yet if these should be converted as well. Using a local variable is ok, even desirable. Nested/multiple readers is not an issue, the bug fixed by patch 1 is purely that kvm_vcpu.srcu_idx gets corrupted. In an ideal world, KVM would _only_ track the SRCU index in local variables, but that would require plumbing the local variable down into vcpu_enter_guest() and kvm_vcpu_block() so that SRCU can be unlocked prior to entering the guest or scheduling out the vCPU. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C2F5C433EF for ; Tue, 19 Apr 2022 15:46:46 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjSpX2Rf3z2yg5 for ; Wed, 20 Apr 2022 01:46:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=nllDsrmM; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::42b; helo=mail-pf1-x42b.google.com; envelope-from=seanjc@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=nllDsrmM; dkim-atps=neutral Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KjSnm5Mtcz2yJ5 for ; Wed, 20 Apr 2022 01:46:02 +1000 (AEST) Received: by mail-pf1-x42b.google.com with SMTP id l127so6951893pfl.6 for ; Tue, 19 Apr 2022 08:46:02 -0700 (PDT) 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=hcC70nEaEjCrZOBwR+bHJFoY8sXKM5tdaihGvVikeUA=; b=nllDsrmMLB7AAvdsCYhHwzGAwZygD09xcbijCyvxam19T71okMswczeidyoTR5SpG0 rh2btGFKQ8mFqLW0jb05ZgH7OBBqFC3qd+RSoYqhjbcOEfsOApUER19sCRfFMfoBIpEI yKTQvKsy4m5GlAWzFu8NEv3LhxslcTTwe6M8afBDFsE8xE+g+gSVzSH2Y6X7wQTu3bZ0 kdi4zB98HqqFf25muMksptD1m9ilqCPvrI6q21hqYsF4bYqxNptCkUe1YhNdH7I5dLV1 d2lkK/LTT2KCvd4gEIWUsK4t0WNBMIpaja6VIf/jz4mIVCTT2/Ja8zo91SL4YY1Ex4Nu siWQ== 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=hcC70nEaEjCrZOBwR+bHJFoY8sXKM5tdaihGvVikeUA=; b=XwpRLaHL1slU8jboBcMl1891ET0HTC3DTZJFsiUzahrU7EKeKR5Ry/CvNDY1l4isSI SsRDSewTD7vCCqkbnvEURQdCvmkKFI//yHWnMxBqgGnOEabHHw4Hx9RsfBFlac/i3lHI su6fZTWzuL/H7rZmgULDTPP+uv3t8XgFK7PP+yNqxEz9dxhs0ruwWLunDaxjcXRbQItl vi0yaLrMH1nFsvKz17fYIK4q+F3qwjefzO7xOjNF2N1CzhJt2mdY163WUHUOFhL7v1NH mhLN1xtPmcnBk8K+LNI8uuZV00FmeGmJMjzGlpaBGQknp/81MR4bac3ufu7qkR67sTD5 0Bwg== X-Gm-Message-State: AOAM530fOEDS8I3Oatvx7tvBy2n8uBGm4wlaV1Z5MmDd6aDQPOYOc8Lj s9LuNAhfWmApOus1+qfVqqTumQ== X-Google-Smtp-Source: ABdhPJxyLXIANNTGiAZfsu1/QG9UANwG5wKin3TjbnrIzeNo7+Th34xV36A6olC5ZeEiVQzlg55+OQ== X-Received: by 2002:a05:6a00:b4d:b0:509:1ed1:570e with SMTP id p13-20020a056a000b4d00b005091ed1570emr18500672pfo.19.1650383157493; Tue, 19 Apr 2022 08:45:57 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id z4-20020a17090a66c400b001d0e448810asm13613064pjl.36.2022.04.19.08.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 08:45:56 -0700 (PDT) Date: Tue, 19 Apr 2022 15:45:52 +0000 From: Sean Christopherson To: Maxim Levitsky Subject: Re: [PATCH 3/3] KVM: Add helpers to wrap vcpu->srcu_idx and yell if it's abused Message-ID: References: <20220415004343.2203171-1-seanjc@google.com> <20220415004343.2203171-4-seanjc@google.com> <5b561bf1a0bbf140ea09d516f946a4e8fee8dd2d.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b561bf1a0bbf140ea09d516f946a4e8fee8dd2d.camel@redhat.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Wanpeng Li , Janosch Frank , kvm@vger.kernel.org, David Hildenbrand , Claudio Imbrenda , Anup Patel , Joerg Roedel , Atish Patra , linux-kernel@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Paul Walmsley , Paolo Bonzini , Vitaly Kuznetsov , Christian Borntraeger , linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Jim Mattson Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, Apr 19, 2022, Maxim Levitsky wrote: > On Fri, 2022-04-15 at 00:43 +0000, Sean Christopherson wrote: > > Add wrappers to acquire/release KVM's SRCU lock when stashing the index > > in vcpu->src_idx, along with rudimentary detection of illegal usage, > > e.g. re-acquiring SRCU and thus overwriting vcpu->src_idx. Because the > > SRCU index is (currently) either 0 or 1, illegal nesting bugs can go > > unnoticed for quite some time and only cause problems when the nested > > lock happens to get a different index. > > > > Wrap the WARNs in PROVE_RCU=y, and make them ONCE, otherwise KVM will > > likely yell so loudly that it will bring the kernel to its knees. > > > > Signed-off-by: Sean Christopherson > > --- ... > Looks good to me overall. > > Note that there are still places that acquire the lock and store the idx into > a local variable, for example kvm_xen_vcpu_set_attr and such. > I didn't check yet if these should be converted as well. Using a local variable is ok, even desirable. Nested/multiple readers is not an issue, the bug fixed by patch 1 is purely that kvm_vcpu.srcu_idx gets corrupted. In an ideal world, KVM would _only_ track the SRCU index in local variables, but that would require plumbing the local variable down into vcpu_enter_guest() and kvm_vcpu_block() so that SRCU can be unlocked prior to entering the guest or scheduling out the vCPU.