mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
ANDROID: KVM: arm64: iommu: Create private mapping last
Private EL2 mappings currently cannot be removed. Move the creation of
IOMMU device mappings at the end of the registration function so that
other errors do not result in unnecessary mappings.
Bug: 190463801
Change-Id: If100e35790cf512cabfa9327f790d20540977b7d
Signed-off-by: David Brazdil <dbrazdil@google.com>
(cherry picked from commit e6574a68fa)
Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
committed by
Mostafa Saleh
parent
d040797a83
commit
abb0647b7c
@@ -293,7 +293,7 @@ int __pkvm_iommu_register(unsigned long dev_id,
|
||||
{
|
||||
struct pkvm_iommu *dev = NULL;
|
||||
struct pkvm_iommu_driver *drv;
|
||||
void *dev_va, *mem_va = NULL;
|
||||
void *mem_va = NULL;
|
||||
int ret = 0;
|
||||
|
||||
drv = get_driver(drv_id);
|
||||
@@ -337,18 +337,11 @@ int __pkvm_iommu_register(unsigned long dev_id,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Create EL2 mapping for the device. */
|
||||
ret = __pkvm_create_private_mapping(dev_pa, dev_size,
|
||||
PAGE_HYP_DEVICE,(unsigned long *)&dev_va);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
/* Populate the new device entry. */
|
||||
*dev = (struct pkvm_iommu){
|
||||
.id = dev_id,
|
||||
.ops = drv->ops,
|
||||
.pa = dev_pa,
|
||||
.va = dev_va,
|
||||
.size = dev_size,
|
||||
};
|
||||
|
||||
@@ -358,13 +351,21 @@ int __pkvm_iommu_register(unsigned long dev_id,
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmap the device's MMIO range from host stage-2. Future attempts to
|
||||
* map will be blocked by pkvm_iommu_host_stage2_adjust_range.
|
||||
* Unmap the device's MMIO range from host stage-2. If registration
|
||||
* is successful, future attempts to re-map will be blocked by
|
||||
* pkvm_iommu_host_stage2_adjust_range.
|
||||
*/
|
||||
ret = host_stage2_unmap_dev_locked(dev_pa, dev_size);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
/* Create EL2 mapping for the device. */
|
||||
ret = __pkvm_create_private_mapping(dev_pa, dev_size,
|
||||
PAGE_HYP_DEVICE, (unsigned long *)(&dev->va));
|
||||
if (ret){
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Register device and prevent host from mapping the MMIO range. */
|
||||
list_add_tail(&dev->list, &iommu_list);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user