OSDN Git Service

KVM: arm/arm64: Fix vgic init race
authorChristoffer Dall <christoffer.dall@arm.com>
Tue, 3 Jul 2018 20:54:14 +0000 (22:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:36:34 +0000 (08:36 +0200)
commit0a10ce961bb34a0a42e60534479d8a79fc46d927
treed875555e6619c85b132e3bd99ffd3b81895a3cdf
parentf51c345732ef8e3983b64aaf65b833e14b233ba7
KVM: arm/arm64: Fix vgic init race

[ Upstream commit 1d47191de7e15900f8fbfe7cccd7c6e1c2d7c31a ]

The vgic_init function can race with kvm_arch_vcpu_create() which does
not hold kvm_lock() and we therefore have no synchronization primitives
to ensure we're doing the right thing.

As the user is trying to initialize or run the VM while at the same time
creating more VCPUs, we just have to refuse to initialize the VGIC in
this case rather than silently failing with a broken VCPU.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/arm/vgic/vgic-init.c