]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list
authorPaul Mackerras <paulus@ozlabs.org>
Wed, 29 May 2019 01:54:00 +0000 (11:54 +1000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit1e2bb57325e6e8367bfb798611b56dd396d46c8a
tree98f116a9a3b6c236db7f8debc2ddbd17249a4a45
parent4d9bb55ed011267c5d49d55658953867696c2e8a
KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list

BugLink: https://bugs.launchpad.net/bugs/1838824
[ Upstream commit 1659e27d2bc1ef47b6d031abe01b467f18cb72d9 ]

Currently the Book 3S KVM code uses kvm->lock to synchronize access
to the kvm->arch.rtas_tokens list.  Because this list is scanned
inside kvmppc_rtas_hcall(), which is called with the vcpu mutex held,
taking kvm->lock cause a lock inversion problem, which could lead to
a deadlock.

To fix this, we add a new mutex, kvm->arch.rtas_token_lock, which nests
inside the vcpu mutexes, and use that instead of kvm->lock when
accessing the rtas token list.

This removes the lockdep_assert_held() in kvmppc_rtas_tokens_free().
At this point we don't hold the new mutex, but that is OK because
kvmppc_rtas_tokens_free() is only called when the whole VM is being
destroyed, and at that point nothing can be looking up a token in
the list.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/book3s_rtas.c