ANDROID: KVM: arm64: iommu: Run validate() on struct pkvm_iommu
In preparation for needing to validate more aspects of a device that is about to be registered, change the callback to accept the to-be-added 'struct pkvm_iommu' rather than individual inputs. Bug: 190463801 Signed-off-by: David Brazdil <dbrazdil@google.com> Change-Id: I3fb911e4280c220ddd779cf6a5fc9c302a5617f7
This commit is contained in:
@@ -20,10 +20,11 @@ struct pkvm_iommu_ops {
|
||||
int (*init)(void *data, size_t size);
|
||||
|
||||
/*
|
||||
* Driver-specific validation of device registration inputs.
|
||||
* This should be stateless. No locks are held at entry.
|
||||
* Driver-specific validation of a device that is being registered.
|
||||
* All fields of the device struct have been populated.
|
||||
* Called with the host lock held.
|
||||
*/
|
||||
int (*validate)(phys_addr_t base, size_t size);
|
||||
int (*validate)(struct pkvm_iommu *dev);
|
||||
|
||||
/*
|
||||
* Callback to apply a host stage-2 mapping change at driver level.
|
||||
|
||||
@@ -306,12 +306,6 @@ int __pkvm_iommu_register(unsigned long dev_id,
|
||||
if (!is_mmio_range(dev_pa, dev_size))
|
||||
return -EINVAL;
|
||||
|
||||
if (drv->ops->validate) {
|
||||
ret = drv->ops->validate(dev_pa, dev_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accept memory donation if the host is providing new memory.
|
||||
* Note: We do not return the memory even if there is an error later.
|
||||
@@ -350,6 +344,12 @@ int __pkvm_iommu_register(unsigned long dev_id,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dev->ops->validate) {
|
||||
ret = dev->ops->validate(dev);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmap the device's MMIO range from host stage-2. If registration
|
||||
* is successful, future attempts to re-map will be blocked by
|
||||
|
||||
@@ -465,9 +465,9 @@ static int s2mpu_init(void *data, size_t size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int s2mpu_validate(phys_addr_t pa, size_t size)
|
||||
static int s2mpu_validate(struct pkvm_iommu *dev)
|
||||
{
|
||||
if (size != S2MPU_MMIO_SIZE)
|
||||
if (dev->size != S2MPU_MMIO_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user