ANDROID: KVM: arm64: Adjust PSCI MEM_PROTECT refcount across share/unshare
When a protected guest shares or unshares a page with the host, we should decrement and increment the PSCI MEM_PROTECT refcount respectively since shared pages do not require poisoning on the reclaim path and will therefore not be accounted for. Bug: 258425493 Reported-by: Quentin Perret <qperret@google.com> Signed-off-by: Will Deacon <willdeacon@google.com> Change-Id: I80a4fad44de4313c6708a8259a1802ded379f03b
This commit is contained in:
@@ -929,6 +929,9 @@ static int host_complete_share(u64 addr, const struct pkvm_mem_transition *tx,
|
||||
{
|
||||
u64 size = tx->nr_pages * PAGE_SIZE;
|
||||
|
||||
if (tx->initiator.id == PKVM_ID_GUEST)
|
||||
psci_mem_protect_dec();
|
||||
|
||||
return __host_set_page_state_range(addr, size, PKVM_PAGE_SHARED_BORROWED);
|
||||
}
|
||||
|
||||
@@ -937,6 +940,9 @@ static int host_complete_unshare(u64 addr, const struct pkvm_mem_transition *tx)
|
||||
u64 size = tx->nr_pages * PAGE_SIZE;
|
||||
pkvm_id owner_id = initiator_owner_id(tx);
|
||||
|
||||
if (tx->initiator.id == PKVM_ID_GUEST)
|
||||
psci_mem_protect_inc();
|
||||
|
||||
return host_stage2_set_owner_locked(addr, size, owner_id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user