From: Paul Mackerras <paulus@ozlabs.org>
To: kvm-ppc@vger.kernel.org
Subject: Re: [PATCH] KVM: PPC: Book3S HV: Fix race between kvm_unmap_hva_range and MMU mode switch
Date: Tue, 18 Dec 2018 00:59:39 +0000 [thread overview]
Message-ID: <20181218005939.GA25748@blackberry> (raw)
On Fri, Nov 16, 2018 at 09:30:36PM +1100, Paul Mackerras wrote:
> Testing has revealed an occasional crash which appears to be caused
> by a race between kvmppc_switch_mmu_to_hpt and kvm_unmap_hva_range_hv.
> The symptom is a NULL pointer dereference in __find_linux_pte() called
> from kvm_unmap_radix() with kvm->arch.pgtable = NULL.
>
> Looking at kvmppc_switch_mmu_to_hpt(), it does indeed clear
> kvm->arch.pgtable (via kvmppc_free_radix()) before setting
> kvm->arch.radix to NULL, and there is nothing to prevent
> kvm_unmap_hva_range_hv() or the other MMU callback functions from
> being called concurrently with kvmppc_switch_mmu_to_hpt() or
> kvmppc_switch_mmu_to_radix().
>
> This patch therefore adds calls to spin_lock/unlock on the kvm->mmu_lock
> around the assignments to kvm->arch.radix, and makes sure that the
> partition-scoped radix tree or HPT is only freed after changing
> kvm->arch.radix.
>
> This also takes the kvm->mmu_lock in kvmppc_rmap_reset() to make sure
> that the clearing of each rmap array (one per memslot) doesn't happen
> concurrently with use of the array in the kvm_unmap_hva_range_hv()
> or the other MMU callbacks.
>
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Applied to my kvm-ppc-next branch.
next reply other threads:[~2018-12-18 0:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 0:59 Paul Mackerras [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-11-16 10:30 [PATCH] KVM: PPC: Book3S HV: Fix race between kvm_unmap_hva_range and MMU mode switch Paul Mackerras
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=20181218005939.GA25748@blackberry \
--to=paulus@ozlabs.org \
--cc=kvm-ppc@vger.kernel.org \
/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