Skip to content
Snippets Groups Projects
Commit 0024e984 authored by Will Deacon's avatar Will Deacon
Browse files

ANDROID: KVM: arm64: Ensure vCPU is initialised before bumping 'nr_vcpus'


When initialising a new vCPU, a pointer to the vCPU is inserted into the
relevant index of 'hyp_vm->vcpus[]' and 'hyp_vm->nr_vcpus' is
incremented to publish the new entry. However, this is done without
sufficient memory barriers, allowing a concurrent attempt to load the
new vCPU to succeed with a partially initialised object.

Ensure that 'hyp_vm->nr_vcpus' is incremented with release semantics and
loaded with acquire semantics when 'hyp_vm->vcpus_lock' is not held on
the vCPU loading path.

Bug: 396117524
Fixes: d4abeb0b ("ANDROID: KVM: arm64: Introduce new spinlock for hypervisor VM vCPUs[] array")
Reported-by: default avatarBen Simner <ben.simner@cl.cam.ac.uk>
Change-Id: I8c33a81fb5f0e5868781d8f28f266e94d08e8265
Signed-off-by: default avatarWill Deacon <willdeacon@google.com>
parent fab059ac
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment