From: Paolo Bonzini <pbonzini@redhat.com>
To: Ben Gardon <bgardon@google.com>, leohou1402 <leohou1402@gmail.com>
Cc: "maciej.szmigiero@oracle.com" <maciej.szmigiero@oracle.com>,
"seanjc@google.com" <seanjc@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"cannonmatthews@google.com" <cannonmatthews@google.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"pshier@google.com" <pshier@google.com>,
"pfeiner@google.com" <pfeiner@google.com>,
"junaids@google.com" <junaids@google.com>,
"jmattson@google.com" <jmattson@google.com>,
"yulei.kernel@gmail.com" <yulei.kernel@gmail.com>,
"kernellwp@gmail.com" <kernellwp@gmail.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>
Subject: Re: reproducible BUG() in kvm_mmu_get_root() in TDP MMU
Date: Tue, 5 Jan 2021 19:06:23 +0100 [thread overview]
Message-ID: <f360715b-e61b-7e68-1aa9-84df51331d95@redhat.com> (raw)
In-Reply-To: <CANgfPd8fFB6QM3bOhxQ0WPjw6f5FLqBm1ynCenAxymByq4Lz5g@mail.gmail.com>
On 05/01/21 18:49, Ben Gardon wrote:
> for_each_tdp_mmu_root(kvm, root) {
> kvm_mmu_get_root(kvm, root);
> <Do something, yield the MMU lock>
> kvm_mmu_put_root(kvm, root);
> }
>
> In these cases the get and put root calls are there to ensure that the
> root is not freed while the function is running, however they do this
> too well. If the put root call reduces the root's root_count to 0, it
> should be removed from the roots list and freed before the MMU lock is
> released. However the above pattern never bothers to free the root.
> The following would fix this bug:
>
> -kvm_mmu_put_root(kvm, root);
> +if (kvm_mmu_put_root(kvm, root))
> + kvm_tdp_mmu_free_root(kvm, root);
Is it worth writing a more complex iterator struct, so that
for_each_tdp_mmu_root takes care of the get and put?
Paolo
next prev parent reply other threads:[~2021-01-05 18:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 23:05 reproducible BUG() in kvm_mmu_get_root() in TDP MMU Maciej S. Szmigiero
[not found] ` <8A352C2E-E7D2-4873-807F-635A595DCAEF@gmail.com>
2021-01-05 17:01 ` Ben Gardon
2021-01-05 17:49 ` Ben Gardon
2021-01-05 18:06 ` Paolo Bonzini [this message]
2021-01-05 18:46 ` Sean Christopherson
2021-01-05 19:21 ` Ben Gardon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f360715b-e61b-7e68-1aa9-84df51331d95@redhat.com \
--to=pbonzini@redhat.com \
--cc=bgardon@google.com \
--cc=cannonmatthews@google.com \
--cc=jmattson@google.com \
--cc=junaids@google.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=leohou1402@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.szmigiero@oracle.com \
--cc=peterx@redhat.com \
--cc=pfeiner@google.com \
--cc=pshier@google.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=yulei.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox