1
0
Fork 0
Commit Graph

125783 Commits (fb68407b0d9efba962c03f55009c797e22f024bc)

Author SHA1 Message Date
Joerg Roedel edcb34da25 AMD IOMMU: use calc_devid in prealloc_protection_domains
Impact: cleanup

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:57 +01:00
Joerg Roedel c226f85309 AMD IOMMU: convert amd_iommu_isolate to bool
Impact: cleanup

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:57 +01:00
Joerg Roedel 0cfd7aa90b AMD IOMMU: convert iommu->need_sync to bool
Impact: use bool instead of int for iommu->need_sync

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:57 +01:00
Joerg Roedel ab89672286 AMD IOMMU: use dev_name instead of self-build print_devid
Impact: use generic dev_name instead of own function

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel 1ac4cbbc5e AMD IOMMU: allocate a new protection for hotplugged devices
Impact: also hotplug devices benefit from device isolation

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel e2dc14a2a6 AMD IOMMU: add a domain flag for default domains
Impact: adds a new protection domain flag

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel 26961efe0d AMD IOMMU: register functions for the IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel 645c4c8d72 AMD IOMMU: add domain address lookup function for IOMMU API
Impact: add a generic function to lockup addresses in protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel eb74ff6cc0 AMD IOMMU: add domain unmap function for IOMMU API
Impact: add a generic function to unmap pages into protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel c6229ca649 AMD IOMMU: add domain map function for IOMMU API
Impact: add a generic function to map pages into protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel 01106066a6 AMD IOMMU: add device attach function for IOMMU API
Impact: add a generic function to attach devices to protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:56 +01:00
Joerg Roedel 684f288884 AMD IOMMU: add device detach function for IOMMU API
Impact: add a generic function to detach devices from protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:55 +01:00
Joerg Roedel 98383fc301 AMD IOMMU: add domain destroy function for IOMMU API
Impact: add a generic function for releasing protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:55 +01:00
Joerg Roedel c156e347d6 AMD IOMMU: add domain init function for IOMMU API
Impact: add a generic function for allocation protection domains

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:55 +01:00
Joerg Roedel 6d98cd8043 AMD IOMMU: add domain cleanup helper function
Impact: add a function to remove all devices from a domain

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:55 +01:00
Joerg Roedel e275a2a0fc AMD IOMMU: add device notifier callback
Impact: inform IOMMU about state change of a device in the driver core

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:55 +01:00
Joerg Roedel 355bf553ed AMD IOMMU: add device detach helper functions
Impact: add helper functions to detach a device from a domain

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:55 +01:00
Joerg Roedel f1179dc005 AMD IOMMU: rename set_device_domain function
Impact: rename set_device_domain() to attach_device()

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 863c74ebd0 AMD IOMMU: add device reference counting for protection domains
Impact: know how many devices are assigned to a domain

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 5b28df6f43 AMD IOMMU: add checks for dma_ops domain to dma_ops functions
Impact: detect when a driver uses a device assigned otherwise

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 9fdb19d64c AMD IOMMU: add protection domain flags
Imapct: add a new struct member to 'struct protection_domain'

When using protection domains for dma_ops and KVM its better to know for
which subsystem it was allocated. Add a flags member to struct
protection domain for that purpose.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 43f4960983 AMD IOMMU: add iommu_flush_domain function
Impact: add a function to flush a domain id on every IOMMU

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 9e919012e3 AMD IOMMU: don't remove protection domain from iommu_pd_list
Impact: save unneeded logic to add and remove domains to the list

The removal of a protection domain from the iommu_pd_list is not
necessary. Another benefit is that we save complexity because we don't
have to readd it later when the device no longer uses the domain.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 237b6f3329 AMD IOMMU: move invalidation command building to a separate function
Impact: refactoring of iommu_queue_inv_iommu_pages

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel 8d201968e1 AMD IOMMU: refactor completion wait handling into separate functions
Impact: split one function into three

The separate functions are required synchronize commands across all
hardware IOMMUs in the system.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:54 +01:00
Joerg Roedel a2acfb7579 AMD IOMMU: add domain id free function
Impact: add code to release a domain id

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:53 +01:00
Joerg Roedel 86db2e5d47 AMD IOMMU: make dma_ops_free_pagetable generic
Impact: change code to free pagetables from protection domains

The dma_ops_free_pagetable function can only free pagetables from
dma_ops domains. Change that to free pagetables of pure protection
domains.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:53 +01:00
Joerg Roedel 38e817febe AMD IOMMU: rename iommu_map to iommu_map_page
Impact: function rename

The iommu_map function maps only one page. Make this clear in the
function name.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:53 +01:00
Mike Day cdc7b83726 intel-iommu: fix bit shift at DOMAIN_FLAG_P2P_MULTIPLE_DEVICES
Signed-off-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:08 +01:00
Joerg Roedel e4754c96cf VT-d: remove now unused intel_iommu_found function
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:08 +01:00
Joerg Roedel a8bcbb0de4 VT-d: register functions for the IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:08 +01:00
Joerg Roedel d14d65777c VT-d: adapt domain iova_to_phys function for IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:08 +01:00
Joerg Roedel dde57a210d VT-d: adapt domain map and unmap functions for IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:08 +01:00
Joerg Roedel 4c5478c94e VT-d: adapt device attach and detach functions for IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:08 +01:00
Joerg Roedel 5d450806eb VT-d: adapt domain init and destroy functions for IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:07 +01:00
Joerg Roedel 19de40a847 KVM: change KVM to use IOMMU API
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:11:07 +01:00
Joerg Roedel 1aaf118352 select IOMMU_API when DMAR and/or AMD_IOMMU is selected
These two IOMMUs can implement the current version of this API. So
select the API if one or both of these IOMMU drivers is selected.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:10:09 +01:00
Joerg Roedel fc2100eb4d add frontend implementation for the IOMMU API
This API can be used by KVM for accessing different types of IOMMUs to
do device passthrough to guests. Beside that this API can also be used
by device drivers to map non-linear host memory into dma-linear
addresses to prevent sgather-gather DMA. UIO may be another user for
this API.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-03 14:10:09 +01:00
Joerg Roedel 4a77a6cf6d introcude linux/iommu.h for an iommu api
This patch introduces the API to abstract the exported VT-d functions
for KVM into a generic API. This way the AMD IOMMU implementation can
plug into this API later.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:10:09 +01:00
Joerg Roedel c4fa386428 KVM: rename vtd.c to iommu.c
Impact: file renamed

The code in the vtd.c file can be reused for other IOMMUs as well. So
rename it to make it clear that it handle more than VT-d.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:10:09 +01:00
Weidong Han b653574a7d Deassign device in kvm_free_assgined_device
In kvm_iommu_unmap_memslots(), assigned_dev_head is already empty.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:10:08 +01:00
Weidong Han 0a92035674 KVM: support device deassignment
Support device deassignment, it can be used in device hotplug.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:19 +01:00
Weidong Han 260782bcfd KVM: use the new intel iommu APIs
intel iommu APIs are updated, use the new APIs.

In addition, change kvm_iommu_map_guest() to just create the domain, let kvm_iommu_assign_device() assign device.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:19 +01:00
Weidong Han fe40f1e020 Check agaw is sufficient for mapped memory
When domain is related to multiple iommus, need to check if the minimum agaw is sufficient for the mapped memory

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:19 +01:00
Weidong Han faa3d6f5ff Change intel iommu APIs of virtual machine domain
These APIs are used by KVM to use VT-d

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:18 +01:00
Weidong Han ea6606b02f Change domain_context_mapping_one for virtual machine domain
vm_domid won't be set in context, find available domain id for a device from its iommu.

For a virtual machine domain, a default agaw will be set, and skip top levels of page tables for iommu which has less agaw than default.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:18 +01:00
Weidong Han 5e98c4b1d6 Allocation and free functions of virtual machine domain
virtual machine domain is different from native DMA-API domain, implement separate allocation and free functions for virtual machine domain.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:18 +01:00
Weidong Han 5331fe6f56 Add domain_flush_cache
Because virtual machine domain may have multiple devices from different iommus, it cannot use __iommu_flush_cache.

In some common low level functions, use domain_flush_cache instead of __iommu_flush_cache. On the other hand, in some functions, iommu can is specified or domain cannot be got, still use __iommu_flush_cache

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:18 +01:00
Weidong Han c7151a8dfe Add/remove domain device info for virtual machine domain
Add iommu reference count in domain, and add a lock to protect iommu setting including iommu_bmp, iommu_count and iommu_coherency.

virtual machine domain may have multiple devices from different iommus, so it needs to do more things when add/remove domain device info. Thus implement separate these functions for virtual machine domain.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:18 +01:00
Weidong Han 1ce28feb22 Add domain flag DOMAIN_FLAG_VIRTUAL_MACHINE
Add this flag for VT-d used in virtual machine, like KVM.

Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2009-01-03 14:02:18 +01:00