Commit 6e2b235
committed
KVM: Grab vcpu->mutex across installing the vCPU's fd and bumping online_vcpus
During vCPU creation, acquire vcpu->mutex prior to exposing the vCPU to
userspace, and hold the mutex until online_vcpus is bumped, i.e. until the
vCPU is fully online from KVM's perspective.
To ensure asynchronous vCPU ioctls also wait for the vCPU to come online,
explicitly check online_vcpus at the start of kvm_vcpu_ioctl(), and take
the vCPU's mutex to wait if necessary (having to wait for any ioctl should
be exceedingly rare, i.e. not worth optimizing).
Reported-by: Will Deacon <will@kernel.org>
Reported-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/all/20240730155646.1687-1-will@kernel.org
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20241009150455.1057573-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 0664dc7 commit 6e2b235
1 file changed
Lines changed: 46 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4132 | 4132 | | |
4133 | 4133 | | |
4134 | 4134 | | |
4135 | | - | |
| 4135 | + | |
| 4136 | + | |
| 4137 | + | |
| 4138 | + | |
| 4139 | + | |
| 4140 | + | |
| 4141 | + | |
| 4142 | + | |
4136 | 4143 | | |
4137 | 4144 | | |
4138 | 4145 | | |
| |||
4149 | 4156 | | |
4150 | 4157 | | |
4151 | 4158 | | |
| 4159 | + | |
4152 | 4160 | | |
4153 | 4161 | | |
4154 | 4162 | | |
4155 | 4163 | | |
4156 | 4164 | | |
4157 | 4165 | | |
4158 | 4166 | | |
| 4167 | + | |
4159 | 4168 | | |
4160 | 4169 | | |
4161 | 4170 | | |
| |||
4282 | 4291 | | |
4283 | 4292 | | |
4284 | 4293 | | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
4285 | 4321 | | |
4286 | 4322 | | |
4287 | 4323 | | |
| |||
4297 | 4333 | | |
4298 | 4334 | | |
4299 | 4335 | | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
| 4343 | + | |
| 4344 | + | |
4300 | 4345 | | |
4301 | 4346 | | |
4302 | 4347 | | |
| |||
0 commit comments