Commit d7929503 authored by Sebastian Ene's avatar Sebastian Ene Committed by Will Deacon
Browse files

ANDROID: KVM: arm64: Protect the hypervisor memcaches with the allocator lock on refill



Fix a race which happens when the system runs out of memory and the
hyp_alloc_reclaim is called at the same time with hyp_alloc_refill.
While the first one acquires the allocator lock the other one does not
and this can make the topup of the vcpu memcaches on the refill path to
return -ENOMEM even though the host memcaches were consumed. This can
lead the host to enter on the topup failure case which ends up calling
free_hyp_memcache even though the pages were given to the hypervisor.
This will generate an exception as the host is trying to access the
hypervisor memory while trying to free the already given pages.

Bug: 376641463
Bug: 278749606
Test: from an EL1 module do the following in a loop:
allocate pages and call the topup vcpu memcaches for the hypervisor
allocator. Loop until the low memory condition is triggered which calls
from a different cpu the hypervisor memory reclaim and triggers the race.
Change-Id: I67d7ca3cbcf357b5bc470076645be6263406e74f
Signed-off-by: default avatarSebastian Ene <sebastianene@google.com>
parent 7bfa7157
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment