mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ANDROID: KVM: arm64: Add 'host_stage2_adjust_mmio_range' to kvm_iommu_ops
Add a new kvm_iommu_ops hook to the lower-EL instruction/data abort handler, which allows the IOMMU driver to restrict the region of device memory that is about to be mapped in the host stage-2. This can be used by the IOMMU driver to restrict access to the MMIO registers of the IOMMU itself. Test: builds, boots Bug: 190463801 Signed-off-by: David Brazdil <dbrazdil@google.com> Change-Id: I58f7b7a78795a3bfc4d77f7128e4fdc1110fde58
This commit is contained in:
@@ -131,6 +131,8 @@ struct kvm_iommu_ops {
|
||||
phys_addr_t fault_pa, unsigned int len,
|
||||
bool is_write, int rd);
|
||||
void (*host_stage2_set_owner)(phys_addr_t addr, size_t size, u8 owner_id);
|
||||
int (*host_stage2_adjust_mmio_range)(phys_addr_t addr, phys_addr_t *start,
|
||||
phys_addr_t *end);
|
||||
};
|
||||
|
||||
extern struct kvm_iommu_ops kvm_iommu_ops;
|
||||
|
||||
@@ -346,6 +346,17 @@ static int host_stage2_idmap(u64 addr)
|
||||
|
||||
prot = is_memory ? PKVM_HOST_MEM_PROT : PKVM_HOST_MMIO_PROT;
|
||||
|
||||
/**
|
||||
* Let device drivers adjust the permitted range first.
|
||||
* host_stage2_adjust_range() should be last to also properly align it.
|
||||
*/
|
||||
if (!is_memory && kvm_iommu_ops.host_stage2_adjust_mmio_range) {
|
||||
ret = kvm_iommu_ops.host_stage2_adjust_mmio_range(addr, &range.start,
|
||||
&range.end);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
hyp_spin_lock(&host_kvm.lock);
|
||||
ret = host_stage2_adjust_range(addr, &range);
|
||||
if (ret)
|
||||
|
||||
Reference in New Issue
Block a user