BACKPORT: FROMLIST: KVM: arm64: pkvm: Add __pkvm_host_add_remove_page()
Add a small helper to remove and add back a page from the host stage-2. This will be used to temporarily unmap a piece of shared sram (device memory) from the host while we handle a SCMI request, preventing the host from modifying the request after it is verified. Link: https://lore.kernel.org/all/20241212180423.1578358-22-smostafa@google.com/ Bug: 357781595 Bug: 384432312 Change-Id: I4f6625c8c435b945821c934d1ad435ba1fd66b39 Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
committed by
Mostafa Saleh
parent
2e3d19be3e
commit
61dced62ff
@@ -62,6 +62,7 @@ int __pkvm_guest_relinquish_to_host(struct pkvm_hyp_vcpu *vcpu,
|
||||
u64 ipa, u64 *ppa);
|
||||
int __pkvm_host_use_dma(u64 phys_addr, size_t size);
|
||||
int __pkvm_host_unuse_dma(u64 phys_addr, size_t size);
|
||||
int __pkvm_host_add_remove_page(u64 pfn, bool remove);
|
||||
|
||||
bool addr_is_memory(phys_addr_t phys);
|
||||
int host_stage2_idmap_locked(phys_addr_t addr, u64 size, enum kvm_pgtable_prot prot);
|
||||
|
||||
@@ -2592,3 +2592,20 @@ int host_stage2_get_leaf(phys_addr_t phys, kvm_pte_t *ptep, s8 *level)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporarily unmap a page from the host stage-2, if @remove is true, or put it
|
||||
* back. After restoring the ownership to host, the page will be lazy-mapped.
|
||||
*/
|
||||
int __pkvm_host_add_remove_page(u64 pfn, bool remove)
|
||||
{
|
||||
int ret;
|
||||
u64 host_addr = hyp_pfn_to_phys(pfn);
|
||||
u8 owner = remove ? PKVM_ID_HYP : PKVM_ID_HOST;
|
||||
|
||||
host_lock_component();
|
||||
ret = host_stage2_set_owner_locked(host_addr, PAGE_SIZE, owner);
|
||||
host_unlock_component();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user